fix: include version jar in classpath for Forge/NeoForge module resolution
The Minecraft client jar (version jar) contains all MC classes including PreparableReloadListener. Forges
This commit is contained in:
+4
-10
@@ -544,18 +544,13 @@ public class LaunchCommandBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
System.out.println(ZAnsi.cyan(" buildClasspathFromManifest: " + paths.size() + " libraries in classpath"));
|
System.out.println(ZAnsi.cyan(" buildClasspathFromManifest: " + paths.size() + " libraries in classpath"));
|
||||||
|
if (isForgeLike) {
|
||||||
|
System.out.println(ZAnsi.cyan(" Version ID: " + getVersionId() + " (MC: " + instance.getMinecraftVersion() + ")"));
|
||||||
|
System.out.println(ZAnsi.cyan(" Paths dir: " + instance.getPath().resolve("versions")));
|
||||||
|
}
|
||||||
|
|
||||||
Path versionJar = findVersionJar();
|
Path versionJar = findVersionJar();
|
||||||
if (versionJar != null) {
|
if (versionJar != null) {
|
||||||
// For Forge/NeoForge: do NOT add version jar to classpath.
|
|
||||||
// Forge loads Minecraft classes through its own module system
|
|
||||||
// (securejarhandler + BootstrapLauncher module layer). Having the
|
|
||||||
// version jar on the classpath creates an automatic module (e.g.
|
|
||||||
// _1._20._1) that conflicts with Forge's "minecraft" module,
|
|
||||||
// causing ResolutionException split-package errors.
|
|
||||||
if (isForgeLike) {
|
|
||||||
System.out.println(ZAnsi.cyan(" Skipping version jar for Forge/NeoForge (loaded via module system): " + versionJar.getFileName()));
|
|
||||||
} else {
|
|
||||||
if (isValidJar(versionJar)) {
|
if (isValidJar(versionJar)) {
|
||||||
paths.add(0, versionJar.toAbsolutePath().toString());
|
paths.add(0, versionJar.toAbsolutePath().toString());
|
||||||
System.out.println(ZAnsi.green(" Added version jar: " + versionJar.getFileName()));
|
System.out.println(ZAnsi.green(" Added version jar: " + versionJar.getFileName()));
|
||||||
@@ -564,7 +559,6 @@ public class LaunchCommandBuilder {
|
|||||||
Files.delete(versionJar);
|
Files.delete(versionJar);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
String separator = System.getProperty("os.name").toLowerCase().contains("win") ? ";" : ":";
|
String separator = System.getProperty("os.name").toLowerCase().contains("win") ? ";" : ":";
|
||||||
return String.join(separator, paths);
|
return String.join(separator, paths);
|
||||||
|
|||||||
Reference in New Issue
Block a user