From 1fbc66d6903d7bd013dcf159c81384abca38998c Mon Sep 17 00:00:00 2001 From: Adubbz Date: Sun, 5 Oct 2014 12:41:32 +1100 Subject: [PATCH] Hopefully fixed issues with obfuscation --- .../biomesoplenty/asm/BOPTransformer.java | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/main/java/biomesoplenty/asm/BOPTransformer.java b/src/main/java/biomesoplenty/asm/BOPTransformer.java index 233c96bdf..cc3beec90 100644 --- a/src/main/java/biomesoplenty/asm/BOPTransformer.java +++ b/src/main/java/biomesoplenty/asm/BOPTransformer.java @@ -8,6 +8,7 @@ package biomesoplenty.asm; +import java.io.IOException; import java.util.Iterator; import org.objectweb.asm.Opcodes; @@ -20,16 +21,37 @@ import org.objectweb.asm.tree.MethodNode; import org.objectweb.asm.tree.VarInsnNode; import net.minecraft.launchwrapper.IClassTransformer; +import net.minecraft.launchwrapper.Launch; public class BOPTransformer implements IClassTransformer { + private static final boolean isObfuscated; + private static final String registerVariantNames; + + static + { + boolean obfuscated = true; + + try + { + obfuscated = Launch.classLoader.getClassBytes("net.minecraft.world.World") == null; + } + catch (IOException e) + { + e.printStackTrace(); + } + + isObfuscated = obfuscated; + registerVariantNames = isObfuscated ? "func_177592_e" : "registerVariantNames"; + } + @Override public byte[] transform(String name, String transformedName, byte[] basicClass) { if (name.equals("net.minecraft.client.resources.model.ModelBakery")) { ClassNode classNode = ASMUtil.getClassNode(basicClass); - MethodNode variantsMethodNode = ASMUtil.getMethodNode(classNode, "registerVariantNames", "()V"); + MethodNode variantsMethodNode = ASMUtil.getMethodNode(classNode, registerVariantNames, "()V"); InsnList instructions = new InsnList();