From 3d20af9a9c751051eda37c9ebcddcf67fdc26c6d Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Tue, 13 Oct 2026 03:27:20 +0200 Subject: [PATCH] Datafix: every server fix ported; saves without a DataVersion upgrade from -1 --- crates/horizon-client/src/save.rs | 7 +++---- crates/horizon-world/src/datafix/mod.rs | 14 +++++++------- docs/world-data.md | 2 +- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/crates/horizon-client/src/save.rs b/crates/horizon-client/src/save.rs index 274ad9820..1b1a21d18 100644 --- a/crates/horizon-client/src/save.rs +++ b/crates/horizon-client/src/save.rs @@ -121,10 +121,9 @@ pub fn upgrade_older_world(world: &Path) -> Result<()> { let Some(root) = read_dat(&world.join("level.dat")) else { return Ok(()); }; - let version = root - .get("Data") - .and_then(|d| number(d.get("DataVersion"))) - .unwrap_or(i64::from(DATA_VERSION)); + let version = root.get("Data").map_or(i64::from(DATA_VERSION), |d| { + number(d.get("DataVersion")).unwrap_or(-1) // saves of 1.8 and before have none + }); if version >= i64::from(DATA_VERSION) { return Ok(()); } diff --git a/crates/horizon-world/src/datafix/mod.rs b/crates/horizon-world/src/datafix/mod.rs index 0d04bb63f..014c84614 100644 --- a/crates/horizon-world/src/datafix/mod.rs +++ b/crates/horizon-world/src/datafix/mod.rs @@ -1,13 +1,13 @@ -//! Vanilla's DataFixers from the 1.19 schemas on (`net.minecraft.util.datafix`): -//! the data of worlds saved by 1.18.2 to 26.2 brought to the 26.3 format exactly +//! Vanilla's DataFixers (`net.minecraft.util.datafix`, DataVersion 99 on): +//! the data of worlds saved by 1.8 to 26.2 brought to the 26.3 format exactly //! as 26.3 does when it reads them, and the file fixes it runs when it opens //! such a world (`net.minecraft.util.filefix`). //! //! DataFixerUpper reads the data once with the schema of its version (running //! the schema's read hooks), applies every fix with a key above that version //! in order, and writes it with the current schema. Each fix finds its values -//! with the schema just below its own key ([`schema`]). Data older than -//! [`OLDEST_SUPPORTED`] needs fixes that are not ported. The fixes of client +//! with the schema just below its own key ([`schema`]). Every +//! fix of the server data is ported ([`OLDEST_SUPPORTED`]). The fixes of client //! files (options, hotbars, debug profiles) are not ported either. mod block_state_data; mod chunk_flatten; @@ -34,9 +34,9 @@ use schema::{Key, Ty, key, walk}; /// The DataVersion of the game. pub const CURRENT: i32 = crate::DATA_VERSION; -/// Data saved before this DataVersion (1.17 is 2724) needs fixes that are not -/// ported (2717 and everything before). -pub const OLDEST_SUPPORTED: i32 = 2571; +/// Data saved before this DataVersion needs fixes that are not ported. Every +/// server fix is, down to the saves of 1.8, which have no DataVersion (read as -1). +pub const OLDEST_SUPPORTED: i32 = -1; /// `Identifier.tryParse` validity, as `NamespacedSchema.ensureNamespaced` uses it. pub fn identifier(id: &str) -> Option<(String, String)> { diff --git a/docs/world-data.md b/docs/world-data.md index 57543de8f..59b6049b7 100644 --- a/docs/world-data.md +++ b/docs/world-data.md @@ -68,7 +68,7 @@ The registry loader checks data version, duplicate states, default IDs and block-name coverage. The local oracle exports all 35,723 state identities and defaults from vanilla. This imports identities, not block implementations, shapes or behavior. Registry exports and game-derived fixtures stay in `.local/`. -Chunk access requires data version 5023. A world saved by an older version is upgraded when it is opened, as 26.3 does: the file fixes (`FileFixerUpper`) and level.dat, then vanilla's DataFixers over every chunk, entity chunk, POI chunk, player, saved data, advancements and statistics file (`horizon_world::datafix`; vanilla upgrades each file as it reads it, Horizon all of them on opening). `tools/test_datafix_parity.py` compares the result with vanilla's own upgrade over worlds written by older server jars. Worlds older than the ported fixes are refused with a message pointing at `tools/upgrade_world.py`, which runs vanilla's `--forceUpgrade` on a copy. `BlockRegistry::resolve` rejects invalid property descriptors. The separate +Chunk access requires data version 5023. A world saved by an older version is upgraded when it is opened, as 26.3 does: the file fixes (`FileFixerUpper`) and level.dat, then vanilla's DataFixers over every chunk, entity chunk, POI chunk, player, saved data, advancements and statistics file (`horizon_world::datafix`; vanilla upgrades each file as it reads it, Horizon all of them on opening). `tools/test_datafix_parity.py` compares the result with vanilla's own upgrade over worlds written by older server jars. Every server data fix is ported, from the saves of 1.8 (no DataVersion) on; only the fixes of client files (options, hotbars) are not. `BlockRegistry::resolve` rejects invalid property descriptors. The separate [block-state JSON codec](block-state-codecs.md) reproduces vanilla property fallback for compact and full JSON forms.