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/<v>-<loader>/<v>-<loader>.jar`; a player who only played such a
profile has no `versions/<v>/`, 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 <noreply@anthropic.com>
This commit is contained in:
Ludovic Marie
2026-10-25 17:26:03 +01:00
parent e99414e9d3
commit 65d3edfc3a
2 changed files with 41 additions and 0 deletions
+18
View File
@@ -191,6 +191,24 @@ fn client_jars(base: &Path, version: &str) -> Vec<String> {
jars.push(jar);
}
}
jars.extend(loader_jars(base, version));
jars
}
/// The client jars the Modrinth App keeps for a mod loader's profile: `versions/<v>-<loader>/`,
/// 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<String> {
let prefix = format!("{version}-");
let mut jars: Vec<String> = 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
}
+23
View File
@@ -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");