| 1 | package net.minecraft.data.loot.packs;
|
| 2 |
|
| 3 | import net.minecraft.advancements.predicates.StatePropertiesPredicate;
|
| 4 | import net.minecraft.core.HolderGetter;
|
| 5 | import net.minecraft.core.registries.Registries;
|
| 6 | import net.minecraft.data.loot.LootTableSubProvider;
|
| 7 | import net.minecraft.world.item.Items;
|
| 8 | import net.minecraft.world.level.block.Block;
|
| 9 | import net.minecraft.world.level.block.Blocks;
|
| 10 | import net.minecraft.world.level.block.SweetBerryBushBlock;
|
| 11 | import net.minecraft.world.level.storage.loot.BuiltInLootTables;
|
| 12 | import net.minecraft.world.level.storage.loot.LootPool;
|
| 13 | import net.minecraft.world.level.storage.loot.LootTable;
|
| 14 | import net.minecraft.world.level.storage.loot.entries.LootItem;
|
| 15 | import net.minecraft.world.level.storage.loot.functions.SetItemCountFunction;
|
| 16 | import net.minecraft.world.level.storage.loot.predicates.MatchBlock;
|
| 17 | import net.minecraft.world.level.storage.loot.providers.number.ints.ContextIntProviders;
|
| 18 |
|
| 19 | public class VanillaBlockInteractLoot implements LootTableSubProvider {
|
| 20 | private final LootTableSubProvider.Context output;
|
| 21 | private final HolderGetter<Block> blocks;
|
| 22 |
|
| 23 | public VanillaBlockInteractLoot(final LootTableSubProvider.Context output) {
|
| 24 | this.output = output;
|
| 25 | this.blocks = output.lookup(Registries.BLOCK);
|
| 26 | }
|
| 27 |
|
| 28 | @Override
|
| 29 | public void run() {
|
| 30 | this.output
|
| 31 | .accept(
|
| 32 | BuiltInLootTables.HARVEST_BEEHIVE,
|
| 33 | LootTable.lootTable()
|
| 34 | .withPool(
|
| 35 | LootPool.lootPool()
|
| 36 | .setRolls(ContextIntProviders.exactly(1))
|
| 37 | .add(LootItem.lootTableItem(Items.HONEYCOMB).apply(SetItemCountFunction.setCount(ContextIntProviders.exactly(3))))
|
| 38 | )
|
| 39 | );
|
| 40 | this.output
|
| 41 | .accept(
|
| 42 | BuiltInLootTables.HARVEST_CAVE_VINE,
|
| 43 | LootTable.lootTable().withPool(LootPool.lootPool().setRolls(ContextIntProviders.exactly(1)).add(LootItem.lootTableItem(Items.GLOW_BERRIES)))
|
| 44 | );
|
| 45 | this.output
|
| 46 | .accept(
|
| 47 | BuiltInLootTables.HARVEST_SWEET_BERRY_BUSH,
|
| 48 | LootTable.lootTable()
|
| 49 | .withPool(
|
| 50 | LootPool.lootPool()
|
| 51 | .add(
|
| 52 | LootItem.lootTableItem(Items.SWEET_BERRIES)
|
| 53 | .apply(SetItemCountFunction.setCount(ContextIntProviders.exactly(1)))
|
| 54 | .when(
|
| 55 | MatchBlock.blockMatches(this.blocks, Blocks.SWEET_BERRY_BUSH, StatePropertiesPredicate.Builder.properties().hasProperty(SweetBerryBushBlock.AGE, 3))
|
| 56 | )
|
| 57 | )
|
| 58 | )
|
| 59 | .withPool(LootPool.lootPool().add(LootItem.lootTableItem(Items.SWEET_BERRIES).apply(SetItemCountFunction.setCount(ContextIntProviders.between(1, 2)))))
|
| 60 | );
|
| 61 | this.output
|
| 62 | .accept(
|
| 63 | BuiltInLootTables.CARVE_PUMPKIN,
|
| 64 | LootTable.lootTable()
|
| 65 | .withPool(
|
| 66 | LootPool.lootPool()
|
| 67 | .setRolls(ContextIntProviders.exactly(1))
|
| 68 | .add(LootItem.lootTableItem(Items.PUMPKIN_SEEDS).apply(SetItemCountFunction.setCount(ContextIntProviders.exactly(4))))
|
| 69 | )
|
| 70 | );
|
| 71 | this.output
|
| 72 | .accept(
|
| 73 | BuiltInLootTables.TILL_ROOTED_DIRT,
|
| 74 | LootTable.lootTable()
|
| 75 | .withPool(
|
| 76 | LootPool.lootPool()
|
| 77 | .setRolls(ContextIntProviders.exactly(1))
|
| 78 | .add(LootItem.lootTableItem(Items.HANGING_ROOTS).apply(SetItemCountFunction.setCount(ContextIntProviders.exactly(1))))
|
| 79 | )
|
| 80 | );
|
| 81 | }
|
| 82 | }
|
| 83 |
|