[PR #4136] [MERGED] Portal trips like vanilla: loading screen until the exit is found, portal cooldown kept on the client #5437

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/4136
Author: @ludovic111
Created: 10/30/2026
Status: ✅ Merged
Merged: 10/30/2026
Merged by: @ludovic111

Base: main ← Head: fix/portal-overlay-cooldown


📝 Commits (4)

  • 7cce0bf Keep the portal cooldown on a server's client so the overlay fades in the arrival portal
  • 88e79c1 Keep a portal traveller on the loading screen until its exit is found
  • 2c91574 Ignore a portal traveller's old moves until it lands
  • f03c177 Drop the old level's pending teleport when a portal trip starts

📊 Changes

8 files changed (+106 additions, -34 deletions)

View changed files

📝 crates/horizon-client/src/game/agent.rs (+2 -0)
📝 crates/horizon-client/src/game/nether_portal.rs (+15 -3)
📝 crates/horizon-client/src/game/remote.rs (+3 -0)
📝 crates/horizon-client/src/game/render_tick.rs (+5 -0)
📝 crates/horizon-client/src/game/server_travel.rs (+15 -5)
📝 crates/horizon-client/src/lan/guest.rs (+5 -0)
📝 crates/horizon-client/src/lan/hub.rs (+56 -26)
📝 tools/lan_e2e.py (+5 -0)

📄 Description

🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself.

Fixes two parts of #4031 on the server-thread path (the default single player, LAN guests, dedicated servers):

  • "Nether portal purple overlay occasionally froze on screen after changing dimensions"
  • "Teleporting via End portal spawned the player high in the air at world spawn"

The fall sound part of #4031 is #4043 (DUzzL).

Both come from the same place: how a portal trip reaches the client. That's why they are one PR: the overlay fix only holds once the client waits for the exit (see "Why together").

1. The client sees nothing before the exit is found

Vanilla finds a portal's exit before ServerPlayer.teleport sends anything: the End platform (EndPortalBlock.getPortalDestination → EndPlatformFeature.createEndPlatform), the Nether portal, or the spawn column after the End (findRespawnPositionAndUseSpawnBlock). The client stays on its level loading screen until then.

Horizon finds the exit once the destination has loaded (arrive_server_trips). Meanwhile change_level had already given the client the rough target point. In the game on main (server thread):

  • leaving the End, the player stood at the raw world spawn (-31.5, 71, 0.5), in the air (on_ground: false), before the spawn search moved them to (-41.5, 81, -9.5);
  • going into the End, the client was at (100.5, 49, 0.5) with 0 chunks loaded.

On a slower PC that wait lasts longer, which matches the report.

Now:

  • LanHub::change_level(.., portal: true, ..) sends no position and holds back LEVEL_CHUNKS_LOAD_START, so the client stays on LevelLoadingScreen.
  • LanHub::land sends the position, LEVEL_CHUNKS_LOAD_START and the portal sound (TeleportTransition.PLAY_PORTAL_SOUND, vanilla's post-teleport transition) once the trip's exit is found.
  • Guest::landing drops the moves the client sent from the old level until then. Before, the teleport sent at once (awaiting_teleport) did that. Without it, a trip from a far portal pulled the player's server position back to the old coordinates, and the level never loaded around the exit.

2. The portal cooldown reaches the client

Vanilla's handleRespawn / handleLogin give the new LocalPlayer the server's portalCooldown from the spawn info. It is Player.getDimensionChangingDelay() = 10, set by Entity.handlePortal before the teleport. LocalPlayer.aiStep counts it down (processPortalCooldown), but not on the loading screen. While the player stands in the arrival portal, the client's setAsInsidePortal only restarts it, so the overlay fades out.

Horizon sent portal_cooldown: 0 and the client never looked at a cooldown. A player standing in the arrival portal saw the overlay build up again to full and stay there.

Now:

  • the spawn info carries the cooldown: PLAYER_DELAY for a portal trip, the player's own for a command teleport between levels;
  • the client keeps the LocalPlayer's cooldown in portals.player.cooldown, and client_inside_nether_portal restarts it instead of driving the overlay;
  • in-frame, the window's player uses the server-side state the same way.

horizon-ctl state now reports player.portal_effect, which is portalEffectIntensity.

Why together

With only part 2, a trip whose exit waits for chunks still put the client at the rough point, and its 10 ticks ran out before it was placed in the portal. lan_e2e --check portals (a LAN guest) failed that way: the overlay was at 0.875 after 40 ticks in the arrival portal. With part 1, the countdown starts when the client lands in the portal, as in vanilla.

Tested in the game (fast builds, scratch homes, survival)

main this PR
Nether portal, server thread: overlay 12 s after arriving, standing in the arrival portal full purple (screenshot) portal_effect 1.0 on arrival, then 0.0
same, --in-frame full purple (screenshot) 1.0, then 0.0
step out of the arrival portal (>10 ticks), step back in — 0.0125/tick up to 1.0, back to the Overworld, then fades (both paths)
End portal from spawn, server thread client at (100.5, 49, 0.5) with 0 chunks, platform built after loading screen, then on the platform (100.5, 49, 0.5) in 0.17 s
End portal far away underground (1202, 29, -800), right after a /tp — on the platform in 0.18 s (server thread), 0.93 s (in-frame)
leaving the End (credits, then respawn), server thread at the raw world spawn (-31.5, 71, 0.5) in the air (on_ground: false), then moved to (-41.5, 81, -9.5) loading screen, then straight onto the spawn column
lan_e2e --check portals (LAN guest through a Nether portal, host into the End and back) — PASS (it failed with the cooldown part alone: 0.875)
lan_e2e --check levels 7 of 8 steps pass, guest_end fails the same 7 of 8: guest_end's failure is in the test itself (wrong gateway NBT key, credits never closed), #4145, fixed in its own PR; with that fix every step passes

Self-check

pr_ready (tools/pr_ready.py on ludovics-mac-mini, against origin/main at d6adbe1cb, 57 min 1 s)

Check Result
Scope ✅ 8 files, +106 −34
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 475 passed (5 min 9 s)
rustfmt ✅ (5 s)
clippy ✅ (1 min 27 s)
tests: horizon-client ✅ 928 passed (3 min 8 s)
doc tests ✅ 0 passed (2 s)
content root tests ➖ content root untouched
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ❌ 34 affected, 32 passed, failed: dispenser (45 min 6 s)
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

dispenser (1 of 6000 cases, the snow golem from a dispensed carved pumpkin) fails on main too: main's regression from #3959 (the golem's base check needs the head), fixed by #4120. Not from this PR.

Needs Ludovic: nothing.

🤖 Generated with Claude Code


🔄 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/4136 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/30/2026 **Status:** ✅ Merged **Merged:** 10/30/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/portal-overlay-cooldown` --- ### 📝 Commits (4) - [`7cce0bf`](https://github.com/horizon-rust/horizon/commit/7cce0bf15bb62de96b310342736b113c45d47fe0) Keep the portal cooldown on a server's client so the overlay fades in the arrival portal - [`88e79c1`](https://github.com/horizon-rust/horizon/commit/88e79c11197a58d02e805106a8743dbd78ff23e8) Keep a portal traveller on the loading screen until its exit is found - [`2c91574`](https://github.com/horizon-rust/horizon/commit/2c91574bbb0cfcb87937b5a4e7fbecc48a7afab3) Ignore a portal traveller's old moves until it lands - [`f03c177`](https://github.com/horizon-rust/horizon/commit/f03c1771afd151bca75b24371b65de0cae8ad949) Drop the old level's pending teleport when a portal trip starts ### 📊 Changes **8 files changed** (+106 additions, -34 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/agent.rs` (+2 -0) 📝 `crates/horizon-client/src/game/nether_portal.rs` (+15 -3) 📝 `crates/horizon-client/src/game/remote.rs` (+3 -0) 📝 `crates/horizon-client/src/game/render_tick.rs` (+5 -0) 📝 `crates/horizon-client/src/game/server_travel.rs` (+15 -5) 📝 `crates/horizon-client/src/lan/guest.rs` (+5 -0) 📝 `crates/horizon-client/src/lan/hub.rs` (+56 -26) 📝 `tools/lan_e2e.py` (+5 -0) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. Fixes two parts of #4031 on the server-thread path (the default single player, LAN guests, dedicated servers): - "Nether portal purple overlay occasionally froze on screen after changing dimensions" - "Teleporting via End portal spawned the player high in the air at world spawn" The fall sound part of #4031 is #4043 (DUzzL). Both come from the same place: how a portal trip reaches the client. That's why they are one PR: the overlay fix only holds once the client waits for the exit (see "Why together"). ## 1. The client sees nothing before the exit is found Vanilla finds a portal's exit before `ServerPlayer.teleport` sends anything: the End platform (`EndPortalBlock.getPortalDestination` → `EndPlatformFeature.createEndPlatform`), the Nether portal, or the spawn column after the End (`findRespawnPositionAndUseSpawnBlock`). The client stays on its level loading screen until then. Horizon finds the exit once the destination has loaded (`arrive_server_trips`). Meanwhile `change_level` had already given the client the rough target point. In the game on main (server thread): - leaving the End, the player stood at the raw world spawn (-31.5, 71, 0.5), in the air (`on_ground: false`), before the spawn search moved them to (-41.5, 81, -9.5); - going into the End, the client was at (100.5, 49, 0.5) with **0 chunks** loaded. On a slower PC that wait lasts longer, which matches the report. Now: - `LanHub::change_level(.., portal: true, ..)` sends no position and holds back `LEVEL_CHUNKS_LOAD_START`, so the client stays on `LevelLoadingScreen`. - `LanHub::land` sends the position, `LEVEL_CHUNKS_LOAD_START` and the portal sound (`TeleportTransition.PLAY_PORTAL_SOUND`, vanilla's post-teleport transition) once the trip's exit is found. - `Guest::landing` drops the moves the client sent from the old level until then. Before, the teleport sent at once (`awaiting_teleport`) did that. Without it, a trip from a far portal pulled the player's server position back to the old coordinates, and the level never loaded around the exit. ## 2. The portal cooldown reaches the client Vanilla's `handleRespawn` / `handleLogin` give the new `LocalPlayer` the server's `portalCooldown` from the spawn info. It is `Player.getDimensionChangingDelay()` = 10, set by `Entity.handlePortal` before the teleport. `LocalPlayer.aiStep` counts it down (`processPortalCooldown`), but not on the loading screen. While the player stands in the arrival portal, the client's `setAsInsidePortal` only restarts it, so the overlay fades out. Horizon sent `portal_cooldown: 0` and the client never looked at a cooldown. A player standing in the arrival portal saw the overlay build up again to full and stay there. Now: - the spawn info carries the cooldown: `PLAYER_DELAY` for a portal trip, the player's own for a command teleport between levels; - the client keeps the LocalPlayer's cooldown in `portals.player.cooldown`, and `client_inside_nether_portal` restarts it instead of driving the overlay; - in-frame, the window's player uses the server-side state the same way. `horizon-ctl state` now reports `player.portal_effect`, which is `portalEffectIntensity`. ## Why together With only part 2, a trip whose exit waits for chunks still put the client at the rough point, and its 10 ticks ran out before it was placed in the portal. `lan_e2e --check portals` (a LAN guest) failed that way: the overlay was at 0.875 after 40 ticks in the arrival portal. With part 1, the countdown starts when the client lands in the portal, as in vanilla. ## Tested in the game (fast builds, scratch homes, survival) | | main | this PR | |---|---|---| | Nether portal, server thread: overlay 12 s after arriving, standing in the arrival portal | full purple (screenshot) | `portal_effect` 1.0 on arrival, then 0.0 | | same, `--in-frame` | full purple (screenshot) | 1.0, then 0.0 | | step out of the arrival portal (>10 ticks), step back in | — | 0.0125/tick up to 1.0, back to the Overworld, then fades (both paths) | | End portal from spawn, server thread | client at (100.5, 49, 0.5) with 0 chunks, platform built after | loading screen, then on the platform (100.5, 49, 0.5) in 0.17 s | | End portal far away underground (1202, 29, -800), right after a `/tp` | — | on the platform in 0.18 s (server thread), 0.93 s (in-frame) | | leaving the End (credits, then respawn), server thread | at the raw world spawn (-31.5, 71, 0.5) in the air (`on_ground: false`), then moved to (-41.5, 81, -9.5) | loading screen, then straight onto the spawn column | | `lan_e2e --check portals` (LAN guest through a Nether portal, host into the End and back) | — | PASS (it failed with the cooldown part alone: 0.875) | | `lan_e2e --check levels` | 7 of 8 steps pass, `guest_end` fails | the same 7 of 8: `guest_end`'s failure is in the test itself (wrong gateway NBT key, credits never closed), #4145, fixed in its own PR; with that fix every step passes | ## Self-check **pr_ready** (`tools/pr_ready.py` on ludovics-mac-mini, against origin/main at d6adbe1cb, 57 min 1 s) | Check | Result | | --- | --- | | Scope | ✅ 8 files, +106 −34 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 475 passed (5 min 9 s) | | rustfmt | ✅ (5 s) | | clippy | ✅ (1 min 27 s) | | tests: horizon-client | ✅ 928 passed (3 min 8 s) | | doc tests | ✅ 0 passed (2 s) | | content root tests | ➖ content root untouched | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ❌ 34 affected, 32 passed, failed: dispenser (45 min 6 s) | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | `dispenser` (1 of 6000 cases, the snow golem from a dispensed carved pumpkin) fails on main too: main's regression from #3959 (the golem's base check needs the head), fixed by #4120. Not from this PR. Needs Ludovic: nothing. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:12:35 +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#5437
No description provided.