Repository navigation
Add machine porting hooks and composable processors - #113
Conversation
dshadowwolf
left a comment
There was a problem hiding this comment.
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"), |
There was a problem hiding this comment.
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, ...).
There was a problem hiding this comment.
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()) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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()) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
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.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.