Fixed ClassCastException when loading ModLoader mods

This commit is contained in:
James Clarke 2013-07-02 20:46:35 +01:00
parent 7e87a2e18f
commit b2ef2bed36

View file

@ -81,8 +81,21 @@ public class ModClassLoader extends URLClassLoader
public Class<? extends BaseModProxy> loadBaseModClass(String modClazzName) throws Exception public Class<? extends BaseModProxy> loadBaseModClass(String modClazzName) throws Exception
{ {
AccessTransformer transformer = (AccessTransformer)mainClassLoader.getTransformers().get(0); AccessTransformer accessTransformer = null;
transformer.ensurePublicAccessFor(modClazzName); for (IClassTransformer transformer : mainClassLoader.getTransformers())
{
if (transformer instanceof AccessTransformer)
{
accessTransformer = (AccessTransformer) transformer;
break;
}
}
if (accessTransformer == null)
{
FMLLog.log(Level.SEVERE, "No access transformer found");
throw new LoaderException();
}
accessTransformer.ensurePublicAccessFor(modClazzName);
return (Class<? extends BaseModProxy>) Class.forName(modClazzName, true, this); return (Class<? extends BaseModProxy>) Class.forName(modClazzName, true, this);
} }
} }