Search in sources :

Example 16 with PacketPlayOutEntityMetadata

use of net.minecraft.server.v1_14_R1.PacketPlayOutEntityMetadata in project MechanicsMain by WeaponMechanics.

the class FakeEntity_1_14_R1 method show.

public void show() {
    // Construct the packets out of the loop to save resources, they will
    // be the same for each Player.
    Packet<?> spawn = type.isAlive() ? new PacketPlayOutSpawnEntityLiving((EntityLiving) entity) : new PacketPlayOutSpawnEntity(entity, type == EntityType.FALLING_BLOCK ? Block.getCombinedId(block) : 0);
    PacketPlayOutEntityMetadata meta = new PacketPlayOutEntityMetadata(cache, entity.getDataWatcher(), true);
    PacketPlayOutEntityHeadRotation head = new PacketPlayOutEntityHeadRotation(entity, convertYaw(getYaw()));
    PacketPlayOutEntityLook look = new PacketPlayOutEntityLook(cache, convertYaw(getYaw()), convertPitch(getPitch()), false);
    PacketPlayOutEntityVelocity velocity = new PacketPlayOutEntityVelocity(cache, new Vec3D(motion.getX(), motion.getY(), motion.getZ()));
    for (Player temp : DistanceUtil.getPlayersInRange(location)) {
        PlayerConnection connection = ((CraftPlayer) temp).getHandle().playerConnection;
        if (connections.contains(connection)) {
            continue;
        }
        connection.sendPacket(spawn);
        connection.sendPacket(meta);
        connection.sendPacket(head);
        connection.sendPacket(velocity);
        connection.sendPacket(look);
        PacketPlayOutEntityEquipment[] equipment = getEquipmentPacket();
        if (equipment != null) {
            for (PacketPlayOutEntityEquipment packet : equipment) {
                connection.sendPacket(packet);
            }
        }
        connections.add(connection);
    }
}
Also used : Player(org.bukkit.entity.Player) CraftPlayer(org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer) PacketPlayOutEntityLook(net.minecraft.server.v1_14_R1.PacketPlayOutEntity.PacketPlayOutEntityLook)

Aggregations

MemoryNPCDataStore (net.citizensnpcs.api.npc.MemoryNPCDataStore)8 NPC (net.citizensnpcs.api.npc.NPC)8 NPCRegistry (net.citizensnpcs.api.npc.NPCRegistry)8 NPCHolder (net.citizensnpcs.npc.ai.NPCHolder)8 ArmorStandTrait (net.citizensnpcs.trait.ArmorStandTrait)8 FixedMetadataValue (org.bukkit.metadata.FixedMetadataValue)8 BukkitRunnable (org.bukkit.scheduler.BukkitRunnable)8 PacketPlayOutEntityMetadata (net.minecraft.server.v1_16_R3.PacketPlayOutEntityMetadata)4 ArrayList (java.util.ArrayList)2 PacketPlayOutEntityLook (net.minecraft.server.v1_14_R1.PacketPlayOutEntity.PacketPlayOutEntityLook)2 Item (net.minecraft.server.v1_16_R2.DataWatcher.Item)2 PacketPlayOutEntityMetadata (net.minecraft.server.v1_16_R2.PacketPlayOutEntityMetadata)2 Item (net.minecraft.server.v1_16_R3.DataWatcher.Item)2 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)1 ChannelOutboundHandlerAdapter (io.netty.channel.ChannelOutboundHandlerAdapter)1 ChannelPromise (io.netty.channel.ChannelPromise)1 BlockPosition (net.minecraft.server.v1_10_R1.BlockPosition)1 EntityPlayer (net.minecraft.server.v1_10_R1.EntityPlayer)1 PacketPlayOutBed (net.minecraft.server.v1_10_R1.PacketPlayOutBed)1 PacketPlayOutEntityMetadata (net.minecraft.server.v1_10_R1.PacketPlayOutEntityMetadata)1