9
0
mirror of https://github.com/HibiscusMC/HMCCosmetics.git synced 2026-01-03 14:22:14 +00:00

fix: 1.20.6 shooting error illegal arguments on equipment slot update

This commit is contained in:
LoJoSho
2024-06-15 08:33:05 -05:00
parent 0b2ade1598
commit 9d3ad0b54b
2 changed files with 12 additions and 1 deletions

View File

@@ -11,6 +11,9 @@ import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Arrays;
import java.util.List;
public class HMCCInventoryUtils {
/**
@@ -189,4 +192,12 @@ public class HMCCInventoryUtils {
public static NamespacedKey getCosmeticKey() {
return new NamespacedKey(HMCCosmeticsPlugin.getInstance(), "cosmetic");
}
/**
* This returns all the slots a player can have on them. In 1.20.6+, the enum includes BODY, which is not a valid slot for a player.
* @return A list of all the slots a player can have on them
*/
public static List<EquipmentSlot> getPlayerArmorSlots() {
return Arrays.asList(EquipmentSlot.HEAD, EquipmentSlot.CHEST, EquipmentSlot.LEGS, EquipmentSlot.FEET, EquipmentSlot.OFF_HAND, EquipmentSlot.HAND);
}
}

View File

@@ -62,7 +62,7 @@ public class HMCCPacketManager extends PacketManager {
List<Player> sendTo
) {
HashMap<EquipmentSlot, ItemStack> items = new HashMap<>();
for (EquipmentSlot slot : EquipmentSlot.values()) {
for (EquipmentSlot slot : HMCCInventoryUtils.getPlayerArmorSlots()) {
ItemStack item = player.getInventory().getItem(slot);
if (empty) item = new ItemStack(Material.AIR);
items.put(slot, item);