mirror of
https://github.com/GTNewHorizons/Applied-Energistics-2-Unofficial.git
synced 2026-11-14 01:14:11 +00:00
use decrStackSize to pull from unknown IInventory (#1474)
Co-authored-by: Martin Robertz <[email protected]>
This commit is contained in:
1 parent
952e08760f
commit
26ceda1b16
2 files changed
+11
-57
No files matched your search
@@ -133,20 +133,7 @@ public class MEIInventoryWrapper implements IMEInventory<IAEItemStack> {
|
||||
reqNum = Req.stackSize;
|
||||
}
|
||||
|
||||
ItemStack retrieved = null;
|
||||
|
||||
if (sub.stackSize < Req.stackSize) {
|
||||
retrieved = Platform.cloneItemStack(sub);
|
||||
sub.stackSize = 0;
|
||||
} else {
|
||||
retrieved = sub.splitStack(Req.stackSize);
|
||||
}
|
||||
|
||||
if (sub.stackSize <= 0) {
|
||||
this.target.setInventorySlotContents(x, null);
|
||||
} else {
|
||||
this.target.setInventorySlotContents(x, sub);
|
||||
}
|
||||
ItemStack retrieved = this.target.decrStackSize(x, reqNum);
|
||||
|
||||
if (retrieved != null) {
|
||||
Gathered.stackSize += retrieved.stackSize;
|
||||
|
||||
@@ -56,25 +56,13 @@ public class AdaptorIInventory extends InventoryAdaptor {
|
||||
}
|
||||
|
||||
if (boundAmounts > 0) {
|
||||
if (rv == null) {
|
||||
rv = is.copy();
|
||||
filter = rv;
|
||||
rv.stackSize = boundAmounts;
|
||||
amount -= boundAmounts;
|
||||
} else {
|
||||
rv.stackSize += boundAmounts;
|
||||
amount -= boundAmounts;
|
||||
}
|
||||
|
||||
if (is.stackSize == boundAmounts) {
|
||||
this.i.setInventorySlotContents(x, null);
|
||||
this.i.markDirty();
|
||||
} else {
|
||||
final ItemStack po = is.copy();
|
||||
po.stackSize -= boundAmounts;
|
||||
this.i.setInventorySlotContents(x, po);
|
||||
this.i.markDirty();
|
||||
filter = this.i.decrStackSize(x, boundAmounts);
|
||||
if (filter != null) {
|
||||
amount -= filter.stackSize;
|
||||
if (rv == null) rv = filter;
|
||||
else rv.stackSize += filter.stackSize;
|
||||
}
|
||||
this.i.markDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -126,34 +114,13 @@ public class AdaptorIInventory extends InventoryAdaptor {
|
||||
final ItemStack is = this.i.getStackInSlot(x);
|
||||
if (is != null && this.canRemoveStackFromSlot(x, is)
|
||||
&& (filter == null || Platform.isSameItemFuzzy(is, filter, fuzzyMode))) {
|
||||
int newAmount = amount;
|
||||
if (newAmount > is.stackSize) {
|
||||
newAmount = is.stackSize;
|
||||
}
|
||||
if (destination != null && !destination.canInsert(is)) {
|
||||
newAmount = 0;
|
||||
}
|
||||
|
||||
ItemStack rv = null;
|
||||
if (newAmount > 0) {
|
||||
rv = is.copy();
|
||||
rv.stackSize = newAmount;
|
||||
if (destination != null && !destination.canInsert(is)) continue;
|
||||
|
||||
if (is.stackSize == rv.stackSize) {
|
||||
this.i.setInventorySlotContents(x, null);
|
||||
this.i.markDirty();
|
||||
} else {
|
||||
final ItemStack po = is.copy();
|
||||
po.stackSize -= rv.stackSize;
|
||||
this.i.setInventorySlotContents(x, po);
|
||||
this.i.markDirty();
|
||||
}
|
||||
}
|
||||
ItemStack rv = this.i.decrStackSize(x, amount);
|
||||
this.i.markDirty();
|
||||
if (rv != null && rv.stackSize > 0) return rv;
|
||||
|
||||
if (rv != null) {
|
||||
// i.markDirty();
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
Reference in new issue
Block a user