User Tools

Site Tools


← Go back to the homepage

Fabric Tutorials


These pages will help you setup a productive development environment and semi-automated releases.


These pages are essential must-reads when modding with Fabric, and modding Minecraft in general, if you are new to modding, it is recommended you read the following.


Blocks and Block Entities

Data Generation

World Generation


These pages will guide you through Mojang's Brigadier library which allows you to create commands with complex arguments and actions.


These pages will guide you through using the many events included in Fabric API, and how to create your own events for you or other mods to use.



Mixins & ASM

These pages will guide you through the usage of SpongePowered's Mixin library, which is a highly complex topic. We recommend you read these pages thoroughly.



Contribute to Fabric


Getting started with Data Generation

Data Generation is a new module of the Fabric API, it allows you to dynamically generate Recipes, Language Files, Loot Tables, Advancements and pretty much anything with Custom Providers.

To implement data generation, add the following to your build.gradle:

loom {
    runs {
        // This adds a new gradle task that runs the datagen API: "gradlew runDatagenClient"
        datagenClient {
            inherit client
            name "Data Generation"
            vmArg "-Dfabric-api.datagen"
            vmArg "-Dfabric-api.datagen.output-dir=${file("src/main/generated")}"
            vmArg "-Dfabric-api.datagen.strict-validation"
            runDir "build/datagen"
// Add the datagenned files into the jar.
sourceSets {
    main {
        resources {
            srcDirs += [

Next, create a class that extends DataGeneratorEntrypoint, and add it to your fabric.mod.json:

public class MyModDatagen implements DataGeneratorEntrypoint {
    public void onInitializeDataGenerator(FabricDataGenerator fabricDataGenerator) {
        // ...

This will register your datagen entrypoint, allowing onInitializeDataGenerator to be called when the gradlew runDatagenClient task is ran.

"entrypoints": {
    "fabric-datagen": [

Adding Providers

This is a generic guide on how to add a provider, for more in depth infomation on each provider, see their respective pages:

In this example, we will be creating a tag provider, as it is the simplest to understand.

Firstly, inside your MyModDatagen class, create a new private static class that extends FabricTagProvider<T>:

If you want, you can place this class in a seperate file, but we recommend it stays in your datagen entrypoint class.

private static class MyTagGenerator extends FabricTagProvider<Item> {
        public MyTagGenerator(FabricDataGenerator dataGenerator) {
            super(dataGenerator, Registry.ITEM);
        protected void generateTags() {

We will add some basic tags inside generateTags() for example's sake.

// We will create an item tag called "smelly_items".
private static final TagKey<Item> SMELLY_ITEMS = TagKey.of(Registry.ITEM_KEY, new Identifier("mymod:smelly_items"));
protected void generateTags() {
     // This creates a tag builder, where we add slime balls, rotten flesh and everything in the minecraft:dirt item tag.
     // This will automatically generate "assets/mymod/tags/items/smelly_items.json" in the "generated" folder.

Now, we will need to register this provider to the data generator in the onInitializeDataGenerator in your entrypoint class like so:

public class MyModDatagen implements DataGeneratorEntrypoint {
    public void onInitializeDataGenerator(FabricDataGenerator fabricDataGenerator) {

When we run gradlew runDatagenClient, we should see the generated folder forms, and the item tag json should be present:

  "replace": false,
  "values": [
      "id": "#minecraft:dirt",
      "required": false
tutorial/datagen_setup.txt · Last modified: 2022/08/29 18:39 by modmuss50