[PR #214] [MERGED] LAN: offline players get a kept generated name instead of Player (#195) #2412

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

📋 Pull Request Information

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

Base: main ← Head: fix/lan-name-195


📝 Commits (1)

  • dacdf69 LAN: offline players get a kept generated name instead of Player (#195)

📊 Changes

6 files changed (+237 additions, -22 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+21 -7)
📝 crates/horizon-client/src/game/agent.rs (+5 -0)
📝 crates/horizon-client/src/game/control.rs (+1 -1)
📝 crates/horizon-client/src/lib.rs (+1 -0)
➕ crates/horizon-client/src/offline_name.rs (+122 -0)
📝 tools/test_lan_lifecycle.py (+87 -14)

📄 Description

Fixes #195

Root cause. Every offline Horizon player joined as Player: --name defaulted to Player, and the LAN host is also Player (its world's player UUID is offline_uuid("Player"), which the host reserves). Every guest therefore had the host's offline UUID and was refused with multiplayer.disconnect.duplicate_login ("You logged in from another location").

Vanilla. net.minecraft.client.main.Main defaults --username to "Player" + System.currentTimeMillis() % 1000, and the official launcher always passes the account's name, so two players rarely share one.

Fix.

  • offline_name.rs: when no name is given, Horizon generates Player + five digits once and keeps it in horizon-player.txt next to options.txt (name:Player12345). The player keeps the same offline UUID, so their inventory on a friend's world is still there next time. Five digits rather than vanilla's three, because the name is kept: one shared name per thousand pairs is too many. An edited file is used as written if StringUtil.isValidPlayerName accepts it; an invalid one is replaced.
  • Order of precedence: a signed-in account (--session-file, #164, untouched), then --name, then HORIZON_PLAYER_NAME, then the kept name. The name is only resolved when joining a server, so harness and dedicated runs don't create the file.
  • The host's handling of a real duplicate stays as it was. A guest that really is the host's profile is refused with duplicate_login. Of two guests with the same profile, the older one is kicked, as in PlayerList.disconnectAllPlayersWithProfile.
  • The control socket's title report now includes the disconnect reason (menu.disconnected), for the harness.

Evidence.

  • tools/test_lan_lifecycle.py has a new guests case: one host and two guests, each with its own home, both using default names. Both join together (Player28907 and Player12518), the host's lan status lists both, a rejoin keeps the same name, and a guest connecting as Player is refused with "…another location" while the other guest stays. It passes with this branch. With main's binary the first guest never joins (timeout), which reproduces #195.
  • Unit tests: generation, keeping and reusing the name, and replacing invalid names.
  • In game on a vscreen: the host sees the guest Player25600 in its world (screenshot agent-state/wave6a-shots/host-sees-guest.png).
  • Mac mini: cargo fmt --check and workspace clippy -D warnings are clean, and the lib tests pass.

Not here: a name field in the launcher for offline play. The name can be edited in horizon-player.txt or passed with --name.

🤖 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/214 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/14/2026 **Status:** ✅ Merged **Merged:** 10/14/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/lan-name-195` --- ### 📝 Commits (1) - [`dacdf69`](https://github.com/horizon-rust/horizon/commit/dacdf69293785b5728c6eaafaa430a874b79e7a4) LAN: offline players get a kept generated name instead of Player (#195) ### 📊 Changes **6 files changed** (+237 additions, -22 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+21 -7) 📝 `crates/horizon-client/src/game/agent.rs` (+5 -0) 📝 `crates/horizon-client/src/game/control.rs` (+1 -1) 📝 `crates/horizon-client/src/lib.rs` (+1 -0) ➕ `crates/horizon-client/src/offline_name.rs` (+122 -0) 📝 `tools/test_lan_lifecycle.py` (+87 -14) </details> ### 📄 Description Fixes #195 **Root cause.** Every offline Horizon player joined as `Player`: `--name` defaulted to `Player`, and the LAN host is also `Player` (its world's player UUID is `offline_uuid("Player")`, which the host reserves). Every guest therefore had the host's offline UUID and was refused with `multiplayer.disconnect.duplicate_login` ("You logged in from another location"). **Vanilla.** `net.minecraft.client.main.Main` defaults `--username` to `"Player" + System.currentTimeMillis() % 1000`, and the official launcher always passes the account's name, so two players rarely share one. **Fix.** - `offline_name.rs`: when no name is given, Horizon generates `Player` + five digits once and keeps it in `horizon-player.txt` next to `options.txt` (`name:Player12345`). The player keeps the same offline UUID, so their inventory on a friend's world is still there next time. Five digits rather than vanilla's three, because the name is kept: one shared name per thousand pairs is too many. An edited file is used as written if `StringUtil.isValidPlayerName` accepts it; an invalid one is replaced. - Order of precedence: a signed-in account (`--session-file`, #164, untouched), then `--name`, then `HORIZON_PLAYER_NAME`, then the kept name. The name is only resolved when joining a server, so harness and dedicated runs don't create the file. - The host's handling of a real duplicate stays as it was. A guest that really is the host's profile is refused with `duplicate_login`. Of two guests with the same profile, the older one is kicked, as in `PlayerList.disconnectAllPlayersWithProfile`. - The control socket's title report now includes the disconnect reason (`menu.disconnected`), for the harness. **Evidence.** - `tools/test_lan_lifecycle.py` has a new guests case: one host and two guests, each with its own home, both using default names. Both join together (`Player28907` and `Player12518`), the host's `lan status` lists both, a rejoin keeps the same name, and a guest connecting as `Player` is refused with "…another location" while the other guest stays. It passes with this branch. With main's binary the first guest never joins (timeout), which reproduces #195. - Unit tests: generation, keeping and reusing the name, and replacing invalid names. - In game on a vscreen: the host sees the guest `Player25600` in its world (screenshot `agent-state/wave6a-shots/host-sees-guest.png`). - Mac mini: `cargo fmt --check` and workspace `clippy -D warnings` are clean, and the lib tests pass. Not here: a name field in the launcher for offline play. The name can be edited in `horizon-player.txt` or passed with `--name`. 🤖 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:55:52 +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#2412
No description provided.