Skip to content

Crash with customizablemenus config #1540

@Rigner

Description

@Rigner

Describe the bug
Hey, I've been told about some crashes people are having when using your mod. After looking at the code, it seems that it doesn't handle setting the config directory to custom locations properly.

The relevant code: (this is 1.21.1 but the code is the same on other versions as well)
https://github.com/Keksuccino/FancyMenu/blob/v3-1.21.1/common/src/main/java/de/keksuccino/fancymenu/customization/ScreenCustomization.java#L66
https://github.com/Keksuccino/FancyMenu/blob/v3-1.21.1/common/src/main/java/de/keksuccino/fancymenu/customization/ScreenCustomization.java#L240-L243

2 issues there:

  • The config file path is not using the fabric config directory from FabricLoader.getConfigDir(), it is hardcoded to "config/"
  • If config/fancymenu doesn't exist, createNewFile() will throw an exception. A call to getParent().mkdirs() could be a solution to ensure the directories exist.

Edit: the same directory issue is also present here, but there's a mkdirs() call, so it doesn't break:
https://github.com/Keksuccino/FancyMenu/blob/v3-1.21.1-3.8.0/common/src/main/java/de/keksuccino/fancymenu/customization/customlocals/CustomLocalsHandler.java#L9

To Reproduce
Steps to reproduce the behavior (e.g.):

  1. Set a custom config directory for your installation, using launcher settings, or a running directory that is not .minecraft (and ensure you have no existing config/fancymenu directory)
  2. Boot the game

Expected behavior
The mod should be respecting the fabric config directory properly and not crash if it's not possible to create it.

Game Log
(for privacy reasons, I'll not send the whole file since it's irrelevant)

java.io.IOException: The system cannot find the path specified
 	at java.base/java.io.WinNTFileSystem.createFileExclusively0(Native Method)
 	at java.base/java.io.WinNTFileSystem.createFileExclusively(Unknown Source)
 	at java.base/java.io.File.createNewFile(Unknown Source)
 	at de.keksuccino.fancymenu.customization.ScreenCustomization.readCustomizableScreensFromFile(ScreenCustomization.java:231)
 	at de.keksuccino.fancymenu.customization.ScreenCustomization.isCustomizationEnabledForScreen(ScreenCustomization.java:202)
 	at de.keksuccino.fancymenu.customization.ScreenCustomization.isCustomizationEnabledForScreen(ScreenCustomization.java:190)
 	at de.keksuccino.drippyloadingscreen.customization.DrippyOverlayScreen.forceEnableCustomizations(DrippyOverlayScreen.java:42)
 	at de.keksuccino.drippyloadingscreen.customization.DrippyOverlayScreen.<init>(DrippyOverlayScreen.java:38)
 	at net.minecraft.class_425.<clinit>(SourceFile:34)
 	at net.minecraft.class_310.<init>(SourceFile:683)
 	at net.minecraft.client.main.Main.redirect$zfc000$lunar$main$minecraft(SourceFile:1181)
 	at net.minecraft.client.main.Main.main(SourceFile:239)

Screenshots
N/A

Basic Information (please complete the following information):

  • OS: Windows
  • FancyMenu Version: 3.8.0
  • Fabric Loader: 0.18.5
  • Minecraft Version: 1.21.1 (possibly others too)
  • Active Mods: N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions