Added goal selector clear for entities in UtilEntity

This commit is contained in:
Jonathan Williams 2013-11-22 00:38:24 -08:00
parent 0b7bf00ca7
commit 9c9e5f1ae0
2 changed files with 37 additions and 0 deletions

Binary file not shown.

View File

@ -111,6 +111,43 @@ public class UtilEnt
}
}
public static void removeGoalSelectors(Entity entity)
{
try
{
if (_goalSelector == null)
{
_goalSelector = EntityInsentient.class.getDeclaredField("goalSelector");
_goalSelector.setAccessible(true);
}
if (((CraftEntity)entity).getHandle() instanceof EntityInsentient)
{
EntityInsentient creature = (EntityInsentient)((CraftEntity)entity).getHandle();
PathfinderGoalSelector goalSelector = new PathfinderGoalSelector(((CraftWorld)entity.getWorld()).getHandle().methodProfiler);
_goalSelector.set(creature, goalSelector);
}
}
catch (IllegalArgumentException e)
{
e.printStackTrace();
}
catch (IllegalAccessException e)
{
e.printStackTrace();
}
catch (NoSuchFieldException e)
{
e.printStackTrace();
}
catch (SecurityException e)
{
e.printStackTrace();
}
}
public static void populate()
{
if (creatureMap.isEmpty())