Fabric API

Fabric API

111M Downloads

[1.21] How to obtain registry access instance for data pack reload listeners registered to `ResourceManagerHelper`?

Fuzss opened this issue ยท 3 comments

commented

A lot of data pack reload listeners such as for recipes, tags, and loot tables in vanilla require a registry access instance for decorating JsonOps when deserializing JsonElements.

Personally my JsonElements contain item references. How can I obtain a registry access instance for deserializing those elements?

The equivalent NeoForge event provides the necessary RegistryAccess instance: https://github.com/neoforged/NeoForge/blob/1.21.x/src/main/java/net/neoforged/neoforge/event/AddReloadListenerEvent.java

commented

Resource reload events are in need of big refactors - for now use ServerLifecycleEvents.

commented

Which event in ServerLifecycleEvents would that be?

I tried ServerLifecycleEvents.SERVER_STARTING, ServerLifecycleEvents.SERVER_STARTED, and ServerLifecycleEvents.START_DATA_PACK_RELOAD and all run after the server resource manager has already reloaded all listeners. Tested on both a dedicated server and joining a singleplayer world.

commented

Ill take a look at this, I think I have a reasonable fix for this.