Skip to content

Datagen

wrldmap edited this page Oct 5, 2025 · 1 revision

Datagen was a pain to get working, so let me help you so you don't make the same mistakes I did.

The Main Class

The main datagen class, DataGenerators.java, is one of the simpler parts of the datagen system. It mainly just registers the datagen classes.

Block Loot Tables

This actually requires two classes, BlockLoot.java and ModLootTableProvider.java, the latter of which just does some magic to make it able to be registered. BlockLoot provides block drops for every block in the mod, since by default Minecraft doesn't drop self. It does some filtering stuff, so that the ore blocks get their raw ore drops, Graphite Ore gets its Graphite Dust drops, and the regular blocks drop self. I won't go into too much detail, as I think Kaupenjoe explained it pretty well.

Block Tags

Block Tags are defined in BlockTags.java. I only really use block tags to define that it requires pickaxe and of which tier. It finds the harvestLevel from TintableMaterialBlock, and then uses an if statement to add the specific tag based on that. Currently only 0-3 will work, 0 doesn't define anything, which defaults to wood tier. 1 is stone, 2 is iron, and 3 is diamond. Vanilla Minecraft doesn't add anything for requiring a Netherite level tool to break something, so setting 4 will default to Diamond for now.

Item Models and Block States

Item Models are defined in ItemModels.java and Blockstates are defined in BlockStates.java. ItemModels creates json files defining the 3 textures to use for each block based on form, and BlockStates does the same thing but for blockstates and block models, while also setting the model for the BlockItem.

Language generation

Language is defined in BaseLang.java. It simply just formats the registry names of items and blocks to convert them to being human readable. Also supports adding predefined strings.

Clone this wiki locally