mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-16 13:21:24 +01:00
Inventory#removeItemAnySlot
This commit is contained in:
parent
bfd8b7bcef
commit
48707f87ac
@ -224,10 +224,16 @@ public class CraftInventory implements Inventory {
|
||||
}
|
||||
|
||||
private int first(ItemStack item, boolean withAmount) {
|
||||
// Paper start
|
||||
return first(item, withAmount, getStorageContents());
|
||||
}
|
||||
|
||||
private int first(ItemStack item, boolean withAmount, ItemStack[] inventory) {
|
||||
// Paper end
|
||||
if (item == null) {
|
||||
return -1;
|
||||
}
|
||||
ItemStack[] inventory = this.getStorageContents();
|
||||
// ItemStack[] inventory = this.getStorageContents(); // Paper - let param deal
|
||||
for (int i = 0; i < inventory.length; i++) {
|
||||
if (inventory[i] == null) continue;
|
||||
|
||||
@ -339,6 +345,17 @@ public class CraftInventory implements Inventory {
|
||||
|
||||
@Override
|
||||
public HashMap<Integer, ItemStack> removeItem(ItemStack... items) {
|
||||
// Paper start
|
||||
return removeItem(false, items);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<Integer, ItemStack> removeItemAnySlot(ItemStack... items) {
|
||||
return removeItem(true, items);
|
||||
}
|
||||
|
||||
private HashMap<Integer, ItemStack> removeItem(boolean searchEntire, ItemStack... items) {
|
||||
// Paper end
|
||||
Preconditions.checkArgument(items != null, "items cannot be null");
|
||||
HashMap<Integer, ItemStack> leftover = new HashMap<Integer, ItemStack>();
|
||||
|
||||
@ -350,7 +367,10 @@ public class CraftInventory implements Inventory {
|
||||
int toDelete = item.getAmount();
|
||||
|
||||
while (true) {
|
||||
int first = this.first(item, false);
|
||||
// Paper start - Allow searching entire contents
|
||||
ItemStack[] toSearch = searchEntire ? getContents() : getStorageContents();
|
||||
int first = this.first(item, false, toSearch);
|
||||
// Paper end
|
||||
|
||||
// Drat! we don't have this type in the inventory
|
||||
if (first == -1) {
|
||||
|
Loading…
Reference in New Issue
Block a user