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
tutorial:datagen_loot [2023/04/10 06:19] – Update block drop generation code for 1.19.3 and 1.19.4 justinhuprimetutorial:datagen_loot [2023/06/16 17:29] (current) – 1.20+ addProvider change slainlight
Line 25: Line 25:
 @Override @Override
 public void onInitializeDataGenerator(FabricDataGenerator fabricDataGenerator) { public void onInitializeDataGenerator(FabricDataGenerator fabricDataGenerator) {
-    fabricDataGenerator.addProvider(MyBlockLootTables::new);+    // ... 
 +    FabricDataGenerator.Pack myPack = fabricDataGenerator.createPack(); 
 +    myPack.addProvider(MyBlockLootTables::new); 
 +    // ...
 } }
 </code> </code>
 +
 +If you're using versions pre-1.20, please replace ''myPack.addProvider(MyBlockLootTables::new);'' with ''fabricDataGenerator.addProvider(MyBlockLootTables::new);''。You can also remove ''FabricDataGenerator.Pack myPack = fabricDataGenerator.createPack();''
  
 Let's just create a simple ore block and an item to drop from it for a block loot table. Add this to your block init or ''Tutorial'' class in this case. Let's just create a simple ore block and an item to drop from it for a block loot table. Add this to your block init or ''Tutorial'' class in this case.
Line 68: Line 73:
  
 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);
     }     }
Line 87: Line 92:
 @Override @Override
 public void onInitializeDataGenerator(FabricDataGenerator fabricDataGenerator) { public void onInitializeDataGenerator(FabricDataGenerator fabricDataGenerator) {
-    fabricDataGenerator.addProvider(MyChestLootTables::new);+    FabricDataGenerator.Pack myPack = fabricDataGenerator.createPack(); 
 +    myPack.addProvider(MyChestLootTables::new);
 } }
 </code> </code>
 +
 +If you're using versions pre-1.20, please replace ''myPack.addProvider(MyBlockLootTables::new);'' with ''fabricDataGenerator.addProvider(MyBlockLootTables::new);''。You can also remove ''FabricDataGenerator.Pack myPack = fabricDataGenerator.createPack();''
tutorial/datagen_loot.1681107556.txt.gz · Last modified: 2023/04/10 06:19 by justinhuprime