Search in sources :

Example 6 with ControllerMove

use of net.minecraft.server.v1_15_R1.ControllerMove in project Citizens2 by CitizensDev.

the class NMSImpl method getDestination.

@Override
public Location getDestination(org.bukkit.entity.Entity entity) {
    Entity handle = getHandle(entity);
    ControllerMove controller = handle instanceof EntityInsentient ? ((EntityInsentient) handle).getControllerMove() : handle instanceof EntityHumanNPC ? ((EntityHumanNPC) handle).getControllerMove() : null;
    return new Location(entity.getWorld(), controller.d(), controller.e(), controller.f());
}
Also used : CraftEntity(org.bukkit.craftbukkit.v1_15_R1.entity.CraftEntity) LivingEntity(org.bukkit.entity.LivingEntity) Entity(net.minecraft.server.v1_15_R1.Entity) SkinnableEntity(net.citizensnpcs.npc.skin.SkinnableEntity) PathEntity(net.minecraft.server.v1_15_R1.PathEntity) EntityInsentient(net.minecraft.server.v1_15_R1.EntityInsentient) ControllerMove(net.minecraft.server.v1_15_R1.ControllerMove) EntityHumanNPC(net.citizensnpcs.nms.v1_15_R1.entity.EntityHumanNPC) Location(org.bukkit.Location)

Example 7 with ControllerMove

use of net.minecraft.server.v1_15_R1.ControllerMove in project Citizens2 by CitizensDev.

the class NMSImpl method getDestination.

@Override
public Location getDestination(org.bukkit.entity.Entity entity) {
    Entity handle = getHandle(entity);
    ControllerMove controller = handle instanceof EntityInsentient ? ((EntityInsentient) handle).getControllerMove() : handle instanceof EntityHumanNPC ? ((EntityHumanNPC) handle).getControllerMove() : null;
    return new Location(entity.getWorld(), controller.d(), controller.e(), controller.f());
}
Also used : Entity(net.minecraft.server.v1_16_R3.Entity) LivingEntity(org.bukkit.entity.LivingEntity) SkinnableEntity(net.citizensnpcs.npc.skin.SkinnableEntity) CraftEntity(org.bukkit.craftbukkit.v1_16_R3.entity.CraftEntity) PathEntity(net.minecraft.server.v1_16_R3.PathEntity) EntityInsentient(net.minecraft.server.v1_16_R3.EntityInsentient) ControllerMove(net.minecraft.server.v1_16_R3.ControllerMove) EntityHumanNPC(net.citizensnpcs.nms.v1_16_R3.entity.EntityHumanNPC) Location(org.bukkit.Location)

Example 8 with ControllerMove

use of net.minecraft.server.v1_15_R1.ControllerMove in project Citizens2 by CitizensDev.

the class EntityHumanNPC method initialise.

private void initialise(MinecraftServer minecraftServer) {
    Socket socket = new EmptySocket();
    NetworkManager conn = null;
    try {
        conn = new EmptyNetworkManager(EnumProtocolDirection.CLIENTBOUND);
        playerConnection = new EmptyNetHandler(minecraftServer, conn, this);
        conn.setPacketListener(playerConnection);
        socket.close();
    } catch (IOException e) {
    // swallow
    }
    AttributeInstance range = getAttributeInstance(GenericAttributes.FOLLOW_RANGE);
    if (range == null) {
        range = getAttributeMap().b(GenericAttributes.FOLLOW_RANGE);
    }
    range.setValue(Setting.DEFAULT_PATHFINDING_RANGE.asDouble());
    controllerJump = new PlayerControllerJump(this);
    controllerLook = new PlayerControllerLook(this);
    controllerMove = new PlayerControllerMove(this);
    navigation = new PlayerNavigation(this, world);
    invulnerableTicks = 0;
    // the default (0) breaks step climbing
    NMS.setStepHeight(getBukkitEntity(), 1);
    setSkinFlags((byte) 0xFF);
    EmptyAdvancementDataPlayer.clear(this.getAdvancementData());
    NMSImpl.setAdvancement(this.getBukkitEntity(), new EmptyAdvancementDataPlayer(minecraftServer, CitizensAPI.getDataFolder().getParentFile(), this));
}
Also used : EmptyNetworkManager(net.citizensnpcs.nms.v1_15_R1.network.EmptyNetworkManager) PlayerControllerLook(net.citizensnpcs.nms.v1_15_R1.util.PlayerControllerLook) EmptySocket(net.citizensnpcs.nms.v1_15_R1.network.EmptySocket) EmptyNetHandler(net.citizensnpcs.nms.v1_15_R1.network.EmptyNetHandler) PlayerControllerMove(net.citizensnpcs.nms.v1_15_R1.util.PlayerControllerMove) PlayerNavigation(net.citizensnpcs.nms.v1_15_R1.util.PlayerNavigation) AttributeInstance(net.minecraft.server.v1_15_R1.AttributeInstance) PlayerControllerJump(net.citizensnpcs.nms.v1_15_R1.util.PlayerControllerJump) IOException(java.io.IOException) EmptyAdvancementDataPlayer(net.citizensnpcs.nms.v1_15_R1.util.EmptyAdvancementDataPlayer) EmptyNetworkManager(net.citizensnpcs.nms.v1_15_R1.network.EmptyNetworkManager) NetworkManager(net.minecraft.server.v1_15_R1.NetworkManager) Socket(java.net.Socket) EmptySocket(net.citizensnpcs.nms.v1_15_R1.network.EmptySocket)

Example 9 with ControllerMove

use of net.minecraft.server.v1_15_R1.ControllerMove in project Citizens2 by CitizensDev.

the class NMSImpl method getDestination.

@Override
public Location getDestination(org.bukkit.entity.Entity entity) {
    Entity handle = getHandle(entity);
    ControllerMove controller = handle instanceof EntityInsentient ? ((EntityInsentient) handle).getControllerMove() : handle instanceof EntityHumanNPC ? ((EntityHumanNPC) handle).getControllerMove() : null;
    return new Location(entity.getWorld(), controller.d(), controller.e(), controller.f());
}
Also used : PathEntity(net.minecraft.server.v1_12_R1.PathEntity) LivingEntity(org.bukkit.entity.LivingEntity) SkinnableEntity(net.citizensnpcs.npc.skin.SkinnableEntity) CraftEntity(org.bukkit.craftbukkit.v1_12_R1.entity.CraftEntity) Entity(net.minecraft.server.v1_12_R1.Entity) EntityInsentient(net.minecraft.server.v1_12_R1.EntityInsentient) ControllerMove(net.minecraft.server.v1_12_R1.ControllerMove) EntityHumanNPC(net.citizensnpcs.nms.v1_12_R1.entity.EntityHumanNPC) Location(org.bukkit.Location)

Example 10 with ControllerMove

use of net.minecraft.server.v1_15_R1.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_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)

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 EntityHumanNPC (net.citizensnpcs.nms.v1_14_R1.entity.EntityHumanNPC)1 EntityHumanNPC (net.citizensnpcs.nms.v1_15_R1.entity.EntityHumanNPC)1 EmptyNetHandler (net.citizensnpcs.nms.v1_15_R1.network.EmptyNetHandler)1 EmptyNetworkManager (net.citizensnpcs.nms.v1_15_R1.network.EmptyNetworkManager)1 EmptySocket (net.citizensnpcs.nms.v1_15_R1.network.EmptySocket)1 EmptyAdvancementDataPlayer (net.citizensnpcs.nms.v1_15_R1.util.EmptyAdvancementDataPlayer)1 PlayerControllerJump (net.citizensnpcs.nms.v1_15_R1.util.PlayerControllerJump)1 PlayerControllerLook (net.citizensnpcs.nms.v1_15_R1.util.PlayerControllerLook)1