[PR #731] [CLOSED] Run single player on its server thread by default #2762

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/731
Author: @ludovic111
Created: 10/17/2026
Status: ❌ Closed

Base: main ← Head: fix/server-thread-default


📝 Commits (10+)

  • 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
  • 805d553 Give mob, beacon, sculk and splash effects to every player
  • e4741b7 Decode the server's command tree and complete commands with it
  • 5f12705 Merge remote-tracking branch 'origin/feat/server-command-tree' into pt5/integration
  • a4feb65 Show the server's recipe book on a server and place its recipes
  • 30f0c71 Merge remote-tracking branch 'origin/feat/remote-recipe-book' into pt5/integration
  • 4ff23b6 Run single player on its server thread by default
  • b9f3821 Make agents, the host window and LAN guests work on the server thread

📊 Changes

44 files changed (+2999 additions, -435 deletions)

View changed files

📝 crates/horizon-client/src/command/mod.rs (+1 -0)
➕ crates/horizon-client/src/command/network.rs (+404 -0)
📝 crates/horizon-client/src/game.rs (+44 -26)
📝 crates/horizon-client/src/game/agent.rs (+33 -1)
📝 crates/horizon-client/src/game/beacon.rs (+4 -0)
📝 crates/horizon-client/src/game/chat.rs (+27 -6)
📝 crates/horizon-client/src/game/control.rs (+35 -15)
📝 crates/horizon-client/src/game/creaking.rs (+8 -0)
📝 crates/horizon-client/src/game/creatures.rs (+34 -7)
📝 crates/horizon-client/src/game/debug_keys.rs (+1 -2)
📝 crates/horizon-client/src/game/dedicated.rs (+12 -12)
📝 crates/horizon-client/src/game/events.rs (+16 -3)
📝 crates/horizon-client/src/game/falling_damage.rs (+1 -1)
📝 crates/horizon-client/src/game/integrated.rs (+64 -7)
📝 crates/horizon-client/src/game/lan.rs (+60 -6)
📝 crates/horizon-client/src/game/lan_actions.rs (+65 -10)
📝 crates/horizon-client/src/game/lan_crafting.rs (+80 -0)
📝 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)

...and 24 more files

📄 Description

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

Warning

Blocked; do not merge yet (draft). The server sends its clients only mobs and dropped items (lan_entities). Minecarts, boats, armor stands, paintings, item frames, projectiles, experience orbs, falling blocks and primed TNT are never sent to them. With the server thread on by default, single player would stop showing all of these. world_reopen fails on this: its summoned minecart is on the server but not in the window. LAN guests already have this gap today. The fixes below also help with --server-thread and on LAN without the flip, so they could be split out if that is wanted.

Task 6 of the server-thread work: single player now runs on its server thread by default, the same way vanilla's integrated server does. --no-server-thread or HORIZON_SERVER_THREAD=0 turns it off and goes back to the in-frame world.

Merge order. Merge this after #695, #697, #700, #708 and #714. The branch merges them (#700 is stacked on #697, which is stacked on #695), so the diff on main gets smaller as each one lands. The last two commits are this PR's own work.

What changes

Run single player on its server thread by default:

  • options.server_thread is on unless HORIZON_SERVER_THREAD=0 is set or --no-server-thread is passed. There is a help line for the flag.
  • lan_e2e passes the mode on to the host explicitly.

The default exposed some places that still used the window's own state. With the server thread on, the window is a client of the server, so those places never reached the world. Fixed here:

  • Agent and control commands. give, time and the agent's command now run on the server as the world's owner (owner_console_command), in the owner's level (between two ticks, the level in place is the one ticked last).
  • defaultgamemode run by a guest or by the owner now reaches the hub, so guests join in the right mode. The hub is taken out while a guest acts, so set_default_game_mode never saw it before.
  • Held slot. The remote client sends its held slot before it uses an item, starts mining or attacks (MultiPlayerGameMode.ensureHasSentCarriedItem).
  • Chat events. Remote chat lines now feed the agent's event log, so wait-for chat works.
  • Crouching. The remote client applies another player's crouch flag (DATA_SHARED_FLAGS_ID) to their model and name tag. The entity tracker now sends Entity's shared flags and pose back at 0. A value back at its default was left out of the state, so a player standing up again was never sent.
  • Respawn. A respawned player is removed for the other players and sent to them again (removePlayerImmediately and addRespawnedPlayer). Their clients had kept the dead body.
  • Teleport. A teleport drops the moves the guest sent before it. Vanilla handles those moves on arrival, before the teleport. Here they waited for the next tick and were applied after it, so a fall in them hurt the guest where it landed (out of the void with /tp).
  • place. On a client of a server, the agent's place waits up to a second for the server's block before it reports no change.
  • Tick time. Flight summaries (fly ... raw) now report the tick time (tick_ms, tick_ms_max): the server thread's when it is on, the frame's tick otherwise.

Harness changes:

  • lan_e2e:
    • finds the guest by name in lan status (with the server thread on, the owner is listed too);
    • reads what the host window draws from its remote view;
    • treats a guest as dead when its death screen is open (the last health the guest was sent can stay above 0);
    • respawns the guest before clearing the hazard box (a dead player's commands do not run);
    • in the pvp-off step, accepts health going up from natural regeneration.
  • agent_control_e2e waits two ticks where the server answers a click, and tries the next free spot when the trunk above the broken log hides a spot's faces.

Measured (Mac mini M4 Pro)

Method:

  • Same fast binary for both modes: base is HORIZON_SERVER_THREAD=0, new is the default.
  • Fresh world, seed 1234, creative, render distance 12.
  • perf_bench's options and scenes: village and forest, a 12 s straight flight at constant speed, 2 s settle, offscreen.
  • Order base/new/base/new. Frame times come from every frame of the flight.

The machine was heavily loaded by other sessions throughout (load average 71–84 on 14 cores), so the absolute numbers are noisy. The direction was the same in both pairs.

scene mode frame avg p99 p99.9 tick avg (max)
village base, run 1 14.0 ms 122 ms 172 ms 9.3 ms (35)
village new, run 1 2.4 ms 49 ms 143 ms 2.7 ms (10)
village base, run 2 4.2 ms 59 ms 133 ms 5.9 ms (25)
village new, run 2 3.8 ms 75 ms 181 ms 3.1 ms (25)
forest base, run 1 58.1 ms 307 ms 357 ms 14.1 ms (64)
forest new, run 1 1.6 ms 35 ms 134 ms 3.0 ms (8)
forest base, run 2 36.7 ms 229 ms 293 ms 8.3 ms (40)
forest new, run 2 3.0 ms 56 ms 159 ms 2.6 ms (11)
  • In the forest, the server thread takes the frame from about 17–27 FPS to 340–630 FPS.
  • In the village, the average and p99 are better in both pairs. p99.9 is mixed: 133/172 ms base against 143/181 ms new.
  • The ThinkPad run has not been done yet; it goes through the orchestrator.

Checks

  • cargo fmt --all --check, cargo clippy --workspace --all-targets -- -D warnings: clean.
  • cargo test -p horizon-client --lib: 825 passed. It includes a new tracker test: cleared flags and pose go back to their default.
  • tools/agent_control_e2e.py --mode cli: survival, ui, options and events all pass, twice on the new default and once with HORIZON_SERVER_THREAD=0. Before these fixes, survival and events failed on the default.
  • tools/lan_e2e.py, in-frame (HORIZON_SERVER_THREAD=0), on the build just before the teleport change: 18 checks pass; portals is skipped because it needs the server thread.
  • tools/lan_e2e.py --server-thread, full run: tab, self, armour, nametags, walls, chest, crafting, sign, damage, mobs and hazards pass.
    • In that run, the guest died just after hazards and the later checks found its death screen open. The in-frame run hit the same cascade once in two runs.
    • Run on their own: pvp, containers, feedback, commands, recipes, effects and portals pass. trials failed once on vault timing ("ejecting") and passed in three other server-thread runs.
    • Before these fixes, self, armour, walls, crafting, hazards and portals failed on the server thread.
  • Local parity: full run 85 passed, 3 failed. After the last commit, command_exec and save_roundtrip pass; world_reopen still fails on the blocker above (see the comment).

Still missing on the server thread (not blockers, reported)

  • Block-break progress from other players (BlockDestruction) is not drawn. The breaking renderer has a single crumbling_sprite uniform (gfx.rs / entity.wgsl) and needs a per-vertex stage in breaking::geometry (perf-gpu's area).
  • The remote client ignores LightUpdate, ClearTitles and SetSubtitleText.
  • Command suggestions that need the server (ask_server) are not requested. The furnace and smoker recipe books, and the RecipeBookSeen / RecipeBookChangeSettings packets, are not done.
  • Conduits have no server-side effect at all (reported on #700).
  • The hub never sends SetHealth 0 when a guest dies, so the guest's health stays at its last positive value under the death screen.

🤖 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/731 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/17/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/server-thread-default` --- ### 📝 Commits (10+) - [`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 - [`805d553`](https://github.com/horizon-rust/horizon/commit/805d5532e541deb1888216c8ebfc15775d8b2ea5) Give mob, beacon, sculk and splash effects to every player - [`e4741b7`](https://github.com/horizon-rust/horizon/commit/e4741b7793211787741f520d9667cebfd9aaeca8) Decode the server's command tree and complete commands with it - [`5f12705`](https://github.com/horizon-rust/horizon/commit/5f12705a2983740d2893f7f7c6d5eecd273d6767) Merge remote-tracking branch 'origin/feat/server-command-tree' into pt5/integration - [`a4feb65`](https://github.com/horizon-rust/horizon/commit/a4feb6516102eaffb9e82437f808e32f4d05bde0) Show the server's recipe book on a server and place its recipes - [`30f0c71`](https://github.com/horizon-rust/horizon/commit/30f0c715b2485205bdeb0904667cd50865c07058) Merge remote-tracking branch 'origin/feat/remote-recipe-book' into pt5/integration - [`4ff23b6`](https://github.com/horizon-rust/horizon/commit/4ff23b686d44249c9c8d6dc9d0f9d3c12ed6afcb) Run single player on its server thread by default - [`b9f3821`](https://github.com/horizon-rust/horizon/commit/b9f3821f24eea22082c4d88e582d833388971158) Make agents, the host window and LAN guests work on the server thread ### 📊 Changes **44 files changed** (+2999 additions, -435 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/command/mod.rs` (+1 -0) ➕ `crates/horizon-client/src/command/network.rs` (+404 -0) 📝 `crates/horizon-client/src/game.rs` (+44 -26) 📝 `crates/horizon-client/src/game/agent.rs` (+33 -1) 📝 `crates/horizon-client/src/game/beacon.rs` (+4 -0) 📝 `crates/horizon-client/src/game/chat.rs` (+27 -6) 📝 `crates/horizon-client/src/game/control.rs` (+35 -15) 📝 `crates/horizon-client/src/game/creaking.rs` (+8 -0) 📝 `crates/horizon-client/src/game/creatures.rs` (+34 -7) 📝 `crates/horizon-client/src/game/debug_keys.rs` (+1 -2) 📝 `crates/horizon-client/src/game/dedicated.rs` (+12 -12) 📝 `crates/horizon-client/src/game/events.rs` (+16 -3) 📝 `crates/horizon-client/src/game/falling_damage.rs` (+1 -1) 📝 `crates/horizon-client/src/game/integrated.rs` (+64 -7) 📝 `crates/horizon-client/src/game/lan.rs` (+60 -6) 📝 `crates/horizon-client/src/game/lan_actions.rs` (+65 -10) 📝 `crates/horizon-client/src/game/lan_crafting.rs` (+80 -0) 📝 `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) _...and 24 more files_ </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. > [!WARNING] > **Blocked; do not merge yet (draft).** The server sends its clients only mobs and dropped items (`lan_entities`). Minecarts, boats, armor stands, paintings, item frames, projectiles, experience orbs, falling blocks and primed TNT are never sent to them. With the server thread on by default, single player would stop showing all of these. `world_reopen` fails on this: its summoned minecart is on the server but not in the window. LAN guests already have this gap today. The fixes below also help with `--server-thread` and on LAN without the flip, so they could be split out if that is wanted. Task 6 of the server-thread work: single player now runs on its server thread by default, the same way vanilla's integrated server does. `--no-server-thread` or `HORIZON_SERVER_THREAD=0` turns it off and goes back to the in-frame world. **Merge order.** Merge this after #695, #697, #700, #708 and #714. The branch merges them (#700 is stacked on #697, which is stacked on #695), so the diff on `main` gets smaller as each one lands. The last two commits are this PR's own work. ## What changes `Run single player on its server thread by default`: - `options.server_thread` is on unless `HORIZON_SERVER_THREAD=0` is set or `--no-server-thread` is passed. There is a help line for the flag. - lan_e2e passes the mode on to the host explicitly. The default exposed some places that still used the window's own state. With the server thread on, the window is a client of the server, so those places never reached the world. Fixed here: - **Agent and control commands.** `give`, `time` and the agent's `command` now run on the server as the world's owner (`owner_console_command`), in the owner's level (between two ticks, the level in place is the one ticked last). - **`defaultgamemode`** run by a guest or by the owner now reaches the hub, so guests join in the right mode. The hub is taken out while a guest acts, so `set_default_game_mode` never saw it before. - **Held slot.** The remote client sends its held slot before it uses an item, starts mining or attacks (`MultiPlayerGameMode.ensureHasSentCarriedItem`). - **Chat events.** Remote chat lines now feed the agent's event log, so `wait-for chat` works. - **Crouching.** The remote client applies another player's crouch flag (`DATA_SHARED_FLAGS_ID`) to their model and name tag. The entity tracker now sends Entity's shared flags and pose back at 0. A value back at its default was left out of the state, so a player standing up again was never sent. - **Respawn.** A respawned player is removed for the other players and sent to them again (`removePlayerImmediately` and `addRespawnedPlayer`). Their clients had kept the dead body. - **Teleport.** A teleport drops the moves the guest sent before it. Vanilla handles those moves on arrival, before the teleport. Here they waited for the next tick and were applied after it, so a fall in them hurt the guest where it landed (out of the void with `/tp`). - **`place`.** On a client of a server, the agent's `place` waits up to a second for the server's block before it reports no change. - **Tick time.** Flight summaries (`fly ... raw`) now report the tick time (`tick_ms`, `tick_ms_max`): the server thread's when it is on, the frame's tick otherwise. Harness changes: - lan_e2e: - finds the guest by name in `lan status` (with the server thread on, the owner is listed too); - reads what the host window draws from its remote view; - treats a guest as dead when its death screen is open (the last health the guest was sent can stay above 0); - respawns the guest before clearing the hazard box (a dead player's commands do not run); - in the pvp-off step, accepts health going up from natural regeneration. - agent_control_e2e waits two ticks where the server answers a click, and tries the next free spot when the trunk above the broken log hides a spot's faces. ## Measured (Mac mini M4 Pro) Method: - Same `fast` binary for both modes: base is `HORIZON_SERVER_THREAD=0`, new is the default. - Fresh world, seed 1234, creative, render distance 12. - perf_bench's options and scenes: village and forest, a 12 s straight flight at constant speed, 2 s settle, offscreen. - Order base/new/base/new. Frame times come from every frame of the flight. The machine was heavily loaded by other sessions throughout (load average 71–84 on 14 cores), so the absolute numbers are noisy. The direction was the same in both pairs. | scene | mode | frame avg | p99 | p99.9 | tick avg (max) | |---|---|---|---|---|---| | village | base, run 1 | 14.0 ms | 122 ms | 172 ms | 9.3 ms (35) | | village | new, run 1 | 2.4 ms | 49 ms | 143 ms | 2.7 ms (10) | | village | base, run 2 | 4.2 ms | 59 ms | 133 ms | 5.9 ms (25) | | village | new, run 2 | 3.8 ms | 75 ms | 181 ms | 3.1 ms (25) | | forest | base, run 1 | 58.1 ms | 307 ms | 357 ms | 14.1 ms (64) | | forest | new, run 1 | 1.6 ms | 35 ms | 134 ms | 3.0 ms (8) | | forest | base, run 2 | 36.7 ms | 229 ms | 293 ms | 8.3 ms (40) | | forest | new, run 2 | 3.0 ms | 56 ms | 159 ms | 2.6 ms (11) | - In the forest, the server thread takes the frame from about 17–27 FPS to 340–630 FPS. - In the village, the average and p99 are better in both pairs. p99.9 is mixed: 133/172 ms base against 143/181 ms new. - The ThinkPad run has not been done yet; it goes through the orchestrator. ## Checks - `cargo fmt --all --check`, `cargo clippy --workspace --all-targets -- -D warnings`: clean. - `cargo test -p horizon-client --lib`: 825 passed. It includes a new tracker test: cleared flags and pose go back to their default. - `tools/agent_control_e2e.py --mode cli`: survival, ui, options and events all pass, twice on the new default and once with `HORIZON_SERVER_THREAD=0`. Before these fixes, survival and events failed on the default. - `tools/lan_e2e.py`, in-frame (`HORIZON_SERVER_THREAD=0`), on the build just before the teleport change: 18 checks pass; portals is skipped because it needs the server thread. - `tools/lan_e2e.py --server-thread`, full run: tab, self, armour, nametags, walls, chest, crafting, sign, damage, mobs and hazards pass. - In that run, the guest died just after hazards and the later checks found its death screen open. The in-frame run hit the same cascade once in two runs. - Run on their own: pvp, containers, feedback, commands, recipes, effects and portals pass. trials failed once on vault timing ("ejecting") and passed in three other server-thread runs. - Before these fixes, self, armour, walls, crafting, hazards and portals failed on the server thread. - Local parity: full run 85 passed, 3 failed. After the last commit, `command_exec` and `save_roundtrip` pass; `world_reopen` still fails on the blocker above (see the comment). ## Still missing on the server thread (not blockers, reported) - **Block-break progress from other players** (`BlockDestruction`) is not drawn. The breaking renderer has a single `crumbling_sprite` uniform (gfx.rs / entity.wgsl) and needs a per-vertex stage in `breaking::geometry` (perf-gpu's area). - The remote client ignores `LightUpdate`, `ClearTitles` and `SetSubtitleText`. - Command suggestions that need the server (`ask_server`) are not requested. The furnace and smoker recipe books, and the `RecipeBookSeen` / `RecipeBookChangeSettings` packets, are not done. - Conduits have no server-side effect at all (reported on #700). - The hub never sends `SetHealth` 0 when a guest dies, so the guest's health stays at its last positive value under the death screen. 🤖 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:51 +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#2762
No description provided.