Until now the mod's translation strings have lived in a hand-written en_us.json file. This tutorial replaces that file with a NeoForge LanguageProvider so all translation keys are generated - keeping them consistent with your Java registries and catching typos at compile time.
gatherData method.Delete the Existing Lang File
Before running datagen you must remove the hand-written lang file so the generated one is not merged with stale entries. Delete:
Datagen will write a fresh copy to the generated resources directory, which the build already places on the resource-pack lookup path.
Language Provider
In your NeoForge data package, create ExampleLangProvider extending LanguageProvider. The superclass constructor takes the pack output, your mod ID, and the target locale:
The locale string ("en_us") determines the output file name. Datagen writes the result to assets/<modid>/lang/<locale>.json.
Adding Translations
LanguageProvider ships typed helpers for the most common registry objects. The addItem and addBlock variants accept a Supplier, so you can pass your DeferredHolder references directly - no .get() needed. For keys that have no dedicated helper (creative tabs, sound subtitles, advancement text) use the generic add(String key, String value) overload:
addEntityType(Supplier<EntityType<?>>, String), addEnchantment(Supplier<Enchantment>, String), and addEffect(Supplier<MobEffect>, String). Each resolves the registry key for you so the translation key always stays in sync with the registered name.Multiple Languages
To ship more than one language, create a separate LanguageProvider subclass per locale and register each one independently. Only the locale string passed to super() changes:
Each provider writes its own independent JSON file. You do not need to repeat keys that Minecraft would fall back to - any key missing from a non-English file falls back to en_us automatically in vanilla.
en_us. The French class above is shown for illustration only - you don't need to create it.Registering the Provider
Language files are client-side assets, so use event.includeClient() rather than event.includeServer():
Running Datagen
Run NeoForge Data. The generated file appears at:
Open it and verify every key from the deleted hand-written file is present. Launch the game and confirm item names, block names, creative tab labels, and advancement text all display correctly.
item.examplemod.iron_stick) it usually means either the generated file wasn't included in the resource pack path or the datagen run failed silently - check the run console for errors.You can find the source for this tutorial here:
View Source on GitHubCustom Entities (MultiLoader 1.21+)
Register an EntityType, create a PathfinderMob subclass with wandering and look-at goals, wire up attribute registration on both loaders, add a client-only renderer using a vanilla model, register a colour-tinted spawn egg, and generate entity loot tables.
Continue →