3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-17 05:20:05 +01:00

Fixed some various CraftInventory bugs related to dropping Enchantments

Dieser Commit ist enthalten in:
Nathan Adams 2011-12-04 13:22:50 +00:00
Ursprung 1185ca75fc
Commit c6d182286c

Datei anzeigen

@ -205,7 +205,7 @@ public class CraftInventory implements org.bukkit.inventory.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()) { if (cItem != null && cItem.getTypeId() == filteredItem.getTypeId() && cItem.getAmount() < cItem.getMaxStackSize() && cItem.getDurability() == filteredItem.getDurability() && cItem.getEnchantments().equals(filteredItem.getEnchantments())) {
return i; return i;
} }
} }
@ -239,7 +239,9 @@ public class CraftInventory implements org.bukkit.inventory.Inventory {
} else { } else {
// More than a single stack! // More than a single stack!
if (item.getAmount() > getMaxItemStack()) { if (item.getAmount() > getMaxItemStack()) {
setItem(firstFree, new CraftItemStack(item.getTypeId(), getMaxItemStack(), item.getDurability())); CraftItemStack stack = new CraftItemStack(item.getTypeId(), getMaxItemStack(), item.getDurability());
stack.addUnsafeEnchantments(item.getEnchantments());
setItem(firstFree, stack);
item.setAmount(item.getAmount() - getMaxItemStack()); item.setAmount(item.getAmount() - getMaxItemStack());
} else { } else {
// Just store it // Just store it
@ -280,7 +282,7 @@ public class CraftInventory implements org.bukkit.inventory.Inventory {
int toDelete = item.getAmount(); int toDelete = item.getAmount();
while (true) { while (true) {
int first = first(item.getType()); int first = first(item);
// Drat! we don't have this type in the inventory // Drat! we don't have this type in the inventory
if (first == -1) { if (first == -1) {