use of net.minecraft.server.v1_16_R3.ControllerMove in project RoseStacker by Rosewood-Development.
the class NMSHandlerImpl method removeEntityGoals.
@Override
public void removeEntityGoals(LivingEntity livingEntity) {
EntityLiving nmsEntity = ((CraftLivingEntity) livingEntity).getHandle();
if (!(nmsEntity instanceof EntityInsentient))
return;
try {
EntityInsentient insentient = (EntityInsentient) nmsEntity;
// Remove all goal AI other than floating in water
Set<PathfinderGoalWrapped> goals = (Set<PathfinderGoalWrapped>) field_PathfinderGoalSelector_d.get(insentient.goalSelector);
Iterator<PathfinderGoalWrapped> goalsIterator = goals.iterator();
while (goalsIterator.hasNext()) {
PathfinderGoalWrapped goal = goalsIterator.next();
if (goal.j() instanceof PathfinderGoalFloat)
continue;
goalsIterator.remove();
}
// Remove all targetting AI
((Set<PathfinderGoalWrapped>) field_PathfinderGoalSelector_d.get(insentient.targetSelector)).clear();
// Forget any existing targets
insentient.setGoalTarget(null);
// Remove the move controller and replace it with a dummy one
ControllerMove dummyMoveController = new ControllerMove(insentient) {
@Override
public void a() {
}
};
field_EntityInsentient_moveController.set(insentient, dummyMoveController);
} catch (ReflectiveOperationException ex) {
ex.printStackTrace();
}
}
Aggregations