EquipmentAssetProvider.java

net.minecraft.client.data.models.EquipmentAssetProvider

信息

  • 全限定名:net.minecraft.client.data.models.EquipmentAssetProvider
  • 类型:public class
  • 包:net.minecraft.client.data.models
  • 源码路径:src/main/java/net/minecraft/client/data/models/EquipmentAssetProvider.java
  • 起始行号:L22
  • 实现:DataProvider
  • 职责:

    TODO

字段/常量

  • pathProvider
    • 类型: PackOutput.PathProvider
    • 修饰符: private final
    • 源码定位: L23
    • 说明:

      TODO

内部类/嵌套类型

构造器

public EquipmentAssetProvider(PackOutput output) @ L25

  • 构造器名:EquipmentAssetProvider
  • 源码定位:L25
  • 修饰符:public

参数:

  • output: PackOutput

说明:

TODO

方法

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

private static void bootstrap(BiConsumer<ResourceKey<EquipmentAsset>,EquipmentClientInfo> consumer) @ L29

  • 方法名:bootstrap
  • 源码定位:L29
  • 返回类型:void
  • 修饰符:private static

参数:

  • consumer: BiConsumer<ResourceKey,EquipmentClientInfo>

说明:

TODO

private static EquipmentClientInfo onlyHumanoid(String name) @ L129

  • 方法名:onlyHumanoid
  • 源码定位:L129
  • 返回类型:EquipmentClientInfo
  • 修饰符:private static

参数:

  • name: String

说明:

TODO

private static EquipmentClientInfo humanoidAndMountArmor(String name) @ L133

  • 方法名:humanoidAndMountArmor
  • 源码定位:L133
  • 返回类型:EquipmentClientInfo
  • 修饰符:private static

参数:

  • name: String

说明:

TODO

public CompletableFuture<?> run(CachedOutput cache) @ L141

  • 方法名:run
  • 源码定位:L141
  • 返回类型:CompletableFuture<?>
  • 修饰符:public

参数:

  • cache: CachedOutput

说明:

TODO

public String getName() @ L152

  • 方法名:getName
  • 源码定位:L152
  • 返回类型:String
  • 修饰符:public

参数:

说明:

TODO

代码

@OnlyIn(Dist.CLIENT)
public class EquipmentAssetProvider implements DataProvider {
    private final PackOutput.PathProvider pathProvider;
 
    public EquipmentAssetProvider(PackOutput output) {
        this.pathProvider = output.createPathProvider(PackOutput.Target.RESOURCE_PACK, "equipment");
    }
 
    private static void bootstrap(BiConsumer<ResourceKey<EquipmentAsset>, EquipmentClientInfo> consumer) {
        consumer.accept(
            EquipmentAssets.LEATHER,
            EquipmentClientInfo.builder()
                .addHumanoidLayers(Identifier.withDefaultNamespace("leather"), true)
                .addHumanoidLayers(Identifier.withDefaultNamespace("leather_overlay"), false)
                .addLayers(
                    EquipmentClientInfo.LayerType.HORSE_BODY,
                    EquipmentClientInfo.Layer.leatherDyeable(Identifier.withDefaultNamespace("leather"), true),
                    EquipmentClientInfo.Layer.leatherDyeable(Identifier.withDefaultNamespace("leather_overlay"), false)
                )
                .build()
        );
        consumer.accept(EquipmentAssets.CHAINMAIL, onlyHumanoid("chainmail"));
        consumer.accept(EquipmentAssets.COPPER, humanoidAndMountArmor("copper"));
        consumer.accept(EquipmentAssets.IRON, humanoidAndMountArmor("iron"));
        consumer.accept(EquipmentAssets.GOLD, humanoidAndMountArmor("gold"));
        consumer.accept(EquipmentAssets.DIAMOND, humanoidAndMountArmor("diamond"));
        consumer.accept(
            EquipmentAssets.TURTLE_SCUTE, EquipmentClientInfo.builder().addMainHumanoidLayer(Identifier.withDefaultNamespace("turtle_scute"), false).build()
        );
        consumer.accept(EquipmentAssets.NETHERITE, humanoidAndMountArmor("netherite"));
        consumer.accept(
            EquipmentAssets.ARMADILLO_SCUTE,
            EquipmentClientInfo.builder()
                .addLayers(
                    EquipmentClientInfo.LayerType.WOLF_BODY, EquipmentClientInfo.Layer.onlyIfDyed(Identifier.withDefaultNamespace("armadillo_scute"), false)
                )
                .addLayers(
                    EquipmentClientInfo.LayerType.WOLF_BODY,
                    EquipmentClientInfo.Layer.onlyIfDyed(Identifier.withDefaultNamespace("armadillo_scute_overlay"), true)
                )
                .build()
        );
        consumer.accept(
            EquipmentAssets.ELYTRA,
            EquipmentClientInfo.builder()
                .addLayers(
                    EquipmentClientInfo.LayerType.WINGS, new EquipmentClientInfo.Layer(Identifier.withDefaultNamespace("elytra"), Optional.empty(), true)
                )
                .build()
        );
        EquipmentClientInfo.Layer saddleLayer = new EquipmentClientInfo.Layer(Identifier.withDefaultNamespace("saddle"));
        consumer.accept(
            EquipmentAssets.SADDLE,
            EquipmentClientInfo.builder()
                .addLayers(EquipmentClientInfo.LayerType.PIG_SADDLE, saddleLayer)
                .addLayers(EquipmentClientInfo.LayerType.STRIDER_SADDLE, saddleLayer)
                .addLayers(EquipmentClientInfo.LayerType.CAMEL_SADDLE, saddleLayer)
                .addLayers(EquipmentClientInfo.LayerType.CAMEL_HUSK_SADDLE, saddleLayer)
                .addLayers(EquipmentClientInfo.LayerType.HORSE_SADDLE, saddleLayer)
                .addLayers(EquipmentClientInfo.LayerType.DONKEY_SADDLE, saddleLayer)
                .addLayers(EquipmentClientInfo.LayerType.MULE_SADDLE, saddleLayer)
                .addLayers(EquipmentClientInfo.LayerType.SKELETON_HORSE_SADDLE, saddleLayer)
                .addLayers(EquipmentClientInfo.LayerType.ZOMBIE_HORSE_SADDLE, saddleLayer)
                .addLayers(EquipmentClientInfo.LayerType.NAUTILUS_SADDLE, saddleLayer)
                .build()
        );
 
        for (Entry<DyeColor, ResourceKey<EquipmentAsset>> entry : EquipmentAssets.HARNESSES.entrySet()) {
            DyeColor color = entry.getKey();
            ResourceKey<EquipmentAsset> id = entry.getValue();
            consumer.accept(
                id,
                EquipmentClientInfo.builder()
                    .addLayers(
                        EquipmentClientInfo.LayerType.HAPPY_GHAST_BODY,
                        EquipmentClientInfo.Layer.onlyIfDyed(Identifier.withDefaultNamespace(color.getSerializedName() + "_harness"), false)
                    )
                    .build()
            );
        }
 
        for (Entry<DyeColor, ResourceKey<EquipmentAsset>> entry : EquipmentAssets.CARPETS.entrySet()) {
            DyeColor color = entry.getKey();
            ResourceKey<EquipmentAsset> id = entry.getValue();
            consumer.accept(
                id,
                EquipmentClientInfo.builder()
                    .addLayers(
                        EquipmentClientInfo.LayerType.LLAMA_BODY, new EquipmentClientInfo.Layer(Identifier.withDefaultNamespace(color.getSerializedName()))
                    )
                    .build()
            );
        }
 
        consumer.accept(
            EquipmentAssets.TRADER_LLAMA,
            EquipmentClientInfo.builder()
                .addLayers(EquipmentClientInfo.LayerType.LLAMA_BODY, new EquipmentClientInfo.Layer(Identifier.withDefaultNamespace("trader_llama")))
                .build()
        );
        consumer.accept(
            EquipmentAssets.TRADER_LLAMA_BABY,
            EquipmentClientInfo.builder()
                .addLayers(EquipmentClientInfo.LayerType.LLAMA_BODY, new EquipmentClientInfo.Layer(Identifier.withDefaultNamespace("trader_llama_baby")))
                .build()
        );
    }
 
    private static EquipmentClientInfo onlyHumanoid(String name) {
        return EquipmentClientInfo.builder().addHumanoidLayers(Identifier.withDefaultNamespace(name)).build();
    }
 
    private static EquipmentClientInfo humanoidAndMountArmor(String name) {
        return EquipmentClientInfo.builder()
            .addHumanoidLayers(Identifier.withDefaultNamespace(name))
            .addLayers(EquipmentClientInfo.LayerType.HORSE_BODY, EquipmentClientInfo.Layer.leatherDyeable(Identifier.withDefaultNamespace(name), false))
            .addLayers(EquipmentClientInfo.LayerType.NAUTILUS_BODY, EquipmentClientInfo.Layer.leatherDyeable(Identifier.withDefaultNamespace(name), false))
            .build();
    }
 
    @Override
    public CompletableFuture<?> run(CachedOutput cache) {
        Map<ResourceKey<EquipmentAsset>, EquipmentClientInfo> equipmentAssets = new HashMap<>();
        bootstrap((id, asset) -> {
            if (equipmentAssets.putIfAbsent(id, asset) != null) {
                throw new IllegalStateException("Tried to register equipment asset twice for id: " + id);
            }
        });
        return DataProvider.saveAll(cache, EquipmentClientInfo.CODEC, this.pathProvider::json, equipmentAssets);
    }
 
    @Override
    public String getName() {
        return "Equipment Asset Definitions";
    }
}

引用的其他类

  • EquipmentClientInfo

    • 引用位置: 参数/方法调用/构造调用/返回值
    • 关联成员: EquipmentClientInfo.Layer(), EquipmentClientInfo.Layer.leatherDyeable(), EquipmentClientInfo.Layer.onlyIfDyed(), EquipmentClientInfo.builder(), Layer()
  • CachedOutput

    • 引用位置: 参数
  • DataProvider

    • 引用位置: 实现/方法调用
    • 关联成员: DataProvider.saveAll()
  • PackOutput

    • 引用位置: 参数/字段
  • Identifier

    • 引用位置: 方法调用
    • 关联成员: Identifier.withDefaultNamespace()
  • ResourceKey

    • 引用位置: 参数
  • EquipmentAsset

    • 引用位置: 参数