TerraformersMC / ModMenu

A menu for, you guessed it, mods!
MIT License
509 stars 157 forks source link

[1.21.3] Mods will have an non-functional config button when `ModMenuApi#getModConfigScreenFactory` is not implemented. #797

Open MrCrayfish opened 5 days ago

MrCrayfish commented 5 days ago

In my mod Configured, I only provide config screens for other mods using ModMenuApi#getProvidedConfigScreenFactories, I do not provide one to the mod itself. However, as of https://github.com/TerraformersMC/ModMenu/commit/4fd1eb7fe056dc89656bc6a93363fd73070a6a9b and https://github.com/TerraformersMC/ModMenu/commit/39f0fcf8d01cecdce08505a4ee748f08abd9cb6f, ModMenu will now believe that Configured itself has a config and will show a config button that is non-functional when clicked. My implementation of ModMenuApi#getProvidedConfigScreenFactories has also explicitly ensured that a config screen is not provided by itself.

Solution, default implementation of getModConfigScreenFactory should return null instead of an empty factory, then check for null before putting into ModMenu#configScreenFactories map. I am not sure what implications this will have changing the default implementation, but I don't see another way to detect if a mod has a config screen without an expensive to ConfigScreenFactory#create.

MrCrayfish commented 5 days ago

As a temporary solution, I've implemented getModConfigScreenFactory to return null instead of screen -> null.