Skip to content

Fix inventory behavior with new body/saddle slot #6218

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 12, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public final class Inventories {
private static final int CHEST_SLOT = 38;
private static final int LEG_SLOT = 37;
private static final int BOOT_SLOT = 36;
private static final int BODY_SLOT = 41;
private static final int SADDLE_SLOT = 42;
private static final boolean HAS_OFFHAND = VersionUtil.getServerBukkitVersion().isHigherThanOrEqualTo(VersionUtil.v1_9_R01);
private static final int INVENTORY_SIZE = HAS_OFFHAND ? 41 : 40;

Expand Down Expand Up @@ -224,6 +226,10 @@ public static int removeItems(final Player player, final Predicate<ItemStack> re
int removedAmount = 0;
final ItemStack[] items = player.getInventory().getContents();
for (int i = 0; i < items.length; i++) {
if (isContortedSlot(i)) {
continue;
}

if (!includeArmor && isArmorSlot(i)) {
continue;
}
Expand Down Expand Up @@ -251,6 +257,10 @@ public static boolean removeItemAmount(final Player player, final ItemStack toRe
final ItemStack[] items = player.getInventory().getContents();

for (int i = 0; i < items.length; i++) {
if (isContortedSlot(i)) {
continue;
}

final ItemStack item = items[i];
if (isEmpty(item)) {
continue;
Expand Down Expand Up @@ -342,6 +352,10 @@ private static InventoryData parseInventoryData(final Inventory inventory, final
final HashMap<ItemStack, List<Integer>> partialSlots = new HashMap<>();

for (int i = 0; i < inventoryContents.length; i++) {
if (isContortedSlot(i)) {
continue;
}

if (!includeArmor && isArmorSlot(i)) {
continue;
}
Expand Down Expand Up @@ -403,6 +417,10 @@ private static boolean isEmpty(final ItemStack stack) {
return stack == null || MaterialUtil.isAir(stack.getType());
}

public static boolean isContortedSlot(final int slot) {
return slot == BODY_SLOT || slot == SADDLE_SLOT;
}

private static boolean isArmorSlot(final int slot) {
return slot == HELM_SLOT || slot == CHEST_SLOT || slot == LEG_SLOT || slot == BOOT_SLOT;
}
Expand Down
Loading