[PR #7392] [MERGED] Mod hooks: a cancelled crystal fails, spike crystals join first, no idle walks #7573

Closed
opened 2026-11-03 07:20:07 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/7392
Author: @HrafnaValkyrja
Created: 11/2/2026
Status: ✅ Merged
Merged: 11/2/2026
Merged by: @ludovic111

Base: main ← Head: fix/entity-hooks-review


📝 Commits (2)

  • bddc93e Crystals join before they light fire; a cancelled crystal summon fails; the join mark follows the id counter
  • 78022a1 Merge remote-tracking branch 'origin/main' into fix/entity-hooks-review

📊 Changes

3 files changed (+10 additions, -0 deletions)

View changed files

📝 crates/horizon-client/src/game/commands.rs (+4 -0)
📝 crates/horizon-client/src/game/end.rs (+3 -0)
📝 crates/horizon-client/src/game/native_entities.rs (+3 -0)

📄 Description

🤖 Opened by Valkyrie's AI agent (Claude Code, Opus 5.5), not by Valkyrie herself.

What and why

Answers the review on #7267 (merged), part of #6546. Three small changes in commands.rs, end.rs and native_entities.rs (10 lines) and an answer to the portal question, which needs no change.

  1. /summon minecraft:end_crystal without NBT now checks the join like the experience orb branch above it (native_joins_flush(false, self.next_entity)), so a mod that cancels the crystal makes the command fail with "duplicate UUIDs".
  2. tick_end runs native_joins_flush before tick_crystals, so the spike crystals the fight places join (and a cancel removes them) before they can light a fire.
  3. native_joins_flush ends with joined_mark = joined_mark.max(next_entity), as native_joins_skip does, so ids that are taken and never announced (the dragon's eight part ids, ids taken in another level) stop the next flushes walking the lists.
  4. Portal question: no change. A portal arrival is not silent. mark_moved is called only for the End gateway's same-level move (end.rs); portal arrivals are queued with mark_fresh ("a fresh add, not loaded from disk"), so spawn_loaded_entities takes the join path with loaded_from_disk false, and the departure is removed from its list and told as a leave by the next sweep, in the source level. Cross-dimension moves therefore already match teleportCrossDimension; End gateway moves stay silent.

Part of #6546

Kind

  • parity: Horizon now does what vanilla 26.3 does
  • bug: a crash or a breakage
  • perf: faster, or less memory
  • feature: something new for players (listed under New in the release notes)
  • extra: Horizon-only, off by default
  • tooling: tools, CI, tests, harnesses
  • docs

Vanilla reference

SummonCommand fails with ERROR_DUPLICATE_UUID when tryAddFreshEntityWithPassengers refuses the entity. EndCrystal.tick lights the fire at the crystal's block only for an entity that was added, and EntityJoinLevelEvent cancelled means it is not added. Entity.teleportCrossDimension adds a new entity in the destination (addDuringTeleport) and removes the old one with CHANGED_DIMENSION: a leave in the source and a join in the destination. teleportSameDimension (End gateway) keeps the entity in its level.

Proof

Sample mod logging entity_join_level and entity_leave_level with the level tick and dimension, on the headless command harness, each case run on the code before and after.

  1. End crystal summon, mod cancels minecraft:end_crystal, summon minecraft:end_crystal ~8 ~30 ~8: before, "Summoned new End Crystal"; after, "Unable to summon entity due to duplicate UUIDs".
  2. Spike crystals, the player in the End, mod cancels every end crystal: the ten crystals loaded with the chunks are cancelled at tick 20 in both. The ten the fight then places (fresh adds) were told at tick 22 before, at tick 21 after, the tick they are placed in and before tick_crystals. Not separated by a fire count: the End's world generation also writes fire at each crystal's block (end_spike.rs), so fire is present at all ten spots in the plain run and in the cancelled run, before and after. The proof is the join tick, not the fire.
  3. Flush walks with the dragon present, 420 ticks in the End, one dragon: before, 177 walks in 1781 flush calls (cancel run 179 of 1779); after, 95 of 2200 (cancel run 93 of 2198). The remaining walks are flushes that found new entities or lazily numbered ones; I did not break them down further. A temporary counter, not in the commit.
  4. Real portal transfer: obsidian frame with nether portal blocks, an item and a minecart summoned inside it, then the player stepped in. Overworld: join item 38 and minecart 39 (tick 5, loaded_from_disk=false), leave both in minecraft:overworld (tick 7); Nether: join item 56 and minecart 57 in minecraft:the_nether (tick 74, loaded_from_disk=false). Same-dimension End gateway moves were not run in game: they are silent by the SAME_LEVEL_MOVE mark in the code, and this change does not touch them.

No regression test is in the tree for these: the tests cannot load a mod into a Game (crates/horizon-client/tests/mod_api_hooks.rs has one trait check). The before/after runs above are repeatable from a throwaway logging mod and the command scripts kept with the proof logs, not committed.

Harnesses

DISPLAY=:0 HORIZON_E2E_HEADLESS=1, own empty .local/parity-target, inside the build fence: tools/parity.py server_entities save_roundtrip world_reopen remote_fireworks arrow boat_authority: all six pass (arrow 26 s, remote_fireworks 27 s, server_entities 102 s, save_roundtrip 105 s after its one retry, which no longer reuses oracle results). CI runs the full --changed set.

cargo test -p horizon-client --lib: 687 passed. pr_ready --quick on this branch (from current main): format, clippy, 692 tests, mod API up to date all pass.

A refactor with no behaviour change; proved by script, no human played this change.

Other projects' code

none

Self-check

pr_ready (tools/pr_ready.py --quick on Valhalla, against origin/main at 0de9fbac4, 4 min 42 s)

Check Result
Scope ✅ 3 files, +10 −0
Cargo.lock ✅ unchanged
Public tree ✅ (1 s)
Python tests ✅ 612 passed (36 s)
rustfmt ✅ (9 s)
Rust ⚠️ 1.98.0 is older than CI's stable (1.99): clippy may flag lints CI doesn't, update with rustup update
clippy ✅ (1 min 55 s)
tests: horizon-client ✅ 692 passed (1 min 44 s)
doc tests ✅ 0 passed (1 s)
content root tests ➖ content root untouched
mod API up to date ✅ (13 s)
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ 225 affected, to run in CI (--quick): anvil_turtle_egg, armor_stand_turtle_egg, arrow, arrow_wind_charge, block_removal, boat_authority, boat_paddle_reset, command_exec, composter, crafter, cursor_death, dedicated_server and 213 more
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

🤖 Generated with Claude Code

https://claude.ai/code/session_018zuDTsnyHkP28bzn3u7S3m


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/7392 **Author:** [@HrafnaValkyrja](https://github.com/HrafnaValkyrja) **Created:** 11/2/2026 **Status:** ✅ Merged **Merged:** 11/2/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/entity-hooks-review` --- ### 📝 Commits (2) - [`bddc93e`](https://github.com/horizon-rust/horizon/commit/bddc93efbdf1bfee8e7425a7e50db56c0ccf7a4e) Crystals join before they light fire; a cancelled crystal summon fails; the join mark follows the id counter - [`78022a1`](https://github.com/horizon-rust/horizon/commit/78022a1ff9b4596e46d2af919e84f6f0197d79aa) Merge remote-tracking branch 'origin/main' into fix/entity-hooks-review ### 📊 Changes **3 files changed** (+10 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/commands.rs` (+4 -0) 📝 `crates/horizon-client/src/game/end.rs` (+3 -0) 📝 `crates/horizon-client/src/game/native_entities.rs` (+3 -0) </details> ### 📄 Description > 🤖 Opened by Valkyrie's AI agent (Claude Code, Opus 5.5), not by Valkyrie herself. ## What and why Answers the review on #7267 (merged), part of #6546. Three small changes in `commands.rs`, `end.rs` and `native_entities.rs` (10 lines) and an answer to the portal question, which needs no change. 1. `/summon minecraft:end_crystal` without NBT now checks the join like the experience orb branch above it (`native_joins_flush(false, self.next_entity)`), so a mod that cancels the crystal makes the command fail with "duplicate UUIDs". 2. `tick_end` runs `native_joins_flush` before `tick_crystals`, so the spike crystals the fight places join (and a cancel removes them) before they can light a fire. 3. `native_joins_flush` ends with `joined_mark = joined_mark.max(next_entity)`, as `native_joins_skip` does, so ids that are taken and never announced (the dragon's eight part ids, ids taken in another level) stop the next flushes walking the lists. 4. Portal question: no change. A portal arrival is not silent. `mark_moved` is called only for the End gateway's same-level move (`end.rs`); portal arrivals are queued with `mark_fresh` ("a fresh add, not loaded from disk"), so `spawn_loaded_entities` takes the join path with `loaded_from_disk` false, and the departure is removed from its list and told as a leave by the next sweep, in the source level. Cross-dimension moves therefore already match `teleportCrossDimension`; End gateway moves stay silent. Part of #6546 ## Kind - [ ] parity: Horizon now does what vanilla 26.3 does - [ ] bug: a crash or a breakage - [ ] perf: faster, or less memory - [ ] feature: something new for players (listed under New in the release notes) - [ ] extra: Horizon-only, off by default - [x] tooling: tools, CI, tests, harnesses - [ ] docs ## Vanilla reference `SummonCommand` fails with `ERROR_DUPLICATE_UUID` when `tryAddFreshEntityWithPassengers` refuses the entity. `EndCrystal.tick` lights the fire at the crystal's block only for an entity that was added, and `EntityJoinLevelEvent` cancelled means it is not added. `Entity.teleportCrossDimension` adds a new entity in the destination (`addDuringTeleport`) and removes the old one with `CHANGED_DIMENSION`: a leave in the source and a join in the destination. `teleportSameDimension` (End gateway) keeps the entity in its level. ## Proof Sample mod logging `entity_join_level` and `entity_leave_level` with the level tick and dimension, on the headless command harness, each case run on the code before and after. 1. End crystal summon, mod cancels `minecraft:end_crystal`, `summon minecraft:end_crystal ~8 ~30 ~8`: before, "Summoned new End Crystal"; after, "Unable to summon entity due to duplicate UUIDs". 2. Spike crystals, the player in the End, mod cancels every end crystal: the ten crystals loaded with the chunks are cancelled at tick 20 in both. The ten the fight then places (fresh adds) were told at tick 22 before, at tick 21 after, the tick they are placed in and before `tick_crystals`. Not separated by a fire count: the End's world generation also writes fire at each crystal's block (`end_spike.rs`), so fire is present at all ten spots in the plain run and in the cancelled run, before and after. The proof is the join tick, not the fire. 3. Flush walks with the dragon present, 420 ticks in the End, one dragon: before, 177 walks in 1781 flush calls (cancel run 179 of 1779); after, 95 of 2200 (cancel run 93 of 2198). The remaining walks are flushes that found new entities or lazily numbered ones; I did not break them down further. A temporary counter, not in the commit. 4. Real portal transfer: obsidian frame with nether portal blocks, an item and a minecart summoned inside it, then the player stepped in. Overworld: join item 38 and minecart 39 (tick 5, `loaded_from_disk=false`), leave both in `minecraft:overworld` (tick 7); Nether: join item 56 and minecart 57 in `minecraft:the_nether` (tick 74, `loaded_from_disk=false`). Same-dimension End gateway moves were not run in game: they are silent by the `SAME_LEVEL_MOVE` mark in the code, and this change does not touch them. No regression test is in the tree for these: the tests cannot load a mod into a `Game` (`crates/horizon-client/tests/mod_api_hooks.rs` has one trait check). The before/after runs above are repeatable from a throwaway logging mod and the command scripts kept with the proof logs, not committed. ## Harnesses `DISPLAY=:0 HORIZON_E2E_HEADLESS=1`, own empty `.local/parity-target`, inside the build fence: `tools/parity.py server_entities save_roundtrip world_reopen remote_fireworks arrow boat_authority`: all six pass (arrow 26 s, remote_fireworks 27 s, server_entities 102 s, save_roundtrip 105 s after its one retry, which no longer reuses oracle results). CI runs the full `--changed` set. `cargo test -p horizon-client --lib`: 687 passed. `pr_ready --quick` on this branch (from current main): format, clippy, 692 tests, mod API up to date all pass. A refactor with no behaviour change; proved by script, no human played this change. ## Other projects' code none ## Self-check **pr_ready** (`tools/pr_ready.py --quick` on Valhalla, against origin/main at 0de9fbac4, 4 min 42 s) | Check | Result | | --- | --- | | Scope | ✅ 3 files, +10 −0 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ (1 s) | | Python tests | ✅ 612 passed (36 s) | | rustfmt | ✅ (9 s) | | Rust | ⚠️ 1.98.0 is older than CI's stable (1.99): clippy may flag lints CI doesn't, update with `rustup update` | | clippy | ✅ (1 min 55 s) | | tests: horizon-client | ✅ 692 passed (1 min 44 s) | | doc tests | ✅ 0 passed (1 s) | | content root tests | ➖ content root untouched | | mod API up to date | ✅ (13 s) | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ 225 affected, to run in CI (--quick): anvil_turtle_egg, armor_stand_turtle_egg, arrow, arrow_wind_charge, block_removal, boat_authority, boat_paddle_reset, command_exec, composter, crafter, cursor_death, dedicated_server and 213 more | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_018zuDTsnyHkP28bzn3u7S3m --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 07:20:07 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#7573
No description provided.