Fixed Reflection in eclipse, it now works both ways! Yay!
This commit is contained in:
parent
3d67e61086
commit
bb141a530b
2 changed files with 31 additions and 3 deletions
|
@ -11,7 +11,7 @@ import net.minecraft.entity.passive.EntitySheep;
|
|||
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
|
||||
import biomesoplenty.api.BOPItemHelper;
|
||||
import biomesoplenty.common.entities.ai.EntityAITemptArmor;
|
||||
import cpw.mods.fml.common.ObfuscationReflectionHelper;
|
||||
import biomesoplenty.common.helpers.BOPReflectionHelper;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
public class TemptEventHandler
|
||||
|
@ -24,8 +24,8 @@ public class TemptEventHandler
|
|||
if (!(entity instanceof EntityLiving))
|
||||
return;
|
||||
|
||||
//TODO: FEATURE Remove Reflection tasks
|
||||
EntityAITasks tasks = ObfuscationReflectionHelper.getPrivateValue(EntityLiving.class, ((EntityLiving)entity), new String[] { "field_70714_bg" });
|
||||
//TODO: FEATURE Remove Reflection
|
||||
EntityAITasks tasks = BOPReflectionHelper.getPrivateValue(EntityLiving.class, ((EntityLiving)entity), "tasks", "field_70714_bg");
|
||||
|
||||
if (entity instanceof EntityChicken)
|
||||
{
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
package biomesoplenty.common.helpers;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import com.google.common.collect.BiMap;
|
||||
|
||||
import cpw.mods.fml.common.ObfuscationReflectionHelper;
|
||||
import cpw.mods.fml.common.asm.transformers.deobf.FMLDeobfuscatingRemapper;
|
||||
import cpw.mods.fml.relauncher.ReflectionHelper;
|
||||
|
||||
public class BOPReflectionHelper
|
||||
{
|
||||
public static <T, E> T getPrivateValue(Class <? super E > classToAccess, E instance, String fieldName, String obfFieldName)
|
||||
{
|
||||
try
|
||||
{
|
||||
Class.forName("net.minecraft.world.World");
|
||||
|
||||
return ReflectionHelper.getPrivateValue(classToAccess, instance, fieldName);
|
||||
}
|
||||
catch (ClassNotFoundException e)
|
||||
{
|
||||
return ObfuscationReflectionHelper.getPrivateValue(classToAccess, instance, obfFieldName);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue