Skip to content

Add machine porting hooks and composable processors - #113

Merged
dshadowwolf merged 19 commits into
codex/machine-upgrades-displaysfrom
codex/machine-porting-hooks
Nov 17, 2026
Merged

dshadowwolf merged 19 commits into
codex/machine-upgrades-displaysfrom
codex/machine-porting-hooks

Conversation

@faceofcat

@faceofcat faceofcat commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

XML machines could not express the facing, storage admission, processor composition and lifecycle hooks needed by Steam Advantage and EA3. This adds those extension points while retaining existing single-processor definitions and horizontal placement defaults.

Stacked on #112 (codex/machine-upgrades-displays). The current merge order is #111, #112, then this PR.

  • Allow any nonempty subset of six facing directions, with toward-player or away-from-player placement and matching model, shape and display transforms.
  • Add fluid tags, Java/processor item and fluid admission rules, typed transactional resource access, placement-facing preferences and accepted-placement callbacks.
  • Expose an explicitly selected existing redstone source to comparators, including comparator updates through a solid block.
  • Compose custom and recipe processors with stable IDs and resource bindings. Update generated controls, progress, sounds, visuals, JEI and shared reservation handling; deliver Java callbacks for each actual cycle transition with lane identity.
  • Allow one processor-owned energy store to serve capabilities, recipes, gauges, statistics and persistence. Add transactional operating energy per successful work step, including accelerated work.
  • Add companion examples for every feature and detailed purpose, setup and expected-result Info descriptions for all 20 companion machines.

Targets fresh worlds. Legacy Steam Advantage/EA3 save-key and block-entity ID migration are outside this PR. Custom energy stores must honor the documented transaction, telemetry and persistence contracts.

Validation: both push and pull-request CI workflows passed on 1c8457f3, including the full build/check and client GUI smoke tests with and without JEI. Locally, all 144 companion GameTests passed; the focused display and working-area tests passed after replacing obsolete vertical-facing rejection expectations with coordinate and bounds assertions. The recipe diagnostic test now verifies the reported machine is an affected consumer rather than assuming only the Simple Crusher uses that recipe type. Formatting, import checks and resource-description coverage also passed.

@dshadowwolf dshadowwolf left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review findings (read from the diff only; I did not run tests or the game).

"toward-player")),
redstone == null
? null
: redstone.attributes().get("comparator-source"),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comparator-source is stored as-is. The only check is RedstoneControl.comparatorSource, which runs in the DefinedMachineEntity constructor. So <redstone comparator-source="typo"/> loads cleanly and then throws IllegalArgumentException on every placement or chunk load of that machine. Since the redstone outputs are known at this point, validating the id here would turn it into a load-time error(redstone, ...).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in bfd5564. Definition loading now validates comparator-source against recipe output IDs and custom processor schema metadata, reporting the original redstone file/line on an unknown ID. Custom source IDs are cached in the read-only schema; validation never evaluates live signal suppliers. Focused tests cover all recipe sources, invalid IDs, and custom metadata without sampling values.

}

public boolean getPaused() {
return features.findProcessor(java.util.Optional.empty())

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The no-arg getProgress()/getTime()/getPaused() still resolve the first processor in feature order through processor(Optional.empty()) and findProcessor(Optional.empty()). Features are added in declaration order, so if a machine declares A then B with primary="true" on B, these read lane A while definition.processor() (portable/secondary use, refreshDerived in onLoad) points at B. Resolving the empty key to the primary id would keep them consistent.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 2943c27. Defined machines configure the declared primary ID on FeatureHost after registering processors. Both keyless recipe lookup and generic processor lookup honor it, so progress/time/pause getters and keyless controls agree with item/placement behavior. Explicit keys, indexed bindings, and tick order remain independent. Unit and companion regressions cover a custom processor before the primary and selection of the second recipe lane.

net.minecraft.world.level.block.state.properties.BlockStateProperties.FACING)
? net.minecraft.world.level.block.state.properties.BlockStateProperties.FACING
: net.minecraft.world.level.block.state.properties.BlockStateProperties.HORIZONTAL_FACING;
level.setBlock(worldPosition, getBlockState().setValue(property,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possible issue: this runs level.setBlock(..., 3) from onLoad, which fires while the chunk is being added. The block is unchanged, so the entity and its data should survive. But flag 3 sends neighbour updates and a block update into a chunk that may not have finished loading, and neighbours can be in chunks that aren't loaded. Consider Block.UPDATE_CLIENTS only, or deferring the fix-up to the first server tick.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 8ea8eef. The load-time facing correction now uses Block.UPDATE_CLIENTS rather than flag 3, so it updates clients without issuing neighbour notifications while the chunk is loading. The companion regression verifies that correcting a forbidden orientation preserves the same block entity and its inventory.

Minecraft.getInstance().getSoundManager().play(loop);
var loops = LOOPS.computeIfAbsent(machine,
ignored -> new java.util.HashMap<>());
for (var config : machine.definition.processors()) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: the old early return on sounds().running().isPresent() is gone. For a single-processor machine, behavior.processors() is empty, so definition.processors() builds a new synthetic ProcessorConfiguration list on every client tick for every loaded machine, including ones with no running sound. Caching the derived list on the definition, or skipping when no config has a running sound, would avoid that.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in d6b2b40. Each defined entity resolves its immutable processor configurations once during construction. Client sound ticks and other entity consumers reuse that list, including the synthetic single-processor configuration. The sound-loop map is also created lazily only when a configured running sound actually needs a loop.

: MachineContent.recipeType(config.recipeType().id());
}

private void installRecipeAdmission(MachineRecipeType primary) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cleanup: with this in place, MachineResources.recipeInputs(...) (MachineResources.java:167) has no remaining callers in main or test. That leaves two copies of the recipe-input admission logic, and the old one has the "requires items or fluids" validation. Either remove recipeInputs or route this through it.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 270f8fa by routing XML recipe admission through MachineResources.recipeInputs. The Java API remains supported (InventoryArchitectureSmoke still exercises it), and now also accepts lane aliases. One implementation unions rules per physical slot/tank and retains the items-or-fluids validation. Physical recipe-only groups retain filtering without becoming automation groups. Existing recipe/filter coverage plus new alias/validation regressions exercise the shared path; all 13 focused porting GameTests passed.

@dshadowwolf
dshadowwolf merged commit 6416610 into codex/machine-upgrades-displays Nov 17, 2026
5 checks passed
@faceofcat
faceofcat deleted the codex/machine-porting-hooks branch November 17, 2026 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants