mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-09 20:30:28 +01:00
SPIGOT-1567: Rework setItems to set slots correctly regardless of array reference.
This commit is contained in:
parent
4831c56cdb
commit
69e196f796
@ -61,17 +61,15 @@ public class CraftInventory implements Inventory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setContents(ItemStack[] items) {
|
public void setContents(ItemStack[] items) {
|
||||||
if (getInventory().getContents().length < items.length) {
|
if (getSize() < items.length) {
|
||||||
throw new IllegalArgumentException("Invalid inventory size; expected " + getInventory().getContents().length + " or less");
|
throw new IllegalArgumentException("Invalid inventory size; expected " + getSize() + " or less");
|
||||||
}
|
}
|
||||||
|
|
||||||
net.minecraft.server.ItemStack[] mcItems = getInventory().getContents();
|
for (int i = 0; i < getSize(); i++) {
|
||||||
|
|
||||||
for (int i = 0; i < mcItems.length; i++) {
|
|
||||||
if (i >= items.length) {
|
if (i >= items.length) {
|
||||||
mcItems[i] = null;
|
setItem(i, null);
|
||||||
} else {
|
} else {
|
||||||
mcItems[i] = CraftItemStack.asNMSCopy(items[i]);
|
setItem(i, items[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user