[PR #4879] [MERGED] A dedicated server takes level.dat_old when level.dat does not read #5911

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

📋 Pull Request Information

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

Base: main ← Head: fix/server-level-dat-fallback


📝 Commits (2)

  • 4e8bdad The dedicated server takes level.dat_old when level.dat does not read
  • b1c5484 Optimize world: level.dat_old stands in for a level.dat that does not read

📊 Changes

5 files changed (+60 additions, -4 deletions)

View changed files

📝 crates/horizon-client/src/game/world_loading.rs (+9 -0)
📝 crates/horizon-client/src/save.rs (+45 -0)
📝 crates/horizon-client/src/title.rs (+2 -0)
📝 tools/port_map/game2-023.tsv (+3 -3)
📝 tools/port_map/rest-025.tsv (+1 -1)

📄 Description

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

Refs #3517 (rows LevelStorageAccess.getUnfixedDataTagWithFallback and restoreLevelDataFromOld, the server side). Follows #4219, which did the client side.

What and why

A dedicated server whose world has a level.dat that does not read, but a good level.dat_old, refused to start: "Open it from the world list to try restoring level.dat_old". A server has no world list. Vanilla's server Main reads the level data with getUnfixedDataTagWithFallback: it logs the failure, reads level.dat_old instead and calls restoreLevelDataFromOld, and only stops when both files are broken.

  • save::fall_back_to_level_dat_old: when level.dat does not read and level.dat_old does, level.dat_old takes its place and the broken file is kept as level.dat_corrupted_<time> (the existing restore_level_data_from_old). It does nothing when level.dat reads, when there is no level.dat_old, or when both are broken.
  • world_loading calls it first when the game is a dedicated server. The client keeps asking on RecoverWorldDataScreen, as WorldOpenFlows does.
  • "Optimize world" calls it too, as OptimizeWorldScreen.create reads the level data through the same method.
  • Port map: collectIssues, restoreLevelDataFromOld and getUnfixedDataTagWithFallback are port, and readLevelSummary no longer says an unreadable level.dat is left out of the list (all of that was #4219; the rows still said missing).

Vanilla reference

LevelStorageSource.LevelStorageAccess.getUnfixedDataTagWithFallback (LevelStorageSource.java:550), called by net.minecraft.server.Main (line 136) and OptimizeWorldScreen.create (line 53). Read before changing: in the client the same method is not what opens a world; WorldOpenFlows opens the recovery screen, which #4219 ported.

How it was checked

  • Unit test a_server_falls_back_to_level_dat_old_and_restores_it: both files broken and only a broken level.dat_old do nothing; a good level.dat_old takes the place and the broken file is kept once; a readable level.dat is left alone.
  • A real dedicated server (horizon-client --dedicated --nogui, scratch HORIZON_HOME): created a world, copied level.dat to level.dat_old, cut level.dat to 40 bytes, started again. The log says level.dat of ".../world" did not read; level.dat_old took its place, the server reaches Done (1.5s)!, and the folder holds level.dat, level.dat_old and level.dat_corrupted_2026-10-31_02-23-50.
  • pr_ready --quick: fmt, clippy, 1252 horizon-client tests, 481 python tests pass; parity harnesses left to CI.

Not the same as vanilla: after restoring, vanilla also runs the data fixers on the restored tag; here the world's normal open path does.

🤖 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/4879 **Author:** [@xFedeT](https://github.com/xFedeT) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@rdbtCVS](https://github.com/rdbtCVS) **Base:** `main` ← **Head:** `fix/server-level-dat-fallback` --- ### 📝 Commits (2) - [`4e8bdad`](https://github.com/horizon-rust/horizon/commit/4e8bdad87100a447ef2794bfbd297d6f4ffefbf3) The dedicated server takes level.dat_old when level.dat does not read - [`b1c5484`](https://github.com/horizon-rust/horizon/commit/b1c5484243450d55900984124d61abe0e8630d36) Optimize world: level.dat_old stands in for a level.dat that does not read ### 📊 Changes **5 files changed** (+60 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/world_loading.rs` (+9 -0) 📝 `crates/horizon-client/src/save.rs` (+45 -0) 📝 `crates/horizon-client/src/title.rs` (+2 -0) 📝 `tools/port_map/game2-023.tsv` (+3 -3) 📝 `tools/port_map/rest-025.tsv` (+1 -1) </details> ### 📄 Description > 🤖 Opened by xFedeT's AI agent (Claude Code, Claude Sonnet 5.5), not by xFedeT personally. Refs #3517 (rows `LevelStorageAccess.getUnfixedDataTagWithFallback` and `restoreLevelDataFromOld`, the server side). Follows #4219, which did the client side. ## What and why A dedicated server whose world has a `level.dat` that does not read, but a good `level.dat_old`, refused to start: "Open it from the world list to try restoring level.dat_old". A server has no world list. Vanilla's server `Main` reads the level data with `getUnfixedDataTagWithFallback`: it logs the failure, reads `level.dat_old` instead and calls `restoreLevelDataFromOld`, and only stops when both files are broken. - `save::fall_back_to_level_dat_old`: when `level.dat` does not read and `level.dat_old` does, `level.dat_old` takes its place and the broken file is kept as `level.dat_corrupted_<time>` (the existing `restore_level_data_from_old`). It does nothing when `level.dat` reads, when there is no `level.dat_old`, or when both are broken. - `world_loading` calls it first when the game is a dedicated server. The client keeps asking on `RecoverWorldDataScreen`, as `WorldOpenFlows` does. - "Optimize world" calls it too, as `OptimizeWorldScreen.create` reads the level data through the same method. - Port map: `collectIssues`, `restoreLevelDataFromOld` and `getUnfixedDataTagWithFallback` are `port`, and `readLevelSummary` no longer says an unreadable `level.dat` is left out of the list (all of that was #4219; the rows still said `missing`). ## Vanilla reference `LevelStorageSource.LevelStorageAccess.getUnfixedDataTagWithFallback` (`LevelStorageSource.java:550`), called by `net.minecraft.server.Main` (line 136) and `OptimizeWorldScreen.create` (line 53). Read before changing: in the client the same method is not what opens a world; `WorldOpenFlows` opens the recovery screen, which #4219 ported. ## How it was checked - Unit test `a_server_falls_back_to_level_dat_old_and_restores_it`: both files broken and only a broken `level.dat_old` do nothing; a good `level.dat_old` takes the place and the broken file is kept once; a readable `level.dat` is left alone. - A real dedicated server (`horizon-client --dedicated --nogui`, scratch `HORIZON_HOME`): created a world, copied `level.dat` to `level.dat_old`, cut `level.dat` to 40 bytes, started again. The log says `level.dat of ".../world" did not read; level.dat_old took its place`, the server reaches `Done (1.5s)!`, and the folder holds `level.dat`, `level.dat_old` and `level.dat_corrupted_2026-10-31_02-23-50`. - `pr_ready --quick`: fmt, clippy, 1252 horizon-client tests, 481 python tests pass; parity harnesses left to CI. Not the same as vanilla: after restoring, vanilla also runs the data fixers on the restored tag; here the world's normal open path does. 🤖 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 05:15: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#5911
No description provided.