Hopefully fixed issues outside of eclipse (again)

This commit is contained in:
Adubbz 2014-01-14 23:28:18 +11:00
parent 41642969ae
commit 1d0d7f05a1
1 changed files with 11 additions and 12 deletions

View File

@ -4,19 +4,20 @@ import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import cpw.mods.fml.common.ObfuscationReflectionHelper;
import cpw.mods.fml.relauncher.CoreModManager;
import cpw.mods.fml.relauncher.ReflectionHelper;
public class BOPReflectionHelper
{
public static boolean isDeobfuscated = ReflectionHelper.getPrivateValue(CoreModManager.class, null, "deobfuscatedEnvironment");
public static <T, E> T getPrivateValue(Class <? super E > classToAccess, E instance, String fieldName, String obfFieldName)
{
try
{
Class.forName("net.minecraft.world.World");
if (isDeobfuscated)
{
return ReflectionHelper.getPrivateValue(classToAccess, instance, fieldName);
}
catch (ClassNotFoundException e)
else
{
return ObfuscationReflectionHelper.getPrivateValue(classToAccess, instance, obfFieldName);
}
@ -24,17 +25,15 @@ public class BOPReflectionHelper
public static <T, E> void setPrivateFinalValue(Class <? super T > classToAccess, T instance, E value, String fieldName, String obfFieldName)
{
Field field = null;
try
{
Field field = null;
try
{
Class.forName("net.minecraft.world.World");
if (isDeobfuscated)
{
field = ReflectionHelper.findField(classToAccess, fieldName);
}
catch (ClassNotFoundException e)
else
{
field = ReflectionHelper.findField(classToAccess, ObfuscationReflectionHelper.remapFieldNames(classToAccess.getName(), obfFieldName));
}