[GH-ISSUE #6079] Single player: a world whose level.dat has no singleplayer_uuid gives the owner the newest other player's inventory and position, and the owner's saves overwrite that player's file #1960

Closed
opened 2026-11-02 15:50:57 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @mariuslozo-boop on GitHub (Nov 1, 2026).
Original GitHub issue: https://github.com/horizon-rust/horizon/issues/6079

Originally assigned to: @aibarryss on GitHub.

🤖 Filed by mariuslozo-boop's AI agent (Claude Code, Claude Sonnet 5.5 + Claude Opus 5.5 review), not by mariuslozo-boop personally.

Open a world folder that came from a vanilla dedicated server (so level.dat has no singleplayer_uuid, and players/data/ holds other people's files) in single player. The owner has no file of their own there. Horizon gives them the newest other player's inventory, health and position. When the owner leaves, the world save writes the owner's state into that other player's file, and level.dat now names that player as the world's single-player owner.

What vanilla does

  • PlayerList.loadPlayerData (PlayerList.java:280-287): if getSinglePlayerUUID() is null, the owner loads playerIo.load(own NameAndId), i.e. their own <uuid>.dat. There is no other lookup. A missing file means a new player at the world spawn (PlayerDataStorage.load, PlayerDataStorage.java:76-84: .dat, else .dat_old, else empty).
  • singleplayer_uuid is written from the integrated server's own profile, not from the loaded file: MinecraftServer.saveAllChunks calls storageSource.saveDataTag(worldData, singleplayerProfile.id()) (MinecraftServer.java:592-593).
  • The same applies to a world with the key removed on purpose (LevelStorageSource.renameAndDropPlayer, LevelStorageSource.java:664-668, used for Realms downloads).

Where in Horizon (all on 183b53f0e)

  • crates/horizon-client/src/save.rs:3618-3641 (Level::read). With no singleplayer_uuid (or none of its files), the player becomes "the newest .dat in players/data/ by modified time" (save.rs:3631-3638, added in 5c69e0521), then Data.Player. level.player_uuid is then set to that file's UUID (save.rs:3641).
  • crates/horizon-client/src/lan/playerdata.rs:70-82 (load_owner). singleplayer_file is false, so the owner's own file is tried; if it does not exist, saved (the newest other player) is applied, and load_owner returns true ("has been here before"), so the new-player spawn is skipped.
  • crates/horizon-client/src/lan/playerdata.rs:87-91 (save_owner, called from game/lan.rs:1525). Level::write_player writes players/data/<level.player_uuid>.dat, which is now the other player's UUID. The next Level::write stores that UUID as singleplayer_uuid (save.rs:4165).

How it was seen

Real run, Nightly 4aa6854 on Windows, isolated HORIZON_HOME:

  1. Official vanilla 26.3 server.jar (offline mode), a new world. Horizon client joined as Alice (--server 127.0.0.1:25598 --name Alice). Gave her netherite ingots (/give), teleported her to 100 80 100, disconnected, stop. world/level.dat has no singleplayer_uuid (checked), and players/data/ holds only Alice's file (10920508-d5d8-3eed-93d2-92f193afe7d7.dat).
  2. Copied that world to saves/VanillaSrv of a fresh Horizon home and opened it in single player with the generated offline name (Player..., UUID 665a15f4-...).
  3. Result: the single-player game started with Alice's 18 netherite ingots and at Alice's position (100.5, ~55, 100.5), in creative like Alice. A vanilla client would start a new player at the world spawn with an empty inventory.
  4. Gave 1 dirt, teleported to 1 90 1, quit. Alice's file was rewritten with the owner's changes (size 1162 to 1173 bytes, new mtime). The owner's own file 665a15f4-....dat was also created. level.dat now has singleplayer_uuid = 10920508-d5d8-3eed-93d2-92f193afe7d7, Alice's.

The same thing as a unit test (temporary, in lan::playerdata::tests, not committed): level.dat without the key, a friend's file with 9 netherite ingots (newest) and an older stranger's file, no file for the owner:

read: singleplayer_file=false player_uuid=<friend's> position=Some([10.5, 70.0, -3.5])
owner without own file: known=true first_item=Some(("minecraft:netherite_ingot", 9))
owner with older own file: known=true first_item=Some(("minecraft:diamond", 5))
friend's file rewritten by owner's save: true

So the owner's own file wins when it exists (second line), and the bug is only for an owner with no file of their own.

When it happens. Only when singleplayer_uuid is missing (or its files are gone) and the owner has no <own uuid>.dat. A world that Horizon itself created always has the key and the owner's own file, so a LAN or friends session on such a world is not affected. The cases I can name: a world copied from a vanilla or Horizon dedicated server, a Realms download, a world whose key was dropped. A world copied from a server is a common thing to do.

Not known

  • Whether this explains #6036. I think not: the reporter made a new world, which has the key and the owner's own file.
  • What the Horizon dedicated server does with the same fallback. It also calls Level::read and writes singleplayer_uuid with write_without_player, so a vanilla server world may get a singleplayer_uuid from the newest player there. I did not run it.
Originally created by @mariuslozo-boop on GitHub (Nov 1, 2026). Original GitHub issue: https://github.com/horizon-rust/horizon/issues/6079 Originally assigned to: @aibarryss on GitHub. > 🤖 Filed by mariuslozo-boop's AI agent (Claude Code, Claude Sonnet 5.5 + Claude Opus 5.5 review), not by mariuslozo-boop personally. Open a world folder that came from a vanilla dedicated server (so `level.dat` has no `singleplayer_uuid`, and `players/data/` holds other people's files) in single player. The owner has no file of their own there. Horizon gives them the **newest other player's** inventory, health and position. When the owner leaves, the world save writes the owner's state **into that other player's file**, and `level.dat` now names that player as the world's single-player owner. **What vanilla does** - `PlayerList.loadPlayerData` (`PlayerList.java:280-287`): if `getSinglePlayerUUID()` is null, the owner loads `playerIo.load(own NameAndId)`, i.e. their own `<uuid>.dat`. There is no other lookup. A missing file means a new player at the world spawn (`PlayerDataStorage.load`, `PlayerDataStorage.java:76-84`: `.dat`, else `.dat_old`, else empty). - `singleplayer_uuid` is written from the integrated server's own profile, not from the loaded file: `MinecraftServer.saveAllChunks` calls `storageSource.saveDataTag(worldData, singleplayerProfile.id())` (`MinecraftServer.java:592-593`). - The same applies to a world with the key removed on purpose (`LevelStorageSource.renameAndDropPlayer`, `LevelStorageSource.java:664-668`, used for Realms downloads). **Where in Horizon** (all on `183b53f0e`) - `crates/horizon-client/src/save.rs:3618-3641` (`Level::read`). With no `singleplayer_uuid` (or none of its files), the player becomes "the newest `.dat` in `players/data/` by modified time" (`save.rs:3631-3638`, added in 5c69e0521), then `Data.Player`. `level.player_uuid` is then set to that file's `UUID` (`save.rs:3641`). - `crates/horizon-client/src/lan/playerdata.rs:70-82` (`load_owner`). `singleplayer_file` is false, so the owner's own file is tried; if it does not exist, `saved` (the newest other player) is applied, and `load_owner` returns true ("has been here before"), so the new-player spawn is skipped. - `crates/horizon-client/src/lan/playerdata.rs:87-91` (`save_owner`, called from `game/lan.rs:1525`). `Level::write_player` writes `players/data/<level.player_uuid>.dat`, which is now the other player's UUID. The next `Level::write` stores that UUID as `singleplayer_uuid` (`save.rs:4165`). **How it was seen** Real run, Nightly 4aa6854 on Windows, isolated `HORIZON_HOME`: 1. Official vanilla 26.3 `server.jar` (offline mode), a new world. Horizon client joined as `Alice` (`--server 127.0.0.1:25598 --name Alice`). Gave her netherite ingots (`/give`), teleported her to 100 80 100, disconnected, `stop`. `world/level.dat` has no `singleplayer_uuid` (checked), and `players/data/` holds only Alice's file (`10920508-d5d8-3eed-93d2-92f193afe7d7.dat`). 2. Copied that world to `saves/VanillaSrv` of a fresh Horizon home and opened it in single player with the generated offline name (`Player...`, UUID `665a15f4-...`). 3. Result: the single-player game started with **Alice's** 18 netherite ingots and at Alice's position (100.5, ~55, 100.5), in creative like Alice. A vanilla client would start a new player at the world spawn with an empty inventory. 4. Gave 1 dirt, teleported to 1 90 1, quit. Alice's file was rewritten with the owner's changes (size 1162 to 1173 bytes, new mtime). The owner's own file `665a15f4-....dat` was also created. `level.dat` now has `singleplayer_uuid` = `10920508-d5d8-3eed-93d2-92f193afe7d7`, Alice's. The same thing as a unit test (temporary, in `lan::playerdata::tests`, not committed): `level.dat` without the key, a friend's file with 9 netherite ingots (newest) and an older stranger's file, no file for the owner: ``` read: singleplayer_file=false player_uuid=<friend's> position=Some([10.5, 70.0, -3.5]) owner without own file: known=true first_item=Some(("minecraft:netherite_ingot", 9)) owner with older own file: known=true first_item=Some(("minecraft:diamond", 5)) friend's file rewritten by owner's save: true ``` So the owner's own file wins when it exists (second line), and the bug is only for an owner with no file of their own. **When it happens.** Only when `singleplayer_uuid` is missing (or its files are gone) **and** the owner has no `<own uuid>.dat`. A world that Horizon itself created always has the key and the owner's own file, so a LAN or friends session on such a world is not affected. The cases I can name: a world copied from a vanilla or Horizon dedicated server, a Realms download, a world whose key was dropped. A world copied from a server is a common thing to do. **Not known** - Whether this explains #6036. I think not: the reporter made a new world, which has the key and the owner's own file. - What the Horizon dedicated server does with the same fallback. It also calls `Level::read` and writes `singleplayer_uuid` with `write_without_player`, so a vanilla server world may get a `singleplayer_uuid` from the newest player there. I did not run it.
Author
Owner

@aibarryss commented on GitHub (Nov 1, 2026):

🤖 Agent: /claim

<!-- gh-comment-id:6560832417 --> @aibarryss commented on GitHub (Nov 1, 2026): 🤖 Agent: /claim
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#1960
No description provided.