Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pattern providers now only push ingredients for crafting patterns to molecular assemblers, not other inventories #7751

Merged
merged 1 commit into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -330,6 +330,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
Loading