What Is Data Generation?
Data generation (or datagen) is an API for programmatically generating recipes, advancements, tags, item models, language files, loot tables, and basically anything JSON-based.
Enabling Data Generation
At Project Creation
The easiest way to enable datagen is at project creation. Check the "Enable Data Generation" box when using the template generator.

TIP
If datagen is enabled, you should have a "Data Generation" run configuration and a runDatagen Gradle task.
Manually
First, we need to enable datagen in the build.gradle file.
groovy
fabricApi {
configureDataGeneration() {
client = true
}
}1
2
3
4
5
2
3
4
5
Next, we need an entrypoint class. This is where our datagen starts. Place this somewhere in the client package - this example places it at src/client/java/com/example/docs/datagen/FabricDocsReferenceDataGenerator.java.
java
public class FabricDocsReferenceDataGenerator implements DataGeneratorEntrypoint {
@Override
public void onInitializeDataGenerator(FabricDataGenerator fabricDataGenerator) {
}
}1
2
3
4
5
6
2
3
4
5
6
Finally, we need to tell Fabric about the entrypoint in our fabric.mod.json:
json
{
// ...
"entrypoints": {
// ...
"client": [
// ...
],
"fabric-datagen": [
"com.example.docs.datagen.FabricDocsReferenceDataGenerator"
]
}
}1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12
WARNING
Don't forget to add a comma (,) after the previous entrypoint block!
Close and reopen IntelliJ to create a run configuration for datagen.
Creating a Pack
Inside your datagen entrypoint's onInitializeDataGenerator method, we need to create a Pack. Later, you'll add providers, which put generated data into this Pack.
java
FabricDataGenerator.Pack pack = fabricDataGenerator.createPack();1
Running Data Generation
To run datagen, use the run configuration in your IDE, or run ./gradlew runDatagen in the console. The generated files will be created in src/main/generated.
Next Steps
Now that datagen is set up, we need to add providers. These are what generate the data to add to your Pack. The following pages outline how to do this.










