Search in sources :

Example 21 with Packet

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

the class PlayerAnimationImpl method playDefaultAnimation.

protected static void playDefaultAnimation(EntityPlayer player, int radius, int code) {
    PacketPlayOutAnimation packet = new PacketPlayOutAnimation(player, code);
    sendPacketNearby(packet, player, radius);
}
Also used : PacketPlayOutAnimation(net.minecraft.server.v1_15_R1.PacketPlayOutAnimation)

Example 22 with Packet

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

the class EntityHumanNPC method updatePackets.

private void updatePackets(boolean navigating) {
    updateCounter++;
    boolean itemChanged = false;
    for (EnumItemSlot slot : EnumItemSlot.values()) {
        ItemStack equipment = getEquipment(slot);
        ItemStack cache = equipmentCache.get(slot);
        if (!(cache == null && equipment == null) && (cache == null ^ equipment == null || !ItemStack.equals(cache, equipment))) {
            itemChanged = true;
        }
        equipmentCache.put(slot, equipment);
    }
    if (updateCounter++ <= npc.data().<Integer>get(NPC.Metadata.PACKET_UPDATE_DELAY, Setting.PACKET_UPDATE_DELAY.asInt()) && !itemChanged)
        return;
    updateCounter = 0;
    Location current = getBukkitEntity().getLocation(packetLocationCache);
    Packet<?>[] packets = new Packet[EnumItemSlot.values().length];
    int i = 0;
    for (EnumItemSlot slot : EnumItemSlot.values()) {
        packets[i++] = new PacketPlayOutEntityEquipment(getId(), slot, getEquipment(slot));
    }
    NMSImpl.sendPacketsNearby(getBukkitEntity(), current, packets);
}
Also used : EnumItemSlot(net.minecraft.server.v1_10_R1.EnumItemSlot) Packet(net.minecraft.server.v1_10_R1.Packet) ItemStack(net.minecraft.server.v1_10_R1.ItemStack) PacketPlayOutEntityEquipment(net.minecraft.server.v1_10_R1.PacketPlayOutEntityEquipment) Location(org.bukkit.Location)

Example 23 with Packet

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

the class EntityHumanNPC method updatePackets.

private void updatePackets(boolean navigating) {
    updateCounter++;
    boolean itemChanged = false;
    for (int slot = 0; slot < this.inventory.armor.length; slot++) {
        ItemStack equipment = getEquipment(slot);
        ItemStack cache = equipmentCache.get(slot);
        if (!(cache == null && equipment == null) && (cache == null ^ equipment == null || !ItemStack.equals(cache, equipment))) {
            itemChanged = true;
        }
        equipmentCache.put(slot, equipment);
    }
    if (updateCounter++ <= npc.data().<Integer>get(NPC.Metadata.PACKET_UPDATE_DELAY, Setting.PACKET_UPDATE_DELAY.asInt()) && !itemChanged)
        return;
    updateCounter = 0;
    Location current = getBukkitEntity().getLocation(packetLocationCache);
    Packet<?>[] packets = new Packet[this.inventory.armor.length];
    for (int i = 0; i < this.inventory.armor.length; i++) {
        packets[i] = new PacketPlayOutEntityEquipment(getId(), i, getEquipment(i));
    }
    NMSImpl.sendPacketsNearby(getBukkitEntity(), current, packets);
}
Also used : Packet(net.minecraft.server.v1_8_R3.Packet) ItemStack(net.minecraft.server.v1_8_R3.ItemStack) PacketPlayOutEntityEquipment(net.minecraft.server.v1_8_R3.PacketPlayOutEntityEquipment) Location(org.bukkit.Location)

Example 24 with Packet

use of net.minecraft.server.v1_15_R1.Packet in project SimplePets by brainsynder-Dev.

the class EntityControllerPet method reloadLocation.

@Override
public void reloadLocation() {
    if (displayEntity.getPassenger() != null) {
        net.minecraft.server.v1_15_R1.Entity displayEntity = ((CraftEntity) this.displayEntity).getHandle();
        Location loc;
        if (this.displayRider != null) {
            if (this.displayRider.getType().equals(EntityType.SHULKER)) {
                loc = getBukkitEntity().getLocation().clone().subtract(0, 0.735, 0);
            } else {
                loc = getBukkitEntity().getLocation().clone();
            }
        } else {
            loc = getBukkitEntity().getLocation().clone();
        }
        displayEntity.setPositionRotation(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch());
        loc.getWorld().getNearbyEntities(loc, 100, 100, 100).forEach(entity -> {
            if (entity instanceof Player) {
                Player player = (Player) entity;
                PacketPlayOutEntityTeleport packet = new PacketPlayOutEntityTeleport(displayEntity);
                ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
            }
        });
        return;
    }
    net.minecraft.server.v1_15_R1.Entity displayEntity = ((CraftEntity) this.displayEntity).getHandle();
    Location loc;
    if (this.displayRider != null) {
        if (this.displayRider.getType().equals(EntityType.SHULKER)) {
            loc = getBukkitEntity().getLocation().clone().add(0, 0.75, 0);
        } else {
            loc = getBukkitEntity().getLocation().clone();
        }
    } else {
        loc = getBukkitEntity().getLocation().clone();
    }
    displayEntity.setPositionRotation(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch());
    loc.getWorld().getNearbyEntities(loc, 100, 100, 100).forEach(entity -> {
        if (entity instanceof Player) {
            Player player = (Player) entity;
            PacketPlayOutEntityTeleport packet = new PacketPlayOutEntityTeleport(displayEntity);
            ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
        }
    });
}
Also used : net.minecraft.server.v1_15_R1(net.minecraft.server.v1_15_R1) Player(org.bukkit.entity.Player) CraftPlayer(org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer) CraftEntity(org.bukkit.craftbukkit.v1_15_R1.entity.CraftEntity) CraftPlayer(org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer) Location(org.bukkit.Location)

Example 25 with Packet

use of net.minecraft.server.v1_15_R1.Packet in project jop by jop-devel.

the class Ppp method doSend.

void doSend() {
    if (reconnectRequest) {
        // System.out.print("3");
        // start over
        modemHangUp();
        modemInit();
    }
    if (disconnectRequest) {
        // stop the connection
        modemHangUp();
    }
    if (state == CONNECTED) {
        // send waiting ip packets
        if (scnt == 0) {
            // transmit buffer is free
            // use IP timeout
            globTimer = Timer.getTimeoutMs(IP_SEND);
            // 
            // get a ready to send packet with source from this driver.
            // 
            Packet p = PacketPool.getTxPacket(single);
            if (p != null) {
                // send one packet
                sendIp(p);
            }
        } else {
            // check sendTimer;
            if (Timer.timeout(globTimer)) {
                // System.out.print("4");
                // start over
                modemHangUp();
                modemInit();
            }
        }
    } else {
        // do the negotiation stuff
        dropIp();
        if (Timer.timeout(globTimer)) {
            /*
Dbg.intVal(state);
if (lcpAck) Dbg.wr('t'); else Dbg.wr('f');
*/
            if (scnt == 0) {
                // once every three seconds send a REQ
                if (state == MODEM_OK) {
                    makeLCP();
                    state = LCP_SENT;
                } else if (state == LCP_OK && lcpAck) {
                    makePAP();
                    state = PAP_SENT;
                // } else if (state == PAP_OK && ipcpAck) { // wait for remote ipcp and ACK first on Linux
                } else if (state >= PAP_OK && state < CONNECTED) {
                    // ONE
                    makeIPCP();
                    state = IPCP_SENT;
                    // incremenet counter to start over when no respond
                    ++rejCnt;
                }
                // use negotiation timeout
                globTimer = Timer.getTimeoutMs(NEG_SEND);
            }
        }
    }
}
Also used : Packet(ejip123.Packet)

Aggregations

Location (org.bukkit.Location)10 CraftPlayer (org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer)10 GameProfile (com.mojang.authlib.GameProfile)9 Player (org.bukkit.entity.Player)6 ParallelWorld (thpmc.engine.api.world.parallel.ParallelWorld)5 Packet (com.yahoo.fs4.Packet)4 EntityPlayer (net.minecraft.server.v1_15_R1.EntityPlayer)4 BasicPacket (com.yahoo.fs4.BasicPacket)3 ChannelTimeoutException (com.yahoo.fs4.ChannelTimeoutException)3 QueryPacket (com.yahoo.fs4.QueryPacket)3 Packet (ejip123.Packet)3 PacketPlayOutEntityLook (net.minecraft.server.v1_15_R1.PacketPlayOutEntity.PacketPlayOutEntityLook)3 World (org.bukkit.World)3 ParallelUniverse (thpmc.engine.api.world.parallel.ParallelUniverse)3 GetDocSumsPacket (com.yahoo.fs4.GetDocSumsPacket)2 PingPacket (com.yahoo.fs4.PingPacket)2 PongPacket (com.yahoo.fs4.PongPacket)2 QueryResultPacket (com.yahoo.fs4.QueryResultPacket)2 InvalidChannelException (com.yahoo.fs4.mplex.InvalidChannelException)2 Result (com.yahoo.search.Result)2