ASM fixes.

This commit is contained in:
Dragon2488 2016-09-12 21:29:10 +07:00
parent d9aa2535e6
commit 461c02e69f

View file

@ -6,10 +6,15 @@ import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin;
import java.util.Map; import java.util.Map;
@IFMLLoadingPlugin.Name("GregtechASM")
@IFMLLoadingPlugin.SortingIndex(10001)
public class ASM implements IFMLLoadingPlugin, IClassTransformer { public class ASM implements IFMLLoadingPlugin, IClassTransformer {
private static ClassPool pool = ClassPool.getDefault(); private static ClassPool pool = ClassPool.getDefault();
private static final String OBF_METHOD_NAME = "func_178125_b";
private static boolean runtimeDeobfuscation = false;
static { static {
pool.appendClassPath(new LoaderClassPath(Thread.currentThread().getContextClassLoader())); pool.appendClassPath(new LoaderClassPath(Thread.currentThread().getContextClassLoader()));
pool.appendClassPath(new LoaderClassPath(ClassLoader.getSystemClassLoader())); pool.appendClassPath(new LoaderClassPath(ClassLoader.getSystemClassLoader()));
@ -22,7 +27,7 @@ public class ASM implements IFMLLoadingPlugin, IClassTransformer {
CtClass ctClass = pool.getOrNull(s1); CtClass ctClass = pool.getOrNull(s1);
System.out.println(s1); System.out.println(s1);
try { try {
CtMethod method = ctClass.getDeclaredMethod("getModelForState"); CtMethod method = ctClass.getDeclaredMethod(runtimeDeobfuscation ? OBF_METHOD_NAME : "getModelForState");
method.insertBefore( method.insertBefore(
"if(gregtech.common.render.newblocks.BlockRenderer.shouldHook($1)) {" + "if(gregtech.common.render.newblocks.BlockRenderer.shouldHook($1)) {" +
"return gregtech.common.render.newblocks.BlockRenderer.hook($1); }"); "return gregtech.common.render.newblocks.BlockRenderer.hook($1); }");
@ -51,7 +56,7 @@ public class ASM implements IFMLLoadingPlugin, IClassTransformer {
@Override @Override
public void injectData(Map<String, Object> data) { public void injectData(Map<String, Object> data) {
runtimeDeobfuscation = (Boolean) data.get("runtimeDeobfuscationEnabled");
} }
@Override @Override