[PR #4866] [MERGED] fix: prevent dedicated world saves from overwriting player data #5902

Closed
opened 2026-11-03 05:15:48 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/4866
Author: @Iam-Sanja
Created: 10/31/2026
Status: ✅ Merged
Merged: 10/31/2026
Merged by: @rdbtCVS

Base: main ← Head: fix/dedicated-playerdata-overwrite


📝 Commits (2)

  • cd53a3c fix: prevent dedicated world saves from overwriting player data
  • adfda4b Merge main

📊 Changes

2 files changed (+66 additions, -7 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+5 -1)
📝 crates/horizon-client/src/save.rs (+61 -6)

📄 Description

🤖 Opened by Iam-Sanja's AI agent (ChatGPT, OpenAI GPT-6), not by Iam-Sanja personally.

What and why

Fixes #4846

On dedicated Horizon servers, saving world metadata could overwrite an existing player's data file when the world's singleplayer_uuid matched the player's UUID.

If the world-level player state lacked a position, Level::write() could remove the saved Pos field. This caused players to reconnect at world spawn instead of their last position.

This PR:

  • Adds Level::write_without_player() to save world metadata without rewriting player files.
  • Uses this method for dedicated server metadata saves.
  • Keeps existing singleplayer behavior unchanged.
  • Adds a regression test that confirms player files remain byte-for-byte unchanged.

Kind

  • parity: Horizon now does what vanilla 26.3 does
  • bug: a crash or a breakage
  • perf: faster, or less memory
  • feature: something new for players
  • extra: Horizon-only, off by default
  • tooling: tools, CI, tests, harnesses
  • docs

Vanilla reference

Vanilla Minecraft saves dedicated player data separately from world metadata using PlayerDataStorage.save.

Self-check

Command: python3 tools/pr_ready.py --base upstream/main

  • Scope: PASS — 2 files changed (+66 / -7)
  • Cargo.lock: PASS — unchanged
  • Public tree: PASS
  • Python tests: PASS — 481 passed
  • rustfmt: PASS
  • clippy: PASS
  • horizon-client tests: PASS — 1,064 passed
  • Doc tests: PASS
  • Vanilla parity: Not run locally; CI handles the affected checks

Additional manual testing:

  • Release build successful.
  • Regression test dedicated_world_save_preserves_player_file passed.
  • Player position and inventory survived server restarts.
  • Disconnecting and reconnecting restored the correct position.
  • Manual server save did not remove the Pos field.

Screenshots

Not applicable — server-side persistence fix.


🔄 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/4866 **Author:** [@Iam-Sanja](https://github.com/Iam-Sanja) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@rdbtCVS](https://github.com/rdbtCVS) **Base:** `main` ← **Head:** `fix/dedicated-playerdata-overwrite` --- ### 📝 Commits (2) - [`cd53a3c`](https://github.com/horizon-rust/horizon/commit/cd53a3c0ddd746df7dc62521ca2a5037d119f9cc) fix: prevent dedicated world saves from overwriting player data - [`adfda4b`](https://github.com/horizon-rust/horizon/commit/adfda4bd26c171594d3daea6d6624296a53093c9) Merge main ### 📊 Changes **2 files changed** (+66 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+5 -1) 📝 `crates/horizon-client/src/save.rs` (+61 -6) </details> ### 📄 Description > 🤖 Opened by Iam-Sanja's AI agent (ChatGPT, OpenAI GPT-6), not by Iam-Sanja personally. ## What and why Fixes #4846 On dedicated Horizon servers, saving world metadata could overwrite an existing player's data file when the world's `singleplayer_uuid` matched the player's UUID. If the world-level player state lacked a position, `Level::write()` could remove the saved `Pos` field. This caused players to reconnect at world spawn instead of their last position. This PR: - Adds `Level::write_without_player()` to save world metadata without rewriting player files. - Uses this method for dedicated server metadata saves. - Keeps existing singleplayer behavior unchanged. - Adds a regression test that confirms player files remain byte-for-byte unchanged. ## Kind - [ ] parity: Horizon now does what vanilla 26.3 does - [x] bug: a crash or a breakage - [ ] perf: faster, or less memory - [ ] feature: something new for players - [ ] extra: Horizon-only, off by default - [ ] tooling: tools, CI, tests, harnesses - [ ] docs ## Vanilla reference Vanilla Minecraft saves dedicated player data separately from world metadata using `PlayerDataStorage.save`. ## Self-check Command: `python3 tools/pr_ready.py --base upstream/main` - Scope: PASS — 2 files changed (+66 / -7) - Cargo.lock: PASS — unchanged - Public tree: PASS - Python tests: PASS — 481 passed - rustfmt: PASS - clippy: PASS - horizon-client tests: PASS — 1,064 passed - Doc tests: PASS - Vanilla parity: Not run locally; CI handles the affected checks Additional manual testing: - Release build successful. - Regression test `dedicated_world_save_preserves_player_file` passed. - Player position and inventory survived server restarts. - Disconnecting and reconnecting restored the correct position. - Manual server save did not remove the `Pos` field. ## Screenshots Not applicable — server-side persistence fix. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:15:48 +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#5902
No description provided.