Posted July 1, 20205 yr Hello, I'm updating my mod to 1.16 and I can't find a way to add my reloadListener. Here is a code-snipped: @SubscribeEvent public void onServerAboutToStart(FMLServerAboutToStartEvent event) { // worked in 1.15.2 //event.getServer().getResourcePacks().addReloadListener(DATAMANAGER); LOGGER.info("Elemental data registered."); } DATAMANGER is a class, that extends jsonReloadListener. I looked through the options of ResourcePacks, but I can't find a similar function to addReloadListener.
July 1, 20205 yr MinecraftServer now uses a different system called DataPackRegistries to combine the reload and initialization of the listeners in one place. To access it, use: ((IReloadableResourceManager) event.getServer().getDataPackRegistries().func_240970_h_()).addReloadListener(listener); Note that the cast is necessary as the function returns an IResourceManager compared to its stored IReloadableResourceManager variable.
July 2, 20205 yr Author Thank you for your answer! I got the code to compile and I assume my ReloadListener was added. However none of the data got loaded. I tested a little bit and noticed, that my implemented apply() function of DataManager is never called. Previously this function was called whenever I start playing a world or when I use the /reload-command . That's not happining now. Any idea, what the problem might be? My repo if you want to have a deeper look: https://github.com/Tavi007/ElementalCombat Edited July 2, 20205 yr by Tavi007
July 2, 20205 yr Update your workspace to version 32.0.40 at least. It fixes the issue of FMLServerAboutToStartEvent being fired too late on an integrated server.
July 2, 20205 yr Author I updated, but I still have the same issue. Maybe I will wait until a safe 1.16 version is realeased.
July 8, 20205 yr Author I bump this thread up, since I still have the same issue. The DataManager never calls the apply() function and therefor never loads the json files. I also look through the forge issue tracker to see, if it is a known issue, but it's not listed.
September 18, 20205 yr I don't know if you still having issues, but I do have a working re-loadable resource myself. I registered it slightly differently though: public ModConst () { MinecraftForge.EVENT_BUS.addListener( this::addResourceReload ); } private void addResourceReload ( final AddReloadListenerEvent event ) { event.addListener( new CustomReloadListener() ); } For me, extending JsonReloadListener was all I needed. I hope this helps someone. Playing 1.16.2 Forge 33.0.5
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.