From d88ab085b5b684bd72257993be87262ca4257798 Mon Sep 17 00:00:00 2001 From: objz Date: Mon, 25 May 2026 20:58:05 +0200 Subject: [PATCH] fixed: forge/neoforge libraries from instance .minecraft/libraries not on classpath modern forge's installer places some libraries (notably the bootstrap library that defines ForgeBootstrap / BootstrapLauncher) into the instance's .minecraft/libraries/ rather than the shared meta cache. the unified classpath loop introduced in the rework checked downloads.artifact first and pushed meta_dir/libraries/ without ever consulting the local installer dir for libraries that had downloads.artifact set. resolve a single relative path per library (downloads.artifact.path if present, else maven_coord_to_path(name)), then for has_local_libs check the local installer dir first regardless of which path source we used. fixes ClassNotFoundException at launch on forge 1.20.6 and likely similar versions. --- src/instance/launch/mod.rs | 44 +++++++++++++++++++++++++++----------- 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/src/instance/launch/mod.rs b/src/instance/launch/mod.rs index ecf6356..1556c66 100644 --- a/src/instance/launch/mod.rs +++ b/src/instance/launch/mod.rs @@ -310,21 +310,32 @@ pub async fn launch( continue; } - if let Some(artifact) = lib.downloads.as_ref().and_then(|d| d.artifact.as_ref()) { - classpath.push(lib_dir.join(&artifact.path)); - } else if let Some(rel) = crate::net::maven_coord_to_path(&lib.name) { - if has_local_libs { - let in_local = local_lib_dir.join(&rel); - let in_meta = lib_dir.join(&rel); - if in_local.exists() { - classpath.push(in_local); - } else if in_meta.exists() { - classpath.push(in_meta); - } - } else { - classpath.push(lib_dir.join(rel)); + // resolve a relative path for this library. prefer downloads.artifact.path + // when present (vanilla-style), fall back to maven_coord_to_path(name) + // for loader-style entries that only have a coord. + let rel: PathBuf = match lib + .downloads + .as_ref() + .and_then(|d| d.artifact.as_ref()) + .map(|a| PathBuf::from(&a.path)) + .or_else(|| crate::net::maven_coord_to_path(&lib.name).map(PathBuf::from)) + { + Some(p) => p, + None => continue, + }; + + // for forge/neoforge, the installer drops some libs (notably the + // bootstrap library) into /.minecraft/libraries/ rather + // than the shared meta cache. check there first regardless of + // whether the lib has a downloads.artifact entry. + if has_local_libs { + let in_local = local_lib_dir.join(&rel); + if in_local.exists() { + classpath.push(in_local); + continue; } } + classpath.push(lib_dir.join(rel)); } classpath.push( @@ -425,10 +436,12 @@ pub async fn launch( .join("versions") .join(&config.game_version) .join("natives"); + let version_type = merged_profile.type_.as_deref().unwrap_or("release"); let template_ctx = TemplateContext { library_directory: &lib_dir, classpath_separator: sep, version_name: &config.game_version, + version_type, natives_directory: &natives_dir, classpath: &cp_str, game_directory: &minecraft_dir, @@ -443,6 +456,8 @@ pub async fn launch( launcher_name: "rmcl", launcher_version: env!("CARGO_PKG_VERSION"), clientid: "0", + resolution_width: "", + resolution_height: "", }; let (upstream_jvm_args, game_args) = @@ -620,6 +635,9 @@ mod tests { launcher_name: "rmcl", launcher_version: "test", clientid: "0", + version_type: "release", + resolution_width: "", + resolution_height: "", }; let features = FeatureSet::default(); let rule_ctx = RuleContext {