Hopefully fixed issues outside of eclipse (again)
This commit is contained in:
parent
41642969ae
commit
1d0d7f05a1
1 changed files with 11 additions and 12 deletions
|
@ -4,37 +4,36 @@ 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
|
||||
if (isDeobfuscated)
|
||||
{
|
||||
Class.forName("net.minecraft.world.World");
|
||||
|
||||
return ReflectionHelper.getPrivateValue(classToAccess, instance, fieldName);
|
||||
}
|
||||
catch (ClassNotFoundException e)
|
||||
else
|
||||
{
|
||||
return ObfuscationReflectionHelper.getPrivateValue(classToAccess, instance, obfFieldName);
|
||||
}
|
||||
}
|
||||
|
||||
public static <T, E> void setPrivateFinalValue(Class <? super T > classToAccess, T instance, E value, String fieldName, String obfFieldName)
|
||||
{
|
||||
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));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue