Search in sources :

Example 16 with Packet

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

the class NMSImpl method sendPacketsNearby.

public static void sendPacketsNearby(Player from, Location location, Collection<Packet<?>> packets, double radius) {
    radius *= radius;
    final org.bukkit.World world = location.getWorld();
    for (Player ply : Bukkit.getServer().getOnlinePlayers()) {
        if (ply == null || world != ply.getWorld() || (from != null && !ply.canSee(from))) {
            continue;
        }
        if (location.distanceSquared(ply.getLocation(PACKET_CACHE_LOCATION)) > radius) {
            continue;
        }
        for (Packet<?> packet : packets) {
            NMSImpl.sendPacket(ply, packet);
        }
    }
}
Also used : Player(org.bukkit.entity.Player) EntityPlayer(net.minecraft.server.v1_12_R1.EntityPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer) World(org.bukkit.World)

Example 17 with Packet

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

the class EntityHumanNPC method updatePackets.

private void updatePackets(boolean navigating) {
    if (updateCounter++ <= Setting.PACKET_UPDATE_DELAY.asInt())
        return;
    updateCounter = 0;
    Location current = getBukkitEntity().getLocation(packetLocationCache);
    Packet<?>[] packets = new Packet[navigating ? EnumItemSlot.values().length : EnumItemSlot.values().length + 1];
    if (!navigating) {
        packets[5] = new PacketPlayOutEntityHeadRotation(this, (byte) MathHelper.d(NMSImpl.getHeadYaw(this) * 256.0F / 360.0F));
    }
    int i = 0;
    for (EnumItemSlot slot : EnumItemSlot.values()) {
        packets[i++] = new PacketPlayOutEntityEquipment(getId(), slot, getEquipment(slot));
    }
    NMSImpl.sendPacketsNearby(getBukkitEntity(), current, packets);
}
Also used : Packet(net.minecraft.server.v1_12_R1.Packet) EnumItemSlot(net.minecraft.server.v1_12_R1.EnumItemSlot) PacketPlayOutEntityHeadRotation(net.minecraft.server.v1_12_R1.PacketPlayOutEntityHeadRotation) PacketPlayOutEntityEquipment(net.minecraft.server.v1_12_R1.PacketPlayOutEntityEquipment) Location(org.bukkit.Location)

Aggregations

Packet (com.yahoo.fs4.Packet)4 Location (org.bukkit.Location)4 BasicPacket (com.yahoo.fs4.BasicPacket)3 ChannelTimeoutException (com.yahoo.fs4.ChannelTimeoutException)3 QueryPacket (com.yahoo.fs4.QueryPacket)3 Packet (ejip123.Packet)3 CraftPlayer (org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer)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 IOException (java.io.IOException)2 EntityPlayer (net.minecraft.server.v1_12_R1.EntityPlayer)2 Player (org.bukkit.entity.Player)2 CompressionType (com.yahoo.compress.CompressionType)1 IdString (com.yahoo.document.idstring.IdString)1 ParseException (com.yahoo.document.select.parser.ParseException)1 TokenMgrError (com.yahoo.document.select.parser.TokenMgrError)1