[PR #6734] [MERGED] One walk over every entity, plates first #7063

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

📋 Pull Request Information

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

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


📝 Commits (2)

  • 43e2faf refactor: walk every entity for plates and tripwires
  • c789d7b Merge remote-tracking branch 'origin/main' into refactor/entity-walk-plates

📊 Changes

3 files changed (+179 additions, -148 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+60 -134)
📝 crates/horizon-client/src/game/dragon.rs (+10 -0)
📝 crates/horizon-client/src/game/entity.rs (+109 -14)

📄 Description

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

What and why

Slice 3 of #6509, closes #6538: plates and tripwires now use one walk over every entity instead of naming lists.

  • for_each_entity! runs a body for every entity: one loop per list, each compiled for that kind.
  • EntityLists holds the lists borrowed field by field, so GameLevel can walk them while the world is borrowed mutably. That is why the walk is on this view and not a method on Game.
  • New Entity methods: is_removed, is_living, is_ignoring_block_triggers, triggers_blocks, sweeps_blocks_inside.
  • other_trigger_boxes, mob_trigger_boxes, Blockers and trigger_projectiles are gone.

No behaviour change is intended. End crystals, fishing hooks and lightning bolts are not on the walk yet: crystals have no stored velocity for the trait, and adding them to entity_lists! would also make pistons push them. They stay as short named lists next to it.

Fixes #6538

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

Entity.isIgnoringBlockTriggers is false. Bytecode overrides read through tools/rea_vanilla.py: Bat returns true, ArmorStand returns isMarker(), Marker, OminousItemSpawner, Interaction and Display return true. Bat and armor stand are overrides here. The other four kinds are not in the entity lists, so they have nothing to override yet and were never counted.

Numbers

Side-by-side scene: 19 cases parked on an oak plate, a stone plate and a tripwire, read twice, 2 s apart. Dedicated servers. Base means #6556's commit.

result
base vs this PR identical on every case
item, orb, arrow, snowball, trident, still rocket, boat, minecart, TNT, falling block, crystal oak and tripwire pressed, stone not, as vanilla
pig all three pressed, as vanilla
bat, marker stand, empty control, rocket that flies off none pressed, as vanilla
armor stand with NoGravity, visible or invisible pressed in base and this PR, not in vanilla

The armor stand row is an existing difference, not from this PR, and is left alone here. An armor stand with gravity matches vanilla.

The plates_kinds scene on the merged code keeps the bolt on its plate at the recount, as vanilla. In that scene potions, eyes and fangs still drop, as before; /summon makes inert placeholders of them in Horizon. Fishing hooks were not in either scene; their code only moved.

Tick cost

Rule from #6509: no dyn, no allocation per walk. for_each_entity! expands to plain for loops over slices. count_triggers takes LIVING as a const generic, so a stone plate's check of a non-living kind is a constant.

Allocation, by reading the code: this removes one Vec per GameLevel when tridents or rockets exist; hooks and bolts keep theirs, empty unless any exist.

Method: a temporary timer (not in this PR) around count_entities and the touched sweep in tick_blocks. fast profile, dedicated server, 300 plates held down, 2000 more entities, about 15 counts per tick, tick sprint 2800 in 400-tick windows dropping the first. 14 alternating pairs of runs; other builds were running on the machine, with load between 4 and 23.

median per tick range median of each run
base 456 µs 332 to 716 349 to 631
this PR 430 µs 333 to 690 370 to 642

The difference is inside the spread between each build's own runs, so this shows no clear change, in either direction. It doesn't exclude a small one. These builds predate the bolts merge, which adds one loop over an empty list.

Harnesses

Run locally: the ones covering plates and tripwires. CI runs the full --changed set.

PASS block_survival 222s
PASS redstone 6s
PASS server_entities 545s
3 passed, 0 failed in 9.1 min.

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 e9eb640ac, 5 min 11 s)

Check Result
Scope ✅ 3 files, +179 −148
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 602 passed (34 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 ✅ (2 min 20 s)
tests: horizon-client ✅ 604 passed (1 min 59 s)
doc tests ✅ 0 passed (2 s)
content root tests ➖ content root untouched
mod API up to date ✅ (6 s)
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ 276 affected, to run in CI (--quick): active_effect_tick, active_effects, ambient_sound, anchor, armor_stand_frost, arrow, arrow_wind_charge, attribute_health, attribute_map_queries, attribute, attribute_updates, audio_attributes and 264 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/6734 **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-plates` --- ### 📝 Commits (2) - [`43e2faf`](https://github.com/horizon-rust/horizon/commit/43e2faf5e8e3abee49b9f9ee746bf35595ce6790) refactor: walk every entity for plates and tripwires - [`c789d7b`](https://github.com/horizon-rust/horizon/commit/c789d7bebf062ee4233de9a988f56f6794b60561) Merge remote-tracking branch 'origin/main' into refactor/entity-walk-plates ### 📊 Changes **3 files changed** (+179 additions, -148 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+60 -134) 📝 `crates/horizon-client/src/game/dragon.rs` (+10 -0) 📝 `crates/horizon-client/src/game/entity.rs` (+109 -14) </details> ### 📄 Description > 🤖 Opened by Valkyrie's AI agent (Claude Code, Opus 5.5), not by Valkyrie herself. ## What and why Slice 3 of #6509, closes #6538: plates and tripwires now use one walk over every entity instead of naming lists. - `for_each_entity!` runs a body for every entity: one loop per list, each compiled for that kind. - `EntityLists` holds the lists borrowed field by field, so `GameLevel` can walk them while the world is borrowed mutably. That is why the walk is on this view and not a method on `Game`. - New `Entity` methods: `is_removed`, `is_living`, `is_ignoring_block_triggers`, `triggers_blocks`, `sweeps_blocks_inside`. - `other_trigger_boxes`, `mob_trigger_boxes`, `Blockers` and `trigger_projectiles` are gone. No behaviour change is intended. End crystals, fishing hooks and lightning bolts are not on the walk yet: crystals have no stored velocity for the trait, and adding them to `entity_lists!` would also make pistons push them. They stay as short named lists next to it. Fixes #6538 ## 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 `Entity.isIgnoringBlockTriggers` is false. Bytecode overrides read through `tools/rea_vanilla.py`: `Bat` returns true, `ArmorStand` returns `isMarker()`, `Marker`, `OminousItemSpawner`, `Interaction` and `Display` return true. Bat and armor stand are overrides here. The other four kinds are not in the entity lists, so they have nothing to override yet and were never counted. ## Numbers Side-by-side scene: 19 cases parked on an oak plate, a stone plate and a tripwire, read twice, 2 s apart. Dedicated servers. Base means #6556's commit. | | result | |---|---| | base vs this PR | identical on every case | | item, orb, arrow, snowball, trident, still rocket, boat, minecart, TNT, falling block, crystal | oak and tripwire pressed, stone not, as vanilla | | pig | all three pressed, as vanilla | | bat, marker stand, empty control, rocket that flies off | none pressed, as vanilla | | armor stand with `NoGravity`, visible or invisible | pressed in base and this PR, not in vanilla | The armor stand row is an existing difference, not from this PR, and is left alone here. An armor stand with gravity matches vanilla. The `plates_kinds` scene on the merged code keeps the bolt on its plate at the recount, as vanilla. In that scene potions, eyes and fangs still drop, as before; `/summon` makes inert placeholders of them in Horizon. Fishing hooks were not in either scene; their code only moved. ## Tick cost Rule from #6509: no `dyn`, no allocation per walk. `for_each_entity!` expands to plain `for` loops over slices. `count_triggers` takes `LIVING` as a const generic, so a stone plate's check of a non-living kind is a constant. Allocation, by reading the code: this removes one `Vec` per `GameLevel` when tridents or rockets exist; hooks and bolts keep theirs, empty unless any exist. Method: a temporary timer (not in this PR) around `count_entities` and the `touched` sweep in `tick_blocks`. `fast` profile, dedicated server, 300 plates held down, 2000 more entities, about 15 counts per tick, `tick sprint 2800` in 400-tick windows dropping the first. 14 alternating pairs of runs; other builds were running on the machine, with load between 4 and 23. | | median per tick | range | median of each run | |---|---|---|---| | base | 456 µs | 332 to 716 | 349 to 631 | | this PR | 430 µs | 333 to 690 | 370 to 642 | The difference is inside the spread between each build's own runs, so this shows no clear change, in either direction. It doesn't exclude a small one. These builds predate the bolts merge, which adds one loop over an empty list. ## Harnesses Run locally: the ones covering plates and tripwires. CI runs the full `--changed` set. ``` PASS block_survival 222s PASS redstone 6s PASS server_entities 545s 3 passed, 0 failed in 9.1 min. ``` 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 e9eb640ac, 5 min 11 s) | Check | Result | | --- | --- | | Scope | ✅ 3 files, +179 −148 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 602 passed (34 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 | ✅ (2 min 20 s) | | tests: horizon-client | ✅ 604 passed (1 min 59 s) | | doc tests | ✅ 0 passed (2 s) | | content root tests | ➖ content root untouched | | mod API up to date | ✅ (6 s) | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ 276 affected, to run in CI (--quick): active_effect_tick, active_effects, ambient_sound, anchor, armor_stand_frost, arrow, arrow_wind_charge, attribute_health, attribute_map_queries, attribute, attribute_updates, audio_attributes and 264 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:33:06 +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#7063
No description provided.