mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-25 14:24:35 +00:00
Prioritize IItemHandler over IInventory as it is the newer standard
This commit is contained in:
6 files changed
+180
-181
No files matched your search
@@ -54,7 +54,20 @@ public final class InvStack {
|
||||
}
|
||||
|
||||
public void use(int amount) {
|
||||
if (tileEntity instanceof IInventory) {
|
||||
if (InventoryUtils.isItemHandler(tileEntity, side)) {
|
||||
IItemHandler handler = InventoryUtils.getItemHandler(tileEntity, side);
|
||||
|
||||
for (int i = 0; i < slotIDs.size(); i++) {
|
||||
ItemStack stack = itemStacks.get(i);
|
||||
int toUse = Math.min(amount, stack.getCount());
|
||||
handler.extractItem(slotIDs.get(i), toUse, false);
|
||||
amount -= toUse;
|
||||
|
||||
if (amount == 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else if (tileEntity instanceof IInventory) {
|
||||
IInventory inventory = InventoryUtils.checkChestInv((IInventory) tileEntity);
|
||||
|
||||
for (int i = 0; i < slotIDs.size(); i++) {
|
||||
@@ -71,19 +84,6 @@ public final class InvStack {
|
||||
amount -= stack.getCount();
|
||||
}
|
||||
|
||||
if (amount == 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else if (InventoryUtils.isItemHandler(tileEntity, side)) {
|
||||
IItemHandler handler = InventoryUtils.getItemHandler(tileEntity, side);
|
||||
|
||||
for (int i = 0; i < slotIDs.size(); i++) {
|
||||
ItemStack stack = itemStacks.get(i);
|
||||
int toUse = Math.min(amount, stack.getCount());
|
||||
handler.extractItem(slotIDs.get(i), toUse, false);
|
||||
amount -= toUse;
|
||||
|
||||
if (amount == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user