VanillaEquipmentLoot.java

net.minecraft.data.loot.packs.VanillaEquipmentLoot

信息

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

    TODO

字段/常量

内部类/嵌套类型

构造器

方法

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

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

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

参数:

  • output: BiConsumer<ResourceKey,LootTable.Builder>

说明:

TODO

public static LootTable.Builder trialChamberEquipment(Item helmet, Item chestplate, ArmorTrim trim, HolderLookup.RegistryLookup<Enchantment> enchantments) @ L119

  • 方法名:trialChamberEquipment
  • 源码定位:L119
  • 返回类型:LootTable.Builder
  • 修饰符:public static

参数:

  • helmet: Item
  • chestplate: Item
  • trim: ArmorTrim
  • enchantments: HolderLookup.RegistryLookup

说明:

TODO

代码

public record VanillaEquipmentLoot(HolderLookup.Provider registries) implements LootTableSubProvider {
    @Override
    public void generate(BiConsumer<ResourceKey<LootTable>, LootTable.Builder> output) {
        HolderLookup.RegistryLookup<TrimPattern> trimPatterns = this.registries.lookupOrThrow(Registries.TRIM_PATTERN);
        HolderLookup.RegistryLookup<TrimMaterial> trimMaterials = this.registries.lookupOrThrow(Registries.TRIM_MATERIAL);
        HolderLookup.RegistryLookup<Enchantment> enchantments = this.registries.lookupOrThrow(Registries.ENCHANTMENT);
        ArmorTrim flowTrim = new ArmorTrim(trimMaterials.getOrThrow(TrimMaterials.COPPER), trimPatterns.getOrThrow(TrimPatterns.FLOW));
        ArmorTrim boltTrim = new ArmorTrim(trimMaterials.getOrThrow(TrimMaterials.COPPER), trimPatterns.getOrThrow(TrimPatterns.BOLT));
        output.accept(
            BuiltInLootTables.EQUIPMENT_TRIAL_CHAMBER,
            LootTable.lootTable()
                .withPool(
                    LootPool.lootPool()
                        .setRolls(ConstantValue.exactly(1.0F))
                        .add(
                            NestedLootTable.inlineLootTable(
                                    trialChamberEquipment(Items.CHAINMAIL_HELMET, Items.CHAINMAIL_CHESTPLATE, boltTrim, enchantments).build()
                                )
                                .setWeight(4)
                        )
                        .add(
                            NestedLootTable.inlineLootTable(trialChamberEquipment(Items.IRON_HELMET, Items.IRON_CHESTPLATE, flowTrim, enchantments).build())
                                .setWeight(2)
                        )
                        .add(
                            NestedLootTable.inlineLootTable(
                                    trialChamberEquipment(Items.DIAMOND_HELMET, Items.DIAMOND_CHESTPLATE, flowTrim, enchantments).build()
                                )
                                .setWeight(1)
                        )
                )
        );
        output.accept(
            BuiltInLootTables.EQUIPMENT_TRIAL_CHAMBER_MELEE,
            LootTable.lootTable()
                .withPool(
                    LootPool.lootPool()
                        .setRolls(ConstantValue.exactly(1.0F))
                        .add(NestedLootTable.lootTableReference(BuiltInLootTables.EQUIPMENT_TRIAL_CHAMBER))
                )
                .withPool(
                    LootPool.lootPool()
                        .setRolls(ConstantValue.exactly(1.0F))
                        .add(LootItem.lootTableItem(Items.IRON_SWORD).setWeight(4))
                        .add(
                            LootItem.lootTableItem(Items.IRON_SWORD)
                                .apply(
                                    new SetEnchantmentsFunction.Builder()
                                        .withEnchantment(enchantments.getOrThrow(Enchantments.SHARPNESS), ConstantValue.exactly(1.0F))
                                )
                        )
                        .add(
                            LootItem.lootTableItem(Items.IRON_SWORD)
                                .apply(
                                    new SetEnchantmentsFunction.Builder()
                                        .withEnchantment(enchantments.getOrThrow(Enchantments.KNOCKBACK), ConstantValue.exactly(1.0F))
                                )
                        )
                        .add(LootItem.lootTableItem(Items.DIAMOND_SWORD))
                )
        );
        output.accept(
            BuiltInLootTables.EQUIPMENT_TRIAL_CHAMBER_RANGED,
            LootTable.lootTable()
                .withPool(
                    LootPool.lootPool()
                        .setRolls(ConstantValue.exactly(1.0F))
                        .add(NestedLootTable.lootTableReference(BuiltInLootTables.EQUIPMENT_TRIAL_CHAMBER))
                )
                .withPool(
                    LootPool.lootPool()
                        .setRolls(ConstantValue.exactly(1.0F))
                        .add(LootItem.lootTableItem(Items.BOW).setWeight(2))
                        .add(
                            LootItem.lootTableItem(Items.BOW)
                                .apply(
                                    new SetEnchantmentsFunction.Builder()
                                        .withEnchantment(enchantments.getOrThrow(Enchantments.POWER), ConstantValue.exactly(1.0F))
                                )
                        )
                        .add(
                            LootItem.lootTableItem(Items.BOW)
                                .apply(
                                    new SetEnchantmentsFunction.Builder()
                                        .withEnchantment(enchantments.getOrThrow(Enchantments.PUNCH), ConstantValue.exactly(1.0F))
                                )
                        )
                )
        );
    }
 
    public static LootTable.Builder trialChamberEquipment(Item helmet, Item chestplate, ArmorTrim trim, HolderLookup.RegistryLookup<Enchantment> enchantments) {
        return LootTable.lootTable()
            .withPool(
                LootPool.lootPool()
                    .setRolls(ConstantValue.exactly(1.0F))
                    .when(LootItemRandomChanceCondition.randomChance(0.5F))
                    .add(
                        LootItem.lootTableItem(helmet)
                            .apply(SetComponentsFunction.setComponent(DataComponents.TRIM, trim))
                            .apply(
                                new SetEnchantmentsFunction.Builder()
                                    .withEnchantment(enchantments.getOrThrow(Enchantments.PROTECTION), ConstantValue.exactly(4.0F))
                                    .withEnchantment(enchantments.getOrThrow(Enchantments.PROJECTILE_PROTECTION), ConstantValue.exactly(4.0F))
                                    .withEnchantment(enchantments.getOrThrow(Enchantments.FIRE_PROTECTION), ConstantValue.exactly(4.0F))
                            )
                    )
            )
            .withPool(
                LootPool.lootPool()
                    .setRolls(ConstantValue.exactly(1.0F))
                    .when(LootItemRandomChanceCondition.randomChance(0.5F))
                    .add(
                        LootItem.lootTableItem(chestplate)
                            .apply(SetComponentsFunction.setComponent(DataComponents.TRIM, trim))
                            .apply(
                                new SetEnchantmentsFunction.Builder()
                                    .withEnchantment(enchantments.getOrThrow(Enchantments.PROTECTION), ConstantValue.exactly(4.0F))
                                    .withEnchantment(enchantments.getOrThrow(Enchantments.PROJECTILE_PROTECTION), ConstantValue.exactly(4.0F))
                                    .withEnchantment(enchantments.getOrThrow(Enchantments.FIRE_PROTECTION), ConstantValue.exactly(4.0F))
                            )
                    )
            );
    }
}

引用的其他类

  • HolderLookup

    • 引用位置: 参数
  • LootTableSubProvider

    • 引用位置: 实现
  • ResourceKey

    • 引用位置: 参数
  • Item

    • 引用位置: 参数
  • Enchantment

    • 引用位置: 参数
  • ArmorTrim

    • 引用位置: 参数/构造调用
    • 关联成员: ArmorTrim()
  • LootPool

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

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

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

    • 引用位置: 方法调用
    • 关联成员: NestedLootTable.inlineLootTable(), NestedLootTable.lootTableReference()
  • SetComponentsFunction

    • 引用位置: 方法调用
    • 关联成员: SetComponentsFunction.setComponent()
  • SetEnchantmentsFunction

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

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

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