Search in sources :

Example 1 with PathfinderGoalFloat

use of net.minecraft.server.v1_16_R2.PathfinderGoalFloat 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();
    }
}
Also used : PathfinderGoalWrapped(net.minecraft.server.v1_16_R2.PathfinderGoalWrapped) Set(java.util.Set) EntityLiving(net.minecraft.server.v1_16_R2.EntityLiving) PathfinderGoalFloat(net.minecraft.server.v1_16_R2.PathfinderGoalFloat) EntityInsentient(net.minecraft.server.v1_16_R2.EntityInsentient) CraftLivingEntity(org.bukkit.craftbukkit.v1_16_R2.entity.CraftLivingEntity) ControllerMove(net.minecraft.server.v1_16_R2.ControllerMove)

Example 2 with PathfinderGoalFloat

use of net.minecraft.server.v1_16_R2.PathfinderGoalFloat 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();
    }
}
Also used : PathfinderGoalWrapped(net.minecraft.server.v1_16_R3.PathfinderGoalWrapped) Set(java.util.Set) EntityLiving(net.minecraft.server.v1_16_R3.EntityLiving) PathfinderGoalFloat(net.minecraft.server.v1_16_R3.PathfinderGoalFloat) EntityInsentient(net.minecraft.server.v1_16_R3.EntityInsentient) CraftLivingEntity(org.bukkit.craftbukkit.v1_16_R3.entity.CraftLivingEntity) ControllerMove(net.minecraft.server.v1_16_R3.ControllerMove)

Aggregations

Set (java.util.Set)2 ControllerMove (net.minecraft.server.v1_16_R2.ControllerMove)1 EntityInsentient (net.minecraft.server.v1_16_R2.EntityInsentient)1 EntityLiving (net.minecraft.server.v1_16_R2.EntityLiving)1 PathfinderGoalFloat (net.minecraft.server.v1_16_R2.PathfinderGoalFloat)1 PathfinderGoalWrapped (net.minecraft.server.v1_16_R2.PathfinderGoalWrapped)1 ControllerMove (net.minecraft.server.v1_16_R3.ControllerMove)1 EntityInsentient (net.minecraft.server.v1_16_R3.EntityInsentient)1 EntityLiving (net.minecraft.server.v1_16_R3.EntityLiving)1 PathfinderGoalFloat (net.minecraft.server.v1_16_R3.PathfinderGoalFloat)1 PathfinderGoalWrapped (net.minecraft.server.v1_16_R3.PathfinderGoalWrapped)1 CraftLivingEntity (org.bukkit.craftbukkit.v1_16_R2.entity.CraftLivingEntity)1 CraftLivingEntity (org.bukkit.craftbukkit.v1_16_R3.entity.CraftLivingEntity)1