Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to launch Minecraft on versions past 1.18.2 #78

Open
Cinder4198 opened this issue Feb 24, 2024 · 2 comments
Open

Unable to launch Minecraft on versions past 1.18.2 #78

Cinder4198 opened this issue Feb 24, 2024 · 2 comments

Comments

@Cinder4198
Copy link

Cinder4198 commented Feb 24, 2024

When launching any Minecraft version after 1.18.2 through the API, the game doesn't launch and returns this error in the output stream:

[22:39:08] [Datafixer Bootstrap/INFO]: 198 Datafixer optimizations took 308 milliseconds
[22:39:10] [Render thread/INFO]: [STDERR]: java.lang.NoClassDefFoundError: Could not initialize class com.mojang.blaze3d.systems.RenderSystem
[22:39:10] [Render thread/INFO]: [STDERR]: 	at ab.a(SourceFile:66)
[22:39:10] [Render thread/INFO]: [STDERR]: 	at evi.a(SourceFile:2605)
[22:39:10] [Render thread/INFO]: [STDERR]: 	at evi.a(SourceFile:2580)
[22:39:10] [Render thread/INFO]: [STDERR]: 	at net.minecraft.client.main.Main.main(SourceFile:233)
[22:39:10] [Render thread/INFO]: [STDERR]: Caused by: java.lang.ExceptionInInitializerError: Exception java.lang.UnsatisfiedLinkError: Failed to locate library: liblwjgl.so [in thread "Render thread"]
[22:39:10] [Render thread/INFO]: [STDERR]: 	at org.lwjgl.system.Library.loadSystem(Library.java:174)
[22:39:10] [Render thread/INFO]: [STDERR]: 	at org.lwjgl.system.Library.loadSystem(Library.java:64)
[22:39:10] [Render thread/INFO]: [STDERR]: 	at org.lwjgl.system.Library.<clinit>(Library.java:52)
[22:39:10] [Render thread/INFO]: [STDERR]: 	at org.lwjgl.system.MemoryUtil.<clinit>(MemoryUtil.java:100)
[22:39:10] [Render thread/INFO]: [STDERR]: 	at eoz.<clinit>(SourceFile:8)
[22:39:10] [Render thread/INFO]: [STDERR]: 	at epw.<init>(SourceFile:49)
[22:39:10] [Render thread/INFO]: [STDERR]: 	at eqd.<init>(SourceFile:33)
[22:39:10] [Render thread/INFO]: [STDERR]: 	at com.mojang.blaze3d.systems.RenderSystem.<clinit>(SourceFile:51)
[22:39:10] [Render thread/INFO]: [STDERR]: 	at net.minecraft.client.main.Main.main(SourceFile:220)

Here's a bit of the code I'm using

File workingDirectory = new File(Platform.getCurrentPlatform().getWorkingDirectory().getPath());

MinecraftLauncherBackend mcLauncherBackend = new MinecraftLauncherBackend(workingDirectory);

System.out.println(mcLauncherBackend.getVersionList());
String version = "1.20.4";

mcLauncherBackend.updateMinecraft(version, null);

ProcessBuilder mcProcessBuilder = mcLauncherBackend.launchMinecraft(loginSession, version);

File output;
output = new File("./temp.txt");
System.out.println(output.getAbsolutePath());
mcProcessBuilder.redirectOutput(output);


mcProcessBuilder.start();
System.out.println(workingDirectory);
System.out.println(Platform.getCurrentPlatform().getWorkingDirectory());

It launches fine when using 1.18.2 and versions below. I honestly don't know if I'm doing something wrong, or if there's something up with the api.

@Cinder4198
Copy link
Author

Turns out the natives folder is handled differently pre and post 1.19. Before, each version folder just had a natives folder with all the files in it, but after 1.19, it instead creates a new natives folder for each game launch, and removes it every time the game is quit. I tried manually making a new natives folder, but the game always clears it at the start of each launch, and copying the liblwjgl.so file I downloaded into it while its starting up didn't help.

The natives folder that minecraft generates on startup (when I'm using the normal minecraft launcher) is named '-natives-' and appears empty when I open it. I've been trying to figure out how to create my own natives folder and have the game use that, but I kind of have no idea what I'm doing so it's been kind of a struggle.

@Cinder4198
Copy link
Author

I made some code to work around the issue, its really scuffed but it works.
https://github.com/Cinder4198/MCLauncherAPINativesPatch

First, you want to use NativesVersionChecker to return a boolean for if the version needs the patch or not.
boolean isPost1_19 = new NativesVersionChecker().checker(<version>);

Then, if it returns true, use NativesDownloader to download the natives. You should run this after using MinecraftLauncherBackend.update. The first argument will be where your versions are stored, the second will be which version's natives to download, and the third will be which version folder to download them into. Usually the second and third argument will be the same, but this may not be the case if you're using a modded version or something.
if(isPost1_19)new NativesDownloader(<versionFolderLocation>, <versionNativesToDownload>, <versionFolderName>);

After that, use the NativesCommandPatcher to get a version of the launch command that will use the newly generated Natives folder instead of the default.

if(isPost1_19) patchedCommand = new NativesCommandPatcher().patcher(mcProcessBuilder.command(), profile.getVersion());

After that, just use the patched launch command in place of the normal one, then the game should launch. Hope this helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant