On 2/12/21 10:32 AM, Peter Hessler wrote:
On 2021 Feb 11 (Thu) at 22:47:10 +0100 (+0100), Muhammad Kaisar Arkhan wrote:
:On 2/11/21 9:43 PM, Muhammad Kaisar Arkhan wrote:
:> Hello ports@,
:>
:> Thanks to games/lwjgl3 which was recently imported to the ports tree. It
:> is now possible to play Minecraft 1.13 and above.
:>
:> This patch adds support for launching Minecraft 1.13 and above by
:> generating and applying a OneSix library patch to make MultiMC use the
:> system-wide LWJGL library instead of the version that's from Mojang when
:> you launch Minecraft. A lot of changes to MultiMC was also done to make
:> it load libraries outside of MultiMC's libraries folder.
:>
:> OK?
:>
:
:Here's an updated diff because I forgot to remove a unimportant log print for
:debugging purposes.
:
:It should be good now.
:

I gave the previous version of this diff a spin, and it worked for me
with 1.12.2, 1.16.5, and the most recent snapshot 21w06a.

I did get an error about glfw when I first started it, but once I
switched to java 11 instead of java 8 it just worked.

Should we modify the port to use java 11?



The reason why it crashed on Java 8 and runs on Java 11 is because of LWJGL being compiled on Java 11 which generates a JNI (Java Native Interface) that's incompatible with Java 8.

From my experience, I get this exception:
java.lang.NoSuchMethodError: java.nio.ByteBuffer.position(I)Ljava/nio/ByteBuffer;

This is a rather common issue and the typical solution is to compile the JNI with Java 8.

If you compile games/lwjgl3 with Java 8 by changing `MODJAVA_VER` to 1.8, it'll work fine. I'm not sure if this causes issues or not down the line when running with Java 11, I suspect it'll loose optimizations which are possible on Java 9 and above.

Also, I would rather not make games/multimc to only use Java 11 mainly because in older versions of Minecraft (1.12 and below) especially with mods, the game will crash due to strict rules surrounding "reflective access" introduced in Java 9, the main reason of why the game still ships with Java 8 on Windows.

You could try by launching Minecraft 1.12 and only install the Forge Mod Loader (Edit Instance -> Version -> Install Forge), it will crash due to illegal reflective access on Java 11.

I'm not sure what's the correct way to solve this issue, I was thinking about having two FLAVOR of games/lwjgl3, one compiled with Java 8 for compatibility reasons and the other compiled with Java 11 which will have all of the fancy optimizations.

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

Reply via email to