Skip to content

Bring reviewed machine upgrades and porting hooks onto main - #114

Merged
dshadowwolf merged 34 commits into
master-2.0-1.21.1-neofrom
codex/complete-machine-porting-stack
Nov 18, 2026
Merged

dshadowwolf merged 34 commits into
master-2.0-1.21.1-neofrom
codex/complete-machine-porting-stack

Conversation

@faceofcat

Copy link
Copy Markdown
Collaborator

Main is missing the machine upgrades and porting hooks because #112 merged into the #111 feature branch, and #113 merged into the #112 feature branch, after #111 had already merged into main. This PR brings the completed, reviewed stack directly onto master-2.0-1.21.1-neo.

It includes the shared upgrades and working-area displays from #112, the machine porting hooks and composable processors from #113, and all eight follow-up review fixes. The original commits are preserved. No new implementation changes were added for this PR.

Validation: the resulting tree exactly matches commit 270f8fa4e102490361bac807c75649cda721d733 and the #113 merge tree. Both PR CI and push CI passed on that implementation, including the client GUI checks; the server logs confirmed 147 companion and 110 library GameTests passed. The merge was conflict-free, git diff --check passed, and the working tree is clean. Fresh CI runs will validate this PR against main.

faceofcat and others added 28 commits November 17, 2026 10:59
…e-porting-hooks

Add machine porting hooks and composable processors

@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).

int total = previous + count;
processor.tick(host, 1 + total / 8);
int remainder = total % 8;
if (processor.processing() && remainder != previous) {

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 remainder is only written back while processing() is still true, so a cycle that completes on a batched tick leaves the old fraction saved. With 4 gearboxes, say: mid-cycle the stored fraction is 4. The next tick computes total = 8, runs 2 steps, and the cycle completes. Because processing() is now false, the 0 remainder is never stored and the fraction stays at 4. The next cycle's first tick then gets 2 steps again, so each completion banks up to 7/8 of a step, even across an idle period. That contradicts the javadoc's "idle … processors never bank work".

Suggest also storing (or clearing) the remainder when the batch ran work and ended the cycle, for example clearing it whenever processing() is false after the 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 6a4314f. The clock now clears its saved fraction when execution becomes IDLE, including a batch that completes a custom processor cycle. Paused, held, blocked, and stalled cycles retain their existing fraction without accruing work. Added regression coverage for 1-7 gearboxes, completion, 40 idle ticks without dirtying saves, save/reload, and restarting without a banked extra step. The focused ProcessorClockTest suite passed locally.

Comment thread docs/xml-machines.md Outdated
`<upgrades range-storage="upgrades" legacy-layout="upgrades"/>`. Both component
sockets must be automatic. The migration moves indexes 4 and 5 into
`mmdlib_gearbox/0` and `mmdlib_capacitor/0`, then maps the nine extras to local
indexes 0�8 in their original order. New saves contain the separate component

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 dash in indexes 0–8 is a raw Windows-1252 byte (0x96), not UTF-8. iconv -f utf-8 rejects the file at this point, so the site export or VitePress will show a replacement character. Replace it with a UTF-8 – or a plain -.

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 0d3dd84. Replaced the raw Windows-1252 dash with a plain ASCII hyphen (indexes 0-8). Strict UTF-8 decoding of the complete document now succeeds.

Comment thread docs/xml-machines.md Outdated
flag. Ghost inventories do not accept this attribute.

The runtime supports an optional item storage, an optional fluid storage, an optional energy
buffer named `energy`, and at most one recipe type and processor per machine. Supply

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.

This unchanged paragraph still says "at most one recipe type and processor per machine", which contradicts the new Several processors per machine section (line 1725) that this PR adds. It needs rewording, for example: zero or more processors, with <recipe-type>/<processor> omitted for plain storage.

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 bd3587d. The storage overview now describes zero or more processors, distinguishes recipe-backed and custom Java processors, links to the multiple-processor section, and explains omitting processor/recipe declarations for plain storage.

if (capacitorSlot == null && power != null && energyCapacitors)
capacitorSlot = componentSocket(root, slots, groups, ids,
"capacitor");
if (itemId == null && !slots.isEmpty())

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.

A fluid-only machine that has a processor and inherits <upgrades/> (anything extending base_powered_machine) now gets the automatic gearbox and capacitor sockets, so it ends up with an implicit items inventory. The sockets are DISABLED, so hoppers can't move anything. But MachineContent now registers a non-null ItemHandler capability, because getSlots() > 0. That breaks the docs' promise at xml-machines.md:610 ("no dummy inventory or item capability is created"), and pipes and hoppers will see the machine as connectable. Either return no capability when every slot is a component socket, or adjust the docs.

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 a173057. XML machines now register the item capability only if at least one slot permits automation by role. Manual upgrade sockets remain available to the GUI and saved storage without making fluid-only machines connectable to item pipes; machines with automatable slots keep their full stable slot numbering. Updated the documentation and added an upgraded fluid-still companion regression that checks no item capability on every face or the unsided query, while fluid/energy capabilities remain available. Runtime regression execution is deferred to CI.

return fluid.fluid().is(TagKey.create(Registries.FLUID, fuelTag));
if (host.level() == null)
return false;
return host.level().getRecipeManager().getRecipes().stream().anyMatch(

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, since this is a teaching example: acceptsFluid runs on every insert and every simulated transfer (pipes simulate every tick). Each call streams all loaded recipes and re-parses the type ResourceLocation. Hoisting the id to a constant and filtering by recipe type, or caching the accepted fluid set per reload, would show readers the cheap pattern instead.

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 57b1fba. The recipe type ID is now a static constant, and AdmissionDemo looks up only recipes of the registered lava_smelting type rather than streaming all loaded recipes. It still queries the current recipe manager so datapack reloads remain visible without maintaining a stale fluid cache. The companion source compiled during the focused clock test run; the existing admission GameTest covers accepted and rejected fluids in CI.

Comment thread scripts/generate_upgrade_assets.py Outdated
'....ygyygygy....',
'................',
]
assert all(len(row) == 16 for row in rows)

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.

Nit: unlike the gearbox and capacitor sprites (lines 41 and 64), this assertion doesn't check len(rows) == 16, so a missing or extra row in the range art would silently write a non-square PNG.

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 245413f. The range sprite now asserts len(rows) == 16 as well as 16 pixels per row, matching the other upgrade sprites. Validated all three generated pixel arrays as 16x16 using a checking PNG-writer stub, without rewriting the assets.

@dshadowwolf
dshadowwolf merged commit 9d88587 into master-2.0-1.21.1-neo Nov 18, 2026
5 checks passed
@faceofcat
faceofcat deleted the codex/complete-machine-porting-stack branch November 18, 2026 17:28
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