diff --git a/build.gradle b/build.gradle index 11189c2..e57a16f 100644 --- a/build.gradle +++ b/build.gradle @@ -3,12 +3,3 @@ plugins { id 'com.gtnewhorizons.gtnhconvention' } - -jar { - manifest { - attributes += [ - "FMLCorePluginContainsFMLMod": true, - "FMLCorePlugin": "thaumcraft.codechicken.core.launch.DepLoader" - ] - } -} diff --git a/gradle.properties b/gradle.properties index 45a5100..22b5eb5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -102,7 +102,7 @@ mixinsPackage = # Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin! # This parameter is for legacy compatibility only # Example value: (coreModClass = asm.FMLPlugin) + (modGroup = com.myname.mymodid) -> com.myname.mymodid.asm.FMLPlugin -coreModClass = +coreModClass = nuker.ThaumcraftDepLoaderNuker # If your project is only a consolidation of mixins or a core mod and does NOT contain a 'normal' mod ( = some class # that is annotated with @Mod) you want this to be true. When in doubt: leave it on false! diff --git a/src/main/java/baubles/nuker/ThaumcraftDepLoaderNuker.java b/src/main/java/baubles/nuker/ThaumcraftDepLoaderNuker.java new file mode 100644 index 0000000..f864d7d --- /dev/null +++ b/src/main/java/baubles/nuker/ThaumcraftDepLoaderNuker.java @@ -0,0 +1,78 @@ +package baubles.nuker; + +import cpw.mods.fml.relauncher.FMLRelaunchLog; +import cpw.mods.fml.relauncher.IFMLLoadingPlugin; +import net.minecraft.launchwrapper.ITweaker; +import net.minecraft.launchwrapper.Launch; +import org.apache.logging.log4j.Level; + +import java.lang.reflect.Field; +import java.util.List; +import java.util.Map; + +/** + * The purpose of this plugin is to neutralize Thaumcraft's IFMLLoadingPlugin, + * it doesn't prevent the IFMLLoadingPlugin from being constructed, but it does + * prevent the methods from running. + * We are doing that because Thaumcraft's plugin is downloading the Baubles mod + * if it is not present and that will cause issues with this mod. + * This plugin needs to be sorted index below 0 to run before Thaumcraft's plugin. + * It neutralizes Thaumcraft's plugin by finding its corresponding CoreModManager$FMLPluginWrapper + * in the ITweakers list, and it replaces the reference to the IFMLLoadingPlugin instance with "this". + * As a result the methods from Thaumcraft's plugin will run 0 time and the methods + * from this plugin will run twice. + */ +@SuppressWarnings("unused") +@IFMLLoadingPlugin.SortingIndex(-1) +@IFMLLoadingPlugin.MCVersion("1.7.10") +public class ThaumcraftDepLoaderNuker implements IFMLLoadingPlugin { + + private boolean flag; + + @Override + public String[] getASMTransformerClass() { + return null; + } + + @Override + public String getModContainerClass() { + return null; + } + + @Override + public String getSetupClass() { + return null; + } + + @SuppressWarnings("unchecked") + @Override + public void injectData(Map data) { + if (flag) return; + flag = true; + List tweakers = (List) Launch.blackboard.get("Tweaks"); + Field coreModInstance = null; + for (ITweaker tweaker : tweakers) { + if ("cpw.mods.fml.relauncher.CoreModManager$FMLPluginWrapper".equals(tweaker.getClass().getName())) { + try { + if (coreModInstance == null) { + coreModInstance = tweaker.getClass().getDeclaredField("coreModInstance"); + coreModInstance.setAccessible(true); + } + final Object plugin = coreModInstance.get(tweaker); + final String name = plugin.getClass().getName(); + if ("thaumcraft.codechicken.core.launch.DepLoader".equals(name)) { + coreModInstance.set(tweaker, this); + FMLRelaunchLog.fine("[ThaumcraftDepLoaderNuker] Redirected %s FMLPluginWrapper to call our FMLPlugin %s instead", name, this.getClass().getName()); + } + } catch (NoSuchFieldException | IllegalAccessException e) { + FMLRelaunchLog.log(Level.ERROR, e, "[ThaumcraftDepLoaderNuker] An error occurred trying to read the Tweakers"); + } + } + } + } + + @Override + public String getAccessTransformerClass() { + return null; + } +} diff --git a/src/main/java/thaumcraft/codechicken/core/launch/DepLoader.java b/src/main/java/thaumcraft/codechicken/core/launch/DepLoader.java deleted file mode 100644 index 92c07ac..0000000 --- a/src/main/java/thaumcraft/codechicken/core/launch/DepLoader.java +++ /dev/null @@ -1,41 +0,0 @@ -package thaumcraft.codechicken.core.launch; - -import cpw.mods.fml.relauncher.IFMLCallHook; -import cpw.mods.fml.relauncher.IFMLLoadingPlugin; -import java.util.Map; - -@IFMLLoadingPlugin.SortingIndex(-100) -@IFMLLoadingPlugin.MCVersion("1.7.10") -public class DepLoader implements IFMLLoadingPlugin, IFMLCallHook { - - @Override - public String[] getASMTransformerClass() { - return null; - } - - @Override - public String getModContainerClass() { - return null; - } - - @Override - public String getSetupClass() { - return null; - } - - @Override - public void injectData(Map data) { - - } - - @Override - public String getAccessTransformerClass() { - return null; - } - - @Override - public Void call() throws Exception { - return null; - } - -}