Search in sources :

Example 1 with NetworkManager

use of net.minecraft.server.v1_14_R1.NetworkManager in project DragonsOnline by UniverseCraft.

the class PlayerNPC116R3 method spawn.

public void spawn() {
    registry.unregister(this);
    uuid = UUID.randomUUID();
    this.isDestroyed = false;
    DedicatedServer server = ((CraftServer) Bukkit.getServer()).getServer();
    WorldServer world = ((CraftWorld) location.getWorld()).getHandle();
    // displayName);
    GameProfile gameProfile = new GameProfile(uuid, "");
    gameProfile.getProperties().clear();
    gameProfile.getProperties().put("textures", new Property("textures", texture, signature));
    this.handle = new EntityPlayer(server, world, gameProfile, new PlayerInteractManager(world));
    handle.persist = true;
    handle.collides = false;
    handle.setCustomNameVisible(false);
    handle.setInvulnerable(npc.isImmortal());
    handle.playerConnection = new PlayerConnection(((CraftServer) Bukkit.getServer()).getServer(), new NetworkManager(EnumProtocolDirection.SERVERBOUND), handle);
    ((CraftWorld) location.getWorld()).addEntity(handle, CreatureSpawnEvent.SpawnReason.CUSTOM);
    handle.setLocation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
    registry.register(this);
    for (Entity e : getEntity().getNearbyEntities(SPAWN_RADIUS, SPAWN_RADIUS, SPAWN_RADIUS)) {
        if (e instanceof Player) {
            registry.updateSpawns((Player) e, true);
        }
    }
}
Also used : Entity(org.bukkit.entity.Entity) PacketPlayOutEntity(net.minecraft.server.v1_16_R3.PacketPlayOutEntity) Player(org.bukkit.entity.Player) EntityPlayer(net.minecraft.server.v1_16_R3.EntityPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer) GameProfile(com.mojang.authlib.GameProfile) PlayerInteractManager(net.minecraft.server.v1_16_R3.PlayerInteractManager) EntityPlayer(net.minecraft.server.v1_16_R3.EntityPlayer) DedicatedServer(net.minecraft.server.v1_16_R3.DedicatedServer) WorldServer(net.minecraft.server.v1_16_R3.WorldServer) CraftServer(org.bukkit.craftbukkit.v1_16_R3.CraftServer) NetworkManager(net.minecraft.server.v1_16_R3.NetworkManager) CraftWorld(org.bukkit.craftbukkit.v1_16_R3.CraftWorld) Property(com.mojang.authlib.properties.Property) PlayerConnection(net.minecraft.server.v1_16_R3.PlayerConnection)

Example 2 with NetworkManager

use of net.minecraft.server.v1_14_R1.NetworkManager 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);
}
Also used : EmptyNetworkManager(net.citizensnpcs.nms.v1_11_R1.network.EmptyNetworkManager) PlayerControllerLook(net.citizensnpcs.nms.v1_11_R1.util.PlayerControllerLook) EmptySocket(net.citizensnpcs.nms.v1_11_R1.network.EmptySocket) EmptyNetHandler(net.citizensnpcs.nms.v1_11_R1.network.EmptyNetHandler) PlayerControllerMove(net.citizensnpcs.nms.v1_11_R1.util.PlayerControllerMove) PlayerNavigation(net.citizensnpcs.nms.v1_11_R1.util.PlayerNavigation) AttributeInstance(net.minecraft.server.v1_11_R1.AttributeInstance) PlayerControllerJump(net.citizensnpcs.nms.v1_11_R1.util.PlayerControllerJump) IOException(java.io.IOException) EmptyNetworkManager(net.citizensnpcs.nms.v1_11_R1.network.EmptyNetworkManager) NetworkManager(net.minecraft.server.v1_11_R1.NetworkManager) Socket(java.net.Socket) EmptySocket(net.citizensnpcs.nms.v1_11_R1.network.EmptySocket)

Example 3 with NetworkManager

use of net.minecraft.server.v1_14_R1.NetworkManager 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_14_R1.network.EmptyNetworkManager) PlayerControllerLook(net.citizensnpcs.nms.v1_14_R1.util.PlayerControllerLook) EmptySocket(net.citizensnpcs.nms.v1_14_R1.network.EmptySocket) EmptyNetHandler(net.citizensnpcs.nms.v1_14_R1.network.EmptyNetHandler) PlayerControllerMove(net.citizensnpcs.nms.v1_14_R1.util.PlayerControllerMove) PlayerNavigation(net.citizensnpcs.nms.v1_14_R1.util.PlayerNavigation) AttributeInstance(net.minecraft.server.v1_14_R1.AttributeInstance) PlayerControllerJump(net.citizensnpcs.nms.v1_14_R1.util.PlayerControllerJump) IOException(java.io.IOException) EmptyAdvancementDataPlayer(net.citizensnpcs.nms.v1_14_R1.util.EmptyAdvancementDataPlayer) EmptyNetworkManager(net.citizensnpcs.nms.v1_14_R1.network.EmptyNetworkManager) NetworkManager(net.minecraft.server.v1_14_R1.NetworkManager) Socket(java.net.Socket) EmptySocket(net.citizensnpcs.nms.v1_14_R1.network.EmptySocket)

Example 4 with NetworkManager

use of net.minecraft.server.v1_14_R1.NetworkManager 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);
}
Also used : EmptyNetworkManager(net.citizensnpcs.nms.v1_10_R1.network.EmptyNetworkManager) PlayerControllerLook(net.citizensnpcs.nms.v1_10_R1.util.PlayerControllerLook) EmptySocket(net.citizensnpcs.nms.v1_10_R1.network.EmptySocket) EmptyNetHandler(net.citizensnpcs.nms.v1_10_R1.network.EmptyNetHandler) PlayerControllerMove(net.citizensnpcs.nms.v1_10_R1.util.PlayerControllerMove) PlayerNavigation(net.citizensnpcs.nms.v1_10_R1.util.PlayerNavigation) AttributeInstance(net.minecraft.server.v1_10_R1.AttributeInstance) PlayerControllerJump(net.citizensnpcs.nms.v1_10_R1.util.PlayerControllerJump) IOException(java.io.IOException) NetworkManager(net.minecraft.server.v1_10_R1.NetworkManager) EmptyNetworkManager(net.citizensnpcs.nms.v1_10_R1.network.EmptyNetworkManager) Socket(java.net.Socket) EmptySocket(net.citizensnpcs.nms.v1_10_R1.network.EmptySocket)

Example 5 with NetworkManager

use of net.minecraft.server.v1_14_R1.NetworkManager 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());
    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) PlayerControllerLook(net.citizensnpcs.nms.v1_12_R1.util.PlayerControllerLook) EmptySocket(net.citizensnpcs.nms.v1_12_R1.network.EmptySocket) IOException(java.io.IOException) 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) 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)8 Socket (java.net.Socket)8 GameProfile (com.mojang.authlib.GameProfile)1 Property (com.mojang.authlib.properties.Property)1 Consumer (java.util.function.Consumer)1 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 PlayerControllerLook (net.citizensnpcs.nms.v1_10_R1.util.PlayerControllerLook)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 PlayerControllerLook (net.citizensnpcs.nms.v1_11_R1.util.PlayerControllerLook)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