Skip to content

Fix comparator block entities, mode toggling and loading - #260

Open
Paul1365972 wants to merge 4 commits into
MCHPR:masterfrom
Paul1365972:fix/comparator-state
Open

Paul1365972 wants to merge 4 commits into
MCHPR:masterfrom
Paul1365972:fix/comparator-state

Conversation

@Paul1365972

@Paul1365972 Paul1365972 commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Redpiler's flush wrote comparator blocks but never their block entities, only reset did.
Saves and copies taken while Redpiler was running got stale OutputSignal values.
With --io-only it was worse, reset wrote live output strengths next to block states frozen at compile time, so a comparator could end up unpowered with an output of 15.

flush now writes the block entity together with each comparator block it writes, and reset flushes all changed nodes, including internal ones under --io-only, before clearing its state.
Saves and copies need no extra flush since every tick path already flushes right after ticking.

Also fixed:

  • Toggling a comparator's mode overwrote the powered state set by its tick with the old one.
  • Loading a schematic or item whose comparator block entity has no OutputSignal panicked. It now loads with an output of 0. Values outside 0..=15 are clamped because Redpiler indexes arrays by signal strength without bounds checks.
  • Numeric NBT fields now accept every numeric tag type, as vanilla does. This also covers the Count and Slot of container items.

Known limitations:

  • With --io-only, internal nodes are still only written on reset, so saves and copies during a run see their compile-time state.
  • With --io-only --optimize, comparators pruned as orphans are never written and keep their compile-time block state and block entity after reset.

@Paul1365972
Paul1365972 force-pushed the fix/comparator-state branch 2 times, most recently from f5487b6 to a118bdf Compare September 12, 2026 15:53
@Paul1365972

Copy link
Copy Markdown
Contributor Author

Dropped the extra reset before the final save, Drop already resets and saves.
Dropped the flush calls in save() and worldedit, they were no-ops since every tick path already flushes right after ticking.
They only matter once flushing is deferred, and #261 adds them back where needed.

@Paul1365972 Paul1365972 changed the title Fix comparator block entity syncing Fix comparator block entities, mode toggling and loading Sep 30, 2026
@Paul1365972

Copy link
Copy Markdown
Contributor Author

Since the last push:

benburk added a commit to benburk/MCHPRS that referenced this pull request Oct 29, 2026
As MCHPR#260 does in flush: a comparator's block entity holds the
strength the backend computed, so it can be read back from the world.
benburk added a commit to benburk/MCHPRS that referenced this pull request Nov 2, 2026
As MCHPR#260 does in flush: a comparator's block entity holds the
strength the backend computed, so it can be read back from the world.
@Paul1365972
Paul1365972 marked this pull request as draft November 2, 2026 22:08
@Paul1365972
Paul1365972 marked this pull request as ready for review November 16, 2026 18:57
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.

1 participant