Search in sources :

Example 6 with ControllerJump

use of net.minecraft.server.v1_16_R3.ControllerJump in project Citizens2 by CitizensDev.

the class NMSImpl method setShouldJump.

@Override
public void setShouldJump(org.bukkit.entity.Entity entity) {
    Entity handle = NMSImpl.getHandle(entity);
    if (handle == null)
        return;
    if (handle instanceof EntityInsentient) {
        ControllerJump controller = ((EntityInsentient) handle).getControllerJump();
        controller.jump();
    } else if (handle instanceof EntityHumanNPC) {
        ((EntityHumanNPC) handle).setShouldJump();
    }
}
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) ControllerJump(net.minecraft.server.v1_15_R1.ControllerJump) EntityHumanNPC(net.citizensnpcs.nms.v1_15_R1.entity.EntityHumanNPC)

Example 7 with ControllerJump

use of net.minecraft.server.v1_16_R3.ControllerJump 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
    }
    AttributeModifiable range = getAttributeInstance(GenericAttributes.FOLLOW_RANGE);
    if (range == null) {
        try {
            AttributeProvider provider = (AttributeProvider) ATTRIBUTE_MAP.invoke(getAttributeMap());
            Map<AttributeBase, AttributeModifiable> all = Maps.newHashMap((Map<AttributeBase, AttributeModifiable>) ATTRIBUTE_PROVIDER_MAP.invoke(provider));
            all.put(GenericAttributes.FOLLOW_RANGE, new AttributeModifiable(GenericAttributes.FOLLOW_RANGE, new Consumer<AttributeModifiable>() {

                @Override
                public void accept(AttributeModifiable att) {
                    throw new UnsupportedOperationException("Tried to change value for default attribute instance FOLLOW_RANGE");
                }
            }));
            ATTRIBUTE_PROVIDER_MAP_SETTER.invoke(provider, ImmutableMap.copyOf(all));
        } catch (Throwable e) {
            e.printStackTrace();
        }
        range = getAttributeMap().a(GenericAttributes.FOLLOW_RANGE);
    }
    range.setValue(Setting.DEFAULT_PATHFINDING_RANGE.asDouble());
    controllerJump = new PlayerControllerJump(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.getDataFixer(), minecraftServer.getPlayerList(), minecraftServer.getAdvancementData(), CitizensAPI.getDataFolder().getParentFile(), this));
}
Also used : EmptyNetworkManager(net.citizensnpcs.nms.v1_16_R3.network.EmptyNetworkManager) EmptySocket(net.citizensnpcs.nms.v1_16_R3.network.EmptySocket) IOException(java.io.IOException) EmptyNetHandler(net.citizensnpcs.nms.v1_16_R3.network.EmptyNetHandler) PlayerControllerMove(net.citizensnpcs.nms.v1_16_R3.util.PlayerControllerMove) Consumer(java.util.function.Consumer) AttributeModifiable(net.minecraft.server.v1_16_R3.AttributeModifiable) PlayerNavigation(net.citizensnpcs.nms.v1_16_R3.util.PlayerNavigation) PlayerControllerJump(net.citizensnpcs.nms.v1_16_R3.util.PlayerControllerJump) AttributeBase(net.minecraft.server.v1_16_R3.AttributeBase) EmptyAdvancementDataPlayer(net.citizensnpcs.nms.v1_16_R3.util.EmptyAdvancementDataPlayer) EmptyNetworkManager(net.citizensnpcs.nms.v1_16_R3.network.EmptyNetworkManager) NetworkManager(net.minecraft.server.v1_16_R3.NetworkManager) Socket(java.net.Socket) EmptySocket(net.citizensnpcs.nms.v1_16_R3.network.EmptySocket) AttributeProvider(net.minecraft.server.v1_16_R3.AttributeProvider)

Example 8 with ControllerJump

use of net.minecraft.server.v1_16_R3.ControllerJump in project Citizens2 by CitizensDev.

the class NMSImpl method setShouldJump.

@Override
public void setShouldJump(org.bukkit.entity.Entity entity) {
    Entity handle = NMSImpl.getHandle(entity);
    if (handle == null)
        return;
    if (handle instanceof EntityInsentient) {
        ControllerJump controller = ((EntityInsentient) handle).getControllerJump();
        controller.a();
    } else if (handle instanceof EntityHumanNPC) {
        ((EntityHumanNPC) handle).setShouldJump();
    }
}
Also used : PathEntity(net.minecraft.server.v1_11_R1.PathEntity) LivingEntity(org.bukkit.entity.LivingEntity) CraftEntity(org.bukkit.craftbukkit.v1_11_R1.entity.CraftEntity) SkinnableEntity(net.citizensnpcs.npc.skin.SkinnableEntity) Entity(net.minecraft.server.v1_11_R1.Entity) EntityInsentient(net.minecraft.server.v1_11_R1.EntityInsentient) ControllerJump(net.minecraft.server.v1_11_R1.ControllerJump) EntityHumanNPC(net.citizensnpcs.nms.v1_11_R1.entity.EntityHumanNPC)

Example 9 with ControllerJump

use of net.minecraft.server.v1_16_R3.ControllerJump in project Citizens2 by CitizensDev.

the class NMSImpl method setShouldJump.

@Override
public void setShouldJump(org.bukkit.entity.Entity entity) {
    Entity handle = NMSImpl.getHandle(entity);
    if (handle == null)
        return;
    if (handle instanceof EntityInsentient) {
        ControllerJump controller = ((EntityInsentient) handle).getControllerJump();
        controller.jump();
    } else if (handle instanceof EntityHumanNPC) {
        ((EntityHumanNPC) handle).setShouldJump();
    }
}
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) ControllerJump(net.minecraft.server.v1_16_R3.ControllerJump) EntityHumanNPC(net.citizensnpcs.nms.v1_16_R3.entity.EntityHumanNPC)

Aggregations

SkinnableEntity (net.citizensnpcs.npc.skin.SkinnableEntity)8 LivingEntity (org.bukkit.entity.LivingEntity)8 IOException (java.io.IOException)1 Socket (java.net.Socket)1 Consumer (java.util.function.Consumer)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 EntityHumanNPC (net.citizensnpcs.nms.v1_16_R3.entity.EntityHumanNPC)1 EmptyNetHandler (net.citizensnpcs.nms.v1_16_R3.network.EmptyNetHandler)1 EmptyNetworkManager (net.citizensnpcs.nms.v1_16_R3.network.EmptyNetworkManager)1 EmptySocket (net.citizensnpcs.nms.v1_16_R3.network.EmptySocket)1 EmptyAdvancementDataPlayer (net.citizensnpcs.nms.v1_16_R3.util.EmptyAdvancementDataPlayer)1 PlayerControllerJump (net.citizensnpcs.nms.v1_16_R3.util.PlayerControllerJump)1 PlayerControllerMove (net.citizensnpcs.nms.v1_16_R3.util.PlayerControllerMove)1 PlayerNavigation (net.citizensnpcs.nms.v1_16_R3.util.PlayerNavigation)1 EntityHumanNPC (net.citizensnpcs.nms.v1_8_R3.entity.EntityHumanNPC)1