ChestSpecialRenderer.java

net.minecraft.client.renderer.special.ChestSpecialRenderer

信息

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

    TODO

字段/常量

  • ENDER_CHEST

    • 类型: Identifier
    • 修饰符: public static final
    • 源码定位: L23
    • 说明:

      TODO

  • REGULAR

    • 类型: MultiblockChestResources<Identifier>
    • 修饰符: public static final
    • 源码定位: L24
    • 说明:

      TODO

  • TRAPPED

    • 类型: MultiblockChestResources<Identifier>
    • 修饰符: public static final
    • 源码定位: L25
    • 说明:

      TODO

  • CHRISTMAS

    • 类型: MultiblockChestResources<Identifier>
    • 修饰符: public static final
    • 源码定位: L26
    • 说明:

      TODO

  • COPPER_UNAFFECTED

    • 类型: MultiblockChestResources<Identifier>
    • 修饰符: public static final
    • 源码定位: L27
    • 说明:

      TODO

  • COPPER_EXPOSED

    • 类型: MultiblockChestResources<Identifier>
    • 修饰符: public static final
    • 源码定位: L28
    • 说明:

      TODO

  • COPPER_WEATHERED

    • 类型: MultiblockChestResources<Identifier>
    • 修饰符: public static final
    • 源码定位: L29
    • 说明:

      TODO

  • COPPER_OXIDIZED

    • 类型: MultiblockChestResources<Identifier>
    • 修饰符: public static final
    • 源码定位: L30
    • 说明:

      TODO

  • sprites

    • 类型: SpriteGetter
    • 修饰符: private final
    • 源码定位: L31
    • 说明:

      TODO

  • model

    • 类型: ChestModel
    • 修饰符: private final
    • 源码定位: L32
    • 说明:

      TODO

  • sprite

    • 类型: SpriteId
    • 修饰符: private final
    • 源码定位: L33
    • 说明:

      TODO

  • openness

    • 类型: float
    • 修饰符: private final
    • 源码定位: L34
    • 说明:

      TODO

内部类/嵌套类型

  • net.minecraft.client.renderer.special.ChestSpecialRenderer.Unbaked
    • 类型: record
    • 修饰符: public
    • 源码定位: L62
    • 说明:

      TODO

构造器

public ChestSpecialRenderer(SpriteGetter sprites, ChestModel model, SpriteId sprite, float openness) @ L36

  • 构造器名:ChestSpecialRenderer
  • 源码定位:L36
  • 修饰符:public

参数:

  • sprites: SpriteGetter
  • model: ChestModel
  • sprite: SpriteId
  • openness: float

说明:

TODO

方法

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

private static MultiblockChestResources<Identifier> createDefaultTextures(String prefix) @ L43

  • 方法名:createDefaultTextures
  • 源码定位:L43
  • 返回类型:MultiblockChestResources
  • 修饰符:private static

参数:

  • prefix: String

说明:

TODO

public void submit(PoseStack poseStack, SubmitNodeCollector submitNodeCollector, int lightCoords, int overlayCoords, boolean hasFoil, int outlineColor) @ L49

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

参数:

  • poseStack: PoseStack
  • submitNodeCollector: SubmitNodeCollector
  • lightCoords: int
  • overlayCoords: int
  • hasFoil: boolean
  • outlineColor: int

说明:

TODO

public void getExtents(Consumer<Vector3fc> output) @ L54

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

参数:

  • output: Consumer

说明:

TODO

代码

@OnlyIn(Dist.CLIENT)
public class ChestSpecialRenderer implements NoDataSpecialModelRenderer {
    public static final Identifier ENDER_CHEST = Identifier.withDefaultNamespace("ender");
    public static final MultiblockChestResources<Identifier> REGULAR = createDefaultTextures("normal");
    public static final MultiblockChestResources<Identifier> TRAPPED = createDefaultTextures("trapped");
    public static final MultiblockChestResources<Identifier> CHRISTMAS = createDefaultTextures("christmas");
    public static final MultiblockChestResources<Identifier> COPPER_UNAFFECTED = createDefaultTextures("copper");
    public static final MultiblockChestResources<Identifier> COPPER_EXPOSED = createDefaultTextures("copper_exposed");
    public static final MultiblockChestResources<Identifier> COPPER_WEATHERED = createDefaultTextures("copper_weathered");
    public static final MultiblockChestResources<Identifier> COPPER_OXIDIZED = createDefaultTextures("copper_oxidized");
    private final SpriteGetter sprites;
    private final ChestModel model;
    private final SpriteId sprite;
    private final float openness;
 
    public ChestSpecialRenderer(SpriteGetter sprites, ChestModel model, SpriteId sprite, float openness) {
        this.sprites = sprites;
        this.model = model;
        this.sprite = sprite;
        this.openness = openness;
    }
 
    private static MultiblockChestResources<Identifier> createDefaultTextures(String prefix) {
        return new MultiblockChestResources<>(
            Identifier.withDefaultNamespace(prefix), Identifier.withDefaultNamespace(prefix + "_left"), Identifier.withDefaultNamespace(prefix + "_right")
        );
    }
 
    @Override
    public void submit(PoseStack poseStack, SubmitNodeCollector submitNodeCollector, int lightCoords, int overlayCoords, boolean hasFoil, int outlineColor) {
        submitNodeCollector.submitModel(this.model, this.openness, poseStack, lightCoords, overlayCoords, -1, this.sprite, this.sprites, outlineColor, null);
    }
 
    @Override
    public void getExtents(Consumer<Vector3fc> output) {
        PoseStack poseStack = new PoseStack();
        this.model.setupAnim(this.openness);
        this.model.root().getExtentsForGui(poseStack, output);
    }
 
    @OnlyIn(Dist.CLIENT)
    public record Unbaked(Identifier texture, float openness, ChestType chestType) implements NoDataSpecialModelRenderer.Unbaked {
        public static final MapCodec<ChestSpecialRenderer.Unbaked> MAP_CODEC = RecordCodecBuilder.mapCodec(
            i -> i.group(
                    Identifier.CODEC.fieldOf("texture").forGetter(ChestSpecialRenderer.Unbaked::texture),
                    Codec.FLOAT.optionalFieldOf("openness", 0.0F).forGetter(ChestSpecialRenderer.Unbaked::openness),
                    ChestType.CODEC.optionalFieldOf("chest_type", ChestType.SINGLE).forGetter(ChestSpecialRenderer.Unbaked::chestType)
                )
                .apply(i, ChestSpecialRenderer.Unbaked::new)
        );
 
        public Unbaked(Identifier texture, ChestType chestType) {
            this(texture, 0.0F, chestType);
        }
 
        public Unbaked(Identifier texture) {
            this(texture, 0.0F, ChestType.SINGLE);
        }
 
        @Override
        public MapCodec<ChestSpecialRenderer.Unbaked> type() {
            return MAP_CODEC;
        }
 
        public ChestSpecialRenderer bake(SpecialModelRenderer.BakingContext context) {
            ChestModel model = new ChestModel(context.entityModelSet().bakeLayer(ChestRenderer.LAYERS.select(this.chestType)));
            SpriteId fullTexture = Sheets.CHEST_MAPPER.apply(this.texture);
            return new ChestSpecialRenderer(context.sprites(), model, fullTexture, this.openness);
        }
    }
}

引用的其他类