diff --git a/src/main/java/biomesoplenty/common/helpers/BOPReflectionHelper.java b/src/main/java/biomesoplenty/common/helpers/BOPReflectionHelper.java index 7cb31a68e..f9639c6a1 100755 --- a/src/main/java/biomesoplenty/common/helpers/BOPReflectionHelper.java +++ b/src/main/java/biomesoplenty/common/helpers/BOPReflectionHelper.java @@ -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 getPrivateValue(Class 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 void setPrivateFinalValue(Class 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)); }