Search in sources :

Example 6 with EmptySocket

use of net.citizensnpcs.nms.v1_17_R1.network.EmptySocket 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);
    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());
    try {
        ADVANCEMENT_DATA_PLAYER.invoke(this, new EmptyAdvancementDataPlayer(minecraftServer, CitizensAPI.getDataFolder().getParentFile(), this));
    } catch (Throwable e) {
        e.printStackTrace();
    }
}
Also used : EmptyNetworkManager(net.citizensnpcs.nms.v1_13_R2.network.EmptyNetworkManager) EmptySocket(net.citizensnpcs.nms.v1_13_R2.network.EmptySocket) EmptyNetHandler(net.citizensnpcs.nms.v1_13_R2.network.EmptyNetHandler) PlayerControllerMove(net.citizensnpcs.nms.v1_13_R2.util.PlayerControllerMove) PlayerNavigation(net.citizensnpcs.nms.v1_13_R2.util.PlayerNavigation) AttributeInstance(net.minecraft.server.v1_13_R2.AttributeInstance) PlayerControllerJump(net.citizensnpcs.nms.v1_13_R2.util.PlayerControllerJump) IOException(java.io.IOException) EmptyAdvancementDataPlayer(net.citizensnpcs.nms.v1_13_R2.util.EmptyAdvancementDataPlayer) NetworkManager(net.minecraft.server.v1_13_R2.NetworkManager) EmptyNetworkManager(net.citizensnpcs.nms.v1_13_R2.network.EmptyNetworkManager) Socket(java.net.Socket) EmptySocket(net.citizensnpcs.nms.v1_13_R2.network.EmptySocket)

Example 7 with EmptySocket

use of net.citizensnpcs.nms.v1_17_R1.network.EmptySocket 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);
    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) 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 8 with EmptySocket

use of net.citizensnpcs.nms.v1_17_R1.network.EmptySocket 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.a(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);
    controllerMove = new PlayerControllerMove(this);
    navigation = new PlayerNavigation(this, world);
    invulnerableTicks = 0;
    // the default (0) breaks step climbing
    NMS.setStepHeight(getBukkitEntity(), 1);
    setSkinFlags((byte) 0xFF);
}
Also used : EmptyNetworkManager(net.citizensnpcs.nms.v1_8_R3.network.EmptyNetworkManager) EmptySocket(net.citizensnpcs.nms.v1_8_R3.network.EmptySocket) EmptyNetHandler(net.citizensnpcs.nms.v1_8_R3.network.EmptyNetHandler) PlayerControllerMove(net.citizensnpcs.nms.v1_8_R3.util.PlayerControllerMove) PlayerNavigation(net.citizensnpcs.nms.v1_8_R3.util.PlayerNavigation) AttributeInstance(net.minecraft.server.v1_8_R3.AttributeInstance) PlayerControllerJump(net.citizensnpcs.nms.v1_8_R3.util.PlayerControllerJump) IOException(java.io.IOException) EmptyNetworkManager(net.citizensnpcs.nms.v1_8_R3.network.EmptyNetworkManager) NetworkManager(net.minecraft.server.v1_8_R3.NetworkManager) EmptySocket(net.citizensnpcs.nms.v1_8_R3.network.EmptySocket) Socket(java.net.Socket)

Example 9 with EmptySocket

use of net.citizensnpcs.nms.v1_17_R1.network.EmptySocket 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 10 with EmptySocket

use of net.citizensnpcs.nms.v1_17_R1.network.EmptySocket 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);
    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());
    try {
        ADVANCEMENT_DATA_PLAYER.invoke(this, new EmptyAdvancementDataPlayer(minecraftServer, CitizensAPI.getDataFolder().getParentFile(), this));
    } catch (Throwable e) {
        e.printStackTrace();
    }
}
Also used : EmptyNetworkManager(net.citizensnpcs.nms.v1_12_R1.network.EmptyNetworkManager) EmptySocket(net.citizensnpcs.nms.v1_12_R1.network.EmptySocket) EmptyNetHandler(net.citizensnpcs.nms.v1_12_R1.network.EmptyNetHandler) PlayerControllerMove(net.citizensnpcs.nms.v1_12_R1.util.PlayerControllerMove) PlayerNavigation(net.citizensnpcs.nms.v1_12_R1.util.PlayerNavigation) AttributeInstance(net.minecraft.server.v1_12_R1.AttributeInstance) PlayerControllerJump(net.citizensnpcs.nms.v1_12_R1.util.PlayerControllerJump) IOException(java.io.IOException) EmptyAdvancementDataPlayer(net.citizensnpcs.nms.v1_12_R1.util.EmptyAdvancementDataPlayer) NetworkManager(net.minecraft.server.v1_12_R1.NetworkManager) EmptyNetworkManager(net.citizensnpcs.nms.v1_12_R1.network.EmptyNetworkManager) EmptySocket(net.citizensnpcs.nms.v1_12_R1.network.EmptySocket) Socket(java.net.Socket)

Aggregations

IOException (java.io.IOException)10 Socket (java.net.Socket)10 Consumer (java.util.function.Consumer)3 Attribute (net.minecraft.world.entity.ai.attributes.Attribute)2 AttributeInstance (net.minecraft.world.entity.ai.attributes.AttributeInstance)2 AttributeSupplier (net.minecraft.world.entity.ai.attributes.AttributeSupplier)2 EmptyNetHandler (net.citizensnpcs.nms.v1_10_R1.network.EmptyNetHandler)1 EmptyNetworkManager (net.citizensnpcs.nms.v1_10_R1.network.EmptyNetworkManager)1 EmptySocket (net.citizensnpcs.nms.v1_10_R1.network.EmptySocket)1 PlayerControllerJump (net.citizensnpcs.nms.v1_10_R1.util.PlayerControllerJump)1 PlayerControllerMove (net.citizensnpcs.nms.v1_10_R1.util.PlayerControllerMove)1 PlayerNavigation (net.citizensnpcs.nms.v1_10_R1.util.PlayerNavigation)1 EmptyNetHandler (net.citizensnpcs.nms.v1_11_R1.network.EmptyNetHandler)1 EmptyNetworkManager (net.citizensnpcs.nms.v1_11_R1.network.EmptyNetworkManager)1 EmptySocket (net.citizensnpcs.nms.v1_11_R1.network.EmptySocket)1 PlayerControllerJump (net.citizensnpcs.nms.v1_11_R1.util.PlayerControllerJump)1 PlayerControllerMove (net.citizensnpcs.nms.v1_11_R1.util.PlayerControllerMove)1 PlayerNavigation (net.citizensnpcs.nms.v1_11_R1.util.PlayerNavigation)1 EmptyNetHandler (net.citizensnpcs.nms.v1_12_R1.network.EmptyNetHandler)1 EmptyNetworkManager (net.citizensnpcs.nms.v1_12_R1.network.EmptyNetworkManager)1