-
-
Notifications
You must be signed in to change notification settings - Fork 1
Compat Datagen
IchHabeHunger54 edited this page Mar 27, 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");
}
public void generate() {}
}
Next, add the provider to your datagen event handler:
@SubscribeEvent
public static void gatherData(GatherDataEvent event) {
//other event handlers here
event.getGenerator().addProvider(event.includeServer(), new MyCompatDataProvider(event));
}
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.
this.CREATE_MILLING.add(this.CREATE_MILLING.builder(YourItems.YOUR_FLOWER.get()));
(with the according properties then set on the builder) - Use one of the various helper methods, e.g.
this.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 most locations, ResourceLocation
s instead of Item
s or Ingredient
s 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.