From 9f19e05592b5da3150a8da233f57016f26b55385 Mon Sep 17 00:00:00 2001 From: NotMyWing Date: Fri, 24 May 2024 19:05:06 +1100 Subject: [PATCH] Fix non-deterministic ME Interface behavior As a side effect, allows ME Interfaces to fully utilize allowed operations instead of doing at most 1 push per cycle Closes #440 --- src/main/java/appeng/helpers/DualityInterface.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/java/appeng/helpers/DualityInterface.java b/src/main/java/appeng/helpers/DualityInterface.java index fd7565fece5..05619132def 100644 --- a/src/main/java/appeng/helpers/DualityInterface.java +++ b/src/main/java/appeng/helpers/DualityInterface.java @@ -978,6 +978,8 @@ public boolean pushPattern(final ICraftingPatternDetails patternDetails, final I continue; } else { IMEMonitor 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()) { @@ -985,9 +987,16 @@ public boolean pushPattern(final ICraftingPatternDetails patternDetails, final I } 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()) { @@ -995,6 +1004,7 @@ public boolean pushPattern(final ICraftingPatternDetails patternDetails, final I } } pushItemsOut(s); + return true; } } @@ -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()) {