Jomcraft-Network / DefaultSettings

DefaultSettings Minecraft Mod
https://www.curseforge.com/minecraft/mc-mods/defaultsettings
Apache License 2.0
3 stars 1 forks source link

Failed to load options java.lang.NullPointerException #12

Open ClaudiusMinimus opened 1 year ago

ClaudiusMinimus commented 1 year ago

One of my testers came across an interesting bug. He was testing an install build and the options set in DefaultSettings did not load - nothing but vanilla configs loaded. The result was none of my default configs loaded, so there was no custom menu, no quests, no custom settings, and most important, he loaded into a vanilla overworld and not my custom skyblock world. He is able to reproduce this issue, but I have not. I tried 4 or 5 times, but my installs were fine.

Minecraft: 1.19.2 Forge: 43.2.3 DefaultSettings: 1.19.x-2.8.7

This is how he reproduced the failed install:

  1. using whatever launcher go into create new instance/profile from zip file
  2. select Create_Skyblock_Forge_1.19.2-0.9.0.zip (This is an unpublished version for testing)
  3. wait for it to install
  4. copy over an existing options.txt to the instance folder (_see troubleshoot-0_9_package.zip also contains log files, and the pack's default configs_)
  5. launch the pack
  6. observe problem: dev menu, no quests, normal world
  7. close everything, manually delete the options.txt file
  8. re-launch the pack
  9. observe everything is fixed because default settings applied

The player believes it is step 4 is the cause. In troubleshoot-0_9_package.zip is his latest.log file and that is where I found the error Failed to load options java.lang.NullPointerException

I also did a file comparison between his options.txt (on left) and the one that comes with the pack in config/defaultsettings/Default (on right) and it looks like all of his keybindings are in his file. image

zaftnotameni commented 1 year ago

i'm the one that originally reported this to @ClaudiusMinimus

OS is windows 10 if that matters.

The fact that there is a lot in this options file kind of makes sense because i bring it with me over from pack to pack (mostly because of things like fov, ui scale, volume settings, quest keybinds).

Reproducing the issue has been 100% consistent (in the 4 times i tried) for me.

PT400C commented 1 year ago

Thank you very much for reporting that bug! It really is a strange one. Especially the NullPointerException is odd.

To mitigate this you might wanna swap step 4 and 5 (also stop the game after step 5 has finished). Under certain circumstances the mod doesn't really know what to do when the options.txt already exists on the first startup (end-user's side of the pack). It expects it to not be there.

Does it work if you do it this way?

Next month I'll dive deeper into the mod to iron out all those weird problems that have been there for some time. Including this one ofc.

zaftnotameni commented 1 year ago

To mitigate this you might wanna swap step 4 and 5 (also stop the game after step 5 has finished). Under certain circumstances the mod doesn't really know what to do when the options.txt already exists on the first startup (end-user's side of the pack). It expects it to not be there.

yes, as I described in the reproduction steps, even after the problem has happened, if I just delete options.txt and re-launch, everything works.

so this isn't really a blocker for anyone, just costs a game reload.


as you said i imagine the source of the problem is in the assumption that it is not the first boot if options.txt is present , maybe there's a different way to detect that

https://github.com/Jomcraft-Network/DefaultSettings/blob/5c9c008a185e89233aeb6e88d6314356718ef06b/src/main/java/net/jomcraft/defaultsettings/FileUtil.java#L61

PT400C commented 1 year ago

Yeah, you pointed out the exact problem. That check via the options.txt is fine in most cases but inappropriate in others.

I'll substitute that with a custom solution that isn't dependent on any Minecraft files :) It should be fixed by the next major release in Feb/Mar 2023.

Note: For further reference, there's also the core library playing it's role. https://github.com/Jomcraft-Network/JCPlugin/blob/28594bbdaeb0b8e6a37c795dd972e6d12922f806/src/main/java/net/jomcraft/jcplugin/FileUtilNoMC.java#L265