perf: creative node verifies its registration instead of trusting it forever #31

Merged
layue13 merged 1 commits from perf/creative-node-self-heal into main 2026-11-07 16:02:53 +00:00
Owner

Requested by Ethyn · project thread

Pareto follow-up to #29

What

thaumicadditions#29 made the creative node register its location in TileNode.locations once. The original rewrote it every tick, which also healed the map after TC4 or another mod cleared or changed it. This PR keeps #29's saving but checks, each tick, that the entry still exists and matches (dimension, x, y, z); if not, generateId() runs again that same tick.

Before / after, all dimensions

dimension original #29 this PR
result (map content) rewritten every tick written once, never repaired same as original: repaired within the same tick
per-tick cost string concat + ArrayList + 4 Integers + put a boolean test one HashMap get + 4 int compares, no allocation
memory none none none
worst-case latency / stale window 0 until chunk reload 0

Tests

CreativeNodeRegistryTest: the 2 existing + cleared map repaired next tick, altered entry restored next tick, intact entry not rewritten (same list instance).

Scenario for a real server

Place a creative node, run a vis relay/wand check that reads TileNode.locations; clear the map with a harness (or reload another TC4 node type that clears it) and confirm the node is registered again within one tick.

🤖 Generated with Claude Code

<!-- claude-projects-attribution --> _Requested by **Ethyn** · [project thread](https://claude.ai/code/project/chan_01DUNCDJLEksDHKpX5X5cThi?thread=cmsg_01DUNCDJLEksDHKpX5X5cThiWWzw9g2ZbURExfCGHZcnLC)_ Pareto follow-up to #29 ## What thaumicadditions#29 made the creative node register its location in `TileNode.locations` once. The original rewrote it every tick, which also healed the map after TC4 or another mod cleared or changed it. This PR keeps #29's saving but checks, each tick, that the entry still exists and matches (dimension, x, y, z); if not, `generateId()` runs again that same tick. ## Before / after, all dimensions | dimension | original | #29 | this PR | |---|---|---|---| | result (map content) | rewritten every tick | written once, never repaired | same as original: repaired within the same tick | | per-tick cost | string concat + ArrayList + 4 Integers + put | a boolean test | one HashMap get + 4 int compares, no allocation | | memory | none | none | none | | worst-case latency / stale window | 0 | until chunk reload | 0 | ## Tests CreativeNodeRegistryTest: the 2 existing + cleared map repaired next tick, altered entry restored next tick, intact entry not rewritten (same list instance). ## Scenario for a real server Place a creative node, run a vis relay/wand check that reads `TileNode.locations`; clear the map with a harness (or reload another TC4 node type that clears it) and confirm the node is registered again within one tick. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
layue13 added 1 commit 2026-11-07 15:11:06 +00:00
perf: creative node verifies its registration instead of trusting it forever
Build / build (push) Skipped
Build / publish (push) Skipped
Build / build (pull_request) Successful in 2m11s
Build / publish (pull_request) Skipped
0ae97629e3
#29 registered the location once. The old per-tick rewrite also repaired the shared
TileNode.locations map when another mod cleared or altered it. One lookup and four
int compares per tick restore that: generateId runs again as soon as the entry is
missing or different.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
layue13 merged commit 579c7064e2 into main 2026-11-07 16:02:53 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: TDLM/thaumicadditions#31