#How to load custom data for mod

7 messages · Page 1 of 1 (latest)

modest nimbus
#

I have shop that I want to store it's stock as json within resources/data/mod_name, any examples I can base on? Article on wiki is outdated (ResourceManagerHelper.get is package-private)

kindred drift
#

create a singleton IdentifiableResourceReloadListener and mixin into ResourceManagerHelperImpl

modest nimbus
#

will try, thanks 🤝

orchid moat
#

please dont mixin to ResourceManagerHelperImpl classes. use the api

kindred drift
orchid moat
#

easiest option is to extend JsonDataLoader with your class, provide your location (data/<namespace>/<datatype>/<path> = <namespace>:<path>)

#

once you have that class, you call ResourceManagerHelper.get(ResourceType.SERVER_DATA).registerReloadListener(new YourClassHere()) in your mod initializer

in your jsondataloader class, the apply method can be used to handle the json that gets loaded in either via codec or otherwise.

if you have a codec (you should) then you can go further and use a DynamicRegistry and let everything be automatic