Skip to content

Commit

Permalink
Revert "Fix for issue #98 (Player#getInventory#getArmorContents is al…
Browse files Browse the repository at this point in the history
…ways AIR)" (#112)

This change is being reverted as it can cause weird duplication issues with the inventory slots when players rejoin the game.
  • Loading branch information
RhysB authored Nov 25, 2024
1 parent eca365a commit f22fa8d
Showing 1 changed file with 8 additions and 27 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
package org.bukkit.craftbukkit.inventory;

import net.minecraft.server.InventoryPlayer;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;

import java.util.ArrayList;

public class CraftInventoryPlayer extends CraftInventory implements PlayerInventory {
public CraftInventoryPlayer(net.minecraft.server.InventoryPlayer inventory) {
super(inventory);
Expand Down Expand Up @@ -45,7 +42,7 @@ public ItemStack getLeggings() {
}

public ItemStack getBoots() {
return getItem(getSize());
return getItem(getSize() + 0);
}

public void setHelmet(ItemStack helmet) {
Expand All @@ -61,33 +58,17 @@ public void setLeggings(ItemStack leggings) {
}

public void setBoots(ItemStack boots) {
setItem(getSize(), boots);
setItem(getSize() + 0, boots);
}

public ItemStack[] getArmorContents() {
ArrayList<ItemStack> contents = new ArrayList<>();

ItemStack boots = getItem(getSize());
if (boots != null && boots.getType() != Material.AIR) {
contents.add(boots);
}

ItemStack leggings = getItem(getSize() + 1);
if (leggings != null && leggings.getType() != Material.AIR) {
contents.add(leggings);
}

ItemStack chestplate = getItem(getSize() + 2);
if (chestplate != null && chestplate.getType() != Material.AIR) {
contents.add(chestplate);
}
public CraftItemStack[] getArmorContents() {
net.minecraft.server.ItemStack[] mcItems = getInventory().getArmorContents();
CraftItemStack[] ret = new CraftItemStack[mcItems.length];

ItemStack helmet = getItem(getSize() + 3);
if (helmet != null && helmet.getType() != Material.AIR) {
contents.add(helmet);
for (int i = 0; i < mcItems.length; i++) {
ret[i] = new CraftItemStack(mcItems[i]);
}

return contents.toArray(new ItemStack[0]);
return ret;
}

public void setArmorContents(ItemStack[] items) {
Expand Down

0 comments on commit f22fa8d

Please sign in to comment.