Skip to content

Commit

Permalink
Fix non-deterministic ME Interface behavior
Browse files Browse the repository at this point in the history
As a side effect, allows ME Interfaces to fully utilize allowed operations instead of doing at most 1 push per cycle
Closes #440
  • Loading branch information
NotMyWing committed May 24, 2024
1 parent 5f20e33 commit 9f19e05
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/main/java/appeng/helpers/DualityInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -978,23 +978,33 @@ public boolean pushPattern(final ICraftingPatternDetails patternDetails, final I
continue;
} else {
IMEMonitor<IAEItemStack> inv = sm.getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class));

var allItemsCanBeInserted = true;
for (int x = 0; x < table.getSizeInventory(); x++) {
final ItemStack is = table.getStackInSlot(x);
if (is.isEmpty()) {
continue;
}
IAEItemStack result = inv.injectItems(AEItemStack.fromItemStack(is), Actionable.SIMULATE, this.mySource);
if (result != null) {
return false;
allItemsCanBeInserted = false;
break;
}
}

if (!allItemsCanBeInserted) {
continue;
}

this.visitedFaces.clear();
for (int x = 0; x < table.getSizeInventory(); x++) {
final ItemStack is = table.getStackInSlot(x);
if (!is.isEmpty()) {
addToSendListFacing(is, s);
}
}
pushItemsOut(s);

return true;
}
}
Expand Down Expand Up @@ -1044,7 +1054,7 @@ public boolean pushPattern(final ICraftingPatternDetails patternDetails, final I
}

if (this.acceptsItems(ad, table)) {
visitedFaces.remove(s);
this.visitedFaces.clear();
for (int x = 0; x < table.getSizeInventory(); x++) {
final ItemStack is = table.getStackInSlot(x);
if (!is.isEmpty()) {
Expand Down

0 comments on commit 9f19e05

Please sign in to comment.