private void injectDeobfPlugin() { try { Class<?> wrapperClass = Class.forName("cpw.mods.fml.relauncher.CoreModManager$FMLPluginWrapper"); Constructor wrapperConstructor = wrapperClass.getConstructor(String.class, IFMLLoadingPlugin.class, File.class, Integer.TYPE, String[].class); Field f_loadPlugins = CoreModManager.class.getDeclaredField("loadPlugins"); wrapperConstructor.setAccessible(true); f_loadPlugins.setAccessible(true); ((List)f_loadPlugins.get(null)).add(2, wrapperConstructor.newInstance("CCCDeobfPlugin", new MCPDeobfuscationTransformer.LoadPlugin(), null, 0, new String[0])); } catch (Exception e) { logger.error("Failed to inject MCPDeobfuscation Transformer", e); } }
private void injectNewTransformer() throws ClassNotFoundException, NoSuchMethodException, NoSuchFieldException, IllegalAccessException, InvocationTargetException, InstantiationException { Class e = Class.forName("cpw.mods.fml.relauncher.CoreModManager$FMLPluginWrapper"); Constructor wrapperConstructor = e.getConstructor(new Class[]{String.class, IFMLLoadingPlugin.class, File.class, Integer.TYPE, String[].class}); Field loadPlugins = CoreModManager.class.getDeclaredField("loadPlugins"); wrapperConstructor.setAccessible(true); loadPlugins.setAccessible(true); ((List)loadPlugins.get((Object)null)).add(wrapperConstructor.newInstance(new Object[]{"CollectiveFrameworkPlugin", new CollectiveFrameworkTransformerPlugin(), null, Integer.valueOf(Integer.MAX_VALUE), new String[0]})); didInject = true; }