tutorial:datagen_loot
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
tutorial:datagen_loot [2022/12/21 06:58] – Fixed header jmanc3 | tutorial:datagen_loot [2024/06/10 20:02] (current) – [Adding Chest Loot] Added a missing parentheses to first .with() statement lunathegaymer | ||
---|---|---|---|
Line 9: | Line 9: | ||
<code java> | <code java> | ||
- | private static class MyBlockLootTables extends | + | private static class MyBlockLootTables extends |
- | public MyBlockLootTables(FabricDataGenerator dataGenerator) { | + | public MyBlockLootTables(FabricDataOutput dataOutput) { |
- | | + | |
} | } | ||
| | ||
@Override | @Override | ||
- | public void accept(BiConsumer< | + | public void generate() { |
// ... | // ... | ||
} | } | ||
Line 25: | Line 25: | ||
@Override | @Override | ||
public void onInitializeDataGenerator(FabricDataGenerator fabricDataGenerator) { | public void onInitializeDataGenerator(FabricDataGenerator fabricDataGenerator) { | ||
- | fabricDataGenerator.addProvider(MyBlockLootTables:: | + | |
+ | FabricDataGenerator.Pack myPack = fabricDataGenerator.createPack(); | ||
+ | myPack.addProvider(MyBlockLootTables:: | ||
+ | // ... | ||
} | } | ||
</ | </ | ||
+ | |||
+ | If you're using versions pre-1.20, please replace '' | ||
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 '' | 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 '' | ||
Line 40: | Line 45: | ||
==== Adding Block Loot ==== | ==== Adding Block Loot ==== | ||
<code java> | <code java> | ||
- | private static class MyBlockLootTables extends | + | private static class MyBlockLootTables extends |
- | public MyBlockLootTables(FabricDataGenerator dataGenerator) { | + | public MyBlockLootTables(FabricDataOutput dataOutput) { |
- | | + | |
} | } | ||
- | + | | |
@Override | @Override | ||
- | public void accept(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. | + | |
- | | + | |
} | } | ||
} | } | ||
Line 69: | Line 73: | ||
private static class MyChestLootTables extends SimpleFabricLootTableProvider { | private static class MyChestLootTables extends SimpleFabricLootTableProvider { | ||
- | public MyChestLootGenerator(FabricDataGenerator | + | public MyChestLootGenerator(FabricDataOutput |
super(dataGenerator, | super(dataGenerator, | ||
} | } | ||
Line 78: | 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, | .with(ItemEntry.builder(Items.DIAMOND_SWORD)).apply(EnchantWithLevelsLootFunction.create(UniformLootNumberProvider.create(20.0F, | ||
); | ); | ||
Line 88: | Line 92: | ||
@Override | @Override | ||
public void onInitializeDataGenerator(FabricDataGenerator fabricDataGenerator) { | public void onInitializeDataGenerator(FabricDataGenerator fabricDataGenerator) { | ||
- | fabricDataGenerator.addProvider(MyChestLootTables:: | + | |
+ | myPack.addProvider(MyChestLootTables:: | ||
} | } | ||
</ | </ | ||
+ | |||
+ | If you're using versions pre-1.20, please replace '' |
tutorial/datagen_loot.txt · Last modified: 2024/06/10 20:02 by lunathegaymer