Skip to content

Compat Datagen

IchHabeHunger54 edited this page Jun 16, 2023 · 2 revisions

To get started with compat datagen, use the CompatDataProvider class. Start by extending the class:

public class MyCompatDataProvider {
    public MyCompatDataProvider(GatherDataEvent event) {
        super(event, "mymodid");
    }

    @Override
    public void generate() {}
}

Next, add a call to the provider to your datagen event handler:

@SubscribeEvent
public static void gatherData(GatherDataEvent event) {
    //other data providers here
    new MyCompatDataProvider(event);
}

Through the provided event parameter, the provider will automatically add itself to the event as needed.

And finally, you can start actually generating things. To do this, you populate your provider's generate() method. There are two options available:

  • Add to-be-datagenned objects directly to the various providers, e.g. CREATE_MILLING.builder(...);
  • Use one of the various helper methods, e.g. addFlowerProcessing(YourItems.YOUR_FLOWER.get(), new ResourceLocation("minecraft:green_dye"), 1); A full list of helpers can be found by browsing through CompatDataProvider's source code.

Note that in many locations, ResourceLocations instead of ItemStacks, FluidStacks or Ingredients are used. This is to allow for items from other mods, e.g. Create's experience nuggets in various Create processing recipes. If you need the id of your own item, the itemId() method provides a shortcut to get it. Similarly, fluidId() and blockId() are available as well.

Clone this wiki locally