mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-10 10:17:38 +01:00
Change enchantment comparisons to isSimilar. Fixes BUKKIT-3183
The purpose of the isSimilar method was designed to consider all NBT data, not solely enchantments, without the need to have exact stack size matches. The respective methods in CraftInventory were still comparing enchantments instead of the ItemMeta. By: Wesley Wolfe <weswolf@aol.com>
This commit is contained in:
parent
9aa9b8775a
commit
a885a5f0ee
@ -147,7 +147,7 @@ public class CraftInventory implements Inventory {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
for (ItemStack i : getContents()) {
|
for (ItemStack i : getContents()) {
|
||||||
if (i != null && item.getTypeId() == i.getTypeId() && item.getDurability() == i.getDurability() && item.getEnchantments().equals(i.getEnchantments()) && (amount -= i.getAmount()) <= 0) {
|
if (item.isSimilar(i) && (amount -= i.getAmount()) <= 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -213,15 +213,7 @@ public class CraftInventory implements Inventory {
|
|||||||
for (int i = 0; i < inventory.length; i++) {
|
for (int i = 0; i < inventory.length; i++) {
|
||||||
if (inventory[i] == null) continue;
|
if (inventory[i] == null) continue;
|
||||||
|
|
||||||
boolean equals = false;
|
if (withAmount ? item.equals(inventory[i]) : item.isSimilar(inventory[i])) {
|
||||||
|
|
||||||
if (withAmount) {
|
|
||||||
equals = item.equals(inventory[i]);
|
|
||||||
} else {
|
|
||||||
equals = item.getTypeId() == inventory[i].getTypeId() && item.getDurability() == inventory[i].getDurability() && item.getEnchantments().equals(inventory[i].getEnchantments());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (equals) {
|
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -262,7 +254,7 @@ public class CraftInventory implements Inventory {
|
|||||||
}
|
}
|
||||||
for (int i = 0; i < inventory.length; i++) {
|
for (int i = 0; i < inventory.length; i++) {
|
||||||
ItemStack cItem = inventory[i];
|
ItemStack cItem = inventory[i];
|
||||||
if (cItem != null && cItem.getTypeId() == filteredItem.getTypeId() && cItem.getAmount() < cItem.getMaxStackSize() && cItem.getDurability() == filteredItem.getDurability() && cItem.getEnchantments().equals(filteredItem.getEnchantments())) {
|
if (cItem != null && cItem.getAmount() < cItem.getMaxStackSize() && cItem.isSimilar(filteredItem)) {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user