neoforged / Documentation

The repository containing Neo's documentation
MIT License
26 stars 41 forks source link

Document valid characters for logoFile in neoforge.mods.toml #157

Open cpburnz opened 2 weeks ago

cpburnz commented 2 weeks ago

The documentation for logoFile in neoforge.mods.toml on the Mod Files page makes no mention of the valid characters for logoFile. I was told on Discord the valid characters are lowercase letters, digits, dashes, periods, and underscores. Since uppercase letters were supported in Forge (in my experience), it may be beneficial to note what they are.

If you attempt to use uppercase letters in logoFile, Minecraft will crash when viewing the mod information with an error similar to:

java.lang.IllegalArgumentException: Illegal segment Mod_Logo.png in path [Mod_Logo.png]
    at TRANSFORMER/minecraft@1.20.6/net.minecraft.FileUtil.validatePath(FileUtil.java:175) ~[client-1.20.6-20240429.153634-srg.jar%23172!/:?] {re:classloading}
    at TRANSFORMER/minecraft@1.20.6/net.minecraft.server.packs.PathPackResources.getRootResource(PathPackResources.java:43) ~[client-1.20.6-20240429.153634-srg.jar%23172!/:?] {re:classloading}
    ...

This was tested in NeoForge 20.6.119 and 20.4.237.

sciwhiz12 commented 2 weeks ago

The reason uppercase characters worked in the past was because NeoForge used to have its own class net.neoforged.neoforge.resource.PathPackResources which powered the resource-handling for mod JARs, and was consequently used when getting the logo file from the mod JAR as a root resources.

However in #284 / 1.20.2, we removed that class in favor of vanilla's own implementation in net.minecraft.server.packs.PathPackResources. In doing so, we inherited the restrictions of the vanilla class, which includes enforcing essentially the same restrictions on regular resources (accessed by resource location) on root resources (accessed by string paths) -- only lowercase letters, digits, underscore, periods, and hyphens.