User Tools

Site Tools


tutorial:datagen_advancements

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
Next revisionBoth sides next revision
tutorial:datagen_advancements [2022/12/24 00:50] – Made explicit where the criterion needs to be registered. jmanc3tutorial:datagen_advancements [2023/09/24 18:52] – Use new minecraft wiki mattidragon
Line 13: Line 13:
 Unfortunately there's like three layers of indirection before we can actually start adding some advancements, but we'll go one layer at a time. First things first, in the ''DataGeneration'' file we created earlier, add the following: Unfortunately there's like three layers of indirection before we can actually start adding some advancements, but we'll go one layer at a time. First things first, in the ''DataGeneration'' file we created earlier, add the following:
  
-<code java [highlight_lines_extra="11"]>+<code java [highlight_lines_extra="13"]>
 import net.fabricmc.fabric.api.datagen.v1.DataGeneratorEntrypoint; import net.fabricmc.fabric.api.datagen.v1.DataGeneratorEntrypoint;
 import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator; import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator;
Line 21: Line 21:
     @Override     @Override
     public void onInitializeDataGenerator(FabricDataGenerator generator) {     public void onInitializeDataGenerator(FabricDataGenerator generator) {
 +        FabricDataGenerator.Pack pack = fabricDataGenerator.createPack();
 +        
         /**          /** 
         /* Add our advancements generator         /* Add our advancements generator
          **/          **/
-        generator.createPack().addProvider(AdvancementsProvider::new);+        pack.addProvider(AdvancementsProvider::new);
  
         // .. (Your other generators)         // .. (Your other generators)
Line 214: Line 216:
   * This name is only ever used by ''requirements'' (another property we can add to advancements) which make it so that before an advancement activates, the ''requirements'' (other advancements) need to be fulfilled first. In other words, it mostly doesn't matter what name you give the criterion.   * This name is only ever used by ''requirements'' (another property we can add to advancements) which make it so that before an advancement activates, the ''requirements'' (other advancements) need to be fulfilled first. In other words, it mostly doesn't matter what name you give the criterion.
  
-The second argument is the criterion. In our example we use the ''InventoryChangedCriterion'' and we pass it the item we want it to trigger for ''Items.DIRT''. But there are many criterions. The Minecraft Wiki has them listed as "[[https://minecraft.fandom.com/wiki/Advancement/JSON_format|List of triggers]]". But the better reference to use is the Minecraft source itself. (If you haven't generated the source yet, read [[tutorial:setup#generating_minecraft_sources|here]].) You can take a look at the ''net.minecraft.advancement.criterion'' folder where they are all located and see what's already available.+The second argument is the criterion. In our example we use the ''InventoryChangedCriterion'' and we pass it the item we want it to trigger for ''Items.DIRT''. But there are many criterions. The Minecraft Wiki has them listed as "[[https://minecraft.wiki/w/Advancement/JSON_format#List_of_triggers|List of triggers]]". But the better reference to use is the Minecraft source itself. (If you haven't generated the source yet, read [[tutorial:setup#generating_minecraft_sources|here]].) You can take a look at the ''net.minecraft.advancement.criterion'' folder where they are all located and see what's already available.
  
 | PlayerHurtEntityCriterion.class | ImpossibleCriterion.class | Criterion.class | AbstractCriterion.class | VillagerTradeCriterion.class | PlayerHurtEntityCriterion.class | ImpossibleCriterion.class | Criterion.class | AbstractCriterion.class | VillagerTradeCriterion.class
tutorial/datagen_advancements.txt · Last modified: 2023/10/02 23:11 by jmanc3