use of net.minecraftforge.fml.common.ModClassLoader in project SpongeForge by SpongePowered.
the class SpongeModPluginContainer method constructMod.
@Subscribe
public void constructMod(FMLConstructionEvent event) {
try {
if (this.invalid) {
throw new InvalidPluginException();
}
// Add source file to classloader so we can load it.
ModClassLoader modClassLoader = event.getModClassLoader();
modClassLoader.addFile(getSource());
modClassLoader.clearNegativeCacheFor(this.candidate.getClassList());
Class<?> pluginClazz = Class.forName(this.className, true, modClassLoader);
Injector injector = spongeInjector.getParent().createChildInjector(new PluginModule((PluginContainer) this, pluginClazz));
this.injector = injector;
this.instance = injector.getInstance(pluginClazz);
// TODO: Detect Scala or use meta to know if we're scala and use proper adapter here...
ProxyInjector.inject(this, event.getASMHarvestedData(), FMLCommonHandler.instance().getSide(), new ILanguageAdapter.JavaAdapter());
Sponge.getEventManager().registerListeners(this, this.instance);
} catch (Throwable t) {
this.controller.errorOccurred(this, t);
}
}
Aggregations