| 1 | package net.minecraft.data.loot.packs;
|
| 2 |
|
| 3 | import net.minecraft.core.HolderGetter;
|
| 4 | import net.minecraft.core.registries.Registries;
|
| 5 | import net.minecraft.data.loot.LootTableSubProvider;
|
| 6 | import net.minecraft.world.item.Items;
|
| 7 | import net.minecraft.world.item.alchemy.Potions;
|
| 8 | import net.minecraft.world.item.enchantment.Enchantment;
|
| 9 | import net.minecraft.world.item.enchantment.Enchantments;
|
| 10 | import net.minecraft.world.level.storage.loot.BuiltInLootTables;
|
| 11 | import net.minecraft.world.level.storage.loot.LootPool;
|
| 12 | import net.minecraft.world.level.storage.loot.LootTable;
|
| 13 | import net.minecraft.world.level.storage.loot.entries.LootItem;
|
| 14 | import net.minecraft.world.level.storage.loot.functions.EnchantRandomlyFunction;
|
| 15 | import net.minecraft.world.level.storage.loot.functions.SetItemCountFunction;
|
| 16 | import net.minecraft.world.level.storage.loot.functions.SetPotionFunction;
|
| 17 | import net.minecraft.world.level.storage.loot.providers.number.ints.ContextIntProviders;
|
| 18 |
|
| 19 | public class VanillaPiglinBarterLoot implements LootTableSubProvider {
|
| 20 | private final LootTableSubProvider.Context output;
|
| 21 | private final HolderGetter<Enchantment> enchantments;
|
| 22 |
|
| 23 | public VanillaPiglinBarterLoot(final LootTableSubProvider.Context output) {
|
| 24 | this.output = output;
|
| 25 | this.enchantments = output.lookup(Registries.ENCHANTMENT);
|
| 26 | }
|
| 27 |
|
| 28 | @Override
|
| 29 | public void run() {
|
| 30 | this.output
|
| 31 | .accept(
|
| 32 | BuiltInLootTables.PIGLIN_BARTERING,
|
| 33 | LootTable.lootTable()
|
| 34 | .withPool(
|
| 35 | LootPool.lootPool()
|
| 36 | .setRolls(ContextIntProviders.exactly(1))
|
| 37 | .add(
|
| 38 | LootItem.lootTableItem(Items.BOOK)
|
| 39 | .setWeight(5)
|
| 40 | .apply(new EnchantRandomlyFunction.Builder().withEnchantment(this.enchantments.getOrThrow(Enchantments.SOUL_SPEED)))
|
| 41 | )
|
| 42 | .add(
|
| 43 | LootItem.lootTableItem(Items.IRON_BOOTS)
|
| 44 | .setWeight(8)
|
| 45 | .apply(new EnchantRandomlyFunction.Builder().withEnchantment(this.enchantments.getOrThrow(Enchantments.SOUL_SPEED)))
|
| 46 | )
|
| 47 | .add(LootItem.lootTableItem(Items.POTION).setWeight(8).apply(SetPotionFunction.setPotion(Potions.FIRE_RESISTANCE)))
|
| 48 | .add(LootItem.lootTableItem(Items.SPLASH_POTION).setWeight(8).apply(SetPotionFunction.setPotion(Potions.FIRE_RESISTANCE)))
|
| 49 | .add(LootItem.lootTableItem(Items.POTION).setWeight(10).apply(SetPotionFunction.setPotion(Potions.WATER)))
|
| 50 | .add(LootItem.lootTableItem(Items.IRON_NUGGET).setWeight(10).apply(SetItemCountFunction.setCount(ContextIntProviders.between(10, 36))))
|
| 51 | .add(LootItem.lootTableItem(Items.ENDER_PEARL).setWeight(10).apply(SetItemCountFunction.setCount(ContextIntProviders.between(2, 4))))
|
| 52 | .add(LootItem.lootTableItem(Items.DRIED_GHAST).setWeight(10).apply(SetItemCountFunction.setCount(ContextIntProviders.exactly(1))))
|
| 53 | .add(LootItem.lootTableItem(Items.STRING).setWeight(20).apply(SetItemCountFunction.setCount(ContextIntProviders.between(3, 9))))
|
| 54 | .add(LootItem.lootTableItem(Items.QUARTZ).setWeight(20).apply(SetItemCountFunction.setCount(ContextIntProviders.between(5, 12))))
|
| 55 | .add(LootItem.lootTableItem(Items.OBSIDIAN).setWeight(40))
|
| 56 | .add(LootItem.lootTableItem(Items.CRYING_OBSIDIAN).setWeight(40).apply(SetItemCountFunction.setCount(ContextIntProviders.between(1, 3))))
|
| 57 | .add(LootItem.lootTableItem(Items.FIRE_CHARGE).setWeight(40))
|
| 58 | .add(LootItem.lootTableItem(Items.LEATHER).setWeight(40).apply(SetItemCountFunction.setCount(ContextIntProviders.between(2, 4))))
|
| 59 | .add(LootItem.lootTableItem(Items.SOUL_SAND).setWeight(40).apply(SetItemCountFunction.setCount(ContextIntProviders.between(2, 8))))
|
| 60 | .add(LootItem.lootTableItem(Items.NETHER_BRICK).setWeight(40).apply(SetItemCountFunction.setCount(ContextIntProviders.between(2, 8))))
|
| 61 | .add(LootItem.lootTableItem(Items.SPECTRAL_ARROW).setWeight(40).apply(SetItemCountFunction.setCount(ContextIntProviders.between(6, 12))))
|
| 62 | .add(LootItem.lootTableItem(Items.GRAVEL).setWeight(40).apply(SetItemCountFunction.setCount(ContextIntProviders.between(8, 16))))
|
| 63 | .add(LootItem.lootTableItem(Items.BLACKSTONE).setWeight(40).apply(SetItemCountFunction.setCount(ContextIntProviders.between(8, 16))))
|
| 64 | )
|
| 65 | );
|
| 66 | }
|
| 67 | }
|
| 68 |
|