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 [2023/06/16 17:29] (current) – 1.20+ addProvider change slainlight | ||
---|---|---|---|
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 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.1671605896.txt.gz · Last modified: 2022/12/21 06:58 by jmanc3