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
Last revisionBoth sides next revision
tutorial:datagen_loot [2022/11/14 19:32] nexus-dinotutorial:datagen_loot [2023/06/05 17:45] mcrafterzz
Line 1: Line 1:
-Before reading this, make sure you have a class that implements ''DataGenerationEntrypoint''+====== Loot Table Generation ======
  
-To get started, make a class (or a few, you need one for blocks, chests and entities) that extends ''SimpleFabricLootTableProvider'' and register it like so:+Before reading this, make sure you've read [[datagen_setup|Getting started with Data Generation]], and have a class that implements ''DataGenerationEntrypoint'' 
 + 
 +To begin, make a class (or a few, you need one for blocks, chests and entities) that extends ''SimpleFabricLootTableProvider'' and register it like so:
  
 ==== Setting Up ==== ==== Setting Up ====
Line 7: 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 23: 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 38: 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)));+
     }     }
 } }
Line 67: Line 70:
  
 private static class MyChestLootTables extends SimpleFabricLootTableProvider { private static class MyChestLootTables extends SimpleFabricLootTableProvider {
-    public MyChestLootGenerator(FabricDataGenerator dataGenerator) {+    public MyChestLootGenerator(FabricDataOutput dataGenerator) {
  super(dataGenerator, LootContextTypes.CHEST);  super(dataGenerator, LootContextTypes.CHEST);
     }     }
tutorial/datagen_loot.txt · Last modified: 2023/06/16 17:29 by slainlight