Try a different way of remapping the fields. Should work because it's userspace, not relauncher space

This commit is contained in:
Christian 2013-03-09 17:36:31 -05:00
parent a713300e0a
commit 46b909e818
3 changed files with 14 additions and 15 deletions

View File

@ -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);

View File

@ -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, E> T getPrivateValue(Class<? super E> 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, E> T getPrivateValue(Class<? super E> 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");
}
}

View File

@ -82,7 +82,6 @@ public class FMLServerHandler implements IFMLSidedHandler
public void beginServerLoading(MinecraftServer minecraftServer)
{
server = minecraftServer;
ObfuscationReflectionHelper.detectObfuscation(World.class);
Loader.instance().loadMods();
}