Fix EntityPickupItemEvent getRemaining / PlayerInventory#canHold

Without this change the calculation of fitting items was incorrect, so event.getRemaining() did return 0 when it should not be 0.

By: Brokkonaut <hannos17@gmx.de>
This commit is contained in:
CraftBukkit/Spigot
2019-02-12 04:49:24 +01:00
parent 773e44eee7
commit a6ec0de609
2 changed files with 64 additions and 5 deletions

View File

@@ -66,7 +66,7 @@
public PlayerInventory(EntityHuman entityhuman) {
this.items = NonNullList.a(36, ItemStack.a);
this.armor = NonNullList.a(4, ItemStack.a);
@@ -42,6 +94,23 @@
@@ -42,6 +94,22 @@
return itemstack.getItem() == itemstack1.getItem() && ItemStack.equals(itemstack, itemstack1);
}
@@ -77,8 +77,7 @@
+ ItemStack itemstack1 = this.getItem(i);
+ if (itemstack1.isEmpty()) return itemstack.getCount();
+
+ // Taken from firstPartial(ItemStack)
+ if (!this.a(itemstack, itemstack1)) {
+ if (this.a(itemstack1, itemstack)) { // PAIL rename isSimilarAndNotFull
+ remains -= (itemstack1.getMaxStackSize() < this.getMaxStackSize() ? itemstack1.getMaxStackSize() : this.getMaxStackSize()) - itemstack1.getCount();
+ }
+ if (remains <= 0) return itemstack.getCount();
@@ -90,7 +89,7 @@
public int getFirstEmptySlotIndex() {
for (int i = 0; i < this.items.size(); ++i) {
if (((ItemStack) this.items.get(i)).isEmpty()) {
@@ -502,7 +571,7 @@
@@ -502,7 +570,7 @@
}
public int getMaxStackSize() {
@@ -99,7 +98,7 @@
}
public boolean b(IBlockData iblockdata) {
@@ -554,6 +623,11 @@
@@ -554,6 +622,11 @@
}
public ItemStack getCarried() {