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
tutorial:datagen_tags [2022/08/16 18:59] mineblock11tutorial:datagen_tags [2023/06/05 18:22] (current) – [Adding stuff to the builder] mcrafterzz
Line 5: Line 5:
 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 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 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 80: Line 80:
  
 <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) {
      getOrCreateTagBuilder(SMELLY_ITEMS)      getOrCreateTagBuilder(SMELLY_ITEMS)
                     .add(Items.SLIME_BALL)                     .add(Items.SLIME_BALL)
tutorial/datagen_tags.1660676346.txt.gz · Last modified: 2022/08/16 18:59 by mineblock11