3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-18 20:40:08 +01:00

SPIGOT-1567: Rework setItems to set slots correctly regardless of array reference.

Dieser Commit ist enthalten in:
md_5 2016-03-01 19:59:52 +11:00
Ursprung 4831c56cdb
Commit 69e196f796

Datei anzeigen

@ -61,17 +61,15 @@ public class CraftInventory implements Inventory {
}
public void setContents(ItemStack[] items) {
if (getInventory().getContents().length < items.length) {
throw new IllegalArgumentException("Invalid inventory size; expected " + getInventory().getContents().length + " or less");
if (getSize() < items.length) {
throw new IllegalArgumentException("Invalid inventory size; expected " + getSize() + " or less");
}
net.minecraft.server.ItemStack[] mcItems = getInventory().getContents();
for (int i = 0; i < mcItems.length; i++) {
for (int i = 0; i < getSize(); i++) {
if (i >= items.length) {
mcItems[i] = null;
setItem(i, null);
} else {
mcItems[i] = CraftItemStack.asNMSCopy(items[i]);
setItem(i, items[i]);
}
}
}