Skip to content

Commit

Permalink
Initial support for Forge 1.20.4 (with a few minor issues).
Browse files Browse the repository at this point in the history
Removed the converter project.
  • Loading branch information
ZekerZhayard committed Dec 19, 2023
1 parent fb7f889 commit a3413eb
Show file tree
Hide file tree
Showing 12 changed files with 51 additions and 336 deletions.
54 changes: 0 additions & 54 deletions converter/build.gradle

This file was deleted.

This file was deleted.

This file was deleted.

13 changes: 0 additions & 13 deletions converter/src/main/resources/mmc-pack.json

This file was deleted.

28 changes: 0 additions & 28 deletions converter/src/main/resources/patches/template.json

This file was deleted.

2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

org.gradle.daemon = false

fw_version = 1.5.7
fw_version = 1.5.8
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.lang.module.ModuleReference;
import java.lang.module.ResolvedModule;
import java.lang.reflect.Field;
import java.net.URL;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.HashMap;
Expand Down Expand Up @@ -159,6 +160,15 @@ private static class ParserData {
}
}

public static void setupClassPath(Path libraryDir, List<String> paths) throws Throwable {
Class<?> urlClassPathClass = Class.forName("jdk.internal.loader.URLClassPath");
Object ucp = IMPL_LOOKUP.findGetter(Class.forName("jdk.internal.loader.BuiltinClassLoader"), "ucp", urlClassPathClass).invokeWithArguments(ClassLoader.getSystemClassLoader());
MethodHandle addURLMH = IMPL_LOOKUP.findVirtual(urlClassPathClass, "addURL", MethodType.methodType(void.class, URL.class));
for (String path : paths) {
addURLMH.invokeWithArguments(ucp, libraryDir.resolve(path).toUri().toURL());
}
}

// ForgeWrapper need some extra settings to invoke BootstrapLauncher.
public static Class<?> setupBootstrapLauncher(Class<?> mainClass) throws Throwable {
if (!mainClass.getModule().isOpen(mainClass.getPackageName(), ModuleUtil.class.getModule())) {
Expand Down
1 change: 0 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
rootProject.name = 'ForgeWrapper'

include 'common'
include 'converter'
include 'legacy'
include 'jigsaw'
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ public static void bootstrap(List<String> jvmArgs, String minecraftJar, String l
}
jvmArgs = replacedJvmArgs;

// Remove NewLaunch.jar from property to prevent Forge from adding it to the module path
StringBuilder newCP = new StringBuilder();
for (String path : System.getProperty("java.class.path").split(File.pathSeparator)) {
if (!path.endsWith("NewLaunch.jar")) {
newCP.append(path).append(File.pathSeparator);
}
}
System.setProperty("java.class.path", newCP.substring(0, newCP.length() - 1));

String modulePath = null;
List<String> addExports = new ArrayList<>();
List<String> addOpens = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public static void main(String[] args) throws Throwable {
}
}

ModuleUtil.setupClassPath(detector.getLibraryDir(), detector.getExtraLibraries(forgeGroup, forgeArtifact, forgeFullVersion));
Class<?> mainClass = ModuleUtil.setupBootstrapLauncher(Class.forName(detector.getMainClass(forgeGroup, forgeArtifact, forgeFullVersion)));
mainClass.getMethod("main", String[].class).invoke(null, new Object[] { args });
}
Expand Down
Loading

0 comments on commit a3413eb

Please sign in to comment.