From 54b939e717c1c19d5ad329553a337543736ed435 Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Mon, 12 Oct 2026 17:46:50 +0200 Subject: [PATCH] WIP: unfinished old-saves parity work, stopped by Ludovic Uncommitted changes the agent had in progress when it was stopped on 2026-10-12; may not build or pass its harnesses yet. Co-Authored-By: Claude Opus 5.5 --- .../horizon-world/src/datafix/fixes_cliffs.rs | 289 ++++++++++++++++++ tools/datafix_scene.py | 3 +- tools/datafix_worlds.py | 2 +- 3 files changed, 292 insertions(+), 2 deletions(-) diff --git a/crates/horizon-world/src/datafix/fixes_cliffs.rs b/crates/horizon-world/src/datafix/fixes_cliffs.rs index 0826433c8..796268093 100644 --- a/crates/horizon-world/src/datafix/fixes_cliffs.rs +++ b/crates/horizon-world/src/datafix/fixes_cliffs.rs @@ -4,12 +4,55 @@ use super::dynamic::{ as_bool, as_byte_buffer, as_int, as_int_stream, as_long_stream, as_number, as_str, ceillog2, empty_map, remove, rename, set, stream, string, }; +use super::fixes_a::block_rename; use super::fixes_b::advancements_rename; use super::schema::{Key, Ty, key}; use super::{Cx, FixFn, renamer}; use crate::nbt::{Compound, JavaString, Tag}; pub(super) fn register(out: &mut Vec<(Key, FixFn)>) { + out.push((key(2679, 0), cauldron_rename)); + out.push((key(2680, 0), |cx| { + let t = &[("minecraft:grass_path", "minecraft:dirt_path")]; + cx.rename(Ty::ItemName, renamer(t)); + })); + out.push((key(2680, 0), |cx| { + block_rename(cx, &[("minecraft:grass_path", "minecraft:dirt_path")]) + })); + out.push((key(2690, 0), |cx| cx.rename(Ty::ItemName, renamer(COPPER)))); + out.push((key(2690, 0), |cx| block_rename(cx, COPPER))); + out.push((key(2691, 0), |cx| cx.rename(Ty::ItemName, renamer(WAXED_COPPER)))); + out.push((key(2691, 0), |cx| block_rename(cx, WAXED_COPPER))); + out.push((key(2693, 0), |cx| add_flag(cx, "has_increased_height_already", false))); + out.push((key(2696, 0), |cx| cx.rename(Ty::ItemName, renamer(GRIMSTONE)))); + out.push((key(2696, 0), |cx| block_rename(cx, GRIMSTONE))); + out.push((key(2700, 0), |cx| { + block_rename( + cx, + &[ + ("minecraft:cave_vines_head", "minecraft:cave_vines"), + ("minecraft:cave_vines_body", "minecraft:cave_vines_plant"), + ], + ) + })); + out.push((key(2701, 0), feature_pool_elements)); + out.push((key(2702, 0), arrow_pickup)); + out.push((key(2707, 0), |cx| add_flag(cx, "has_increased_height_already", true))); + out.push((key(2710, 0), |cx| { + stats_rename(cx, &[("minecraft:play_one_minute", "minecraft:play_time")]) + })); + out.push((key(2717, 0), |cx| { + cx.rename( + Ty::ItemName, + renamer(&[("minecraft:azalea_leaves_flowers", "minecraft:flowering_azalea_leaves")]), + ) + })); + out.push((key(2717, 0), |cx| { + block_rename( + cx, + &[("minecraft:azalea_leaves_flowers", "minecraft:flowering_azalea_leaves")], + ) + })); out.push((key(2825, 0), |cx| { add_flag(cx, "has_increased_height_already", false) })); @@ -308,6 +351,252 @@ fn structures_become_configured(cx: &mut Cx) { }); } +// ------------------------------------------------------------------ 2679 to 2717 + +/// `CauldronRenameFix`. +fn cauldron_rename(cx: &mut Cx) { + cx.each(Ty::BlockState, |v| { + if as_str(v.get("Name")).as_deref() != Some("minecraft:cauldron") { + return; + } + let level = v + .get("Properties") + .and_then(|p| as_str(p.get("level"))) + .unwrap_or_else(|| "0".into()); + if level == "0" { + remove(v, "Properties"); + } else { + set(v, "Name", string("minecraft:water_cauldron")); + } + }); +} + +const COPPER: &[(&str, &str)] = &[ + ("minecraft:weathered_copper_block", "minecraft:oxidized_copper_block"), + ("minecraft:semi_weathered_copper_block", "minecraft:weathered_copper_block"), + ("minecraft:lightly_weathered_copper_block", "minecraft:exposed_copper_block"), + ("minecraft:weathered_cut_copper", "minecraft:oxidized_cut_copper"), + ("minecraft:semi_weathered_cut_copper", "minecraft:weathered_cut_copper"), + ("minecraft:lightly_weathered_cut_copper", "minecraft:exposed_cut_copper"), + ("minecraft:weathered_cut_copper_stairs", "minecraft:oxidized_cut_copper_stairs"), + ("minecraft:semi_weathered_cut_copper_stairs", "minecraft:weathered_cut_copper_stairs"), + ("minecraft:lightly_weathered_cut_copper_stairs", "minecraft:exposed_cut_copper_stairs"), + ("minecraft:weathered_cut_copper_slab", "minecraft:oxidized_cut_copper_slab"), + ("minecraft:semi_weathered_cut_copper_slab", "minecraft:weathered_cut_copper_slab"), + ("minecraft:lightly_weathered_cut_copper_slab", "minecraft:exposed_cut_copper_slab"), + ("minecraft:waxed_semi_weathered_copper", "minecraft:waxed_weathered_copper"), + ("minecraft:waxed_lightly_weathered_copper", "minecraft:waxed_exposed_copper"), + ("minecraft:waxed_semi_weathered_cut_copper", "minecraft:waxed_weathered_cut_copper"), + ("minecraft:waxed_lightly_weathered_cut_copper", "minecraft:waxed_exposed_cut_copper"), + ("minecraft:waxed_semi_weathered_cut_copper_stairs", "minecraft:waxed_weathered_cut_copper_stairs"), + ("minecraft:waxed_lightly_weathered_cut_copper_stairs", "minecraft:waxed_exposed_cut_copper_stairs"), + ("minecraft:waxed_semi_weathered_cut_copper_slab", "minecraft:waxed_weathered_cut_copper_slab"), + ("minecraft:waxed_lightly_weathered_cut_copper_slab", "minecraft:waxed_exposed_cut_copper_slab"), +]; + +const WAXED_COPPER: &[(&str, &str)] = &[ + ("minecraft:waxed_copper", "minecraft:waxed_copper_block"), + ("minecraft:oxidized_copper_block", "minecraft:oxidized_copper"), + ("minecraft:weathered_copper_block", "minecraft:weathered_copper"), + ("minecraft:exposed_copper_block", "minecraft:exposed_copper"), +]; + +const GRIMSTONE: &[(&str, &str)] = &[ + ("minecraft:grimstone", "minecraft:deepslate"), + ("minecraft:grimstone_slab", "minecraft:cobbled_deepslate_slab"), + ("minecraft:grimstone_stairs", "minecraft:cobbled_deepslate_stairs"), + ("minecraft:grimstone_wall", "minecraft:cobbled_deepslate_wall"), + ("minecraft:polished_grimstone", "minecraft:polished_deepslate"), + ("minecraft:polished_grimstone_slab", "minecraft:polished_deepslate_slab"), + ("minecraft:polished_grimstone_stairs", "minecraft:polished_deepslate_stairs"), + ("minecraft:polished_grimstone_wall", "minecraft:polished_deepslate_wall"), + ("minecraft:grimstone_tiles", "minecraft:deepslate_tiles"), + ("minecraft:grimstone_tile_slab", "minecraft:deepslate_tile_slab"), + ("minecraft:grimstone_tile_stairs", "minecraft:deepslate_tile_stairs"), + ("minecraft:grimstone_tile_wall", "minecraft:deepslate_tile_wall"), + ("minecraft:grimstone_bricks", "minecraft:deepslate_bricks"), + ("minecraft:grimstone_brick_slab", "minecraft:deepslate_brick_slab"), + ("minecraft:grimstone_brick_stairs", "minecraft:deepslate_brick_stairs"), + ("minecraft:grimstone_brick_wall", "minecraft:deepslate_brick_wall"), + ("minecraft:chiseled_grimstone", "minecraft:chiseled_deepslate"), +]; + +/// `SavedDataFeaturePoolElementFix`: the feature of jigsaw pieces' feature pool +/// elements, from an inline configuration to a configured feature id. +fn feature_pool_elements(cx: &mut Cx) { + cx.each(Ty::StructureFeature, |v| { + let Some(children) = v.get("Children") else { + return; + }; + if !super::dynamic::is_list(Some(children)) { + return; + } + let fixed = stream(Some(children)) + .into_iter() + .map(|mut child| { + let id = as_str(child.get("id")).unwrap_or_default(); + if !matches!( + id.as_str(), + "minecraft:jigsaw" + | "minecraft:nvi" + | "minecraft:pcp" + | "minecraft:bastionremnant" + | "minecraft:runtime" + ) { + return child; + } + let element = child.get("pool_element"); + let is_feature = element.and_then(|e| as_str(e.get("element_type"))).as_deref() + == Some("minecraft:feature_pool_element"); + if is_feature + && let Some(f) = child + .get_mut("pool_element") + .and_then(|p| p.get_mut("feature")) + && let Some(new) = feature_replacement(f) + { + *f = string(new); + } + child + }) + .collect(); + set(v, "Children", Tag::List(fixed)); + }); +} + +fn path_str(v: &Tag, path: &[&str]) -> String { + let mut cur = Some(v.clone()); + for p in path { + cur = match (cur, p.strip_prefix('[').and_then(|s| s.strip_suffix(']'))) { + (Some(c), Some(index)) => { + let i: usize = index.parse().unwrap_or(usize::MAX); + stream(Some(&c)).into_iter().nth(i) + } + (Some(c), None) => c.get(p).cloned(), + (None, _) => None, + }; + } + as_str(cur.as_ref()).unwrap_or_default() +} + +/// `SavedDataFeaturePoolElementFix.getReplacement`. +fn feature_replacement(value: &Tag) -> Option<&'static str> { + let ty = path_str(value, &["type"]); + let name = path_str(value, &["name"]); + let provider = path_str(value, &["config", "state_provider", "type"]); + let state = path_str(value, &["config", "state_provider", "state", "Name"]); + let first = path_str( + value, + &["config", "state_provider", "entries", "[0]", "data", "Name"], + ); + let foliage = path_str(value, &["config", "foliage_placer", "type"]); + let leaves = path_str(value, &["config", "leaves_provider", "state", "Name"]); + let feature = if !ty.is_empty() { + ty + } else if name.is_empty() { + return None; + } else if name == "minecraft:normal_tree" { + "minecraft:tree".to_owned() + } else { + name + }; + match feature.as_str() { + "minecraft:random_patch" => { + if provider == "minecraft:simple_state_provider" { + match state.as_str() { + "minecraft:sweet_berry_bush" => return Some("minecraft:patch_berry_bush"), + "minecraft:cactus" => return Some("minecraft:patch_cactus"), + _ => {} + } + } else if provider == "minecraft:weighted_state_provider" + && (first == "minecraft:grass" || first == "minecraft:fern") + { + return Some("minecraft:patch_taiga_grass"); + } + } + "minecraft:block_pile" => { + if provider != "minecraft:simple_state_provider" + && provider != "minecraft:rotated_block_provider" + { + if provider == "minecraft:weighted_state_provider" { + match first.as_str() { + "minecraft:packed_ice" | "minecraft:blue_ice" => { + return Some("minecraft:pile_ice"); + } + "minecraft:jack_o_lantern" | "minecraft:pumpkin" => { + return Some("minecraft:pile_pumpkin"); + } + _ => {} + } + } + } else { + match state.as_str() { + "minecraft:hay_block" => return Some("minecraft:pile_hay"), + "minecraft:melon" => return Some("minecraft:pile_melon"), + "minecraft:snow" => return Some("minecraft:pile_snow"), + _ => {} + } + } + } + "minecraft:flower" => return Some("minecraft:flower_plain"), + "minecraft:tree" => match foliage.as_str() { + "minecraft:acacia_foliage_placer" => return Some("minecraft:acacia"), + "minecraft:blob_foliage_placer" if leaves == "minecraft:oak_leaves" => { + return Some("minecraft:oak"); + } + "minecraft:pine_foliage_placer" => return Some("minecraft:pine"), + "minecraft:spruce_foliage_placer" => return Some("minecraft:spruce"), + _ => {} + }, + _ => {} + } + None +} + +/// `AbstractArrowPickupFix`. +fn arrow_pickup(cx: &mut Cx) { + cx.each(Ty::Entity, |e| { + let id = as_str(e.get("id")).map(|s| super::dynamic::namespaced(&s)); + if !matches!( + id.as_deref(), + Some("minecraft:arrow" | "minecraft:spectral_arrow" | "minecraft:trident") + ) || e.get("pickup").is_some() + { + return; + } + let from_player = as_bool(e.get("player"), true); + set(e, "pickup", Tag::Byte(i8::from(from_player))); + remove(e, "player"); + }); +} + +/// `StatsRenameFix`: custom statistics and the objectives that count them. +pub(super) fn stats_rename(cx: &mut Cx, table: &[(&str, &'static str)]) { + let r = renamer(table); + cx.each(Ty::Stats, |v| { + if let Some(Tag::Compound(custom)) = v + .get_mut("stats") + .and_then(|s| s.get_mut("minecraft:custom")) + { + let old = std::mem::take(custom); + for (k, value) in old { + let name = super::dynamic::namespaced(&k.to_string_lossy()); + let name = r(&name).map_or(name, str::to_owned); + custom.insert(JavaString::from(name.as_str()), value); + } + } + }); + cx.each(Ty::Objective, |v| { + if let Some(ct) = v.get_mut("CriteriaType") + && as_str(ct.get("type")).as_deref() == Some("minecraft:custom") + && let Some(id) = as_str(ct.get("id")) + { + let id = super::dynamic::namespaced(&id); + let new = r(&id).map_or(id, str::to_owned); + set(ct, "id", string(&new)); + } + }); +} + // ------------------------------------------------------------------ 2825 to 2843 /// `AddFlagIfNotPresentFix` over the world generation settings. diff --git a/tools/datafix_scene.py b/tools/datafix_scene.py index 265f614ec..384c33ae5 100644 --- a/tools/datafix_scene.py +++ b/tools/datafix_scene.py @@ -147,6 +147,7 @@ def items(e, version=None): ITEM_SINCE = { 'minecraft:goat_horn': 3105, 'minecraft:decorated_pot': 3327, + 'minecraft:axolotl_bucket': 2686, } @@ -309,7 +310,7 @@ def entities(e, version): ('allay', 'Inventory:[{id:"minecraft:diamond",Count:1b}]'), ('goat', ''), ] - since = {'allay': 3105, 'chest_boat': 3105, 'text_display': 3325, 'item_display': 3325} + since = {'allay': 3105, 'chest_boat': 3105, 'text_display': 3325, 'item_display': 3325, 'goat': 2700} out = [(k, x) for k, x in out if version >= since.get(k, 0)] if version < 3086: # cats before 1.19 have a numeric CatType out = [(k, 'CatType:1' if k == 'cat' else x) for k, x in out] diff --git a/tools/datafix_worlds.py b/tools/datafix_worlds.py index 27d1b19ce..e390dbf9f 100644 --- a/tools/datafix_worlds.py +++ b/tools/datafix_worlds.py @@ -37,7 +37,7 @@ LOCAL = ROOT / '.local' / 'datafix' # Old server jars and their worlds are inputs, not outputs: keep them beside the # vanilla data, which parallel worktrees share (.local/minecraft links there). SHARED = (ROOT / '.local' / 'minecraft').resolve().parent / 'datafix' -VERSIONS = ['1.17.1', '1.18.1', '1.18.2', '1.19', '1.19.2', '1.19.3', '1.19.4', '1.20.1', '1.20.2', '1.20.4', '1.20.5', '1.20.6', '1.21.1', +VERSIONS = ['1.16.5', '1.17.1', '1.18.1', '1.18.2', '1.19', '1.19.2', '1.19.3', '1.19.4', '1.20.1', '1.20.2', '1.20.4', '1.20.5', '1.20.6', '1.21.1', '1.21.3', '1.21.4', '1.21.5', '1.21.6', '1.21.8', '1.21.9', '1.21.10', '1.21.11', '26.1', '26.1.2', '26.2'] MANIFEST = 'https://piston-meta.mojang.com/mc/game/version_manifest_v2.json' LOCK = json.loads((ROOT / 'research-lock.json').read_text())['java_runtimes']