Skip to content

Instantly share code, notes, and snippets.

@kosakriszi
Created June 14, 2014 16:56
Show Gist options
  • Save kosakriszi/a88fbdaac022632258e7 to your computer and use it in GitHub Desktop.
Save kosakriszi/a88fbdaac022632258e7 to your computer and use it in GitHub Desktop.
// first I add the URL of the binary to the LaunchClassLoader's search paths
classLoader.addURL(forgeLib.toURI().toURL());
JarFile forgeJar = new JarFile(forgeLib);
Enumeration<JarEntry> entries = forgeJar.entries();
// here, I make an effort to pre-load all the class files inside the binary,
// this seems to be necessary for it to even find the classes
while(entries.hasMoreElements()) {
String entryName = entries.nextElement().getName();
if(entryName.endsWith(".class")) {
String searchName = entryName.substring(0, entryName.length()-6).replace('/', '.');
classLoader.findClass(searchName);
}
}
forgeJar.close();
// find the tweaker class, no big deal
forgeTweaker = (ITweaker) classLoader.findClass("cpw.mods.fml.common.launcher.FMLTweaker").newInstance();
// and finally, I add the tweaker to the tweaker queue
List<String> tweakClasses = (List<String>) Launch.blackboard.get("TweakClasses");
tweakClasses.add("cpw.mods.fml.common.launcher.FMLTweaker");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment