[PR #697] [MERGED] Server: one level per dimension, so players can be in different dimensions #2737

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

📋 Pull Request Information

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

Base: main ← Head: feat/server-levels


📝 Commits (7)

  • 45cbb4f LAN: a guest's chest, crafting table or sign no longer takes the host's mouse (#687)
  • a67a323 Server: one level per dimension, so players can be in different dimensions
  • b278436 Mobs see only the guests in their own level
  • d746be2 Merge main into feat/server-levels
  • 7733984 levels.rs: per-level block events carry u32 states (#674)
  • 9240aeb Input capture test: the mock Game has lan_acting (#687)
  • 3a8ba56 Merge commit '7733984e' into HEAD

📊 Changes

21 files changed (+893 additions, -199 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+34 -14)
📝 crates/horizon-client/src/game/agent.rs (+3 -0)
📝 crates/horizon-client/src/game/creaking.rs (+8 -0)
📝 crates/horizon-client/src/game/dedicated.rs (+12 -12)
📝 crates/horizon-client/src/game/falling_damage.rs (+1 -1)
📝 crates/horizon-client/src/game/integrated.rs (+2 -4)
📝 crates/horizon-client/src/game/lan.rs (+54 -6)
📝 crates/horizon-client/src/game/lan_actions.rs (+36 -10)
📝 crates/horizon-client/src/game/lan_mobs.rs (+7 -4)
📝 crates/horizon-client/src/game/lan_pvp.rs (+2 -2)
📝 crates/horizon-client/src/game/lan_trading.rs (+1 -1)
➕ crates/horizon-client/src/game/levels.rs (+350 -0)
📝 crates/horizon-client/src/game/raids.rs (+11 -0)
📝 crates/horizon-client/src/game/sculk.rs (+9 -0)
📝 crates/horizon-client/src/game/server_travel.rs (+141 -118)
📝 crates/horizon-client/src/lan/containers.rs (+2 -2)
📝 crates/horizon-client/src/lan/guest.rs (+4 -0)
📝 crates/horizon-client/src/lan/hub.rs (+97 -16)
📝 crates/horizon-client/src/lan/playerdata.rs (+5 -1)
📝 tests/test_world_input_capture.py (+2 -2)

...and 1 more files

📄 Description

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

Stage 2 of #668's design: a server holds one level per dimension, like vanilla's MinecraftServer.levels, so players can be in different dimensions. This applies to the dedicated server and to single player on the server thread (options.dedicated), with LAN guests too. Before this, a portal did nothing while two or more players were online. With the server thread on, opening a world to LAN turned portals off.

Stacked on #695 (both edit tools/lan_e2e.py); retarget to main once #695 merges.

Design

The tick code reads one level: the one in place, held in Game's own fields. A server keeps the other dimensions' levels in game/levels.rs. Each server tick, tick_server puts each level that has players into place in turn, in vanilla's order (Overworld, Nether, End), the way as_guest swaps a player in. The world tick code (tick_world, Streaming::update, hoppers, palette reads, random ticks, spawning) runs unchanged, one level at a time. None of perf-server-4's hot functions are touched.

  • What a level holds (Parked): the world, its streaming and save, block ticks, tick chunks and random-tick sections; the entities (entity_chunks' set: mobs, items, orbs, falling blocks, TNT, projectiles, boats, carts, paintings, frames, stands, others, the dragon and crystals, tridents, rockets, bolts, ominous spawners); the hoppers, lectern pulses, chest openers and block entity animations; the pending level events, the raids, the sculk index and the creaking scan.
  • Shared, as vanilla's derived levels share the Overworld's level data: game time, day time and weather (they move with the swap), rules, scoreboard, maps, the dragon fight, and the entities waiting to arrive through a portal (already one world-wide list, resolved when their level is in place).
  • Lifetime: a level opens on first use. The Overworld stays loaded. Another level with nobody in it for 300 ticks is saved and closed. save_game saves every level.
  • Passes: the first pass of a tick reads the network and runs the tick's shared parts (clock, weather cycle, functions, autosave). Later passes run tick_world for their level. With one level the tick does exactly what it did before; enter_level is a no-op then.

Hub

  • Hub::tick is split into poll (joins, leaves, packets queued per guest; once per tick), tick_level (the packets, chunks, block changes, acks, containers, entity tracking and player state of the guests in the level in place) and end_tick (latency). tick still runs all three for the in-frame game.
  • Each Guest has a dimension. Hub::here(g) is "placed and in the level in place". It filters chunk sending, block changes, tracking (players only see players in their level), sounds, level and entity events (broadcast_near), time and weather (broadcast_level).
  • The clock and weather last sent are kept per level (set_dimension swaps them), so each level's players hear their own changes once.

Players

  • Travel: each player has their own portal state (GuestPlay.portal), and a portal moves only that player. start_server_trip opens the destination if needed, sends ServerPlayer.teleport's packet sequence from #668 (unchanged), and puts the source level back in place. server_trips holds one trip per traveller, each arriving once its level has loaded around it.
  • Respawn brings a player back to the Overworld's level; the death location names the level they died in.
  • Player data saves and loads each player's Dimension (it was always the Overworld). A returning player is placed (Login) in their own level. An integrated world reopens in its owner's dimension.
  • Game code that looks at guests from inside a level only sees the guests in it: guest ticks, mob targets (lan_present), projectile and falling-block targets, PvP, swings, merchants, streaming around players. Mob hurt/death animation state is kept per level.

What's not like vanilla yet

  • A level with no players isn't ticked (vanilla keeps ticking a level for 300 ticks after it empties, and ticks force-loaded chunks).
  • The in-frame game (a world opened to LAN without the server thread) keeps its single level that follows the host, as before.

Checks

  • cargo fmt --all --check: ok
  • cargo clippy --workspace --all-targets -- -D warnings: ok
  • cargo test -p horizon-client --lib: 812 passed, 0 failed
  • tools/lan_e2e.py --server-thread --check tab --check portals (new portals check, Mac mini): pass. The host plays on its server thread and opens to LAN, then a guest joins.
    • The guest walks into a Nether portal and arrives in the Nether, in a portal built there, with its own "We Need to Go Deeper"; the host stays in the Overworld.
    • With the guest still in the Nether, the host takes an End portal: three levels run at once. The host is on the End platform with its own "The End?".
    • The host leaves through an exit portal and the guest walks back through its portal: both are back in the Overworld.
  • Local parity: running, results follow in a comment.

🤖 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/697 **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-levels` --- ### 📝 Commits (7) - [`45cbb4f`](https://github.com/horizon-rust/horizon/commit/45cbb4f7d668cf578c8b8e7fca8f65d9112385fa) LAN: a guest's chest, crafting table or sign no longer takes the host's mouse (#687) - [`a67a323`](https://github.com/horizon-rust/horizon/commit/a67a323959a43dcfc2d853634b2d1f253b5fbf34) Server: one level per dimension, so players can be in different dimensions - [`b278436`](https://github.com/horizon-rust/horizon/commit/b2784363a138e8e4124428e369d8aa22851cffe7) Mobs see only the guests in their own level - [`d746be2`](https://github.com/horizon-rust/horizon/commit/d746be2ca33d13ee73007589ca42863b5afaeb05) Merge main into feat/server-levels - [`7733984`](https://github.com/horizon-rust/horizon/commit/7733984e7898787e2e388ee0361475c67e27e9cc) levels.rs: per-level block events carry u32 states (#674) - [`9240aeb`](https://github.com/horizon-rust/horizon/commit/9240aeb9ff8b315b38895dd24e64243a46bbd49b) Input capture test: the mock Game has lan_acting (#687) - [`3a8ba56`](https://github.com/horizon-rust/horizon/commit/3a8ba56c61b84bf310645d67738a91857dae0979) Merge commit '7733984e' into HEAD ### 📊 Changes **21 files changed** (+893 additions, -199 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+34 -14) 📝 `crates/horizon-client/src/game/agent.rs` (+3 -0) 📝 `crates/horizon-client/src/game/creaking.rs` (+8 -0) 📝 `crates/horizon-client/src/game/dedicated.rs` (+12 -12) 📝 `crates/horizon-client/src/game/falling_damage.rs` (+1 -1) 📝 `crates/horizon-client/src/game/integrated.rs` (+2 -4) 📝 `crates/horizon-client/src/game/lan.rs` (+54 -6) 📝 `crates/horizon-client/src/game/lan_actions.rs` (+36 -10) 📝 `crates/horizon-client/src/game/lan_mobs.rs` (+7 -4) 📝 `crates/horizon-client/src/game/lan_pvp.rs` (+2 -2) 📝 `crates/horizon-client/src/game/lan_trading.rs` (+1 -1) ➕ `crates/horizon-client/src/game/levels.rs` (+350 -0) 📝 `crates/horizon-client/src/game/raids.rs` (+11 -0) 📝 `crates/horizon-client/src/game/sculk.rs` (+9 -0) 📝 `crates/horizon-client/src/game/server_travel.rs` (+141 -118) 📝 `crates/horizon-client/src/lan/containers.rs` (+2 -2) 📝 `crates/horizon-client/src/lan/guest.rs` (+4 -0) 📝 `crates/horizon-client/src/lan/hub.rs` (+97 -16) 📝 `crates/horizon-client/src/lan/playerdata.rs` (+5 -1) 📝 `tests/test_world_input_capture.py` (+2 -2) _...and 1 more files_ </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. Stage 2 of #668's design: a server holds one level per dimension, like vanilla's `MinecraftServer.levels`, so players can be in different dimensions. This applies to the dedicated server and to single player on the server thread (`options.dedicated`), with LAN guests too. Before this, a portal did nothing while two or more players were online. With the server thread on, opening a world to LAN turned portals off. Stacked on #695 (both edit `tools/lan_e2e.py`); retarget to main once #695 merges. ## Design The tick code reads one level: the one in place, held in `Game`'s own fields. A server keeps the other dimensions' levels in `game/levels.rs`. Each server tick, `tick_server` puts each level that has players into place in turn, in vanilla's order (Overworld, Nether, End), the way `as_guest` swaps a player in. The world tick code (`tick_world`, `Streaming::update`, hoppers, palette reads, random ticks, spawning) runs unchanged, one level at a time. None of perf-server-4's hot functions are touched. - **What a level holds** (`Parked`): the world, its streaming and save, block ticks, tick chunks and random-tick sections; the entities (`entity_chunks`' set: mobs, items, orbs, falling blocks, TNT, projectiles, boats, carts, paintings, frames, stands, others, the dragon and crystals, tridents, rockets, bolts, ominous spawners); the hoppers, lectern pulses, chest openers and block entity animations; the pending level events, the raids, the sculk index and the creaking scan. - **Shared, as vanilla's derived levels share the Overworld's level data:** game time, day time and weather (they move with the swap), rules, scoreboard, maps, the dragon fight, and the entities waiting to arrive through a portal (already one world-wide list, resolved when their level is in place). - **Lifetime:** a level opens on first use. The Overworld stays loaded. Another level with nobody in it for 300 ticks is saved and closed. `save_game` saves every level. - **Passes:** the first pass of a tick reads the network and runs the tick's shared parts (clock, weather cycle, functions, autosave). Later passes run `tick_world` for their level. With one level the tick does exactly what it did before; `enter_level` is a no-op then. ## Hub - `Hub::tick` is split into `poll` (joins, leaves, packets queued per guest; once per tick), `tick_level` (the packets, chunks, block changes, acks, containers, entity tracking and player state of the guests in the level in place) and `end_tick` (latency). `tick` still runs all three for the in-frame game. - Each `Guest` has a `dimension`. `Hub::here(g)` is "placed and in the level in place". It filters chunk sending, block changes, tracking (players only see players in their level), sounds, level and entity events (`broadcast_near`), time and weather (`broadcast_level`). - The clock and weather last sent are kept per level (`set_dimension` swaps them), so each level's players hear their own changes once. ## Players - **Travel:** each player has their own portal state (`GuestPlay.portal`), and a portal moves only that player. `start_server_trip` opens the destination if needed, sends `ServerPlayer.teleport`'s packet sequence from #668 (unchanged), and puts the source level back in place. `server_trips` holds one trip per traveller, each arriving once its level has loaded around it. - **Respawn** brings a player back to the Overworld's level; the death location names the level they died in. - **Player data** saves and loads each player's `Dimension` (it was always the Overworld). A returning player is placed (Login) in their own level. An integrated world reopens in its owner's dimension. - Game code that looks at guests from inside a level only sees the guests in it: guest ticks, mob targets (`lan_present`), projectile and falling-block targets, PvP, swings, merchants, streaming around players. Mob hurt/death animation state is kept per level. ## What's not like vanilla yet - A level with no players isn't ticked (vanilla keeps ticking a level for 300 ticks after it empties, and ticks force-loaded chunks). - The in-frame game (a world opened to LAN without the server thread) keeps its single level that follows the host, as before. ## Checks - `cargo fmt --all --check`: ok - `cargo clippy --workspace --all-targets -- -D warnings`: ok - `cargo test -p horizon-client --lib`: 812 passed, 0 failed - `tools/lan_e2e.py --server-thread --check tab --check portals` (new `portals` check, Mac mini): **pass**. The host plays on its server thread and opens to LAN, then a guest joins. - The guest walks into a Nether portal and arrives in the Nether, in a portal built there, with its own "We Need to Go Deeper"; the host stays in the Overworld. - With the guest still in the Nether, the host takes an End portal: three levels run at once. The host is on the End platform with its own "The End?". - The host leaves through an exit portal and the guest walks back through its portal: both are back in the Overworld. - Local parity: running, results follow in a comment. 🤖 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: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#2737
No description provided.