Skip to content

Instantly share code, notes, and snippets.

@kosakriszi
Created June 16, 2014 04:38
Show Gist options
  • Save kosakriszi/3f39710f2bfba3273e9e to your computer and use it in GitHub Desktop.
Save kosakriszi/3f39710f2bfba3273e9e to your computer and use it in GitHub Desktop.
// this is the forge implementation for loading coremods
private static Method ADDURL;
// the following takes place inside the injectIntoClassLoader(LaunchClassLoader classLoader) method
if(ADDURL == null) {
ADDURL = URLClassLoader.class.getDeclaredMethod("addURL", URL.class);
ADDURL.setAccessible(true);
}
ADDURL.invoke(classLoader.getClass().getClassLoader(), forgeLib.toURI().toURL());
classLoader.addURL(forgeLib.toURI().toURL());
// here I just grab the tweaker instance as per usual
forgeTweaker = ((ITweaker) Class.forName("cpw.mods.fml.common.launcher.FMLTweaker", false, classLoader).newInstance());
Logger.log("Starting Forge!");
// I call the tweaker like this for cleaner console output,
// it's effectively the same, I have tried both ways
forgeTweaker.acceptOptions(args, gameDir, assetsDir, profile);
forgeTweaker.injectIntoClassLoader(classLoader);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment