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/06/05 17:45] mcrafterzztutorial:datagen_loot [2024/06/10 20:02] (current) – [Adding Chest Loot] Added a missing parentheses to first .with() statement lunathegaymer
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 79: Line 82:
                   .pool(LootPool.builder().rolls(ConstantLootNumberProvider.create(1.0F))                   .pool(LootPool.builder().rolls(ConstantLootNumberProvider.create(1.0F))
                   .with(ItemEntry.builder(Items.DIAMOND)                   .with(ItemEntry.builder(Items.DIAMOND)
- .apply(SetCountLootFunction.builder(ConstantLootNumberProvider.create(1.0F)))+ .apply(SetCountLootFunction.builder(ConstantLootNumberProvider.create(1.0F))))
                   .with(ItemEntry.builder(Items.DIAMOND_SWORD)).apply(EnchantWithLevelsLootFunction.create(UniformLootNumberProvider.create(20.0F, 39.0F))))                   .with(ItemEntry.builder(Items.DIAMOND_SWORD)).apply(EnchantWithLevelsLootFunction.create(UniformLootNumberProvider.create(20.0F, 39.0F))))
         );         );
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.1685987147.txt.gz · Last modified: 2023/06/05 17:45 by mcrafterzz