Search in sources :

Example 1 with PacketPlayOutEntityEquipment

use of net.minecraft.server.v1_13_R2.PacketPlayOutEntityEquipment in project InteractionVisualizer by LOOHP.

the class V1_16 method createEntityEquipmentPacket.

@Override
public PacketContainer[] createEntityEquipmentPacket(int entityId, List<ValuePairs<EquipmentSlot, ItemStack>> equipments) {
    List<Pair<EnumItemSlot, net.minecraft.server.v1_16_R1.ItemStack>> nmsList = new ArrayList<>();
    for (ValuePairs<EquipmentSlot, ItemStack> pair : equipments) {
        EnumItemSlot nmsSlot;
        switch(pair.getFirst()) {
            case CHEST:
                nmsSlot = EnumItemSlot.CHEST;
                break;
            case FEET:
                nmsSlot = EnumItemSlot.FEET;
                break;
            case HEAD:
                nmsSlot = EnumItemSlot.HEAD;
                break;
            case LEGS:
                nmsSlot = EnumItemSlot.LEGS;
                break;
            case OFF_HAND:
                nmsSlot = EnumItemSlot.OFFHAND;
                break;
            case HAND:
            default:
                nmsSlot = EnumItemSlot.MAINHAND;
                break;
        }
        net.minecraft.server.v1_16_R1.ItemStack nmsItem = CraftItemStack.asNMSCopy(pair.getSecond());
        nmsList.add(new Pair<>(nmsSlot, nmsItem));
    }
    PacketPlayOutEntityEquipment packet = new PacketPlayOutEntityEquipment(entityId, nmsList);
    return new PacketContainer[] { PacketContainer.fromPacket(packet) };
}
Also used : PacketContainer(com.comphenix.protocol.events.PacketContainer) ArrayList(java.util.ArrayList) EquipmentSlot(org.bukkit.inventory.EquipmentSlot) EnumItemSlot(net.minecraft.server.v1_16_R1.EnumItemSlot) CraftItemStack(org.bukkit.craftbukkit.v1_16_R1.inventory.CraftItemStack) ItemStack(org.bukkit.inventory.ItemStack) PacketPlayOutEntityEquipment(net.minecraft.server.v1_16_R1.PacketPlayOutEntityEquipment) Pair(com.mojang.datafixers.util.Pair)

Example 2 with PacketPlayOutEntityEquipment

use of net.minecraft.server.v1_13_R2.PacketPlayOutEntityEquipment in project InteractionVisualizer by LOOHP.

the class V1_16_2 method createEntityEquipmentPacket.

@Override
public PacketContainer[] createEntityEquipmentPacket(int entityId, List<ValuePairs<EquipmentSlot, ItemStack>> equipments) {
    List<Pair<EnumItemSlot, net.minecraft.server.v1_16_R2.ItemStack>> nmsList = new ArrayList<>();
    for (ValuePairs<EquipmentSlot, ItemStack> pair : equipments) {
        EnumItemSlot nmsSlot;
        switch(pair.getFirst()) {
            case CHEST:
                nmsSlot = EnumItemSlot.CHEST;
                break;
            case FEET:
                nmsSlot = EnumItemSlot.FEET;
                break;
            case HEAD:
                nmsSlot = EnumItemSlot.HEAD;
                break;
            case LEGS:
                nmsSlot = EnumItemSlot.LEGS;
                break;
            case OFF_HAND:
                nmsSlot = EnumItemSlot.OFFHAND;
                break;
            case HAND:
            default:
                nmsSlot = EnumItemSlot.MAINHAND;
                break;
        }
        net.minecraft.server.v1_16_R2.ItemStack nmsItem = CraftItemStack.asNMSCopy(pair.getSecond());
        nmsList.add(new Pair<>(nmsSlot, nmsItem));
    }
    PacketPlayOutEntityEquipment packet = new PacketPlayOutEntityEquipment(entityId, nmsList);
    return new PacketContainer[] { PacketContainer.fromPacket(packet) };
}
Also used : PacketContainer(com.comphenix.protocol.events.PacketContainer) ArrayList(java.util.ArrayList) EquipmentSlot(org.bukkit.inventory.EquipmentSlot) EnumItemSlot(net.minecraft.server.v1_16_R2.EnumItemSlot) CraftItemStack(org.bukkit.craftbukkit.v1_16_R2.inventory.CraftItemStack) ItemStack(org.bukkit.inventory.ItemStack) PacketPlayOutEntityEquipment(net.minecraft.server.v1_16_R2.PacketPlayOutEntityEquipment) Pair(com.mojang.datafixers.util.Pair)

Example 3 with PacketPlayOutEntityEquipment

use of net.minecraft.server.v1_13_R2.PacketPlayOutEntityEquipment in project InteractionVisualizer by LOOHP.

the class V1_16_4 method createEntityEquipmentPacket.

@Override
public PacketContainer[] createEntityEquipmentPacket(int entityId, List<ValuePairs<EquipmentSlot, ItemStack>> equipments) {
    List<Pair<EnumItemSlot, net.minecraft.server.v1_16_R3.ItemStack>> nmsList = new ArrayList<>();
    for (ValuePairs<EquipmentSlot, ItemStack> pair : equipments) {
        EnumItemSlot nmsSlot;
        switch(pair.getFirst()) {
            case CHEST:
                nmsSlot = EnumItemSlot.CHEST;
                break;
            case FEET:
                nmsSlot = EnumItemSlot.FEET;
                break;
            case HEAD:
                nmsSlot = EnumItemSlot.HEAD;
                break;
            case LEGS:
                nmsSlot = EnumItemSlot.LEGS;
                break;
            case OFF_HAND:
                nmsSlot = EnumItemSlot.OFFHAND;
                break;
            case HAND:
            default:
                nmsSlot = EnumItemSlot.MAINHAND;
                break;
        }
        net.minecraft.server.v1_16_R3.ItemStack nmsItem = CraftItemStack.asNMSCopy(pair.getSecond());
        nmsList.add(new Pair<>(nmsSlot, nmsItem));
    }
    PacketPlayOutEntityEquipment packet = new PacketPlayOutEntityEquipment(entityId, nmsList);
    return new PacketContainer[] { PacketContainer.fromPacket(packet) };
}
Also used : PacketContainer(com.comphenix.protocol.events.PacketContainer) ArrayList(java.util.ArrayList) EquipmentSlot(org.bukkit.inventory.EquipmentSlot) EnumItemSlot(net.minecraft.server.v1_16_R3.EnumItemSlot) CraftItemStack(org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack) ItemStack(org.bukkit.inventory.ItemStack) PacketPlayOutEntityEquipment(net.minecraft.server.v1_16_R3.PacketPlayOutEntityEquipment) Pair(com.mojang.datafixers.util.Pair)

Example 4 with PacketPlayOutEntityEquipment

use of net.minecraft.server.v1_13_R2.PacketPlayOutEntityEquipment in project MechanicsMain by WeaponMechanics.

the class FakeEntity_1_13_R2 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, 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 : CraftPlayer(org.bukkit.craftbukkit.v1_13_R2.entity.CraftPlayer) Player(org.bukkit.entity.Player) PacketPlayOutEntityLook(net.minecraft.server.v1_13_R2.PacketPlayOutEntity.PacketPlayOutEntityLook)

Example 5 with PacketPlayOutEntityEquipment

use of net.minecraft.server.v1_13_R2.PacketPlayOutEntityEquipment 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_11_R1.EnumItemSlot) Packet(net.minecraft.server.v1_11_R1.Packet) ItemStack(net.minecraft.server.v1_11_R1.ItemStack) PacketPlayOutEntityEquipment(net.minecraft.server.v1_11_R1.PacketPlayOutEntityEquipment) Location(org.bukkit.Location)

Aggregations

Location (org.bukkit.Location)9 Pair (com.mojang.datafixers.util.Pair)4 ArrayList (java.util.ArrayList)4 PacketContainer (com.comphenix.protocol.events.PacketContainer)3 PacketPlayOutEntityEquipment (net.minecraft.server.v1_16_R3.PacketPlayOutEntityEquipment)3 Player (org.bukkit.entity.Player)3 EquipmentSlot (org.bukkit.inventory.EquipmentSlot)3 ItemStack (org.bukkit.inventory.ItemStack)3 PacketPlayOutEntityLook (net.minecraft.server.v1_13_R2.PacketPlayOutEntity.PacketPlayOutEntityLook)2 EnumItemSlot (net.minecraft.server.v1_16_R3.EnumItemSlot)2 Vector (org.bukkit.util.Vector)2 UltraCosmeticsData (be.isach.ultracosmetics.UltraCosmeticsData)1 ChestType (be.isach.ultracosmetics.treasurechests.ChestType)1 TreasureChestDesign (be.isach.ultracosmetics.treasurechests.TreasureChestDesign)1 MathUtils (be.isach.ultracosmetics.util.MathUtils)1 PacketSender (be.isach.ultracosmetics.util.PacketSender)1 Particles (be.isach.ultracosmetics.util.Particles)1 UtilParticles (be.isach.ultracosmetics.util.UtilParticles)1 CustomPathFinderGoalPanic (be.isach.ultracosmetics.v1_13_R2.pathfinders.CustomPathFinderGoalPanic)1 IEntityUtil (be.isach.ultracosmetics.version.IEntityUtil)1