These can be hot functions (i.e entity ticking and block ticking), so inline where possible, and avoid the abstraction of the Either class.
Also check class loader cache before locking to speed up cached hits to avoid the lock wasn't gonna make a unique build just for that but can lump it in here.