Tavi007 Posted July 1, 2020 Posted July 1, 2020 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. Quote
ChampionAsh5357 Posted July 1, 2020 Posted July 1, 2020 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. Quote
Tavi007 Posted July 2, 2020 Author Posted July 2, 2020 (edited) 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, 2020 by Tavi007 Quote
ChampionAsh5357 Posted July 2, 2020 Posted July 2, 2020 Update your workspace to version 32.0.40 at least. It fixes the issue of FMLServerAboutToStartEvent being fired too late on an integrated server. Quote
Tavi007 Posted July 2, 2020 Author Posted July 2, 2020 I updated, but I still have the same issue. Maybe I will wait until a safe 1.16 version is realeased. Quote
Tavi007 Posted July 8, 2020 Author Posted July 8, 2020 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. Quote
ZephyrWolf_ Posted September 18, 2020 Posted September 18, 2020 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 Quote
Recommended Posts
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.