Resources, data packs and localisation
Status: Partly implemented. The mod’s
assets/anddatapack/folders mount as packs (mod/<id>), lang files translatecl_text_translatablekeys, andlifecycle.resources_reloaded/lifecycle.data_reloadedfire after reloads. Reading resource or data files from code, reload listeners with their own stage, server-locale translation and sending server resource packs are Planned.
Concepts: Data-driven content.
Mod packs
| Folder in the mod | Mounted as | Contains |
|---|---|---|
assets/<ns>/ |
resource pack mod/<id> (above vanilla, below the player’s packs) |
textures, models, block states, item model definitions, sounds.json and sounds, lang files, fonts, shaders, GUI sprites |
datapack/<ns>/ |
data pack mod/<id> (above vanilla, below the world’s packs) |
recipes, loot tables, tags, advancements, enchantments, damage types, … |
The player’s resource packs and the world’s data packs can override mod files, exactly as with vanilla content.
Localisation
Put translations in assets/<ns>/lang/<locale>.json (en_us.json first; other locales fall back to it), in the vanilla format:
{
"item.my_mod.ruby": "Ruby",
"block.my_mod.ruby_block": "Block of Ruby",
"my_mod.welcome": "Welcome, %s!",
"key.my_mod.zoom": "Zoom",
"config.my_mod.gift.rubies": "Rubies on join"
}
| Key | Used for |
|---|---|
item.<ns>.<path>, block.<ns>.<path> |
Item and block names |
key.<ns>.<path> |
Keybind names in Controls |
config.<mod id>.<path> |
Labels on the Config page |
| anything else | cl_text_translatable(CL_STR("my_mod.welcome")) with cl_text_add_arg (Lua cl.text.translatable("my_mod.welcome", player.name)) |
Translatable text is translated on the client, in the player’s language, so the server sends one message to everyone.
Reload events
| Event | When |
|---|---|
lifecycle.resources_reloaded |
After a resource reload on the client (F3+T, the pack screen) |
lifecycle.data_reloaded |
After /reload on the server |
Planned
Reading raw resource files (client) and data files (server) from code, reload listeners that prepare data in the background, translating a key on the server for one player’s locale, and sending a server resource pack to players.