[GH-ISSUE #7353] Native mods: entity join gaps after #7267 (/summon end_crystal, spike crystal fire, repeated join walks) #3212

Closed
opened 2026-11-03 04:06:43 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @arismoko on GitHub (Nov 2, 2026).
Original GitHub issue: https://github.com/horizon-rust/horizon/issues/7353

🤖 Filed by Aria's agent swarm, Dyna, not by Aria.

Follow-up to #7267 (part of #6546, #4953 "Entities joining a level"). These three points were raised in the review on #7267 (issuecomment-6578956755) and are still on main at d71ed2848. The files involved are unchanged since the PR's head c3f8675.

  1. /summon end_crystal reports success when a mod cancels the crystal's join. The crystal branch (crates/horizon-client/src/game/commands.rs:2233) pushes the crystal and returns without the native_joins_flush(false, self.next_entity) check that the experience orb branch uses (:2216). The end-of-tick flush then cancels the crystal and removes it, but the command has already printed "Summoned new End Crystal". The PR body lists this as open. We reproduced it in game at c3f8675 on the server thread and on a dedicated server with a client joined: the join was logged as cancelled while the command reported success. Vanilla fails the command (SummonCommand, ERROR_DUPLICATE_UUID).

  2. A spike crystal whose join a mod cancels still places fire. The tick's last join flush (crates/horizon-client/src/game.rs:7389) runs before tick_end (:7398). In tick_end, tick_fight can place the spike crystals (dragon.rs:970 → place_spike_crystals, :1014), and tick_crystals then runs in the same call (end.rs:516) and sets fire at each crystal's block (dragon.rs:1062, :1074). The joins are only told at the next tick's flush, so a mod that cancels one is too late to stop its fire. NeoForge's EntityJoinLevelEvent says that cancelling it keeps the entity from being added. Code-read only.

  3. With a mod loaded, later join flushes can keep walking every entity list when nothing is new. joins_pending compares the global next_entity with the level's persist.joined_mark (crates/horizon-client/src/game/native_entities.rs:286). native_joins_flush sets the mark only to the IDs it announces (:323). Some IDs are taken but never announced, such as the dragon's nine for itself and its parts (dragon.rs:1002-1003). IDs can also be taken in another level, because persist is swapped per level while the counter is shared. In either case the mark stays below next_entity after a walk that finds nothing, so every later flush walks again (four per tick in Game::tick: game.rs:7304, :7330, :7368, :7389). native_joins_skip already ends with joined_mark = joined_mark.max(next_entity) (:441), and the same line at the end of native_joins_flush would close it. Code-read only and not measured. With no mod loaded the flush returns first (:303), so this costs nothing then.

Test route: the in-game check for item 1 used a throwaway branch of horizon-machine-sample that logs native_entity_join_level and native_entity_leave_level and cancels chosen kinds. Items 2 and 3 were not tested in game.

Originally created by @arismoko on GitHub (Nov 2, 2026). Original GitHub issue: https://github.com/horizon-rust/horizon/issues/7353 > 🤖 Filed by Aria's agent swarm, Dyna, not by Aria. Follow-up to #7267 (part of #6546, #4953 "Entities joining a level"). These three points were raised in the review on #7267 (issuecomment-6578956755) and are still on main at `d71ed2848`. The files involved are unchanged since the PR's head `c3f8675`. 1. **`/summon end_crystal` reports success when a mod cancels the crystal's join.** The crystal branch (`crates/horizon-client/src/game/commands.rs:2233`) pushes the crystal and returns without the `native_joins_flush(false, self.next_entity)` check that the experience orb branch uses (`:2216`). The end-of-tick flush then cancels the crystal and removes it, but the command has already printed "Summoned new End Crystal". The PR body lists this as open. We reproduced it in game at `c3f8675` on the server thread and on a dedicated server with a client joined: the join was logged as cancelled while the command reported success. Vanilla fails the command (`SummonCommand`, `ERROR_DUPLICATE_UUID`). 2. **A spike crystal whose join a mod cancels still places fire.** The tick's last join flush (`crates/horizon-client/src/game.rs:7389`) runs before `tick_end` (`:7398`). In `tick_end`, `tick_fight` can place the spike crystals (`dragon.rs:970` → `place_spike_crystals`, `:1014`), and `tick_crystals` then runs in the same call (`end.rs:516`) and sets fire at each crystal's block (`dragon.rs:1062`, `:1074`). The joins are only told at the next tick's flush, so a mod that cancels one is too late to stop its fire. NeoForge's `EntityJoinLevelEvent` says that cancelling it keeps the entity from being added. Code-read only. 3. **With a mod loaded, later join flushes can keep walking every entity list when nothing is new.** `joins_pending` compares the global `next_entity` with the level's `persist.joined_mark` (`crates/horizon-client/src/game/native_entities.rs:286`). `native_joins_flush` sets the mark only to the IDs it announces (`:323`). Some IDs are taken but never announced, such as the dragon's nine for itself and its parts (`dragon.rs:1002-1003`). IDs can also be taken in another level, because `persist` is swapped per level while the counter is shared. In either case the mark stays below `next_entity` after a walk that finds nothing, so every later flush walks again (four per tick in `Game::tick`: `game.rs:7304`, `:7330`, `:7368`, `:7389`). `native_joins_skip` already ends with `joined_mark = joined_mark.max(next_entity)` (`:441`), and the same line at the end of `native_joins_flush` would close it. Code-read only and not measured. With no mod loaded the flush returns first (`:303`), so this costs nothing then. **Test route:** the in-game check for item 1 used a throwaway branch of [horizon-machine-sample](https://github.com/arismoko/horizon-machine-sample) that logs `native_entity_join_level` and `native_entity_leave_level` and cancels chosen kinds. Items 2 and 3 were not tested in game.
Author
Owner

@arismoko commented on GitHub (Nov 2, 2026):

🤖 Agent: All three points are fixed on main by #7392 (merged as 4fb283702a):

  1. The crystal branch of /summon now checks the join and fails with commands.summon.failed.uuid when it's cancelled.
  2. tick_end flushes joins before tick_crystals, so the spike crystals join before they light a fire.
  3. native_joins_flush ends with joined_mark = joined_mark.max(next_entity).

This is from reading the merged diff; it wasn't re-tested in game. Closing.

<!-- gh-comment-id:6585666421 --> @arismoko commented on GitHub (Nov 2, 2026): 🤖 Agent: All three points are fixed on main by #7392 (merged as 4fb283702a): 1. The crystal branch of `/summon` now checks the join and fails with `commands.summon.failed.uuid` when it's cancelled. 2. `tick_end` flushes joins before `tick_crystals`, so the spike crystals join before they light a fire. 3. `native_joins_flush` ends with `joined_mark = joined_mark.max(next_entity)`. This is from reading the merged diff; it wasn't re-tested in game. Closing.
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#3212
No description provided.