From 461c02e69fb17c7e793ef9388b6d3044c5058d30 Mon Sep 17 00:00:00 2001 From: Dragon2488 Date: Mon, 12 Sep 2016 21:29:10 +0700 Subject: [PATCH] ASM fixes. --- src/main/java/gregtech/asm/ASM.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/gregtech/asm/ASM.java b/src/main/java/gregtech/asm/ASM.java index fa421508..e7baf498 100644 --- a/src/main/java/gregtech/asm/ASM.java +++ b/src/main/java/gregtech/asm/ASM.java @@ -6,10 +6,15 @@ import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin; import java.util.Map; +@IFMLLoadingPlugin.Name("GregtechASM") +@IFMLLoadingPlugin.SortingIndex(10001) public class ASM implements IFMLLoadingPlugin, IClassTransformer { private static ClassPool pool = ClassPool.getDefault(); + private static final String OBF_METHOD_NAME = "func_178125_b"; + private static boolean runtimeDeobfuscation = false; + static { pool.appendClassPath(new LoaderClassPath(Thread.currentThread().getContextClassLoader())); pool.appendClassPath(new LoaderClassPath(ClassLoader.getSystemClassLoader())); @@ -22,7 +27,7 @@ public class ASM implements IFMLLoadingPlugin, IClassTransformer { CtClass ctClass = pool.getOrNull(s1); System.out.println(s1); try { - CtMethod method = ctClass.getDeclaredMethod("getModelForState"); + CtMethod method = ctClass.getDeclaredMethod(runtimeDeobfuscation ? OBF_METHOD_NAME : "getModelForState"); method.insertBefore( "if(gregtech.common.render.newblocks.BlockRenderer.shouldHook($1)) {" + "return gregtech.common.render.newblocks.BlockRenderer.hook($1); }"); @@ -51,7 +56,7 @@ public class ASM implements IFMLLoadingPlugin, IClassTransformer { @Override public void injectData(Map data) { - + runtimeDeobfuscation = (Boolean) data.get("runtimeDeobfuscationEnabled"); } @Override