[PR #6095] [MERGED] A world without singleplayer_uuid gives its owner a new player, not another player's #6650

Closed
opened 2026-11-03 06:24:21 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/6095
Author: @xFedeT
Created: 11/1/2026
Status: ✅ Merged
Merged: 11/1/2026
Merged by: @ludovic111

Base: main ← Head: fix/singleplayer-owner


📝 Commits (1)

  • be35f0c A world without singleplayer_uuid gives its owner a new player, not another player's file

📊 Changes

2 files changed (+38 additions, -14 deletions)

View changed files

📝 crates/horizon-client/src/lan/playerdata.rs (+34 -0)
📝 crates/horizon-client/src/save.rs (+4 -14)

📄 Description

🤖 Opened by xFedeT's AI agent (Claude Code, Sonnet 5.5), not by xFedeT personally.

Fixes #6079.

What was wrong

With no singleplayer_uuid in level.dat (a world copied from a server, a Realms download), Level::read took the newest .dat of players/data/ as the player, so the owner started with another player's inventory and position, and the owner's save wrote into that player's file and made singleplayer_uuid name them. PlayerList.loadPlayerData has no such lookup: without the key the owner loads their own <uuid>.dat, and a missing file is a new player at the spawn; MinecraftServer.saveAllChunks writes the integrated server's own profile as singleplayer_uuid.

What changes

  • save.rs (Level::read): the newest-file fallback is removed. The player is the file singleplayer_uuid names, else the legacy Data.Player; lan/playerdata.rs::load_owner already loads the owner's own file after that, and a missing one is a new player.
  • lan/playerdata.rs::save_owner: level.player_uuid is the owner's profile when nothing set it, so the first save writes the owner's UUID as singleplayer_uuid and the owner's state into the owner's own file.
  • A test for the report's case: a world without the key and with a friend's file holding 9 netherite ingots. The owner is not known, gets no inventory, and after save_owner the friend's file is byte-for-byte the same, singleplayer_uuid is the owner, and the owner's file exists.

Verification

cargo test -p horizon-client --lib -- save:: lan:: world_load: 199 passed, including the new test and the existing owner tests (#5351's named-file-first order is unchanged). Clippy and rustfmt are clean for the changed files; the only clippy error is the existing needless_borrow in horizon-world.

Not done

  • I did not rerun the real vanilla-server world of the report in game; the test builds the same files.
  • #5351's order (the file singleplayer_uuid names before the owner's own) is unchanged. The issue's question about the Horizon dedicated server's own fallback is not touched here.

🤖 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/6095 **Author:** [@xFedeT](https://github.com/xFedeT) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/singleplayer-owner` --- ### 📝 Commits (1) - [`be35f0c`](https://github.com/horizon-rust/horizon/commit/be35f0cd18fcce995c7a97706b757f02615fda0f) A world without singleplayer_uuid gives its owner a new player, not another player's file ### 📊 Changes **2 files changed** (+38 additions, -14 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/lan/playerdata.rs` (+34 -0) 📝 `crates/horizon-client/src/save.rs` (+4 -14) </details> ### 📄 Description > 🤖 Opened by xFedeT's AI agent (Claude Code, Sonnet 5.5), not by xFedeT personally. Fixes #6079. ## What was wrong With no `singleplayer_uuid` in `level.dat` (a world copied from a server, a Realms download), `Level::read` took the newest `.dat` of `players/data/` as the player, so the owner started with another player's inventory and position, and the owner's save wrote into that player's file and made `singleplayer_uuid` name them. `PlayerList.loadPlayerData` has no such lookup: without the key the owner loads their own `<uuid>.dat`, and a missing file is a new player at the spawn; `MinecraftServer.saveAllChunks` writes the integrated server's own profile as `singleplayer_uuid`. ## What changes - `save.rs` (`Level::read`): the newest-file fallback is removed. The player is the file `singleplayer_uuid` names, else the legacy `Data.Player`; `lan/playerdata.rs::load_owner` already loads the owner's own file after that, and a missing one is a new player. - `lan/playerdata.rs::save_owner`: `level.player_uuid` is the owner's profile when nothing set it, so the first save writes the owner's UUID as `singleplayer_uuid` and the owner's state into the owner's own file. - A test for the report's case: a world without the key and with a friend's file holding 9 netherite ingots. The owner is not known, gets no inventory, and after `save_owner` the friend's file is byte-for-byte the same, `singleplayer_uuid` is the owner, and the owner's file exists. ## Verification `cargo test -p horizon-client --lib -- save:: lan:: world_load`: 199 passed, including the new test and the existing owner tests (#5351's named-file-first order is unchanged). Clippy and rustfmt are clean for the changed files; the only clippy error is the existing `needless_borrow` in `horizon-world`. ## Not done - I did not rerun the real vanilla-server world of the report in game; the test builds the same files. - #5351's order (the file `singleplayer_uuid` names before the owner's own) is unchanged. The issue's question about the Horizon dedicated server's own fallback is not touched here. 🤖 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 06:24:21 +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#6650
No description provided.