mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-01 20:52:12 -07:00
Inventory#removeItemAnySlot
This commit is contained in:
@@ -224,10 +224,16 @@ public class CraftInventory implements Inventory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private int first(ItemStack item, boolean withAmount) {
|
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) {
|
if (item == null) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
ItemStack[] inventory = this.getStorageContents();
|
// ItemStack[] inventory = this.getStorageContents(); // Paper - let param deal
|
||||||
for (int i = 0; i < inventory.length; i++) {
|
for (int i = 0; i < inventory.length; i++) {
|
||||||
if (inventory[i] == null) continue;
|
if (inventory[i] == null) continue;
|
||||||
|
|
||||||
@@ -339,6 +345,17 @@ public class CraftInventory implements Inventory {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HashMap<Integer, ItemStack> removeItem(ItemStack... items) {
|
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");
|
Preconditions.checkArgument(items != null, "items cannot be null");
|
||||||
HashMap<Integer, ItemStack> leftover = new HashMap<Integer, ItemStack>();
|
HashMap<Integer, ItemStack> leftover = new HashMap<Integer, ItemStack>();
|
||||||
|
|
||||||
@@ -350,7 +367,10 @@ public class CraftInventory implements Inventory {
|
|||||||
int toDelete = item.getAmount();
|
int toDelete = item.getAmount();
|
||||||
|
|
||||||
while (true) {
|
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
|
// Drat! we don't have this type in the inventory
|
||||||
if (first == -1) {
|
if (first == -1) {
|
||||||
|
Reference in New Issue
Block a user