diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/REntity.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/REntity.java index a5be3c41..5035e30f 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/REntity.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/REntity.java @@ -89,7 +89,7 @@ public class REntity { private final int objectData; @Getter private String displayName; - protected final Map itemSlots; + protected final Map itemSlots; public REntity(REntityServer server, EntityType entityType, Location location) { this(server, entityType, location, 0); @@ -220,7 +220,7 @@ public class REntity { .add(nameVisibleWatcher, displayName != null).build()); } - public void setItem(Object slot, ItemStack stack) { + public void setItem(org.bukkit.inventory.EquipmentSlot slot, ItemStack stack) { itemSlots.put(slot, stack); server.updateEntity(this, getEquipmentPacket(slot, stack)); } @@ -368,8 +368,19 @@ public class REntity { return packet; } - protected Object getEquipmentPacket(Object slot, ItemStack stack) { - return new ClientboundSetEquipmentPacket(entityId, Collections.singletonList(Pair.of((EquipmentSlot) slot, CraftItemStack.asNMSCopy(stack)))); + protected Object getEquipmentPacket(org.bukkit.inventory.EquipmentSlot slot, ItemStack stack) { + return new ClientboundSetEquipmentPacket(entityId, Collections.singletonList(Pair.of(toNmsSlot(slot), CraftItemStack.asNMSCopy(stack)))); + } + + private static EquipmentSlot toNmsSlot(org.bukkit.inventory.EquipmentSlot slot) { + return switch (slot) { + case HEAD -> EquipmentSlot.HEAD; + case CHEST -> EquipmentSlot.CHEST; + case LEGS -> EquipmentSlot.LEGS; + case FEET -> EquipmentSlot.FEET; + case OFF_HAND -> EquipmentSlot.OFFHAND; + default -> EquipmentSlot.MAINHAND; + }; } private byte rotToByte(float rot) { diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/RPlayer.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/RPlayer.java index b57e1ee3..e13343dc 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/RPlayer.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/RPlayer.java @@ -98,7 +98,7 @@ public class RPlayer extends REntity implements RInteractableEntity { packetSink.accept(getNamedSpawnPacket()); entityDataPacket().add(skinPartsDataWatcher, (byte) 0x7F).send(packetSink); - for (Map.Entry entry : itemSlots.entrySet()) { + for (Map.Entry entry : itemSlots.entrySet()) { packetSink.accept(getEquipmentPacket(entry.getKey(), entry.getValue())); }