Search in sources :

Example 1 with PacketPlayOutEntityEquipment

use of net.minecraft.network.protocol.game.PacketPlayOutEntityEquipment in project InteractionVisualizer by LOOHP.

the class V1_18 method createEntityEquipmentPacket.

@Override
public PacketContainer[] createEntityEquipmentPacket(int entityId, List<ValuePairs<EquipmentSlot, ItemStack>> equipments) {
    List<Pair<EnumItemSlot, net.minecraft.world.item.ItemStack>> nmsList = new ArrayList<>();
    for (ValuePairs<EquipmentSlot, ItemStack> pair : equipments) {
        EnumItemSlot nmsSlot;
        switch(pair.getFirst()) {
            case CHEST:
                nmsSlot = EnumItemSlot.e;
                break;
            case FEET:
                nmsSlot = EnumItemSlot.c;
                break;
            case HEAD:
                nmsSlot = EnumItemSlot.f;
                break;
            case LEGS:
                nmsSlot = EnumItemSlot.d;
                break;
            case OFF_HAND:
                nmsSlot = EnumItemSlot.b;
                break;
            case HAND:
            default:
                nmsSlot = EnumItemSlot.a;
                break;
        }
        net.minecraft.world.item.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.world.entity.EnumItemSlot) CraftItemStack(org.bukkit.craftbukkit.v1_18_R1.inventory.CraftItemStack) ItemStack(org.bukkit.inventory.ItemStack) PacketPlayOutEntityEquipment(net.minecraft.network.protocol.game.PacketPlayOutEntityEquipment) Pair(com.mojang.datafixers.util.Pair)

Example 2 with PacketPlayOutEntityEquipment

use of net.minecraft.network.protocol.game.PacketPlayOutEntityEquipment in project InteractionVisualizer by LOOHP.

the class V1_18_2 method createEntityEquipmentPacket.

@Override
public PacketContainer[] createEntityEquipmentPacket(int entityId, List<ValuePairs<EquipmentSlot, ItemStack>> equipments) {
    List<Pair<EnumItemSlot, net.minecraft.world.item.ItemStack>> nmsList = new ArrayList<>();
    for (ValuePairs<EquipmentSlot, ItemStack> pair : equipments) {
        EnumItemSlot nmsSlot;
        switch(pair.getFirst()) {
            case CHEST:
                nmsSlot = EnumItemSlot.e;
                break;
            case FEET:
                nmsSlot = EnumItemSlot.c;
                break;
            case HEAD:
                nmsSlot = EnumItemSlot.f;
                break;
            case LEGS:
                nmsSlot = EnumItemSlot.d;
                break;
            case OFF_HAND:
                nmsSlot = EnumItemSlot.b;
                break;
            case HAND:
            default:
                nmsSlot = EnumItemSlot.a;
                break;
        }
        net.minecraft.world.item.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.world.entity.EnumItemSlot) ItemStack(org.bukkit.inventory.ItemStack) CraftItemStack(org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack) PacketPlayOutEntityEquipment(net.minecraft.network.protocol.game.PacketPlayOutEntityEquipment) Pair(com.mojang.datafixers.util.Pair)

Example 3 with PacketPlayOutEntityEquipment

use of net.minecraft.network.protocol.game.PacketPlayOutEntityEquipment in project InteractionVisualizer by LOOHP.

the class V1_17 method createEntityEquipmentPacket.

@Override
public PacketContainer[] createEntityEquipmentPacket(int entityId, List<ValuePairs<EquipmentSlot, ItemStack>> equipments) {
    List<Pair<EnumItemSlot, net.minecraft.world.item.ItemStack>> nmsList = new ArrayList<>();
    for (ValuePairs<EquipmentSlot, ItemStack> pair : equipments) {
        EnumItemSlot nmsSlot;
        switch(pair.getFirst()) {
            case CHEST:
                nmsSlot = EnumItemSlot.e;
                break;
            case FEET:
                nmsSlot = EnumItemSlot.c;
                break;
            case HEAD:
                nmsSlot = EnumItemSlot.f;
                break;
            case LEGS:
                nmsSlot = EnumItemSlot.d;
                break;
            case OFF_HAND:
                nmsSlot = EnumItemSlot.b;
                break;
            case HAND:
            default:
                nmsSlot = EnumItemSlot.a;
                break;
        }
        net.minecraft.world.item.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.world.entity.EnumItemSlot) ItemStack(org.bukkit.inventory.ItemStack) CraftItemStack(org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack) PacketPlayOutEntityEquipment(net.minecraft.network.protocol.game.PacketPlayOutEntityEquipment) Pair(com.mojang.datafixers.util.Pair)

Aggregations

PacketContainer (com.comphenix.protocol.events.PacketContainer)3 Pair (com.mojang.datafixers.util.Pair)3 ArrayList (java.util.ArrayList)3 PacketPlayOutEntityEquipment (net.minecraft.network.protocol.game.PacketPlayOutEntityEquipment)3 EnumItemSlot (net.minecraft.world.entity.EnumItemSlot)3 EquipmentSlot (org.bukkit.inventory.EquipmentSlot)3 ItemStack (org.bukkit.inventory.ItemStack)3 CraftItemStack (org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack)1 CraftItemStack (org.bukkit.craftbukkit.v1_18_R1.inventory.CraftItemStack)1 CraftItemStack (org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack)1