[PR #6929] [MERGED] Portals find their entities through the entity walk #7203

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

📋 Pull Request Information

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

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


📝 Commits (8)

  • 69936d0 Merge origin/main into refactor/entity-walk-portals
  • cb02bd2 refactor: walk every entity for portals
  • e66262a Merge branch 'fix/pearl-test-drag' into refactor/entity-walk-portals
  • e943c00 Merge remote-tracking branch 'origin/main' into refactor/entity-walk-portals
  • 1d2d694 Merge origin/main into refactor/entity-walk-portals
  • 415b3c2 Merge origin/main into refactor/entity-walk-portals
  • 6d2942c Merge remote-tracking branch 'origin/main' into refactor/entity-walk-portals
  • c2f28b5 Merge remote-tracking branch 'origin/main' into refactor/entity-walk-portals

📊 Changes

2 files changed (+128 additions, -133 deletions)

View changed files

📝 crates/horizon-client/src/game/entity.rs (+88 -0)
📝 crates/horizon-client/src/game/nether_portal.rs (+40 -133)

📄 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 7 (#6542), stacked on slice 3 (#6538, #6734). Moves the portal sweep onto for_each_entity.

handle_entity_portals and find_entity_portals in nether_portal.rs each named the lists they knew (items, orbs, TNT, mobs, boats, carts, projectiles, tridents, rockets) and repeated the same sweep per list. Now one walk does both, and each kind states only where it differs. New Entity methods: id, portal_size (None for a kind the game does not carry through portals), can_use_portal (Entity.canUsePortal, overridden by mobs, TNT, boats, minecarts), portal_from and portal_sweeps. The kind-specific rules that were if chains (arrows and saved projectiles, a rocket that carries its owner, a stuck arrow or grounded trident that did not move) moved onto the kinds.

Behaviour is unchanged. Armor stands and falling blocks stay out of the sweep as before (portal_size is None); the falling block's portal code is separate and was not touched. Fishing hooks, crystals and bolts are not on the walk and stay out; vanilla FishingHook.canUsePortal is false, which absence already matches. No dyn; no allocation added by the walk (the before map is moved out and back, and the ids and inside vectors are the ones that were there). About 125 lines added and 133 removed.

Fixes #6542

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.canUsePortal(ignorePassenger) is (ignorePassenger || !isPassenger()) && isAlive(). Overrides read with tools/rea_vanilla.py on the 26.3 server (survey of 54 entity classes): ThrowableProjectile returns true, FishingHook false, EnderDragon false; no other surveyed class declares it.

Side by side, scenes portal, portal_saved, endportal, endportal_saved (each entity kind placed in a built nether or End portal, counts per dimension each tick): the build before and the build after give byte-identical results in all four. Against the real server, portal matches on 143 of 162 values, the others 3 of 3, 132 of 132 and 3 of 3. The 19 that differ in portal are the same before and after: they are counts of tridents (8), snowballs (3), eggs (3), arrows (2), falling blocks (2) and an item (1) in a dimension at a given tick, existing gaps and not part of this change.

Tick cost

Time in handle_entity_portals plus find_entity_portals per tick, 2000 entities of seven kinds (items, orbs, pigs, minecarts, boats, TNT, marker armor stands) spread over a flat world with one nether portal in a corner chunk, headless, dedicated server, tick sprint. One run per build, under a lock, machine load about 10.7, so noisy:

before after
per tick 294.9 us 284.9 us

One run each gives no spread, so this shows no measurable difference in either direction and does not exclude a small one.

Harnesses

Run locally, the ones covering portals: nether_portal, end_gateway, arrow. CI runs the full --changed set on the merge.

PASS nether_portal 236s
PASS arrow 19s
PASS end_gateway 32s

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 6c951a6f5, 4 min 40 s)

Check Result
Scope ⚠️ 5 files, +314 −286; 600 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 ✅ (1 min 36 s)
tests: horizon-client ✅ 652 passed (2 min 6 s)
doc tests ✅ 0 passed (2 s)
content root tests ➖ content root untouched
mod API up to date ✅ (19 s)
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ 237 affected, to run in CI (--quick): armor_stand_frost, armor_stand_turtle_egg, arrow, arrow_wind_charge, block_particles, block_removal, boat_authority, boat_paddle_reset, boat_submerged, breaking_model, command_exec, composter and 225 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/6929 **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-portals` --- ### 📝 Commits (8) - [`69936d0`](https://github.com/horizon-rust/horizon/commit/69936d0b807fe9c18c5f33b2e6b8fdf75f5f7aa1) Merge origin/main into refactor/entity-walk-portals - [`cb02bd2`](https://github.com/horizon-rust/horizon/commit/cb02bd20a42b7f53338eccfab7c9dae523d668bf) refactor: walk every entity for portals - [`e66262a`](https://github.com/horizon-rust/horizon/commit/e66262accdc8f2448be4e9f876b009428b22302c) Merge branch 'fix/pearl-test-drag' into refactor/entity-walk-portals - [`e943c00`](https://github.com/horizon-rust/horizon/commit/e943c00eceb43a88cc558e678dd4850e34e692c7) Merge remote-tracking branch 'origin/main' into refactor/entity-walk-portals - [`1d2d694`](https://github.com/horizon-rust/horizon/commit/1d2d694dc89adbb7fcff42c98a54ffe795d93e23) Merge origin/main into refactor/entity-walk-portals - [`415b3c2`](https://github.com/horizon-rust/horizon/commit/415b3c2fb4fe77b585e9ef2dac8d82673405a91c) Merge origin/main into refactor/entity-walk-portals - [`6d2942c`](https://github.com/horizon-rust/horizon/commit/6d2942c9ada633e4c28323396edaeb6a2f471f13) Merge remote-tracking branch 'origin/main' into refactor/entity-walk-portals - [`c2f28b5`](https://github.com/horizon-rust/horizon/commit/c2f28b5ddb32a632da67bb81c46b308bf5cdb402) Merge remote-tracking branch 'origin/main' into refactor/entity-walk-portals ### 📊 Changes **2 files changed** (+128 additions, -133 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/entity.rs` (+88 -0) 📝 `crates/horizon-client/src/game/nether_portal.rs` (+40 -133) </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 7 (#6542), stacked on slice 3 (#6538, #6734). Moves the portal sweep onto `for_each_entity`. `handle_entity_portals` and `find_entity_portals` in `nether_portal.rs` each named the lists they knew (items, orbs, TNT, mobs, boats, carts, projectiles, tridents, rockets) and repeated the same sweep per list. Now one walk does both, and each kind states only where it differs. New `Entity` methods: `id`, `portal_size` (None for a kind the game does not carry through portals), `can_use_portal` (`Entity.canUsePortal`, overridden by mobs, TNT, boats, minecarts), `portal_from` and `portal_sweeps`. The kind-specific rules that were `if` chains (arrows and saved projectiles, a rocket that carries its owner, a stuck arrow or grounded trident that did not move) moved onto the kinds. Behaviour is unchanged. Armor stands and falling blocks stay out of the sweep as before (`portal_size` is None); the falling block's portal code is separate and was not touched. Fishing hooks, crystals and bolts are not on the walk and stay out; vanilla `FishingHook.canUsePortal` is false, which absence already matches. No `dyn`; no allocation added by the walk (the `before` map is moved out and back, and the `ids` and `inside` vectors are the ones that were there). About 125 lines added and 133 removed. Fixes #6542 ## 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 `Entity.canUsePortal(ignorePassenger)` is `(ignorePassenger || !isPassenger()) && isAlive()`. Overrides read with `tools/rea_vanilla.py` on the 26.3 server (survey of 54 entity classes): `ThrowableProjectile` returns true, `FishingHook` false, `EnderDragon` false; no other surveyed class declares it. Side by side, scenes `portal`, `portal_saved`, `endportal`, `endportal_saved` (each entity kind placed in a built nether or End portal, counts per dimension each tick): the build before and the build after give byte-identical results in all four. Against the real server, `portal` matches on 143 of 162 values, the others 3 of 3, 132 of 132 and 3 of 3. The 19 that differ in `portal` are the same before and after: they are counts of tridents (8), snowballs (3), eggs (3), arrows (2), falling blocks (2) and an item (1) in a dimension at a given tick, existing gaps and not part of this change. ## Tick cost Time in `handle_entity_portals` plus `find_entity_portals` per tick, 2000 entities of seven kinds (items, orbs, pigs, minecarts, boats, TNT, marker armor stands) spread over a flat world with one nether portal in a corner chunk, headless, dedicated server, `tick sprint`. One run per build, under a lock, machine load about 10.7, so noisy: | | before | after | |---|---|---| | per tick | 294.9 us | 284.9 us | One run each gives no spread, so this shows no measurable difference in either direction and does not exclude a small one. ## Harnesses Run locally, the ones covering portals: nether_portal, end_gateway, arrow. CI runs the full `--changed` set on the merge. ``` PASS nether_portal 236s PASS arrow 19s PASS end_gateway 32s ``` 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 6c951a6f5, 4 min 40 s) | Check | Result | | --- | --- | | Scope | ⚠️ 5 files, +314 −286; 600 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 | ✅ (1 min 36 s) | | tests: horizon-client | ✅ 652 passed (2 min 6 s) | | doc tests | ✅ 0 passed (2 s) | | content root tests | ➖ content root untouched | | mod API up to date | ✅ (19 s) | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ 237 affected, to run in CI (--quick): armor_stand_frost, armor_stand_turtle_egg, arrow, arrow_wind_charge, block_particles, block_removal, boat_authority, boat_paddle_reset, boat_submerged, breaking_model, command_exec, composter and 225 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:40 +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#7203
No description provided.