VanillaPiglinBarterLoot.java

net.minecraft.data.loot.packs.VanillaPiglinBarterLoot

信息

  • 全限定名:net.minecraft.data.loot.packs.VanillaPiglinBarterLoot
  • 类型:public record
  • 包:net.minecraft.data.loot.packs
  • 源码路径:src/main/java/net/minecraft/data/loot/packs/VanillaPiglinBarterLoot.java
  • 起始行号:L22
  • 实现:LootTableSubProvider
  • 职责:

    TODO

字段/常量

内部类/嵌套类型

构造器

方法

下面的方法块按源码顺序生成。

public void generate(BiConsumer<ResourceKey<LootTable>,LootTable.Builder> output) @ L23

  • 方法名:generate
  • 源码定位:L23
  • 返回类型:void
  • 修饰符:public

参数:

  • output: BiConsumer<ResourceKey,LootTable.Builder>

说明:

TODO

代码

public record VanillaPiglinBarterLoot(HolderLookup.Provider registries) implements LootTableSubProvider {
    @Override
    public void generate(BiConsumer<ResourceKey<LootTable>, LootTable.Builder> output) {
        HolderLookup.RegistryLookup<Enchantment> enchantments = this.registries.lookupOrThrow(Registries.ENCHANTMENT);
        output.accept(
            BuiltInLootTables.PIGLIN_BARTERING,
            LootTable.lootTable()
                .withPool(
                    LootPool.lootPool()
                        .setRolls(ConstantValue.exactly(1.0F))
                        .add(
                            LootItem.lootTableItem(Items.BOOK)
                                .setWeight(5)
                                .apply(new EnchantRandomlyFunction.Builder().withEnchantment(enchantments.getOrThrow(Enchantments.SOUL_SPEED)))
                        )
                        .add(
                            LootItem.lootTableItem(Items.IRON_BOOTS)
                                .setWeight(8)
                                .apply(new EnchantRandomlyFunction.Builder().withEnchantment(enchantments.getOrThrow(Enchantments.SOUL_SPEED)))
                        )
                        .add(LootItem.lootTableItem(Items.POTION).setWeight(8).apply(SetPotionFunction.setPotion(Potions.FIRE_RESISTANCE)))
                        .add(LootItem.lootTableItem(Items.SPLASH_POTION).setWeight(8).apply(SetPotionFunction.setPotion(Potions.FIRE_RESISTANCE)))
                        .add(LootItem.lootTableItem(Items.POTION).setWeight(10).apply(SetPotionFunction.setPotion(Potions.WATER)))
                        .add(
                            LootItem.lootTableItem(Items.IRON_NUGGET)
                                .setWeight(10)
                                .apply(SetItemCountFunction.setCount(UniformGenerator.between(10.0F, 36.0F)))
                        )
                        .add(LootItem.lootTableItem(Items.ENDER_PEARL).setWeight(10).apply(SetItemCountFunction.setCount(UniformGenerator.between(2.0F, 4.0F))))
                        .add(LootItem.lootTableItem(Items.DRIED_GHAST).setWeight(10).apply(SetItemCountFunction.setCount(ConstantValue.exactly(1.0F))))
                        .add(LootItem.lootTableItem(Items.STRING).setWeight(20).apply(SetItemCountFunction.setCount(UniformGenerator.between(3.0F, 9.0F))))
                        .add(LootItem.lootTableItem(Items.QUARTZ).setWeight(20).apply(SetItemCountFunction.setCount(UniformGenerator.between(5.0F, 12.0F))))
                        .add(LootItem.lootTableItem(Items.OBSIDIAN).setWeight(40))
                        .add(
                            LootItem.lootTableItem(Items.CRYING_OBSIDIAN)
                                .setWeight(40)
                                .apply(SetItemCountFunction.setCount(UniformGenerator.between(1.0F, 3.0F)))
                        )
                        .add(LootItem.lootTableItem(Items.FIRE_CHARGE).setWeight(40))
                        .add(LootItem.lootTableItem(Items.LEATHER).setWeight(40).apply(SetItemCountFunction.setCount(UniformGenerator.between(2.0F, 4.0F))))
                        .add(LootItem.lootTableItem(Items.SOUL_SAND).setWeight(40).apply(SetItemCountFunction.setCount(UniformGenerator.between(2.0F, 8.0F))))
                        .add(
                            LootItem.lootTableItem(Items.NETHER_BRICK).setWeight(40).apply(SetItemCountFunction.setCount(UniformGenerator.between(2.0F, 8.0F)))
                        )
                        .add(
                            LootItem.lootTableItem(Items.SPECTRAL_ARROW)
                                .setWeight(40)
                                .apply(SetItemCountFunction.setCount(UniformGenerator.between(6.0F, 12.0F)))
                        )
                        .add(LootItem.lootTableItem(Items.GRAVEL).setWeight(40).apply(SetItemCountFunction.setCount(UniformGenerator.between(8.0F, 16.0F))))
                        .add(LootItem.lootTableItem(Items.BLACKSTONE).setWeight(40).apply(SetItemCountFunction.setCount(UniformGenerator.between(8.0F, 16.0F))))
                )
        );
    }
}

引用的其他类

  • LootTableSubProvider

    • 引用位置: 实现
  • ResourceKey

    • 引用位置: 参数
  • LootPool

    • 引用位置: 方法调用
    • 关联成员: LootPool.lootPool()
  • LootTable

    • 引用位置: 参数/方法调用
    • 关联成员: LootTable.lootTable()
  • LootItem

    • 引用位置: 方法调用
    • 关联成员: LootItem.lootTableItem()
  • EnchantRandomlyFunction

    • 引用位置: 方法调用/构造调用
    • 关联成员: Builder(), EnchantRandomlyFunction.Builder()
  • SetItemCountFunction

    • 引用位置: 方法调用
    • 关联成员: SetItemCountFunction.setCount()
  • SetPotionFunction

    • 引用位置: 方法调用
    • 关联成员: SetPotionFunction.setPotion()
  • ConstantValue

    • 引用位置: 方法调用
    • 关联成员: ConstantValue.exactly()
  • UniformGenerator

    • 引用位置: 方法调用
    • 关联成员: UniformGenerator.between()