Skip to content

Commit

Permalink
Pattern providers now only push ingredients for crafting patterns to …
Browse files Browse the repository at this point in the history
…molecular assemblers, not other inventories (#7751)

Fixes #7688

(cherry picked from commit 8435f3d)
  • Loading branch information
shartte committed Apr 1, 2024
1 parent ec5f659 commit 347cfe0
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/main/java/appeng/api/crafting/IPatternDetails.java
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,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);

Expand Down

0 comments on commit 347cfe0

Please sign in to comment.