User Tools

Site Tools


tutorial:datagen_tags

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
tutorial:datagen_tags [2022/08/08 20:06] mineblock11tutorial:datagen_tags [2023/06/05 18:20] – Update to new syntax 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 ItemTagProvider 
-   public MyTagGenerator(FabricDataGenerator dataGenerator) { +   public MyTagGenerator(FabricDataOutput output, CompletableFuture<WrapperLookup> completableFuture) { 
-       super(dataGeneratorRegistry.ITEM);+        super(outputcompletableFuture);
    }    }
  
    @Override    @Override
-   protected void generateTags() { +   protected void configure(WrapperLookup arg) { 
 +   
    }    }
 } }
Line 33: Line 33:
 ===== Adding a tag ===== ===== Adding a tag =====
  
-To add a tag, simply call the ''getOrCreateTagBuilder'' method with your supplied ''TagKey<T>'' in the ''generateTags()'' method like so:+To add a tag, simply call the ''getOrCreateTagBuilder'' method with your supplied ''TagKey<T>'' in the ''configure(WrapperLookup arg)'' method like so:
  
 <code java> <code java>
-private static final TagKey<Item> SMELLY_ITEMS = TagKey.of(Registry.ITEM_KEY, new Identifier("mymod:smelly_items"));+private static final TagKey<Item> SMELLY_ITEMS = TagKey.of(RegistryKeys.ITEM_KEY, new Identifier("mymod:smelly_items"));
    
 @Override @Override
-protected void generateTags() {+protected void configure(WrapperLookup arg) {
      // This creates a tag builder, where we add slime balls, rotten flesh and everything in the minecraft:dirt item tag.      // This creates a tag builder, where we add slime balls, rotten flesh and everything in the minecraft:dirt item tag.
      getOrCreateTagBuilder(SMELLY_ITEMS)      getOrCreateTagBuilder(SMELLY_ITEMS)
Line 49: Line 49:
 </code> </code>
  
-Output from above example:+Output from the example above:
  
 <file javascript smelly_items.json> <file javascript smelly_items.json>
Line 83: Line 83:
  
 @Override @Override
-protected void generateTags() {+protected void configure(WrapperLookup arg) {
      getOrCreateTagBuilder(SMELLY_ITEMS)      getOrCreateTagBuilder(SMELLY_ITEMS)
                     .add(Items.SLIME_BALL)                     .add(Items.SLIME_BALL)
tutorial/datagen_tags.txt · Last modified: 2023/06/05 18:22 by mcrafterzz