[FIX] Forge 1.17+ exit crash

This commit is contained in:
Gravita 2022-04-07 22:09:20 +07:00
parent 2709cbe95f
commit dc27fc04aa

View file

@ -349,19 +349,19 @@ private static void launch(ClientProfile profile, ClientLauncherProcess.ClientPa
}
FMLPatcher.apply();
LauncherEngine.modulesManager.invokeEvent(new ClientProcessPreInvokeMainClassEvent(params, profile, args));
{
List<String> compatClasses = profile.getCompatClasses();
for (String e : compatClasses) {
Class<?> clazz = classLoader.loadClass(e);
MethodHandle runMethod = MethodHandles.publicLookup().findStatic(clazz, "run", MethodType.methodType(void.class));
runMethod.invoke();
}
}
MethodHandle mainMethod = MethodHandles.lookup().findStatic(mainClass, "main", MethodType.methodType(void.class, String[].class)).asFixedArity();
Launcher.LAUNCHED.set(true);
JVMHelper.fullGC();
// Invoke main method
try {
{
List<String> compatClasses = profile.getCompatClasses();
for (String e : compatClasses) {
Class<?> clazz = classLoader.loadClass(e);
MethodHandle runMethod = MethodHandles.publicLookup().findStatic(clazz, "run", MethodType.methodType(void.class));
runMethod.invoke();
}
}
MethodHandle mainMethod = MethodHandles.lookup().findStatic(mainClass, "main", MethodType.methodType(void.class, String[].class)).asFixedArity();
Launcher.LAUNCHED.set(true);
JVMHelper.fullGC();
mainMethod.invokeWithArguments((Object) args.toArray(new String[0]));
LogHelper.debug("Main exit successful");
} catch (Throwable e) {