From 16738c9f26da6e98473498cb05a70a8232de677e Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Thu, 22 Oct 2026 08:10:30 +0200 Subject: [PATCH] Launcher: say when a prepared version has no sounds (#1035) A version prepared while the sound copy failed (Mojang's republished 26.3 asset index, #1076, fixed in #1091), or one that reused such a version's resources when installed, stays silent and showed as plain Prepared. The Play page now says it is prepared without its sounds and makes Prepare again the visible fix; versions --installed and the MCP list say so too. Co-Authored-By: Claude Opus 5.5 --- launcher/src/backend.rs | 50 +++++++++++++++++++++++++++++++++++++++++ launcher/src/cli.rs | 6 +++-- launcher/src/main.rs | 8 +++---- launcher/src/mcp.rs | 2 +- 4 files changed, 59 insertions(+), 7 deletions(-) diff --git a/launcher/src/backend.rs b/launcher/src/backend.rs index bcd932536..3423890d7 100644 --- a/launcher/src/backend.rs +++ b/launcher/src/backend.rs @@ -592,6 +592,32 @@ pub fn is_prepared(tag: &str) -> bool { resources(tag).join(RESOURCES_MANIFEST).exists() } +/// Whether a version's resources hold Minecraft's sounds, which `sounds` copies from the player's own +/// install beside the preparation. A version prepared while that copy failed (Mojang's republished 26.3 +/// asset index, #1076), or one that reused such a version's resources, plays no sound at all (#1035). +pub fn has_sounds(tag: &str) -> bool { + sounds_in(&resources(tag)) +} + +fn sounds_in(resources: &Path) -> bool { + // What the game's sound registry reads (horizon-client sound_events.rs). + resources.join("assets/minecraft/sounds.json").is_file() +} + +/// What the Play page says of a version's resources. +pub fn resources_summary(prepared: bool, sounds: bool, version: &str) -> String { + match (prepared, sounds) { + (false, _) => { + format!("Not prepared. Horizon needs the files of your own Minecraft {version}.") + } + (true, true) => format!("Prepared for Minecraft {version}"), + (true, false) => format!( + "Prepared for Minecraft {version}, without its sounds: the game will be silent. \ + Prepare again to copy them from your Minecraft install." + ), + } +} + /// Whether the resources `from` prepared are the ones preparing `to` would make. The output /// depends on the Horizon version, not only on Minecraft's: the manifest records the hashes of /// the vanilla exporters it was made with (mods/horizon/src/test/java/.../parity), and the @@ -2165,6 +2191,30 @@ mod tests { use super::*; use std::cmp::Ordering::*; + #[test] + fn resources_without_sounds_are_reported() { + let dir = std::env::temp_dir().join(format!("horizon-no-sounds-{}", std::process::id())); + let _ = fs::remove_dir_all(&dir); + fs::create_dir_all(dir.join("assets/minecraft/textures")).unwrap(); + fs::write(dir.join(RESOURCES_MANIFEST), "{}").unwrap(); + assert!(!sounds_in(&dir)); + fs::write(dir.join("assets/minecraft/sounds.json"), "{}").unwrap(); + assert!(sounds_in(&dir)); + fs::remove_dir_all(&dir).unwrap(); + + assert_eq!( + resources_summary(true, true, "26.3"), + "Prepared for Minecraft 26.3" + ); + let silent = resources_summary(true, false, "26.3"); + assert!(silent.contains("without its sounds") && silent.contains("Prepare again")); + // Not prepared says only that, sounds or not. + assert_eq!( + resources_summary(false, false, "26.3"), + resources_summary(false, true, "26.3") + ); + } + #[test] fn the_game_plays_under_its_own_audio_stream_name() { if std::env::var_os("PIPEWIRE_PROPS").is_some() { diff --git a/launcher/src/cli.rs b/launcher/src/cli.rs index 6dcb4b975..1151ee476 100644 --- a/launcher/src/cli.rs +++ b/launcher/src/cli.rs @@ -422,10 +422,12 @@ fn execute(command: Cmd, as_json: bool) -> Result<(), String> { } else { " " }; - let state = if backend::is_prepared(tag) { + let state = if !backend::is_prepared(tag) { + "not prepared" + } else if backend::has_sounds(tag) { "prepared" } else { - "not prepared" + "prepared, no sounds (prepare again)" }; println!("{mark} {tag} {state}"); } diff --git a/launcher/src/main.rs b/launcher/src/main.rs index 41bce0489..d2db14727 100644 --- a/launcher/src/main.rs +++ b/launcher/src/main.rs @@ -1388,6 +1388,8 @@ impl Launcher { )); }; let prepared = backend::is_prepared(&tag); + // Prepared without sounds (#1035): Prepare again is the fix, so it stands out. + let silent = prepared && !backend::has_sounds(&tag); let version = backend::game_version(&tag); let hero = self.hero(&tag, &version, prepared, cx); let running = self.client.is_some() || self.starting_client.is_some(); @@ -1429,15 +1431,13 @@ impl Launcher { let resources_value = if self.preparing { "Preparing…".to_string() - } else if prepared { - format!("Prepared for Minecraft {version}") } else { - format!("Not prepared. Horizon needs the files of your own Minecraft {version}.") + backend::resources_summary(prepared, !silent, &version) }; let mut prepare = button( "prepare", if prepared { "Prepare again" } else { "Prepare" }, - if prepared { + if prepared && !silent { Kind::Ghost } else { Kind::Secondary diff --git a/launcher/src/mcp.rs b/launcher/src/mcp.rs index ca2a81a87..3103961c0 100644 --- a/launcher/src/mcp.rs +++ b/launcher/src/mcp.rs @@ -85,7 +85,7 @@ impl Session { "list_versions" => { let installed = backend::installed(); let mut out = json!({ - "installed": installed.iter().map(|t| json!({ "tag": t, "prepared": backend::is_prepared(t) })).collect::>(), + "installed": installed.iter().map(|t| json!({ "tag": t, "prepared": backend::is_prepared(t), "sounds": backend::has_sounds(t) })).collect::>(), "selected": backend::resolve_version(None).ok(), }); if !args