PreparableReloadListenerfor specifically json data
ResourcesWrapper<Example> DATA = ResourcesWrapper.data(Example.class, "directory")
- load from data packs on the logical server
ResourcesWrapper<Example> ASSETS = ResourcesWrapper.assets(Example.class, "directory")
- load from resource packs on the logical client
.json files in that directory of (data or resource) packs will be parsed into an object of your specified class. You can call
withGson(Gson) to specify a Gson instance to use for deserialization with your custom type adapters.
These methods will automatically register a listener with the appropriate mod loader API.
The runnable will be called immediately after loading your resources.
data: when the server starts or
/reloadcommand is used
- on the logical server only
assets: when the clint starts or the player presses
F3 + T
- on the logical client only
- Causes the values to be synced to all clients.
- This may only be called for data packs.
- Syncing happens when a player connects or after the onLoad action fires.
MergeRule defines how your objects will be combined into one when multiple packs include a file for the same resource location. It's just a function that converts a list of your objects to a single one (
For example, you could implement behaviour like tags where a
replace field is used to decide whether values should replace or be combined with values from previously loaded packs.
Reading Resource Values
entrySet()to get all values.
get(ResourceLocation)to get a specific value.
Make sure to only call these on the logical side where they will be loaded (or either if synced data).