Tinkers Construct

Tinkers Construct

160M Downloads

Illegal direct reload listener reference

cpw opened this issue ยท 2 comments

commented

Do not directly register onto the reload listener, because you can unwittingly become a source of problems, if something else falls over elsewhere.

manager.addReloadListener(new BlueColorReloadListener());
manager.addReloadListener(new PurpleColorReloadListener());
manager.addReloadListener(new OrangeColorReloadListener());

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.

commented

Some notes from Discord:

  • AddReloadListenerEvent is for datapacks. Forge team is looking into a client side version
  • ISelectiveReloadListener is deprecated. Might be worth our own interface to replace that using ModLoader.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.

commented

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.