ConduitRenderer.java

net.minecraft.client.renderer.blockentity.ConduitRenderer

信息

  • 全限定名:net.minecraft.client.renderer.blockentity.ConduitRenderer
  • 类型:public class
  • 包:net.minecraft.client.renderer.blockentity
  • 源码路径:src/main/java/net/minecraft/client/renderer/blockentity/ConduitRenderer.java
  • 起始行号:L35
  • 实现:BlockEntityRenderer<ConduitBlockEntity,ConduitRenderState>
  • 职责:

    TODO

字段/常量

  • DEFAULT_TRANSFORMATION

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

      TODO

  • MAPPER

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

      TODO

  • SHELL_TEXTURE

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

      TODO

  • ACTIVE_SHELL_TEXTURE

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

      TODO

  • WIND_TEXTURE

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

      TODO

  • VERTICAL_WIND_TEXTURE

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

      TODO

  • OPEN_EYE_TEXTURE

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

      TODO

  • CLOSED_EYE_TEXTURE

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

      TODO

  • sprites

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

      TODO

  • eye

    • 类型: ModelPart
    • 修饰符: private final
    • 源码定位: L45
    • 说明:

      TODO

  • wind

    • 类型: ModelPart
    • 修饰符: private final
    • 源码定位: L46
    • 说明:

      TODO

  • shell

    • 类型: ModelPart
    • 修饰符: private final
    • 源码定位: L47
    • 说明:

      TODO

  • cage

    • 类型: ModelPart
    • 修饰符: private final
    • 源码定位: L48
    • 说明:

      TODO

内部类/嵌套类型

构造器

public ConduitRenderer(BlockEntityRendererProvider.Context context) @ L50

  • 构造器名:ConduitRenderer
  • 源码定位:L50
  • 修饰符:public

参数:

  • context: BlockEntityRendererProvider.Context

说明:

TODO

方法

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

public static LayerDefinition createEyeLayer() @ L58

  • 方法名:createEyeLayer
  • 源码定位:L58
  • 返回类型:LayerDefinition
  • 修饰符:public static

参数:

说明:

TODO

public static LayerDefinition createWindLayer() @ L67

  • 方法名:createWindLayer
  • 源码定位:L67
  • 返回类型:LayerDefinition
  • 修饰符:public static

参数:

说明:

TODO

public static LayerDefinition createShellLayer() @ L74

  • 方法名:createShellLayer
  • 源码定位:L74
  • 返回类型:LayerDefinition
  • 修饰符:public static

参数:

说明:

TODO

public static LayerDefinition createCageLayer() @ L81

  • 方法名:createCageLayer
  • 源码定位:L81
  • 返回类型:LayerDefinition
  • 修饰符:public static

参数:

说明:

TODO

public ConduitRenderState createRenderState() @ L88

  • 方法名:createRenderState
  • 源码定位:L88
  • 返回类型:ConduitRenderState
  • 修饰符:public

参数:

说明:

TODO

public void extractRenderState(ConduitBlockEntity blockEntity, ConduitRenderState state, float partialTicks, Vec3 cameraPosition, ModelFeatureRenderer.CrumblingOverlay breakProgress) @ L92

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

参数:

  • blockEntity: ConduitBlockEntity
  • state: ConduitRenderState
  • partialTicks: float
  • cameraPosition: Vec3
  • breakProgress: ModelFeatureRenderer.CrumblingOverlay

说明:

TODO

public void submit(ConduitRenderState state, PoseStack poseStack, SubmitNodeCollector submitNodeCollector, CameraRenderState camera) @ L107

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

参数:

  • state: ConduitRenderState
  • poseStack: PoseStack
  • submitNodeCollector: SubmitNodeCollector
  • camera: CameraRenderState

说明:

TODO

代码

@OnlyIn(Dist.CLIENT)
public class ConduitRenderer implements BlockEntityRenderer<ConduitBlockEntity, ConduitRenderState> {
    public static final Transformation DEFAULT_TRANSFORMATION = new Transformation(new Vector3f(0.5F, 0.5F, 0.5F), null, null, null);
    public static final SpriteMapper MAPPER = new SpriteMapper(TextureAtlas.LOCATION_BLOCKS, "entity/conduit");
    public static final SpriteId SHELL_TEXTURE = MAPPER.defaultNamespaceApply("base");
    public static final SpriteId ACTIVE_SHELL_TEXTURE = MAPPER.defaultNamespaceApply("cage");
    public static final SpriteId WIND_TEXTURE = MAPPER.defaultNamespaceApply("wind");
    public static final SpriteId VERTICAL_WIND_TEXTURE = MAPPER.defaultNamespaceApply("wind_vertical");
    public static final SpriteId OPEN_EYE_TEXTURE = MAPPER.defaultNamespaceApply("open_eye");
    public static final SpriteId CLOSED_EYE_TEXTURE = MAPPER.defaultNamespaceApply("closed_eye");
    private final SpriteGetter sprites;
    private final ModelPart eye;
    private final ModelPart wind;
    private final ModelPart shell;
    private final ModelPart cage;
 
    public ConduitRenderer(BlockEntityRendererProvider.Context context) {
        this.sprites = context.sprites();
        this.eye = context.bakeLayer(ModelLayers.CONDUIT_EYE);
        this.wind = context.bakeLayer(ModelLayers.CONDUIT_WIND);
        this.shell = context.bakeLayer(ModelLayers.CONDUIT_SHELL);
        this.cage = context.bakeLayer(ModelLayers.CONDUIT_CAGE);
    }
 
    public static LayerDefinition createEyeLayer() {
        MeshDefinition mesh = new MeshDefinition();
        PartDefinition root = mesh.getRoot();
        root.addOrReplaceChild(
            "eye", CubeListBuilder.create().texOffs(0, 0).addBox(-4.0F, -4.0F, 0.0F, 8.0F, 8.0F, 0.0F, new CubeDeformation(0.01F)), PartPose.ZERO
        );
        return LayerDefinition.create(mesh, 16, 16);
    }
 
    public static LayerDefinition createWindLayer() {
        MeshDefinition mesh = new MeshDefinition();
        PartDefinition root = mesh.getRoot();
        root.addOrReplaceChild("wind", CubeListBuilder.create().texOffs(0, 0).addBox(-8.0F, -8.0F, -8.0F, 16.0F, 16.0F, 16.0F), PartPose.ZERO);
        return LayerDefinition.create(mesh, 64, 32);
    }
 
    public static LayerDefinition createShellLayer() {
        MeshDefinition mesh = new MeshDefinition();
        PartDefinition root = mesh.getRoot();
        root.addOrReplaceChild("shell", CubeListBuilder.create().texOffs(0, 0).addBox(-3.0F, -3.0F, -3.0F, 6.0F, 6.0F, 6.0F), PartPose.ZERO);
        return LayerDefinition.create(mesh, 32, 16);
    }
 
    public static LayerDefinition createCageLayer() {
        MeshDefinition mesh = new MeshDefinition();
        PartDefinition root = mesh.getRoot();
        root.addOrReplaceChild("shell", CubeListBuilder.create().texOffs(0, 0).addBox(-4.0F, -4.0F, -4.0F, 8.0F, 8.0F, 8.0F), PartPose.ZERO);
        return LayerDefinition.create(mesh, 32, 16);
    }
 
    public ConduitRenderState createRenderState() {
        return new ConduitRenderState();
    }
 
    public void extractRenderState(
        ConduitBlockEntity blockEntity,
        ConduitRenderState state,
        float partialTicks,
        Vec3 cameraPosition,
        ModelFeatureRenderer.@Nullable CrumblingOverlay breakProgress
    ) {
        BlockEntityRenderer.super.extractRenderState(blockEntity, state, partialTicks, cameraPosition, breakProgress);
        state.isActive = blockEntity.isActive();
        state.activeRotation = blockEntity.getActiveRotation(blockEntity.isActive() ? partialTicks : 0.0F);
        state.animTime = blockEntity.tickCount + partialTicks;
        state.animationPhase = blockEntity.tickCount / 66 % 3;
        state.isHunting = blockEntity.isHunting();
    }
 
    public void submit(ConduitRenderState state, PoseStack poseStack, SubmitNodeCollector submitNodeCollector, CameraRenderState camera) {
        if (!state.isActive) {
            poseStack.pushPose();
            poseStack.translate(0.5F, 0.5F, 0.5F);
            poseStack.mulPose(new Quaternionf().rotationY(state.activeRotation * (float) (Math.PI / 180.0)));
            submitNodeCollector.submitModelPart(
                this.shell,
                poseStack,
                SHELL_TEXTURE.renderType(RenderTypes::entitySolid),
                state.lightCoords,
                OverlayTexture.NO_OVERLAY,
                this.sprites.get(SHELL_TEXTURE),
                -1,
                state.breakProgress
            );
            poseStack.popPose();
        } else {
            float rotation = state.activeRotation * (180.0F / (float)Math.PI);
            float hh = Mth.sin(state.animTime * 0.1F) / 2.0F + 0.5F;
            hh = hh * hh + hh;
            poseStack.pushPose();
            poseStack.translate(0.5F, 0.3F + hh * 0.2F, 0.5F);
            Vector3f axis = new Vector3f(0.5F, 1.0F, 0.5F).normalize();
            poseStack.mulPose(new Quaternionf().rotationAxis(rotation * (float) (Math.PI / 180.0), axis));
            submitNodeCollector.submitModelPart(
                this.cage,
                poseStack,
                ACTIVE_SHELL_TEXTURE.renderType(RenderTypes::entityCutout),
                state.lightCoords,
                OverlayTexture.NO_OVERLAY,
                this.sprites.get(ACTIVE_SHELL_TEXTURE),
                -1,
                state.breakProgress
            );
            poseStack.popPose();
            poseStack.pushPose();
            poseStack.translate(0.5F, 0.5F, 0.5F);
            if (state.animationPhase == 1) {
                poseStack.mulPose(new Quaternionf().rotationX((float) (Math.PI / 2)));
            } else if (state.animationPhase == 2) {
                poseStack.mulPose(new Quaternionf().rotationZ((float) (Math.PI / 2)));
            }
 
            SpriteId windSpriteId = state.animationPhase == 1 ? VERTICAL_WIND_TEXTURE : WIND_TEXTURE;
            RenderType windRenderType = windSpriteId.renderType(RenderTypes::entityCutout);
            TextureAtlasSprite windSprite = this.sprites.get(windSpriteId);
            submitNodeCollector.submitModelPart(this.wind, poseStack, windRenderType, state.lightCoords, OverlayTexture.NO_OVERLAY, windSprite);
            poseStack.popPose();
            poseStack.pushPose();
            poseStack.translate(0.5F, 0.5F, 0.5F);
            poseStack.scale(0.875F, 0.875F, 0.875F);
            poseStack.mulPose(new Quaternionf().rotationXYZ((float) Math.PI, 0.0F, (float) Math.PI));
            submitNodeCollector.submitModelPart(this.wind, poseStack, windRenderType, state.lightCoords, OverlayTexture.NO_OVERLAY, windSprite);
            poseStack.popPose();
            poseStack.pushPose();
            poseStack.translate(0.5F, 0.3F + hh * 0.2F, 0.5F);
            poseStack.scale(0.5F, 0.5F, 0.5F);
            poseStack.mulPose(camera.orientation);
            poseStack.mulPose(new Quaternionf().rotationZ((float) Math.PI).rotateY((float) Math.PI));
            float scale = 1.3333334F;
            poseStack.scale(1.3333334F, 1.3333334F, 1.3333334F);
            SpriteId eyeSprite = state.isHunting ? OPEN_EYE_TEXTURE : CLOSED_EYE_TEXTURE;
            submitNodeCollector.submitModelPart(
                this.eye, poseStack, eyeSprite.renderType(RenderTypes::entityCutout), state.lightCoords, OverlayTexture.NO_OVERLAY, this.sprites.get(eyeSprite)
            );
            poseStack.popPose();
        }
    }
}

引用的其他类