Illegal direct reload listener reference
cpw opened this issue ยท 2 comments
Do not directly register onto the reload listener, because you can unwittingly become a source of problems, if something else falls over elsewhere.
Use the AddReloadListenerEvent to register your reload handler, or query ModLoader.isLoadingStateValid() before doing anything with the game state (including requesting resources), as otherwise you could cause a secondary crash, because something else failed and the game is trying to get to an error screen.
Some notes from Discord:
AddReloadListenerEvent
is for datapacks. Forge team is looking into a client side versionISelectiveReloadListener
is deprecated. Might be worth our own interface to replace that usingModLoader.isLoadingStateValid()
in Mantle or in Forge- Probably affects most of our client resource listeners and the fix should be applied to all, that one is just the most obvious as it pulls a resource pack feature
Those listeners need a rewrite anyways, should not be three classes for them. So whoever on our team that fixes it consider making the code cleaner at the same time.
Fixed in 8460817. Key detail is we never needed to throw an exception there at all, probably vanilla code did and it was a direct copy. All the errors for that method are now just logged and ignored, and if the mod loading state is invalid it never runs the color reload at all.