Kurt Mosiejczuk writes:

On Sun, Feb 28, 2021 at 10:49:05PM +0100, Peter Hessler wrote:
Now that multimc can play the most up to date version of Minecraft, here
is a patch to set it up to play 1.16 by default.

Of course I don't want to wreck the experience for people playing older versions or modded, so I added a pkg-readme, with instructions for how
to configure older versions.

Tested with 1.12, 1.16, and snap 21w08b.

Can you check this with known- tricky versions and combinations?

I wiped my $HOME/.local/share/multimc directory to ensure that I have a
clean-state.

I tried running the following:

* Minecraft 1.16.5 with Farbic Mod loader and the following
(performance enhancement) mods: Lithium[2], Sodium[3] and Phosphor[4].
* Minecraft 1.16.5 with Forge Mod loader and Optifine[5] (another
 performance enchanment mod).
* Minecraft 1.16.5 modpack called "All of Fabric 3"[6] which contains 170
 mods (with the addition of Sodium).
* Minecraft 1.12.2 with Forge Mod loader and Optifine.
* Minecraft 1.12.2 modpack called "RLCraft"[7] which contains 125 mods
 (with the addition of Optifine) and is currently the #1 modpack
 according to Curseforge.

Minecraft 1.12.2 with Forge Mod Loader still requires Java 8 as
mentioned below due to incompatibilities with Java 9 and above.

Other than that, 1.16.5 works fine and possibly with modern modloaders (such as the new Forge Mod Loader for newer versions and Fabric Mod Loader) which have changed how they load mods in order to comform with
reflective access restrictions imposed by Java 9.


+To play Minecraft 1.12 and older:
+# pkg_add lwjgl jdk%1.8
+Add the instance you wish to play, then Edit Instance | Settings +and change Java installation to use /usr/local/jdk-1.8.0/bin/java


I'm still confused about this Java 8 thing. I played lots of 1.12.2 with Java 11. This illegal reflection thing still just gets a warning that
it will start crashing in future. It doesn't crash though.

--Kurt

It's mainly due to Java 9 modules along with other major rework of the Java classloaders which causes old modloaders (and also some mods) that
are written before Java 9 was released.

Here's what I got from simply launching Minecraft 1.12 with Forge Mod
Loader and Optifine mod with Java 11 instead of Java 8:

Failed to start Minecraft:
java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.multimc.onesix.OneSixLauncher.launchWithMainClass(OneSixLauncher.java:196) at org.multimc.onesix.OneSixLauncher.launch(OneSixLauncher.java:231)
        at org.multimc.EntryPoint.listen(EntryPoint.java:143)
        at org.multimc.EntryPoint.main(EntryPoint.java:34)
Caused by: java.lang.ClassCastException: class jdk.internal.loader.ClassLoaders$AppClassLoader cannot be cast to class java.net.URLClassLoader (jdk.internal.loader.ClassLoaders$AppClassLoader and java.net.URLClassLoader are in module java.base of loader 'bootstrap') at net.minecraft.launchwrapper.Launch.<init>(Launch.java:34)
        at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
        ... 8 more
Exiting with -1

This can be simply solved by launching the game with Java 1.8.

If you're curious about the details on old modloaders vs new modloaders:

* The essential task of modloaders is to be able to add JARs to the classpath on runtime. This is done via classloaders which have the
   addURL method that allows this to happen.
* Old modloaders used to simply "hijack" the current classloader via reflections with the assumption that it's always URLClassLoader. * Java 9 and above done major rework to the Java classloader since it was a part of the entire Java 9 module system. As a result, the
   class loader wasn't always URLClassloader.
* Because of this, new modloaders now changed the way they load mods.
   Instead of hijacking the current classloader, they replace the
   mainClass which will start their "main function" instead of
Minecraft's with this they're able to replace whatever classloader that was used to theirs which allow provide the necessary things to
   add JAR files to the classpath.
 * High-level documentation on how fabric modloader works:
   https://fabricmc.net/wiki/documentation:fabric_loader
 * The code itself:
   
https://github.com/FabricMC/fabric-loader/blob/master/src/main/java/net/fabricmc/loader/launch/knot/Knot.java

[1]: https://github.com/CaffeineMC
[2]: https://github.com/CaffeineMC/lithium-fabric
[3]: https://github.com/CaffeineMC/sodium-fabric
[4]: https://github.com/CaffeineMC/phosphor-fabric
[5]: https://optifine.net
[6]: https://www.curseforge.com/minecraft/modpacks/all-of-fabric-3
[7]: https://www.curseforge.com/minecraft/modpacks/rlcraft

--
Muhammad Kaisar Arkhan
h...@yukiisbo.red - kai...@arkhan.io
https://yukiisbo.red - https://arkhan.io

Reply via email to