3arthqu4ke / headlessmc

Minecraft on the command line
https://3arthqu4ke.github.io/headlessmc/
MIT License
142 stars 16 forks source link

Versions command throws `java.lang.NullPointerException` #141

Closed chimbersaw closed 5 months ago

chimbersaw commented 5 months ago

Okay, since we figured out the more important bug, here's another one:

I get the java.lang.NullPointerException when running versions command on macos aarch64. Strangely, this does not happen on startup when the versions are printed in the similar manner. This also does not occur on ubuntu.

MacBook-Pro-Maxim:mine maxim$ java -jar headlessmc-launcher-1.9.4.jar 
[12:09:10] [main/WARNING] [VersionService]: ForgeOptiFine 1.16.1.json, class me.earth.headlessmc.launcher.version.VersionParseException: null
[12:09:10] [main/WARNING] [VersionService]: Fabric 1.19.3.json, class me.earth.headlessmc.launcher.version.VersionParseException: null
[12:09:10] [main/WARNING] [VersionService]: ForgeOptiFine 1.16.1.json, class me.earth.headlessmc.launcher.version.VersionParseException: null
[12:09:10] [main/WARNING] [VersionService]: Fabric 1.19.3.json, class me.earth.headlessmc.launcher.version.VersionParseException: null
[12:09:10] [main/INFO] [Main]: Detected: OS(name=Mac OS X, type=OSX, version=13.4.1, arch=true)
[12:09:10] [main/INFO] [Main]: Minecraft Dir: /Users/maxim/Library/Application Support/minecraft
id   name                          parent
0    1.19.3                        
2    fabric-loader-0.15.9-1.19.3   1.19.3
versions
java.lang.NullPointerException
    at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
    at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625)
    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
    at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
    at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    at java.base/java.util.stream.ReferencePipeline.reduce(ReferencePipeline.java:662)
    at java.base/java.util.stream.ReferencePipeline.max(ReferencePipeline.java:698)
    at me.earth.headlessmc.util.Table.lambda$build$0(Table.java:55)
    at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
    at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625)
    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
    at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
    at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
    at me.earth.headlessmc.util.Table.build(Table.java:58)
    at me.earth.headlessmc.launcher.version.VersionUtil.makeTable(VersionUtil.java:25)
    at me.earth.headlessmc.launcher.command.VersionsCommand.execute(VersionsCommand.java:22)
    at me.earth.headlessmc.command.CommandContextImpl.executeCommand(CommandContextImpl.java:39)
    at me.earth.headlessmc.command.CommandContextImpl.execute(CommandContextImpl.java:26)
    at me.earth.headlessmc.command.line.ConsoleListener.listen(ConsoleListener.java:22)
    at me.earth.headlessmc.command.line.CommandLineImpl.listen(CommandLineImpl.java:26)
    at me.earth.headlessmc.launcher.Main.runHeadlessMc(Main.java:91)
    at me.earth.headlessmc.launcher.Main.main(Main.java:36)

Expected behaviour:

maxim@xxxxx:~/hypixel$ java -jar headlessmc-launcher-1.9.4.jar 
[10:13:05] [main/INFO] [Main]: Detected: OS(name=Linux, type=LINUX, version=5.15.0-101-generic, arch=true)
[10:13:05] [main/INFO] [Main]: Minecraft Dir: /home/maxim/.minecraft
id   name                          parent
0    1.19.3                        
1    fabric-loader-0.15.9-1.19.3   1.19.3
versions
id   name                          parent
0    1.19.3                        
1    fabric-loader-0.15.9-1.19.3   1.19.3
chimbersaw commented 5 months ago

Not related to the topic: I have been wondering why isn't the -lwjgl flag enabled by default if that is the main point of headlessmc? If you want to keep it that way, its okay, but I then encourage you to explicitly state this in the How to use section of the README. I personally found out how to actually run mc headless with your project via browsing your github issues. The other way could be using help launch but imo this crucial info should be reflected in the readme.

3arthqu4ke commented 5 months ago

HeadlessMC does not print all versions at startup, e.g. I do not print snapshots since the official launcher adds new ones everytime so the output would be huge.

There might be some version.json in your .minecraft/versions that has a badly formed json? An id field might be missing. I will look into making the parsing more robust so that such malformed versions get filtered out.

Not related to the topic: I have been wondering why isn't the -lwjgl flag enabled by default if that is the main point of headlessmc?

Yes, very true. I will do that when I have time to also rewrite the documentation, it sucks rn. There is the hmc.invert.lwjgl.flag property which makes the lwjgl flag work the other way around.

chimbersaw commented 5 months ago

There might be some version.json in your .minecraft/versions that has a badly formed json? An id field might be missing. I will look into making the parsing more robust so that such malformed versions get filtered out.

Yes, I have found out that there is one version of minecraft causing the problem, which was installed by a 3rd party launcher.

Yes, very true. I will do that when I have time to also rewrite the documentation, it sucks rn. There is the hmc.invert.lwjgl.flag property which makes the lwjgl flag work the other way around.

Okay, thanks!

3arthqu4ke commented 5 months ago

https://github.com/3arthqu4ke/headlessmc/actions/runs/8580610588

You can also try this version, it should not crash anymore on that version. (I think)

chimbersaw commented 5 months ago

https://github.com/3arthqu4ke/headlessmc/actions/runs/8580610588

You can also try this version, it should not crash anymore on that version. (I think)

Yes, there is now crash now, thx

FYI, the parsing problem initially happens at ArgumentFactory#57, where the json has "values" field while you try to parse the "value" field.

image

IDK who is right and who is wrong, just going to provide you with the problematic .json file if you wish to modify your parsing to support this: Fabric 1.19.3.json

chimbersaw commented 5 months ago

Fixed in 1.9.4

chimbersaw commented 5 months ago

Okay sorry