From c0fe597162c3955d27ac9f3d87c13b2c6ad55d6f Mon Sep 17 00:00:00 2001 From: shartte Date: Tue, 12 Mar 2024 14:39:58 +0100 Subject: [PATCH] Pattern providers now only push ingredients for crafting patterns to molecular assemblers, not other inventories (#7751) Fixes #7688 (cherry picked from commit 8435f3d9f1a0c4f65444f4f94710c0fd4a45f6ba) (cherry picked from commit b8fe50c65b108fc8f2d4b2b844f71d2ec8520b42) --- src/main/java/appeng/api/crafting/IPatternDetails.java | 10 ++++++++++ .../crafting/IMolecularAssemblerSupportedPattern.java | 6 ++++++ .../helpers/patternprovider/PatternProviderLogic.java | 6 ++++++ 3 files changed, 22 insertions(+) diff --git a/src/main/java/appeng/api/crafting/IPatternDetails.java b/src/main/java/appeng/api/crafting/IPatternDetails.java index 40388c067ba..627647ee51a 100644 --- a/src/main/java/appeng/api/crafting/IPatternDetails.java +++ b/src/main/java/appeng/api/crafting/IPatternDetails.java @@ -65,6 +65,16 @@ default GenericStack getPrimaryOutput() { */ GenericStack[] getOutputs(); + /** + * @return True if this pattern allows its inputs to be pushed to generic external inventories that would accept + * those inputs. This would usually be true for custom processing patterns, but not true for patterns that + * require custom machines or molecular assemblers (since those are pushed via + * {@link ICraftingMachine#pushPattern}). + */ + default boolean supportsPushInputsToExternalInventory() { + return true; + } + /** * Gives the pattern a chance to reorder its inputs for pushing to external inventories (i.e. NOT to * {@link ICraftingMachine}s). diff --git a/src/main/java/appeng/blockentity/crafting/IMolecularAssemblerSupportedPattern.java b/src/main/java/appeng/blockentity/crafting/IMolecularAssemblerSupportedPattern.java index f22dee82aee..ec84d757a7d 100644 --- a/src/main/java/appeng/blockentity/crafting/IMolecularAssemblerSupportedPattern.java +++ b/src/main/java/appeng/blockentity/crafting/IMolecularAssemblerSupportedPattern.java @@ -22,6 +22,12 @@ public interface IMolecularAssemblerSupportedPattern extends IPatternDetails { void fillCraftingGrid(KeyCounter[] table, CraftingGridAccessor gridAccessor); + @Override + default boolean supportsPushInputsToExternalInventory() { + // Patterns crafted in a molecular assembler are usually pointless to craft in anything else + return false; + } + @FunctionalInterface interface CraftingGridAccessor { void set(int slot, ItemStack stack); diff --git a/src/main/java/appeng/helpers/patternprovider/PatternProviderLogic.java b/src/main/java/appeng/helpers/patternprovider/PatternProviderLogic.java index d1364518593..63fcc822e2c 100644 --- a/src/main/java/appeng/helpers/patternprovider/PatternProviderLogic.java +++ b/src/main/java/appeng/helpers/patternprovider/PatternProviderLogic.java @@ -327,6 +327,12 @@ record PushTarget(Direction direction, PatternProviderTarget target) { possibleTargets.add(new PushTarget(direction, adapter)); } + // If no dedicated crafting machine could be found, and the pattern does not support + // generic external inventories, stop here. + if (!patternDetails.supportsPushInputsToExternalInventory()) { + return false; + } + // Rearrange for round-robin rearrangeRoundRobin(possibleTargets);