User Tools

Site Tools


tutorial:datagen_loot

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_loot [2022/12/21 06:58] – Fixed header jmanc3tutorial:datagen_loot [2023/06/05 17:30] – Add comments inside onInitializeDataGenerator to be consistent with other data generation tutorials on the wiki mcrafterzz
Line 9: Line 9:
  
 <code java> <code java>
-private static class MyBlockLootTables extends SimpleFabricLootTableProvider +private static class MyBlockLootTables extends FabricBlockLootTableProvider 
-    public MyBlockLootTables(FabricDataGenerator dataGenerator) { +    public MyBlockLootTables(FabricDataOutput dataOutput) { 
-         super(dataGenerator, LootContextTypes.BLOCK);+         super(dataOutput);
     }     }
          
     @Override     @Override
-    public void accept(BiConsumer<Identifier, LootTable.Builder> biConsumer) {+    public void generate() {
         // ...         // ...
     }     }
Line 25: Line 25:
 @Override @Override
 public void onInitializeDataGenerator(FabricDataGenerator fabricDataGenerator) { public void onInitializeDataGenerator(FabricDataGenerator fabricDataGenerator) {
 +    // ...
     fabricDataGenerator.addProvider(MyBlockLootTables::new);     fabricDataGenerator.addProvider(MyBlockLootTables::new);
 +    // ...
 } }
 </code> </code>
Line 40: Line 42:
 ==== Adding Block Loot ==== ==== Adding Block Loot ====
 <code java> <code java>
-private static class MyBlockLootTables extends SimpleFabricLootTableProvider +private static class MyBlockLootTables extends FabricBlockLootTableProvider 
-    public MyBlockLootTables(FabricDataGenerator dataGenerator) { +    public MyBlockLootTables(FabricDataOutput dataOutput) { 
-         super(dataGenerator, LootContextTypes.BLOCK);+         super(dataOutput);
     }     }
- +    
     @Override     @Override
-    public void accept(BiConsumer<Identifier, LootTable.Builder> biConsumer) { +    public void generate() { 
-    // The BlockLootTableGenerator class contains a behemoth of utility methods. Just take some time and go through the methods available to override. +        addDrop(Tutorial.TEST_BLOCK, drops(Tutorial.TEST_ITEM));
-        biConsumer.accept(new Identifier("tutorial", "test_block"), BlockLootTableGenerator.drops(Tutorial.TEST_BLOCK, Tutorial.TEST_ITEM, ConstantLootNumberProvider.create(9.0F)));+
     }     }
 } }
tutorial/datagen_loot.txt · Last modified: 2023/06/16 17:29 by slainlight