Search in sources :

Example 11 with ControllerMove

use of net.minecraft.server.v1_13_R2.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();
    }
}
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

SkinnableEntity (net.citizensnpcs.npc.skin.SkinnableEntity)8 Location (org.bukkit.Location)8 LivingEntity (org.bukkit.entity.LivingEntity)8 Set (java.util.Set)2 ControllerMove (net.minecraft.server.v1_16_R3.ControllerMove)2 EntityInsentient (net.minecraft.server.v1_16_R3.EntityInsentient)2 IOException (java.io.IOException)1 Socket (java.net.Socket)1 EntityHumanNPC (net.citizensnpcs.nms.v1_10_R1.entity.EntityHumanNPC)1 EntityHumanNPC (net.citizensnpcs.nms.v1_11_R1.entity.EntityHumanNPC)1 EntityHumanNPC (net.citizensnpcs.nms.v1_12_R1.entity.EntityHumanNPC)1 EntityHumanNPC (net.citizensnpcs.nms.v1_13_R2.entity.EntityHumanNPC)1 EmptyNetHandler (net.citizensnpcs.nms.v1_13_R2.network.EmptyNetHandler)1 EmptyNetworkManager (net.citizensnpcs.nms.v1_13_R2.network.EmptyNetworkManager)1 EmptySocket (net.citizensnpcs.nms.v1_13_R2.network.EmptySocket)1 EmptyAdvancementDataPlayer (net.citizensnpcs.nms.v1_13_R2.util.EmptyAdvancementDataPlayer)1 PlayerControllerJump (net.citizensnpcs.nms.v1_13_R2.util.PlayerControllerJump)1 PlayerControllerLook (net.citizensnpcs.nms.v1_13_R2.util.PlayerControllerLook)1 PlayerControllerMove (net.citizensnpcs.nms.v1_13_R2.util.PlayerControllerMove)1 PlayerNavigation (net.citizensnpcs.nms.v1_13_R2.util.PlayerNavigation)1