[PR #668] [MERGED] Server: the level follows its lone player through Nether and End portals #2714

Closed
opened 2026-11-02 15:58:29 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: main ← Head: feat/server-dimensions


📝 Commits (4)

  • 6154eb9 Network players keep advancements, statistics and a recipe book on the server
  • 6c6b58d Server: the level follows its lone player through Nether and End portals
  • f58a9bd Merge remote-tracking branch 'origin/main' into feat/network-player-progress
  • 03de0e8 Merge branch 'feat/network-player-progress' into feat/server-dimensions

📊 Changes

19 files changed (+1235 additions, -294 deletions)

View changed files

📝 crates/horizon-client/src/advancements.rs (+58 -0)
📝 crates/horizon-client/src/game.rs (+23 -9)
📝 crates/horizon-client/src/game/advancements.rs (+59 -49)
📝 crates/horizon-client/src/game/dedicated.rs (+7 -0)
📝 crates/horizon-client/src/game/end.rs (+74 -51)
📝 crates/horizon-client/src/game/integrated.rs (+5 -11)
📝 crates/horizon-client/src/game/lan.rs (+73 -0)
📝 crates/horizon-client/src/game/lan_actions.rs (+60 -1)
📝 crates/horizon-client/src/game/nether_portal.rs (+19 -14)
📝 crates/horizon-client/src/game/remote.rs (+8 -5)
📝 crates/horizon-client/src/game/scoreboard.rs (+21 -8)
➕ crates/horizon-client/src/game/server_travel.rs (+248 -0)
📝 crates/horizon-client/src/game/stats.rs (+98 -46)
📝 crates/horizon-client/src/lan/advancements.rs (+198 -66)
📝 crates/horizon-client/src/lan/chunks.rs (+81 -15)
📝 crates/horizon-client/src/lan/guest.rs (+19 -0)
📝 crates/horizon-client/src/lan/hub.rs (+172 -14)
📝 crates/horizon-client/src/lan/playerdata.rs (+2 -0)
📝 crates/horizon-client/src/save.rs (+10 -5)

📄 Description

Fourth step toward running single player on the server thread by default: Nether and End travel. Stacked on #662 (base feat/network-player-progress), which gives network players their own advancements, so the dimension triggers count for the right player. For the smoke test the client side of #655 was merged in.

Design

The design covers both servers. The integrated server thread and the dedicated server are the same Game running behind the hub (options.dedicated is set on both), so whatever is built here applies to both at once. Both have the same limit today: the server holds one level for everyone, so remote players can't reach the Nether or the End.

Vanilla's MinecraftServer holds levels, one ServerLevel per dimension, and a player changes level with ServerPlayer.teleport(TeleportTransition). Horizon's in-frame game holds one level at a time: enter_dimension saves the departing level, opens the destination (World, Streaming, SaveDir), and waits for chunks before placing the player.

Stage 1 (this PR, both servers): the server's one level follows its player while only one player is online. That covers single player on the server thread, and a dedicated or LAN world with one person in it.

  • enter_dimension is split. switch_level(target, from) swaps the level and returns where the player goes. The in-frame path keeps the player handling and its travel wait. It behaves as before.
  • server_travel.rs runs Entity.handlePortal for the lone player whenever options.dedicated is set, so on the integrated and the dedicated server alike. It uses the existing portal state, portal_plan, may_enter, the closest-portal search, nether_exit_portal / arrival, and the End's platform and spawn-column placement (end_arrival, split out of place_after_end_travel).
  • Leaving a level follows vanilla's ServerPlayer.teleport into another level. The player gets these packets in order:
    • a Respawn packet with KEEP_ALL_DATA, then the difficulty and the permission level;
    • a teleport to the approximate exit, then the abilities and the level info;
    • the inventory, the held slot, the effects and the post effects;
    • the portal travel sound (level event 1032), then the chunk cache centre.
  • Once the destination has loaded, the server places the exit and teleports the player there. The client waits on its loading screen in the meantime, as with vanilla's synchronous portal forcer.
  • When the lone player respawns away from the Overworld, the level goes back to the Overworld first (respawn_level).

Stage 2 (next, both servers): one level per dimension, like MinecraftServer.levels.

  • Levels. The per-level state moves out of Game into a Level:

    • world, streaming, save and dim;
    • the block ticks and tick chunks;
    • the mobs, items, orbs, falling blocks, TNT and projectiles;
    • the End fight.

    Game holds levels: HashMap<Dim, Level>, with the Overworld always loaded. The other dimensions open on first use and close when they have had no players for a while, as vanilla's chunk tickets let them unload.

  • Ticking. Each server tick swaps each level that has players (or forced chunks) into place and ticks it, the way as_guest swaps a player in. The existing tick code runs unchanged, one level at a time, in vanilla's MinecraftServer.tickChildren order.

  • Hub. Each Guest gets a dim. Chunk sending, entity tracking, block changes and level events only go to guests in the level that is ticking. switch_level becomes "move this player between two loaded levels"; the stage 1 packet sequence stays the same.

  • Saving. Player data stores each player's dimension (it is always minecraft:overworld today). Join and reopen put each player back in their own level.

Stage 2 moves the per-level fields that the world-tick work (perf-server-3) depends on, so it is a separate PR. Until then, with two or more players online, portals take no one; that is how both servers behave today. A player who joins while the level is in the Nether or the End joins that level.

Fixes this needed in what the hub sends

  • Chunk encoding follows the level. The encoder used to send the Overworld's 24 sections for every level, so a client in the Nether or the End read everything 64 blocks off. The in-frame LAN host had the same bug after going through a portal with guests online. The encoder now sends only the level's sections (y 0 to 255 in the Nether and the End), no sky light where the dimension type has none, and heightmaps from the level's floor. A unit test covers it.
  • The dimension type in the spawn info follows the level, and SetDefaultSpawnPosition names the Overworld, where the world spawn is.
  • A level switch keeps the world's block-change log (block_log). Without it, no block change reached any client after a portal. It also keeps the sculk watch list.
  • integrated::wanted no longer refuses worlds whose player is in the Nether or the End.

Client fixes found on the way

  • The network client drew the End as the Overworld: enter_remote_dimension mapped every dimension that wasn't the Nether to the Overworld.
  • PlayerCombatKill for the client's own player now opens the death screen, as ClientPacketListener.handlePlayerCombatKill does. Before, the client waited for a zero-health update the hub never sends once the player is marked dead, so /kill left the player stuck alive on the client.

Checks

  • cargo fmt --all --check, cargo clippy --workspace --all-targets -- -D warnings: clean.
  • cargo test -p horizon-client --lib: 794 passed, including the new encoder test.
  • Smoke test with --server-thread:
    • Nether: an Overworld portal at (3, 101, 0) takes the player to the Nether. They arrive in a portal built at (15.5, 94, 9.5), "We Need to Go Deeper" is announced, the terrain renders correctly, and they land on the ground. Going back through it returns them to the original portal.
    • End: an End portal takes the player to the End platform at (100.5, 49, 0.5), facing west, with obsidian under them, and "The End?" is announced. The world reopens in the End. Dying there and respawning puts the player at the Overworld spawn.

Label: skip-release; the flip PR carries the release note.

🤖 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/668 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/17/2026 **Status:** ✅ Merged **Merged:** 10/17/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/server-dimensions` --- ### 📝 Commits (4) - [`6154eb9`](https://github.com/horizon-rust/horizon/commit/6154eb95c345b3c78bd97c1ba3604e47755caa67) Network players keep advancements, statistics and a recipe book on the server - [`6c6b58d`](https://github.com/horizon-rust/horizon/commit/6c6b58dd55fb068101467887fa3891dbc970ddc8) Server: the level follows its lone player through Nether and End portals - [`f58a9bd`](https://github.com/horizon-rust/horizon/commit/f58a9bdf295b84adef9e844bd626cec0abb8d82b) Merge remote-tracking branch 'origin/main' into feat/network-player-progress - [`03de0e8`](https://github.com/horizon-rust/horizon/commit/03de0e8e13265471d2267c5bf698c2a5e33ad323) Merge branch 'feat/network-player-progress' into feat/server-dimensions ### 📊 Changes **19 files changed** (+1235 additions, -294 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/advancements.rs` (+58 -0) 📝 `crates/horizon-client/src/game.rs` (+23 -9) 📝 `crates/horizon-client/src/game/advancements.rs` (+59 -49) 📝 `crates/horizon-client/src/game/dedicated.rs` (+7 -0) 📝 `crates/horizon-client/src/game/end.rs` (+74 -51) 📝 `crates/horizon-client/src/game/integrated.rs` (+5 -11) 📝 `crates/horizon-client/src/game/lan.rs` (+73 -0) 📝 `crates/horizon-client/src/game/lan_actions.rs` (+60 -1) 📝 `crates/horizon-client/src/game/nether_portal.rs` (+19 -14) 📝 `crates/horizon-client/src/game/remote.rs` (+8 -5) 📝 `crates/horizon-client/src/game/scoreboard.rs` (+21 -8) ➕ `crates/horizon-client/src/game/server_travel.rs` (+248 -0) 📝 `crates/horizon-client/src/game/stats.rs` (+98 -46) 📝 `crates/horizon-client/src/lan/advancements.rs` (+198 -66) 📝 `crates/horizon-client/src/lan/chunks.rs` (+81 -15) 📝 `crates/horizon-client/src/lan/guest.rs` (+19 -0) 📝 `crates/horizon-client/src/lan/hub.rs` (+172 -14) 📝 `crates/horizon-client/src/lan/playerdata.rs` (+2 -0) 📝 `crates/horizon-client/src/save.rs` (+10 -5) </details> ### 📄 Description Fourth step toward running single player on the server thread by default: Nether and End travel. Stacked on #662 (base `feat/network-player-progress`), which gives network players their own advancements, so the dimension triggers count for the right player. For the smoke test the client side of #655 was merged in. ## Design The design covers both servers. The integrated server thread and the dedicated server are the same `Game` running behind the hub (`options.dedicated` is set on both), so whatever is built here applies to both at once. Both have the same limit today: the server holds one level for everyone, so remote players can't reach the Nether or the End. Vanilla's `MinecraftServer` holds `levels`, one `ServerLevel` per dimension, and a player changes level with `ServerPlayer.teleport(TeleportTransition)`. Horizon's in-frame game holds one level at a time: `enter_dimension` saves the departing level, opens the destination (`World`, `Streaming`, `SaveDir`), and waits for chunks before placing the player. **Stage 1 (this PR, both servers):** the server's one level follows its player while only one player is online. That covers single player on the server thread, and a dedicated or LAN world with one person in it. - `enter_dimension` is split. `switch_level(target, from)` swaps the level and returns where the player goes. The in-frame path keeps the player handling and its travel wait. It behaves as before. - `server_travel.rs` runs `Entity.handlePortal` for the lone player whenever `options.dedicated` is set, so on the integrated and the dedicated server alike. It uses the existing portal state, `portal_plan`, `may_enter`, the closest-portal search, `nether_exit_portal` / `arrival`, and the End's platform and spawn-column placement (`end_arrival`, split out of `place_after_end_travel`). - Leaving a level follows vanilla's `ServerPlayer.teleport` into another level. The player gets these packets in order: - a Respawn packet with KEEP_ALL_DATA, then the difficulty and the permission level; - a teleport to the approximate exit, then the abilities and the level info; - the inventory, the held slot, the effects and the post effects; - the portal travel sound (level event 1032), then the chunk cache centre. - Once the destination has loaded, the server places the exit and teleports the player there. The client waits on its loading screen in the meantime, as with vanilla's synchronous portal forcer. - When the lone player respawns away from the Overworld, the level goes back to the Overworld first (`respawn_level`). **Stage 2 (next, both servers): one level per dimension, like `MinecraftServer.levels`.** - **Levels.** The per-level state moves out of `Game` into a `Level`: - `world`, `streaming`, `save` and `dim`; - the block ticks and tick chunks; - the mobs, items, orbs, falling blocks, TNT and projectiles; - the End fight. `Game` holds `levels: HashMap<Dim, Level>`, with the Overworld always loaded. The other dimensions open on first use and close when they have had no players for a while, as vanilla's chunk tickets let them unload. - **Ticking.** Each server tick swaps each level that has players (or forced chunks) into place and ticks it, the way `as_guest` swaps a player in. The existing tick code runs unchanged, one level at a time, in vanilla's `MinecraftServer.tickChildren` order. - **Hub.** Each `Guest` gets a `dim`. Chunk sending, entity tracking, block changes and level events only go to guests in the level that is ticking. `switch_level` becomes "move this player between two loaded levels"; the stage 1 packet sequence stays the same. - **Saving.** Player data stores each player's dimension (it is always `minecraft:overworld` today). Join and reopen put each player back in their own level. Stage 2 moves the per-level fields that the world-tick work (perf-server-3) depends on, so it is a separate PR. Until then, with two or more players online, portals take no one; that is how both servers behave today. A player who joins while the level is in the Nether or the End joins that level. ## Fixes this needed in what the hub sends - **Chunk encoding follows the level.** The encoder used to send the Overworld's 24 sections for every level, so a client in the Nether or the End read everything 64 blocks off. The in-frame LAN host had the same bug after going through a portal with guests online. The encoder now sends only the level's sections (y 0 to 255 in the Nether and the End), no sky light where the dimension type has none, and heightmaps from the level's floor. A unit test covers it. - The dimension type in the spawn info follows the level, and `SetDefaultSpawnPosition` names the Overworld, where the world spawn is. - A level switch keeps the world's block-change log (`block_log`). Without it, no block change reached any client after a portal. It also keeps the sculk watch list. - `integrated::wanted` no longer refuses worlds whose player is in the Nether or the End. ## Client fixes found on the way - The network client drew the End as the Overworld: `enter_remote_dimension` mapped every dimension that wasn't the Nether to the Overworld. - `PlayerCombatKill` for the client's own player now opens the death screen, as `ClientPacketListener.handlePlayerCombatKill` does. Before, the client waited for a zero-health update the hub never sends once the player is marked dead, so `/kill` left the player stuck alive on the client. ## Checks - `cargo fmt --all --check`, `cargo clippy --workspace --all-targets -- -D warnings`: clean. - `cargo test -p horizon-client --lib`: 794 passed, including the new encoder test. - Smoke test with `--server-thread`: - **Nether:** an Overworld portal at (3, 101, 0) takes the player to the Nether. They arrive in a portal built at (15.5, 94, 9.5), "We Need to Go Deeper" is announced, the terrain renders correctly, and they land on the ground. Going back through it returns them to the original portal. - **End:** an End portal takes the player to the End platform at (100.5, 49, 0.5), facing west, with obsidian under them, and "The End?" is announced. The world reopens in the End. Dying there and respawning puts the player at the Overworld spawn. Label: `skip-release`; the flip PR carries the release note. 🤖 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-02 15:58:29 +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#2714
No description provided.