[PR #2501] [MERGED] Server: new players join around the spawn, not inside the host (LAN guests could open no crafting table) #4370

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

📋 Pull Request Information

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

Base: main ← Head: fix/lan-guest-stations


📝 Commits (1)

  • 67c2770 Server: new players join around the spawn, not all on one spot

📊 Changes

3 files changed (+103 additions, -25 deletions)

View changed files

📝 crates/horizon-client/src/game/initial_spawn.rs (+53 -22)
📝 crates/horizon-client/src/game/lan.rs (+11 -2)
📝 tools/lan_e2e.py (+39 -1)

📄 Description

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

The bug

When a world opened to LAN runs on its server thread (the default), a guest joining for the first time can't open a crafting table, a chest, a furnace or any other block it clicks. The same goes for every new player on a dedicated server after the first one.

Why

The server put every player new to the world exactly on the world spawn (LanHub::admit, then lan_guest_joined for a player without saved data). On the server thread, the host's own player joins the same way, so the host and each new guest stood inside each other, at the same coordinates. Then:

  • The click hits the host. The guest's client picks the entity whose box holds its eye, at distance 0, as vanilla's ProjectileUtil.getEntityHitResult does. A right click goes to the host, never to the block.
  • Nothing pushes them apart. Entity.push skips two entities whose centres are less than 0.01 apart, in vanilla too.

Vanilla never stacks new players: ServerPlayer.adjustSpawnLocation places each one with PlayerSpawnFinder.findSpawn, a free column at a random offset within the respawn_radius game rule (10) around the spawn. Horizon did that only for the window's own player in a world it hosts in-frame. That is why the in-frame host was not affected, though its guests still all landed on one spot.

The fix

A player new to the world now gets findSpawn on the server as well (Game::server_player_spawn). It is the same finder as the window's (radius cut by the world border, the suggestion itself in adventure mode), with its candidate checks (level_respawn_pos, room for the player's box) and the fallback to the spawn's own column. The one difference: vanilla blocks the server until each candidate's chunk loads, and a server tick can't. So a candidate in a chunk that isn't loaded yet is passed over, and the exact spawn stays when none is loaded (what happened before). Returning players keep their saved position.

Checks

pr_ready (tools/pr_ready.py --quick on ludovics-mac-mini, against origin/main at 159f2bf89, 12 min 36 s)

Check Result
Scope ✅ 3 files, +103 −25
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 312 passed (1 min 5 s)
rustfmt ✅ (14 s)
clippy ✅ (1 min 28 s)
tests: horizon-client ✅ 1335 passed (9 min 10 s)
doc tests ✅ 0 passed (6 s)
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ 30 affected, to run in CI (--quick): block_removal, command_exec, composter, crafter, cursor_death, dedicated_server, dispenser, friends_integration, hardcore_respawn, lan_integration, locator_bar, mace and 18 more
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)
  • New lan_e2e check spawned. run() records where the host and the guest joined, before anything moves them. The check:

    • asserts the two spots differ;
    • puts both back on their spots;
    • has the guest open a crafting table, a chest, a furnace and a stonecutter there.

    Results with --check spawned --check crafting --check chest:

    host on its server thread host in-frame
    main spawned fails: both joined at [0.5, 65.0, 0.5] (crafting and chest pass: they move the guest first) passes (host at [7.5, 63, -9.5], the guest on the exact spawn)
    this branch all three pass (host [1.5, 65, 0.5], guest [10.5, 69, -8.5]) all three pass
  • Dedicated server (scratch script: two new guests, then a crafting table at the second one's spot):

    • main: both log in at (-527.5, 69.0, 64.5), and the table doesn't open;
    • this branch: they log in at (-523.5, 69.0, 55.5) and (-528.5, 68.0, 67.5), and the table opens.
  • Parity: the 32 harnesses parity.py --changed-files picks for these files: 32 passed, 0 failed (59 min, on the Mac mini). remote_fireworks and server_player_sculk pass here, though they fail on main on playhorizon.

🤖 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/2501 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/26/2026 **Status:** ✅ Merged **Merged:** 10/26/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/lan-guest-stations` --- ### 📝 Commits (1) - [`67c2770`](https://github.com/horizon-rust/horizon/commit/67c27701e97559473e133ffe5bcaee4836c0cdb2) Server: new players join around the spawn, not all on one spot ### 📊 Changes **3 files changed** (+103 additions, -25 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/initial_spawn.rs` (+53 -22) 📝 `crates/horizon-client/src/game/lan.rs` (+11 -2) 📝 `tools/lan_e2e.py` (+39 -1) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. ## The bug When a world opened to LAN runs on its server thread (the default), a guest joining for the first time can't open a crafting table, a chest, a furnace or any other block it clicks. The same goes for every new player on a dedicated server after the first one. ## Why The server put every player new to the world exactly on the world spawn (`LanHub::admit`, then `lan_guest_joined` for a player without saved data). On the server thread, the host's own player joins the same way, so the host and each new guest stood inside each other, at the same coordinates. Then: - **The click hits the host.** The guest's client picks the entity whose box holds its eye, at distance 0, as vanilla's `ProjectileUtil.getEntityHitResult` does. A right click goes to the host, never to the block. - **Nothing pushes them apart.** `Entity.push` skips two entities whose centres are less than 0.01 apart, in vanilla too. Vanilla never stacks new players: `ServerPlayer.adjustSpawnLocation` places each one with `PlayerSpawnFinder.findSpawn`, a free column at a random offset within the `respawn_radius` game rule (10) around the spawn. Horizon did that only for the window's own player in a world it hosts in-frame. That is why the in-frame host was not affected, though its guests still all landed on one spot. ## The fix A player new to the world now gets `findSpawn` on the server as well (`Game::server_player_spawn`). It is the same finder as the window's (radius cut by the world border, the suggestion itself in adventure mode), with its candidate checks (`level_respawn_pos`, room for the player's box) and the fallback to the spawn's own column. The one difference: vanilla blocks the server until each candidate's chunk loads, and a server tick can't. So a candidate in a chunk that isn't loaded yet is passed over, and the exact spawn stays when none is loaded (what happened before). Returning players keep their saved position. ## Checks **pr_ready** (`tools/pr_ready.py --quick` on ludovics-mac-mini, against origin/main at 159f2bf89, 12 min 36 s) | Check | Result | | --- | --- | | Scope | ✅ 3 files, +103 −25 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 312 passed (1 min 5 s) | | rustfmt | ✅ (14 s) | | clippy | ✅ (1 min 28 s) | | tests: horizon-client | ✅ 1335 passed (9 min 10 s) | | doc tests | ✅ 0 passed (6 s) | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ 30 affected, to run in CI (--quick): block_removal, command_exec, composter, crafter, cursor_death, dedicated_server, dispenser, friends_integration, hardcore_respawn, lan_integration, locator_bar, mace and 18 more | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | - **New lan_e2e check `spawned`.** `run()` records where the host and the guest joined, before anything moves them. The check: - asserts the two spots differ; - puts both back on their spots; - has the guest open a crafting table, a chest, a furnace and a stonecutter there. Results with `--check spawned --check crafting --check chest`: | | host on its server thread | host in-frame | |---|---|---| | main | `spawned` fails: both joined at [0.5, 65.0, 0.5] (`crafting` and `chest` pass: they move the guest first) | passes (host at [7.5, 63, -9.5], the guest on the exact spawn) | | this branch | all three pass (host [1.5, 65, 0.5], guest [10.5, 69, -8.5]) | all three pass | - **Dedicated server** (scratch script: two new guests, then a crafting table at the second one's spot): - main: both log in at (-527.5, 69.0, 64.5), and the table doesn't open; - this branch: they log in at (-523.5, 69.0, 55.5) and (-528.5, 68.0, 67.5), and the table opens. - **Parity:** the 32 harnesses `parity.py --changed-files` picks for these files: 32 passed, 0 failed (59 min, on the Mac mini). `remote_fireworks` and `server_player_sculk` pass here, though they fail on main on playhorizon. 🤖 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 04:16: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#4370
No description provided.