mirror of
https://github.com/GTNewHorizons/Baubles-Expanded.git
synced 2026-10-25 20:22:26 +00:00
Improve Thaumcrap's deploader neutralization (#12)
This commit is contained in:
1 parent
c73bbba174
commit
d1cd6ebbc1
4 files changed
+79
-51
No files matched your search
@@ -3,12 +3,3 @@
|
||||
plugins {
|
||||
id 'com.gtnewhorizons.gtnhconvention'
|
||||
}
|
||||
|
||||
jar {
|
||||
manifest {
|
||||
attributes += [
|
||||
"FMLCorePluginContainsFMLMod": true,
|
||||
"FMLCorePlugin": "thaumcraft.codechicken.core.launch.DepLoader"
|
||||
]
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -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!
|
||||
|
||||
@@ -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<String, Object> data) {
|
||||
if (flag) return;
|
||||
flag = true;
|
||||
List<ITweaker> tweakers = (List<ITweaker>) 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;
|
||||
}
|
||||
}
|
||||
@@ -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<String, Object> data) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAccessTransformerClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void call() throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user