mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-09 19:49:35 +01:00
SPIGOT-3920: Make player inventories consistently return null for empty stacks
By: md_5 <git@md-5.net>
This commit is contained in:
parent
130bf49619
commit
1663f776d0
2 changed files with 7 additions and 4 deletions
|
@ -46,7 +46,10 @@ public class CraftInventory implements Inventory {
|
|||
}
|
||||
|
||||
public ItemStack getItem(int index) {
|
||||
net.minecraft.server.ItemStack item = getInventory().getItem(index);
|
||||
return asCraftMirror(getInventory().getItem(index));
|
||||
}
|
||||
|
||||
protected static ItemStack asCraftMirror(net.minecraft.server.ItemStack item) {
|
||||
return item.isEmpty() ? null : CraftItemStack.asCraftMirror(item);
|
||||
}
|
||||
|
||||
|
@ -56,7 +59,7 @@ public class CraftInventory implements Inventory {
|
|||
|
||||
for (int i = 0; i < size; i++) {
|
||||
net.minecraft.server.ItemStack mcItem = mcItems.get(i);
|
||||
items[i] = (mcItem.isEmpty()) ? null : CraftItemStack.asCraftMirror(mcItem);
|
||||
items[i] = asCraftMirror(mcItem);
|
||||
}
|
||||
|
||||
return items;
|
||||
|
|
|
@ -29,7 +29,7 @@ public class CraftInventoryPlayer extends CraftInventory implements org.bukkit.i
|
|||
|
||||
@Override
|
||||
public ItemStack getItemInMainHand() {
|
||||
return CraftItemStack.asCraftMirror(getInventory().getItemInHand());
|
||||
return asCraftMirror(getInventory().getItemInHand());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -39,7 +39,7 @@ public class CraftInventoryPlayer extends CraftInventory implements org.bukkit.i
|
|||
|
||||
@Override
|
||||
public ItemStack getItemInOffHand() {
|
||||
return CraftItemStack.asCraftMirror(getInventory().extraSlots.get(0));
|
||||
return asCraftMirror(getInventory().extraSlots.get(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue