From 46b909e81841254dd60af9070c75ea7a7581ae8d Mon Sep 17 00:00:00 2001 From: Christian Date: Sat, 9 Mar 2013 17:36:31 -0500 Subject: [PATCH] Try a different way of remapping the fields. Should work because it's userspace, not relauncher space --- .../cpw/mods/fml/client/FMLClientHandler.java | 1 - .../common/ObfuscationReflectionHelper.java | 27 ++++++++++--------- .../cpw/mods/fml/server/FMLServerHandler.java | 1 - 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/fml/client/cpw/mods/fml/client/FMLClientHandler.java b/fml/client/cpw/mods/fml/client/FMLClientHandler.java index 1a9c80b64..f90b8ead3 100644 --- a/fml/client/cpw/mods/fml/client/FMLClientHandler.java +++ b/fml/client/cpw/mods/fml/client/FMLClientHandler.java @@ -139,7 +139,6 @@ public class FMLClientHandler implements IFMLSidedHandler loading = true; client = minecraft; - ObfuscationReflectionHelper.detectObfuscation(World.class); // TextureFXManager.instance().setClient(client); FMLCommonHandler.instance().beginLoading(this); new ModLoaderClientHelper(client); diff --git a/fml/common/cpw/mods/fml/common/ObfuscationReflectionHelper.java b/fml/common/cpw/mods/fml/common/ObfuscationReflectionHelper.java index 6195e4730..111fd4ca5 100644 --- a/fml/common/cpw/mods/fml/common/ObfuscationReflectionHelper.java +++ b/fml/common/cpw/mods/fml/common/ObfuscationReflectionHelper.java @@ -15,6 +15,7 @@ package cpw.mods.fml.common; import java.util.Arrays; import java.util.logging.Level; +import cpw.mods.fml.common.asm.transformers.deobf.FMLDeobfuscatingRemapper; import cpw.mods.fml.relauncher.ReflectionHelper; import cpw.mods.fml.relauncher.ReflectionHelper.UnableToAccessFieldException; import cpw.mods.fml.relauncher.ReflectionHelper.UnableToFindFieldException; @@ -27,8 +28,6 @@ import cpw.mods.fml.relauncher.ReflectionHelper.UnableToFindFieldException; */ public class ObfuscationReflectionHelper { - public static boolean obfuscation; - @SuppressWarnings("unchecked") public static T getPrivateValue(Class classToAccess, E instance, int fieldIndex) { @@ -43,12 +42,23 @@ public class ObfuscationReflectionHelper } } + public static String[] remapFieldNames(String className, String... fieldNames) + { + String internalClassName = className.replace('.', '/'); + String[] mappedNames = new String[fieldNames.length]; + int i = 0; + for (String fName : fieldNames) + { + mappedNames[i++] = FMLDeobfuscatingRemapper.INSTANCE.mapFieldName(internalClassName, fName, null); + } + return mappedNames; + } @SuppressWarnings("unchecked") public static T getPrivateValue(Class classToAccess, E instance, String... fieldNames) { try { - return ReflectionHelper.getPrivateValue(classToAccess, instance, fieldNames); + return ReflectionHelper.getPrivateValue(classToAccess, instance, remapFieldNames(classToAccess.getName(),fieldNames)); } catch (UnableToFindFieldException e) { @@ -91,7 +101,7 @@ public class ObfuscationReflectionHelper { try { - ReflectionHelper.setPrivateValue(classToAccess, instance, value, fieldNames); + ReflectionHelper.setPrivateValue(classToAccess, instance, value, remapFieldNames(classToAccess.getName(), fieldNames)); } catch (UnableToFindFieldException e) { @@ -104,13 +114,4 @@ public class ObfuscationReflectionHelper throw e; } } - - /** - * - */ - public static void detectObfuscation(Class clazz) - { - obfuscation = !clazz.getSimpleName().equals("World"); - } - } diff --git a/fml/common/cpw/mods/fml/server/FMLServerHandler.java b/fml/common/cpw/mods/fml/server/FMLServerHandler.java index 91e29739f..131064e23 100644 --- a/fml/common/cpw/mods/fml/server/FMLServerHandler.java +++ b/fml/common/cpw/mods/fml/server/FMLServerHandler.java @@ -82,7 +82,6 @@ public class FMLServerHandler implements IFMLSidedHandler public void beginServerLoading(MinecraftServer minecraftServer) { server = minecraftServer; - ObfuscationReflectionHelper.detectObfuscation(World.class); Loader.instance().loadMods(); }