From eebf5621bf5c937e585639a17fb9e900b854b250 Mon Sep 17 00:00:00 2001 From: rdbtCVS <87152661+rdbtCVS@users.noreply.github.com> Date: Wed, 14 Oct 2026 18:54:51 +0100 Subject: [PATCH 1/2] Fix classic menu panorama resource preparation --- crates/horizon-prepare/src/lib.rs | 15 +++- crates/horizon-prepare/src/main.rs | 22 ++++-- crates/horizon-prepare/src/sounds.rs | 109 +++++++++++++++++++++++++-- docs/native-client.md | 7 +- 4 files changed, 137 insertions(+), 16 deletions(-) diff --git a/crates/horizon-prepare/src/lib.rs b/crates/horizon-prepare/src/lib.rs index 246cb4d51..534abfc8a 100644 --- a/crates/horizon-prepare/src/lib.rs +++ b/crates/horizon-prepare/src/lib.rs @@ -17,7 +17,7 @@ pub mod pyjson; mod sounds; mod survival; -pub use sounds::sounds; +pub use sounds::{panorama, sounds}; use pyjson::Value; use sha2::Digest; @@ -452,7 +452,7 @@ pub fn prepare(options: &Options, log: Log) -> Result { origin, log, }; - steps(&run, &lock, &oracle)?; + steps(&run, &lock, &oracle, options.minecraft_dir.as_deref())?; log(&format!( "Prepared Horizon native-client resources: {}", resources.display() @@ -464,7 +464,12 @@ fn arg(path: &Path) -> String { path.display().to_string() } -fn steps(run: &Run, lock: &artifacts::Lock, oracle: &Path) -> Result<(), String> { +fn steps( + run: &Run, + lock: &artifacts::Lock, + oracle: &Path, + minecraft: Option<&Path>, +) -> Result<(), String> { let root = &run.resources; let repo = &run.root; let server_cp = run.server_classpath.as_str(); @@ -678,6 +683,10 @@ fn steps(run: &Run, lock: &artifacts::Lock, oracle: &Path) -> Result<(), String> count += 1; } + // The JAR holds only gray 1x1 panorama placeholders. Import the indexed + // textures afterwards, including on reruns that just extracted the JAR again. + panorama(repo, minecraft, run.log)?; + // One file each, exported again when the exporter or the jar it reads changed. let single = |what: &str, file: &str, diff --git a/crates/horizon-prepare/src/main.rs b/crates/horizon-prepare/src/main.rs index 1ef1387ad..4be86f525 100644 --- a/crates/horizon-prepare/src/main.rs +++ b/crates/horizon-prepare/src/main.rs @@ -10,6 +10,7 @@ horizon-prepare: prepare Horizon's resources from your own Minecraft Java Editio Usage: horizon-prepare [--prepare] [--server-jar PATH] [--minecraft-dir PATH] [--root PATH] horizon-prepare sounds [--minecraft-dir PATH] [--root PATH] + horizon-prepare panorama [--minecraft-dir PATH] [--root PATH] --prepare Import the pinned game files from your own copy first --server-jar PATH The pinned server jar you downloaded yourself @@ -23,6 +24,9 @@ Needs Minecraft played once from the official launcher, and Java (a JDK) of the research-lock.json pins: JAVA_HOME, else javac and java on the PATH. The resources go to /.local/horizon-client/; pass that to horizon-client --resources. +horizon-prepare panorama repairs the classic menu background in existing resources without Java. +Full preparation also imports these textures after extracting the client JAR's placeholders. + horizon-prepare sounds copies the pinned version's sounds (about 380 MB) from the official launcher's asset store into the same folder, checking every file. It is optional: without it the game is silent. Nothing is downloaded; it needs the version played once from the official launcher. @@ -52,7 +56,7 @@ fn main() -> ExitCode { }; let mut root = None; let mut args = std::env::args_os().skip(1).peekable(); - let sounds = args.next_if(|a| a == "sounds").is_some(); + let assets = args.next_if(|a| a == "sounds" || a == "panorama"); while let Some(arg) = args.next() { let text = arg.to_string_lossy().into_owned(); let (flag, inline) = match text.split_once('=') { @@ -71,8 +75,8 @@ fn main() -> ExitCode { } }; let parsed = match flag.as_str() { - "--prepare" | "--server-jar" if sounds => { - Err(format!("{flag} is for preparing, not for sounds")) + "--prepare" | "--server-jar" if assets.is_some() => { + Err(format!("{flag} is for preparing, not for asset copying")) } "--prepare" if inline.is_none() => { options.import = true; @@ -108,10 +112,14 @@ fn main() -> ExitCode { let _ = writeln!(out, "{line}"); let _ = out.flush(); }; - let result = if sounds { - horizon_prepare::sounds(&options.root, options.minecraft_dir.as_deref(), &log) - } else { - horizon_prepare::prepare(&options, &log) + let result = match assets.as_deref().and_then(|a| a.to_str()) { + Some("sounds") => { + horizon_prepare::sounds(&options.root, options.minecraft_dir.as_deref(), &log) + } + Some("panorama") => { + horizon_prepare::panorama(&options.root, options.minecraft_dir.as_deref(), &log) + } + _ => horizon_prepare::prepare(&options, &log), }; match result { Ok(_) => ExitCode::SUCCESS, diff --git a/crates/horizon-prepare/src/sounds.rs b/crates/horizon-prepare/src/sounds.rs index 75ed221a4..e0787656d 100644 --- a/crates/horizon-prepare/src/sounds.rs +++ b/crates/horizon-prepare/src/sounds.rs @@ -1,4 +1,4 @@ -//! The pinned version's sounds (sounds.json and the .ogg files) from the player's own official +//! The pinned version's sounds and title panorama from the player's own official //! launcher install, each object checked against the asset index's SHA-1, copied into //! `.local/horizon-client//assets` where the game reads them (tools/fetch_sounds.py and //! the tools/lab.py functions it called). Nothing is downloaded. @@ -76,6 +76,37 @@ fn is_sound(name: &str) -> bool { /// `.local/horizon-client/`; returns that folder. Files already there with the right /// SHA-1 are kept. pub fn sounds(root: &Path, minecraft: Option<&Path>, log: Log) -> Result { + copy_assets(root, minecraft, log, is_sound, "Sound", &[]) +} + +/// Replaces the client JAR's 1x1 title placeholders with the full panorama from the +/// launcher's asset store. Also usable on already-prepared resources without Java. +pub fn panorama(root: &Path, minecraft: Option<&Path>, log: Log) -> Result { + copy_assets(root, minecraft, log, is_panorama, "Panorama", &PANORAMA) +} + +const PANORAMA: [&str; 7] = [ + "minecraft/textures/gui/title/background/panorama_0.png", + "minecraft/textures/gui/title/background/panorama_1.png", + "minecraft/textures/gui/title/background/panorama_2.png", + "minecraft/textures/gui/title/background/panorama_3.png", + "minecraft/textures/gui/title/background/panorama_4.png", + "minecraft/textures/gui/title/background/panorama_5.png", + "minecraft/textures/gui/title/background/panorama_overlay.png", +]; + +fn is_panorama(name: &str) -> bool { + PANORAMA.contains(&name) +} + +fn copy_assets( + root: &Path, + minecraft: Option<&Path>, + log: Log, + wanted_asset: fn(&str) -> bool, + label: &str, + required: &[&str], +) -> Result { let lock = Lock::read(root)?; let minecraft = artifacts::minecraft_dir(minecraft); let manifest = artifacts::import_manifest(&lock, &minecraft)?; @@ -95,12 +126,17 @@ pub fn sounds(root: &Path, minecraft: Option<&Path>, log: Log) -> Result = Vec::new(); - for (name, info) in objects.iter().filter(|(name, _)| is_sound(name)) { + for (name, info) in objects.iter().filter(|(name, _)| wanted_asset(name)) { match wanted.iter_mut().find(|(n, _)| n == name) { Some(entry) => entry.1 = info, None => wanted.push((name, info)), } } + for name in required { + if !wanted.iter().any(|(n, _)| n == name) { + return Err(format!("{name} is missing from the asset index")); + } + } let mut total: u64 = 0; for (name, info) in &wanted { let hash = info @@ -125,7 +161,7 @@ pub fn sounds(root: &Path, minecraft: Option<&Path>, log: Log) -> Result Fixture { + Self::with_panorama(name, &PANORAMA) + } + + fn with_panorama(name: &str, panorama: &[&'static str]) -> Fixture { let dir = std::env::temp_dir().join(format!( "horizon-prepare-sounds-{name}-{}", std::process::id() @@ -159,12 +199,16 @@ mod tests { let _ = fs::remove_dir_all(&dir); let root = dir.join("horizon"); let minecraft = dir.join("minecraft"); - let objects: Vec<(&'static str, Vec)> = vec![ + let mut objects: Vec<(&'static str, Vec)> = vec![ ("minecraft/sounds.json", b"{\"a\": {}}".to_vec()), ("minecraft/sounds/ambient/cave1.ogg", b"OggS cave".to_vec()), ("minecraft/sounds/dig/stone1.ogg", b"OggS stone".to_vec()), ("minecraft/lang/fr_fr.json", b"{}".to_vec()), ]; + for &name in panorama { + // Distinct object bytes let the test catch swapped faces too. + objects.push((name, name.as_bytes().to_vec())); + } let mut index = String::from("{\"objects\": {"); for (i, (name, data)) in objects.iter().enumerate() { let hash = sha1_hex(data); @@ -243,6 +287,7 @@ mod tests { assert_eq!(&fs::read(target.join("assets").join(name)).unwrap(), data); } assert!(!target.join("assets/minecraft/lang").exists()); + assert!(!target.join("assets/minecraft/textures").exists()); assert_eq!( fs::read(target.join("asset-index.json")).unwrap(), fs::read(f.minecraft.join("assets/indexes/7.json")).unwrap() @@ -267,6 +312,60 @@ mod tests { assert!(f.run().unwrap_err().starts_with("Missing asset object")); } + #[test] + fn panorama_replaces_jar_placeholders_and_repairs_repeated_preparations() { + let f = Fixture::new("panorama"); + let target = f.root.join(".local/horizon-client/9.9"); + for _ in 0..2 { + // Full preparation extracts the JAR before importing the asset store. + for (name, _) in &f.objects[4..] { + let path = target.join("assets").join(name); + fs::create_dir_all(path.parent().unwrap()).unwrap(); + fs::write(path, b"1x1 gray placeholder").unwrap(); + } + assert_eq!( + panorama(&f.root, Some(&f.minecraft), &|_| {}).unwrap(), + target + ); + for (name, data) in &f.objects[4..] { + assert_eq!(&fs::read(target.join("assets").join(name)).unwrap(), data); + } + } + assert!(!target.join("assets/minecraft/sounds.json").exists()); + assert!(!target.join("assets/minecraft/lang").exists()); + } + + #[test] + fn panorama_objects_are_verified_before_replacing_placeholders() { + let f = Fixture::new("panorama-corrupt"); + fs::write(f.object(4), b"corrupt panorama").unwrap(); + let path = f + .root + .join(".local/horizon-client/9.9/assets") + .join(f.objects[4].0); + fs::create_dir_all(path.parent().unwrap()).unwrap(); + fs::write(&path, b"placeholder").unwrap(); + assert!(panorama(&f.root, Some(&f.minecraft), &|_| {}) + .unwrap_err() + .starts_with("Corrupt asset object")); + assert_eq!(fs::read(path).unwrap(), b"placeholder"); + fs::remove_file(f.object(4)).unwrap(); + assert!(panorama(&f.root, Some(&f.minecraft), &|_| {}) + .unwrap_err() + .starts_with("Missing asset object")); + } + + #[test] + fn panorama_requires_every_face_and_the_overlay_in_the_index() { + let f = Fixture::with_panorama("panorama-incomplete", &PANORAMA[..6]); + let error = panorama(&f.root, Some(&f.minecraft), &|_| {}).unwrap_err(); + assert_eq!( + error, + format!("{} is missing from the asset index", PANORAMA[6]) + ); + assert!(!f.root.join(".local/horizon-client/9.9/assets").exists()); + } + #[test] fn the_index_must_be_the_pinned_one() { let f = Fixture::new("index"); diff --git a/docs/native-client.md b/docs/native-client.md index 3081bac7c..f05199ba7 100644 --- a/docs/native-client.md +++ b/docs/native-client.md @@ -23,7 +23,12 @@ verifies it against the pinned checksums, runs vanilla's data generator and smal exporters against those jars, and extracts the jar's assets and data into ignored `.local/horizon-client/26.3/`. Sounds (about 380 MB) are copied from your launcher's asset store by `horizon-prepare sounds`, each file checked against the asset -index's SHA-1. Prepared resources are private; never commit them. +index's SHA-1. Preparation also replaces the JAR's gray 1×1 title panorama placeholders +with the full textures from that asset store. To repair an existing classic menu background +without rerunning the Java exporters, run `horizon-prepare panorama` (or +`cargo run --release -p horizon-prepare -- panorama` in a checkout). Pass +`--minecraft-dir PATH` when using a different Minecraft installation. +Prepared resources are private; never commit them. Preparation is `horizon-prepare` (`crates/horizon-prepare`, Rust): it needs no Python, only the JDK, for the small exporters that call Mojang's own code. Release folders ship it beside From aab88753b6825e83d88f12b21895a681b2964e5d Mon Sep 17 00:00:00 2001 From: rdbtCVS <87152661+rdbtCVS@users.noreply.github.com> Date: Wed, 14 Oct 2026 19:15:16 +0100 Subject: [PATCH 2/2] Keep title panorama optional during full resource preparation --- crates/horizon-prepare/src/lib.rs | 3 +- crates/horizon-prepare/src/sounds.rs | 59 ++++++++++++++++++++++++---- docs/native-client.md | 7 ++-- 3 files changed, 58 insertions(+), 11 deletions(-) diff --git a/crates/horizon-prepare/src/lib.rs b/crates/horizon-prepare/src/lib.rs index 534abfc8a..e1c165e8e 100644 --- a/crates/horizon-prepare/src/lib.rs +++ b/crates/horizon-prepare/src/lib.rs @@ -685,7 +685,8 @@ fn steps( // The JAR holds only gray 1x1 panorama placeholders. Import the indexed // textures afterwards, including on reruns that just extracted the JAR again. - panorama(repo, minecraft, run.log)?; + // Cosmetic assets are optional when preparing from already-imported JARs. + sounds::optional_panorama(repo, minecraft, run.log); // One file each, exported again when the exporter or the jar it reads changed. let single = |what: &str, diff --git a/crates/horizon-prepare/src/sounds.rs b/crates/horizon-prepare/src/sounds.rs index e0787656d..b18ed3426 100644 --- a/crates/horizon-prepare/src/sounds.rs +++ b/crates/horizon-prepare/src/sounds.rs @@ -85,6 +85,15 @@ pub fn panorama(root: &Path, minecraft: Option<&Path>, log: Log) -> Result, log: Log) { + if let Err(error) = panorama(root, minecraft, log) { + log(&format!( + "Title panorama not imported: {error}; run horizon-prepare panorama later" + )); + } +} + const PANORAMA: [&str; 7] = [ "minecraft/textures/gui/title/background/panorama_0.png", "minecraft/textures/gui/title/background/panorama_1.png", @@ -138,6 +147,7 @@ fn copy_assets( } } let mut total: u64 = 0; + let mut copies = Vec::with_capacity(wanted.len()); for (name, info) in &wanted { let hash = info .get("hash") @@ -151,15 +161,14 @@ fn copy_assets( let relative = artifacts::safe_relative(name) .ok_or_else(|| format!("Unsafe asset name {name:?} in the asset index"))?; let source = launcher_object(&store, hash)?; - artifacts::import_copy( - &source, - &target.join("assets").join(relative), - hash, - "sha1", - "", - )?; + copies.push((source, target.join("assets").join(relative), hash)); total += size; } + // Check the entire set before replacing any placeholders: a missing late face + // must not leave a mixture of real textures and gray faces in either entry point. + for (source, destination, hash) in copies { + artifacts::import_copy(&source, &destination, hash, "sha1", "")?; + } log(&format!( "{label} assets ready: {} files, {:.1} MB", wanted.len(), @@ -366,6 +375,42 @@ mod tests { assert!(!f.root.join(".local/horizon-client/9.9/assets").exists()); } + #[test] + fn full_preparation_keeps_placeholders_when_panorama_is_unavailable() { + for missing in ["store", "install", "last-object"] { + let f = Fixture::new(&format!("optional-panorama-{missing}")); + // The JARs and manifest were imported earlier; the launcher need not remain. + artifacts::import_manifest(&Lock::read(&f.root).unwrap(), &f.minecraft).unwrap(); + let target = f.root.join(".local/horizon-client/9.9/assets"); + for name in PANORAMA { + let path = target.join(name); + fs::create_dir_all(path.parent().unwrap()).unwrap(); + fs::write(path, b"jar placeholder").unwrap(); + } + match missing { + "store" => fs::remove_dir_all(f.minecraft.join("assets")).unwrap(), + "install" => fs::remove_dir_all(&f.minecraft).unwrap(), + _ => fs::remove_file(f.object(f.objects.len() - 1)).unwrap(), + } + // The repair subcommand remains strict, even for a missing final object. + let error = panorama(&f.root, Some(&f.minecraft), &|_| {}).unwrap_err(); + let lines = std::cell::RefCell::new(Vec::new()); + // This is the optional import step used by full preparation after extraction. + optional_panorama(&f.root, Some(&f.minecraft), &|line| { + lines.borrow_mut().push(line.to_string()) + }); + assert_eq!( + *lines.borrow(), + [format!( + "Title panorama not imported: {error}; run horizon-prepare panorama later" + )] + ); + for name in PANORAMA { + assert_eq!(fs::read(target.join(name)).unwrap(), b"jar placeholder"); + } + } + } + #[test] fn the_index_must_be_the_pinned_one() { let f = Fixture::new("index"); diff --git a/docs/native-client.md b/docs/native-client.md index f05199ba7..e51bd8e40 100644 --- a/docs/native-client.md +++ b/docs/native-client.md @@ -23,9 +23,10 @@ verifies it against the pinned checksums, runs vanilla's data generator and smal exporters against those jars, and extracts the jar's assets and data into ignored `.local/horizon-client/26.3/`. Sounds (about 380 MB) are copied from your launcher's asset store by `horizon-prepare sounds`, each file checked against the asset -index's SHA-1. Preparation also replaces the JAR's gray 1×1 title panorama placeholders -with the full textures from that asset store. To repair an existing classic menu background -without rerunning the Java exporters, run `horizon-prepare panorama` (or +index's SHA-1. Preparation also tries to replace the JAR's gray 1×1 title panorama +placeholders with the full textures from that asset store. If the store is missing or +incomplete, preparation logs a warning and keeps the placeholders. To import the panorama +later without rerunning the Java exporters, run `horizon-prepare panorama` (or `cargo run --release -p horizon-prepare -- panorama` in a checkout). Pass `--minecraft-dir PATH` when using a different Minecraft installation. Prepared resources are private; never commit them.