Search in sources :

Example 1 with ItemSlot

use of com.comphenix.protocol.wrappers.EnumWrappers.ItemSlot in project InteractionVisualizer by LOOHP.

the class V1_11 method createEntityEquipmentPacket.

@Override
public PacketContainer[] createEntityEquipmentPacket(int entityId, List<ValuePairs<EquipmentSlot, ItemStack>> equipments) {
    PacketContainer[] packets = new PacketContainer[equipments.size()];
    for (int i = 0; i < equipments.size(); i++) {
        ValuePairs<EquipmentSlot, ItemStack> pair = equipments.get(i);
        PacketContainer packet = InteractionVisualizer.protocolManager.createPacket(PacketType.Play.Server.ENTITY_EQUIPMENT);
        packet.getIntegers().write(0, entityId);
        ItemSlot libSlot;
        switch(pair.getFirst()) {
            case CHEST:
                libSlot = ItemSlot.CHEST;
                break;
            case FEET:
                libSlot = ItemSlot.FEET;
                break;
            case HEAD:
                libSlot = ItemSlot.HEAD;
                break;
            case LEGS:
                libSlot = ItemSlot.LEGS;
                break;
            case OFF_HAND:
                libSlot = ItemSlot.OFFHAND;
                break;
            case HAND:
            default:
                libSlot = ItemSlot.MAINHAND;
                break;
        }
        packet.getItemSlots().write(0, libSlot);
        packet.getItemModifier().write(0, pair.getSecond());
        packets[i] = packet;
    }
    return packets;
}
Also used : PacketContainer(com.comphenix.protocol.events.PacketContainer) EquipmentSlot(org.bukkit.inventory.EquipmentSlot) ItemSlot(com.comphenix.protocol.wrappers.EnumWrappers.ItemSlot) ItemStack(org.bukkit.inventory.ItemStack)

Example 2 with ItemSlot

use of com.comphenix.protocol.wrappers.EnumWrappers.ItemSlot in project InteractionVisualizer by LOOHP.

the class V1_12 method createEntityEquipmentPacket.

@Override
public PacketContainer[] createEntityEquipmentPacket(int entityId, List<ValuePairs<EquipmentSlot, ItemStack>> equipments) {
    PacketContainer[] packets = new PacketContainer[equipments.size()];
    for (int i = 0; i < equipments.size(); i++) {
        ValuePairs<EquipmentSlot, ItemStack> pair = equipments.get(i);
        PacketContainer packet = InteractionVisualizer.protocolManager.createPacket(PacketType.Play.Server.ENTITY_EQUIPMENT);
        packet.getIntegers().write(0, entityId);
        ItemSlot libSlot;
        switch(pair.getFirst()) {
            case CHEST:
                libSlot = ItemSlot.CHEST;
                break;
            case FEET:
                libSlot = ItemSlot.FEET;
                break;
            case HEAD:
                libSlot = ItemSlot.HEAD;
                break;
            case LEGS:
                libSlot = ItemSlot.LEGS;
                break;
            case OFF_HAND:
                libSlot = ItemSlot.OFFHAND;
                break;
            case HAND:
            default:
                libSlot = ItemSlot.MAINHAND;
                break;
        }
        packet.getItemSlots().write(0, libSlot);
        packet.getItemModifier().write(0, pair.getSecond());
        packets[i] = packet;
    }
    return packets;
}
Also used : PacketContainer(com.comphenix.protocol.events.PacketContainer) EquipmentSlot(org.bukkit.inventory.EquipmentSlot) ItemSlot(com.comphenix.protocol.wrappers.EnumWrappers.ItemSlot) ItemStack(org.bukkit.inventory.ItemStack)

Example 3 with ItemSlot

use of com.comphenix.protocol.wrappers.EnumWrappers.ItemSlot in project InteractionVisualizer by LOOHP.

the class V1_13 method createEntityEquipmentPacket.

@Override
public PacketContainer[] createEntityEquipmentPacket(int entityId, List<ValuePairs<EquipmentSlot, ItemStack>> equipments) {
    PacketContainer[] packets = new PacketContainer[equipments.size()];
    for (int i = 0; i < equipments.size(); i++) {
        ValuePairs<EquipmentSlot, ItemStack> pair = equipments.get(i);
        PacketContainer packet = InteractionVisualizer.protocolManager.createPacket(PacketType.Play.Server.ENTITY_EQUIPMENT);
        packet.getIntegers().write(0, entityId);
        ItemSlot libSlot;
        switch(pair.getFirst()) {
            case CHEST:
                libSlot = ItemSlot.CHEST;
                break;
            case FEET:
                libSlot = ItemSlot.FEET;
                break;
            case HEAD:
                libSlot = ItemSlot.HEAD;
                break;
            case LEGS:
                libSlot = ItemSlot.LEGS;
                break;
            case OFF_HAND:
                libSlot = ItemSlot.OFFHAND;
                break;
            case HAND:
            default:
                libSlot = ItemSlot.MAINHAND;
                break;
        }
        packet.getItemSlots().write(0, libSlot);
        packet.getItemModifier().write(0, pair.getSecond());
        packets[i] = packet;
    }
    return packets;
}
Also used : PacketContainer(com.comphenix.protocol.events.PacketContainer) EquipmentSlot(org.bukkit.inventory.EquipmentSlot) ItemSlot(com.comphenix.protocol.wrappers.EnumWrappers.ItemSlot) ItemStack(org.bukkit.inventory.ItemStack)

Example 4 with ItemSlot

use of com.comphenix.protocol.wrappers.EnumWrappers.ItemSlot in project InteractionVisualizer by LOOHP.

the class V1_13_1 method createEntityEquipmentPacket.

@Override
public PacketContainer[] createEntityEquipmentPacket(int entityId, List<ValuePairs<EquipmentSlot, ItemStack>> equipments) {
    PacketContainer[] packets = new PacketContainer[equipments.size()];
    for (int i = 0; i < equipments.size(); i++) {
        ValuePairs<EquipmentSlot, ItemStack> pair = equipments.get(i);
        PacketContainer packet = InteractionVisualizer.protocolManager.createPacket(PacketType.Play.Server.ENTITY_EQUIPMENT);
        packet.getIntegers().write(0, entityId);
        ItemSlot libSlot;
        switch(pair.getFirst()) {
            case CHEST:
                libSlot = ItemSlot.CHEST;
                break;
            case FEET:
                libSlot = ItemSlot.FEET;
                break;
            case HEAD:
                libSlot = ItemSlot.HEAD;
                break;
            case LEGS:
                libSlot = ItemSlot.LEGS;
                break;
            case OFF_HAND:
                libSlot = ItemSlot.OFFHAND;
                break;
            case HAND:
            default:
                libSlot = ItemSlot.MAINHAND;
                break;
        }
        packet.getItemSlots().write(0, libSlot);
        packet.getItemModifier().write(0, pair.getSecond());
        packets[i] = packet;
    }
    return packets;
}
Also used : PacketContainer(com.comphenix.protocol.events.PacketContainer) EquipmentSlot(org.bukkit.inventory.EquipmentSlot) ItemSlot(com.comphenix.protocol.wrappers.EnumWrappers.ItemSlot) ItemStack(org.bukkit.inventory.ItemStack)

Example 5 with ItemSlot

use of com.comphenix.protocol.wrappers.EnumWrappers.ItemSlot in project InteractionVisualizer by LOOHP.

the class V1_15 method createEntityEquipmentPacket.

@Override
public PacketContainer[] createEntityEquipmentPacket(int entityId, List<ValuePairs<EquipmentSlot, ItemStack>> equipments) {
    PacketContainer[] packets = new PacketContainer[equipments.size()];
    for (int i = 0; i < equipments.size(); i++) {
        ValuePairs<EquipmentSlot, ItemStack> pair = equipments.get(i);
        PacketContainer packet = InteractionVisualizer.protocolManager.createPacket(PacketType.Play.Server.ENTITY_EQUIPMENT);
        packet.getIntegers().write(0, entityId);
        ItemSlot libSlot;
        switch(pair.getFirst()) {
            case CHEST:
                libSlot = ItemSlot.CHEST;
                break;
            case FEET:
                libSlot = ItemSlot.FEET;
                break;
            case HEAD:
                libSlot = ItemSlot.HEAD;
                break;
            case LEGS:
                libSlot = ItemSlot.LEGS;
                break;
            case OFF_HAND:
                libSlot = ItemSlot.OFFHAND;
                break;
            case HAND:
            default:
                libSlot = ItemSlot.MAINHAND;
                break;
        }
        packet.getItemSlots().write(0, libSlot);
        packet.getItemModifier().write(0, pair.getSecond());
        packets[i] = packet;
    }
    return packets;
}
Also used : PacketContainer(com.comphenix.protocol.events.PacketContainer) EquipmentSlot(org.bukkit.inventory.EquipmentSlot) ItemSlot(com.comphenix.protocol.wrappers.EnumWrappers.ItemSlot) ItemStack(org.bukkit.inventory.ItemStack)

Aggregations

PacketContainer (com.comphenix.protocol.events.PacketContainer)7 ItemSlot (com.comphenix.protocol.wrappers.EnumWrappers.ItemSlot)7 ItemStack (org.bukkit.inventory.ItemStack)7 EquipmentSlot (org.bukkit.inventory.EquipmentSlot)6 FieldAccessException (com.comphenix.protocol.reflect.FieldAccessException)1 Pair (com.comphenix.protocol.wrappers.Pair)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 List (java.util.List)1 MapCursor (org.bukkit.map.MapCursor)1 MapView (org.bukkit.map.MapView)1 BukkitRunnable (org.bukkit.scheduler.BukkitRunnable)1