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
tutorial:datagen_loot [2023/06/05 17:45] mcrafterzztutorial:datagen_loot [2023/06/16 17:29] (current) – 1.20+ addProvider change slainlight
Line 26: Line 26:
 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 89: 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.txt · Last modified: 2023/06/16 17:29 by slainlight