User Tools

Site Tools


tutorial:datagen_tags

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
Next revisionBoth sides next revision
tutorial:datagen_tags [2022/08/08 20:05] – created mineblock11tutorial:datagen_tags [2023/06/05 17:44] – Change to FabricDataOutput mcrafterzz
Line 1: Line 1:
 ====== Tag Generation ====== ====== Tag Generation ======
  
-The ''FabricTagProvider<T>'' class allows you to generate tag json files.+The ''[[https://github.com/FabricMC/fabric/blob/1.19.2/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/provider/FabricTagProvider.java|FabricTagProvider<T>]]'' class allows you to generate tag json files.
  
 This page will follow you through all aspects of this provider. This page will follow you through all aspects of this provider.
  
-To create a ''FabricTagProvider<T>'' create a class that extends it and register it at your entrypoint like so:+To create a tag generator, create a class that extends ''FabricTagProvider<T>'', where ''T'' is the type of tag you want to generate, and register it at your datagen entrypoint like so:
  
 <code java> <code java>
 private static class MyTagGenerator extends FabricTagProvider<Item> { private static class MyTagGenerator extends FabricTagProvider<Item> {
-   public MyTagGenerator(FabricDataGenerator dataGenerator) {+   public MyTagGenerator(FabricDataOutput dataGenerator) {
        super(dataGenerator, Registry.ITEM);        super(dataGenerator, Registry.ITEM);
    }    }
Line 48: Line 48:
 } }
 </code> </code>
 +
 +Output from the example above:
 +
 +<file javascript smelly_items.json>
 +{
 +  "replace": false,
 +  "values": [
 +    "minecraft:slime_ball",
 +    "minecraft:rotten_flesh",
 +    {
 +      "id": "#minecraft:dirt",
 +      "required": false
 +    }
 +  ]
 +}
 +</file>
  
 ===== Adding stuff to the builder ===== ===== Adding stuff to the builder =====
tutorial/datagen_tags.txt · Last modified: 2023/06/05 18:22 by mcrafterzz