mirror of
https://github.com/Minestom/Minestom.git
synced 2024-10-02 08:27:58 +02:00
Optimize Inventory#clear
This commit is contained in:
parent
d980b3f56c
commit
827526e200
@ -286,6 +286,7 @@ public class Inventory implements InventoryModifier, InventoryClickHandler, View
|
||||
|
||||
protected void setItemStackInternal(int slot, ItemStack itemStack) {
|
||||
itemStacks[slot] = itemStack;
|
||||
this.windowItemsBufferUpdated = false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -608,9 +609,11 @@ public class Inventory implements InventoryModifier, InventoryClickHandler, View
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
// TODO: optimize by sending whole inventory at once? (will need to change to setItemStackInternal)
|
||||
// Clear the item array
|
||||
for (int i = 0; i < getSize(); i++) {
|
||||
setItemStack(i, ItemStack.getAirItem());
|
||||
setItemStackInternal(i, ItemStack.getAirItem());
|
||||
}
|
||||
// Send the cleared inventory to viewers
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user