[PR #6919] [MERGED] Explosions find their targets through the entity walk #7193

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

📋 Pull Request Information

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

Base: main ← Head: refactor/entity-walk-explosions


📝 Commits (9)

  • 4e149f2 wip-walk
  • 0d3c092 merge main
  • 0dcf45c Merge remote-tracking branch 'origin/main' into refactor/entity-walk-plates
  • 4c61e54 refactor: walk every entity for explosions
  • 9730bf4 Merge refactor/entity-walk-plates (slice 3 final) into refactor/entity-walk-explosions
  • 879efa1 Merge remote-tracking branch 'origin/main' into refactor/entity-walk-explosions
  • 74f7d8c Merge branch 'fix/pearl-test-drag' into refactor/entity-walk-explosions
  • d6622bf Merge remote-tracking branch 'origin/main' into refactor/entity-walk-explosions
  • 2382774 Merge main into #6919

📊 Changes

2 files changed (+293 additions, -313 deletions)

View changed files

📝 crates/horizon-client/src/game/entity.rs (+118 -0)
📝 crates/horizon-client/src/game/explosion.rs (+175 -313)

📄 Description

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

Stacks on #6734: the commits up to its head belong to that PR, and this slice is the rest. A PR's base has to be a branch in this repo and ours are on a fork, so this targets main, and the diff shrinks to the slice once #6734 merges.

Part of #6509, slice 4 (#6539).

What changed

explosion_hurt_entities had one loop per entity list (mobs, items, orbs, primed TNT, minecarts, boats, falling blocks, projectiles, rockets, tridents), each with its own copy of the distance, exposure and knockback arithmetic. They are now one pass over entity_handles(). The shared arithmetic is blast_hit, generic over the kind, so there is no dyn and nothing is allocated per walk. What a blast does to a kind (hurt a mob, destroy an item or orb, damage a boat or cart) stays a match on the handle, since those need the whole Game.

Vanilla's exceptions are overrides on the Entity trait:

  • ignores_explosion: VehicleEntity (boats and minecarts: a mob's blast with mob griefing off), ItemEntity (a blast that keeps blocks, with mob griefing off), Warden (digging or emerging), plus the dead and the exploding mob itself, which getEntities(source, box) never lists.
  • pushed_by_explosion: arrows and tridents in the ground, wind charges, armour stands (those stay with explosion_breaks_decorations).
  • explosion_box, explosion_eye_height, push_from_explosion: the per-kind box, eye height and needsSync that the old loops spelled out.

Behaviour is meant to be unchanged. Three things differ in detail and none was observed to change a result:

  • The kinds are now visited in list order (mobs, items, boats, carts, primed TNT, falling blocks, orbs, projectiles, rockets, tridents) instead of the old order. Only the order of random draws between destroying a boat and destroying a cart can differ.
  • The mob pass no longer takes the mob list out of Game while it runs, so mob_team can see a tamed mob's owner. Not exercised by any scene or harness here.
  • Items and orbs destroyed by the blast are squeezed out after the pass, as retain did, instead of removed one at a time.

Fixes #6539

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

ServerExplosion.hurtEntities lists the entities in the blast box, skips those whose ignoreExplosion says so, then hurts and pushes each. The overrides above are from the bytecode of VehicleEntity.ignoreExplosion (getIndirectSourceEntity() instanceof Mob && !mobGriefing) and the other classes named, read through tools/rea_vanilla.py. Side-by-side scenes against the real server (6 existing explosion scenes plus two new ones, blast_walk with every kind in the walk near and far, and blast_walk_nogrief with a creeper blast and mob griefing off): the Horizon values from before and after this change are byte-identical in 7 of 8 scenes. The eighth (tnt) differs only in which blocks the TNT broke and the number of dropped items, which also differ between two runs of the unchanged build (random ray strength); every entity value (health, position, motion) is identical.

Against vanilla, the same scenes were not all clean before this change either, so they are not a pass for this change: blast_walk 132 of 138 values match (the trident is never summoned by Horizon's /summon), blast_walk_nogrief 113 of 138, blast_all 113 of 144, blast_bystanders 13 of 16, blast_cart 8 of 12, tnt 357 of 364. Same numbers before and after.

Tick cost

Time spent inside explosion_hurt_entities, measured in a dedicated server with a sealed pit of about 270 entities that survive a blast (150 nether-star items, 60 invulnerable zombies, 60 primed TNT with a long fuse) and one TNT exploding at its centre every 3 ticks. A timer around the function logs microseconds per call every 100 calls; the first window is dropped. Two rounds, each one run of the old build and one of the new, alternating, four windows per run:

us per call, windows mean
before 1505 1548 1551 1585 1776 1794 1907 1823 1686
after 1530 1577 1433 1451 1531 1604 1543 1930 1575

The machine was loaded (load average 9 to 24) while this ran, and the spread inside one build (1433 to 1930 after, 1505 to 1907 before) is larger than the difference between them. So this shows no measurable cost, and not a measurable gain. It does not cover a blast that destroys hundreds of items or orbs.

Harnesses

tools/parity.py on the harnesses that exercise explosions and knockback: server_knockback pass, team_rules pass, entity_death_loot pass. remote_fireball fails before reaching any explosion: the game it launches for its LAN host exits with status 1 before opening its control socket in this environment. Not run on the unchanged build, so it is unknown whether it fails there too. Also ran the unit tests in explosion.rs through tools/pr_ready.py --quick.

remote_fireball passes run offscreen (48 s); its earlier failure was the local run having no display.

Proved by script against the real 26.3 server; no human played this change.

Other projects' code

none

Self-check

pr_ready (tools/pr_ready.py --quick on Valhalla, against origin/main at 57ddd46c3, 1 min 59 s)

Check Result
Scope ⚠️ 5 files, +479 −466; 945 lines of code: over 500, split it if it can ship in parts
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 610 passed (28 s)
rustfmt ✅ (7 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 ✅ (33 s)
tests: horizon-client ✅ 651 passed (38 s)
doc tests ✅ 0 passed (1 s)
content root tests ➖ content root untouched
mod API up to date ✅ (10 s)
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ 273 affected, to run in CI (--quick): active_effect_tick, active_effects, ambient_sound, anchor, armor_stand_frost, armor_stand_turtle_egg, arrow, arrow_wind_charge, attribute_health, attribute_map_queries, attribute, attribute_updates and 261 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/6919 **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:** `refactor/entity-walk-explosions` --- ### 📝 Commits (9) - [`4e149f2`](https://github.com/horizon-rust/horizon/commit/4e149f24f9bc550d39c82bf5cc4deba18343c13d) wip-walk - [`0d3c092`](https://github.com/horizon-rust/horizon/commit/0d3c092469a006154554371b851f92b6943afc57) merge main - [`0dcf45c`](https://github.com/horizon-rust/horizon/commit/0dcf45ce2cb8b4954c931dac7af43c1b8cb3cc62) Merge remote-tracking branch 'origin/main' into refactor/entity-walk-plates - [`4c61e54`](https://github.com/horizon-rust/horizon/commit/4c61e542cb06231bc8b9a698e974746f5091f8b8) refactor: walk every entity for explosions - [`9730bf4`](https://github.com/horizon-rust/horizon/commit/9730bf403cdc6770fbec166126b0f1e3401456ac) Merge refactor/entity-walk-plates (slice 3 final) into refactor/entity-walk-explosions - [`879efa1`](https://github.com/horizon-rust/horizon/commit/879efa1272450646fc9a52168bc096d53089e017) Merge remote-tracking branch 'origin/main' into refactor/entity-walk-explosions - [`74f7d8c`](https://github.com/horizon-rust/horizon/commit/74f7d8c82a9476711eafe99ee48130a416021e28) Merge branch 'fix/pearl-test-drag' into refactor/entity-walk-explosions - [`d6622bf`](https://github.com/horizon-rust/horizon/commit/d6622bf9e50a26e9b84e340a69ecd004adb457eb) Merge remote-tracking branch 'origin/main' into refactor/entity-walk-explosions - [`2382774`](https://github.com/horizon-rust/horizon/commit/23827747cc8ceafe53ce99d15833e9909b9110e0) Merge main into #6919 ### 📊 Changes **2 files changed** (+293 additions, -313 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/entity.rs` (+118 -0) 📝 `crates/horizon-client/src/game/explosion.rs` (+175 -313) </details> ### 📄 Description > 🤖 Opened by Valkyrie's AI agent (Claude Code, Opus 5.5), not by Valkyrie herself. Stacks on #6734: the commits up to its head belong to that PR, and this slice is the rest. A PR's base has to be a branch in this repo and ours are on a fork, so this targets main, and the diff shrinks to the slice once #6734 merges. Part of #6509, slice 4 (#6539). ## What changed `explosion_hurt_entities` had one loop per entity list (mobs, items, orbs, primed TNT, minecarts, boats, falling blocks, projectiles, rockets, tridents), each with its own copy of the distance, exposure and knockback arithmetic. They are now one pass over `entity_handles()`. The shared arithmetic is `blast_hit`, generic over the kind, so there is no `dyn` and nothing is allocated per walk. What a blast does to a kind (hurt a mob, destroy an item or orb, damage a boat or cart) stays a match on the handle, since those need the whole `Game`. Vanilla's exceptions are overrides on the `Entity` trait: - `ignores_explosion`: `VehicleEntity` (boats and minecarts: a mob's blast with mob griefing off), `ItemEntity` (a blast that keeps blocks, with mob griefing off), `Warden` (digging or emerging), plus the dead and the exploding mob itself, which `getEntities(source, box)` never lists. - `pushed_by_explosion`: arrows and tridents in the ground, wind charges, armour stands (those stay with `explosion_breaks_decorations`). - `explosion_box`, `explosion_eye_height`, `push_from_explosion`: the per-kind box, eye height and `needsSync` that the old loops spelled out. Behaviour is meant to be unchanged. Three things differ in detail and none was observed to change a result: - The kinds are now visited in list order (mobs, items, boats, carts, primed TNT, falling blocks, orbs, projectiles, rockets, tridents) instead of the old order. Only the order of random draws between destroying a boat and destroying a cart can differ. - The mob pass no longer takes the mob list out of `Game` while it runs, so `mob_team` can see a tamed mob's owner. Not exercised by any scene or harness here. - Items and orbs destroyed by the blast are squeezed out after the pass, as `retain` did, instead of removed one at a time. Fixes #6539 ## Kind - [x] 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 `ServerExplosion.hurtEntities` lists the entities in the blast box, skips those whose `ignoreExplosion` says so, then hurts and pushes each. The overrides above are from the bytecode of `VehicleEntity.ignoreExplosion` (`getIndirectSourceEntity() instanceof Mob && !mobGriefing`) and the other classes named, read through `tools/rea_vanilla.py`. Side-by-side scenes against the real server (6 existing explosion scenes plus two new ones, `blast_walk` with every kind in the walk near and far, and `blast_walk_nogrief` with a creeper blast and mob griefing off): the Horizon values from before and after this change are byte-identical in 7 of 8 scenes. The eighth (`tnt`) differs only in which blocks the TNT broke and the number of dropped items, which also differ between two runs of the unchanged build (random ray strength); every entity value (health, position, motion) is identical. Against vanilla, the same scenes were not all clean before this change either, so they are not a pass for this change: `blast_walk` 132 of 138 values match (the trident is never summoned by Horizon's `/summon`), `blast_walk_nogrief` 113 of 138, `blast_all` 113 of 144, `blast_bystanders` 13 of 16, `blast_cart` 8 of 12, `tnt` 357 of 364. Same numbers before and after. ## Tick cost Time spent inside `explosion_hurt_entities`, measured in a dedicated server with a sealed pit of about 270 entities that survive a blast (150 nether-star items, 60 invulnerable zombies, 60 primed TNT with a long fuse) and one TNT exploding at its centre every 3 ticks. A timer around the function logs microseconds per call every 100 calls; the first window is dropped. Two rounds, each one run of the old build and one of the new, alternating, four windows per run: | | us per call, windows | mean | |---|---|---| | before | 1505 1548 1551 1585 1776 1794 1907 1823 | 1686 | | after | 1530 1577 1433 1451 1531 1604 1543 1930 | 1575 | The machine was loaded (load average 9 to 24) while this ran, and the spread inside one build (1433 to 1930 after, 1505 to 1907 before) is larger than the difference between them. So this shows no measurable cost, and not a measurable gain. It does not cover a blast that destroys hundreds of items or orbs. ## Harnesses `tools/parity.py` on the harnesses that exercise explosions and knockback: `server_knockback` pass, `team_rules` pass, `entity_death_loot` pass. `remote_fireball` fails before reaching any explosion: the game it launches for its LAN host exits with status 1 before opening its control socket in this environment. Not run on the unchanged build, so it is unknown whether it fails there too. Also ran the unit tests in `explosion.rs` through `tools/pr_ready.py --quick`. `remote_fireball` passes run offscreen (48 s); its earlier failure was the local run having no display. Proved by script against the real 26.3 server; no human played this change. ## Other projects' code none ## Self-check **pr_ready** (`tools/pr_ready.py --quick` on Valhalla, against origin/main at 57ddd46c3, 1 min 59 s) | Check | Result | | --- | --- | | Scope | ⚠️ 5 files, +479 −466; 945 lines of code: over 500, split it if it can ship in parts | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 610 passed (28 s) | | rustfmt | ✅ (7 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 | ✅ (33 s) | | tests: horizon-client | ✅ 651 passed (38 s) | | doc tests | ✅ 0 passed (1 s) | | content root tests | ➖ content root untouched | | mod API up to date | ✅ (10 s) | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ 273 affected, to run in CI (--quick): active_effect_tick, active_effects, ambient_sound, anchor, armor_stand_frost, armor_stand_turtle_egg, arrow, arrow_wind_charge, attribute_health, attribute_map_queries, attribute, attribute_updates and 261 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 06:35:31 +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#7193
No description provided.