mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-02 13:07:06 +01:00
Added a setArmorContents method to PlayerInventory.
It handles error checking. Null item stacks and air item stacks are both converted to clear slot calls to prevent crashing the client.
This commit is contained in:
parent
e56a8d4720
commit
aa70240917
1 changed files with 14 additions and 0 deletions
|
@ -71,4 +71,18 @@ public class CraftInventoryPlayer extends CraftInventory implements PlayerInvent
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setArmorContents(ItemStack[] items) {
|
||||||
|
int cnt = getSize();
|
||||||
|
if (items == null) {
|
||||||
|
items = new ItemStack[4];
|
||||||
|
}
|
||||||
|
for (ItemStack item : items) {
|
||||||
|
if (item == null || item.getTypeId() == 0) {
|
||||||
|
clear(cnt++);
|
||||||
|
} else {
|
||||||
|
setItem(cnt++, item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue