From 65d3edfc3a1fc391f99dd091e41d031857a61583 Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Sun, 25 Oct 2026 17:26:03 +0100 Subject: [PATCH] Launcher: find the client jar of a Modrinth App mod loader profile (#1783) The Modrinth App keeps a Fabric or Quilt profile's vanilla client jar as `versions/-/-.jar`; a player who only played such a profile has no `versions//`, and Prepare said Minecraft was not found. Those jars are now candidates too, checked against the pinned sha1 like the rest. Co-Authored-By: Claude Opus 5.5 --- launcher/src/sources.rs | 18 ++++++++++++++++++ launcher/src/sources_tests.rs | 23 +++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/launcher/src/sources.rs b/launcher/src/sources.rs index b27b8417b..50953067e 100644 --- a/launcher/src/sources.rs +++ b/launcher/src/sources.rs @@ -191,6 +191,24 @@ fn client_jars(base: &Path, version: &str) -> Vec { jars.push(jar); } } + jars.extend(loader_jars(base, version)); + jars +} + +/// The client jars the Modrinth App keeps for a mod loader's profile: `versions/-/`, +/// the vanilla jar under the loader's name, when only a Fabric or Quilt profile of the version +/// was ever played (#1783). The jar is checked against the pin like the others. +fn loader_jars(base: &Path, version: &str) -> Vec { + let prefix = format!("{version}-"); + let mut jars: Vec = fs::read_dir(base.join("versions")) + .into_iter() + .flatten() + .flatten() + .filter_map(|entry| entry.file_name().into_string().ok()) + .filter(|name| name.starts_with(&prefix)) + .map(|name| format!("versions/{name}/{name}.jar")) + .collect(); + jars.sort(); jars } diff --git a/launcher/src/sources_tests.rs b/launcher/src/sources_tests.rs index 6d882f032..396f50881 100644 --- a/launcher/src/sources_tests.rs +++ b/launcher/src/sources_tests.rs @@ -289,6 +289,29 @@ fn the_modrinth_app_atlauncher_and_gdlauncher_are_found() { } } +/// A Modrinth App that only ever played a Fabric profile of 26.3 keeps the vanilla client jar +/// under the loader's name (#1783); a profile of another version beside it is not taken. +#[test] +fn a_modrinth_loader_profile_has_the_client_jar() { + let s = Scratch::new("modrinth-fabric"); + s.write( + "ModrinthApp/meta/versions/26.3.1-0.18.1/26.3.1-0.18.1.jar", + b"other", + ); + let jar = "versions/26.3-0.18.1/26.3-0.18.1.jar"; + let dir = s.launcher("ModrinthApp", "meta", jar); + s.write( + "ModrinthApp/meta/versions/26.3-0.18.1/26.3-0.18.1.json", + br#"{"id":"26.3-0.18.1","inheritsFrom":"26.3"}"#, + ); + let profile = dir.join("profiles/Fabric 26.3"); + fs::create_dir_all(&profile).unwrap(); + let linked = s.0.join("linked"); + let got = resolve_with(&profile, &[], &linked, &Mojang::new(MANIFEST)).unwrap(); + assert_eq!(got, linked); + assert_linked(&linked, &dir.join("meta"), jar); +} + #[test] fn an_instance_folder_may_be_chosen() { let s = Scratch::new("instance");