Resources and data
Packs in the mod jar
assets/ in the mod jar is added automatically as a client resource pack, and data/ as a server data pack.
- The pack ID is
poly/<mod id>. - It is a required pack and sits on top of vanilla.
- The format is the same as vanilla 26.2.
| Path | Purpose |
|---|---|
assets/<mod>/blockstates/<block>.json, models/block/…, textures/block/… | Block appearance |
assets/<mod>/items/<item>.json, models/item/…, textures/item/… | Item appearance |
assets/<mod>/lang/en_us.json, ko_kr.json | block.<mod>.<id>, item.<mod>.<id>, key.<mod>.<id>, key.category.<mod>.keybinds |
assets/<mod>/textures/entity/… | Mob textures |
assets/<mod>/sounds.json | Sound events |
assets/<mod>/particles/<path>.json, textures/particle/… | Particle sprites |
assets/<mod>/post_effect/<path>.json, shaders/post/… | Post-processing shaders |
data/<mod>/loot_table/blocks/<block>.json | Block drops (nothing drops if missing) |
data/<mod>/recipe/*.json | Recipes |
data/<mod>/advancement/*.json | Advancements |
data/<mod>/worldgen/…, dimension/…, dimension_type/…, damage_type/… | World generation, dimensions, damage types |
data/minecraft/tags/block/mineable/pickaxe.json ("replace": false) | Tool tags |
data/my_mod/loot_table/blocks/glow_block.json
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1.0,
"conditions": [{"condition": "minecraft:survives_explosion"}],
"entries": [{"type": "minecraft:item", "name": "my_mod:glow_block"}]
}
]
}
Reload listeners
Use these when your mod reads data files in its own format.
mod.resources().onDataReload("my_mod/spells", files -> { /* … */ }); // data/<ns>/my_mod/spells/**.json
mod.resources().onAssetReload("my_mod/tips", files -> { /* … */ }); // assets/… (client)
mod.resources().onDataFiles("my_mod/banners", ".txt", files -> { /* … */ }); // received as bytes; onAssetFiles exists too
onDataReloadandonAssetReloadgive you JSON files as aMap<ResourceId, String>.onDataFilesandonAssetFilesgive you files with the extension you specify as aMap<ResourceId, byte[]>.- A file ID is
<namespace>:<path under the directory>, and the pack with the higher priority wins. - Server data: read at startup and on
/reload, after the game data. It is called on the main thread at startup and on the server thread on/reload. - Client assets: read on the client thread at startup and on F3+T.
- If a file cannot be read or a listener fails, Poly Mod Loader logs
POLY-RESOURCE-003and continues.
If you read the result from another thread, publish it by replacing a volatile field as a whole.
static volatile Map<ResourceId, String> messages = Map.of();
mod.resources().onDataReload("my_mod_messages", files -> messages = files);
Error codes
| Code | Meaning |
|---|---|
POLY-RESOURCE-001 | Invalid reload directory |
POLY-RESOURCE-002 | Declared after registration closed |
POLY-RESOURCE-003 | File could not be read or listener failed (logged, then continues) |
POLY-CONTENT-004 | Unknown pack type |