SnowGolemModel.java

net.minecraft.client.model.animal.golem.SnowGolemModel

信息

  • 全限定名:net.minecraft.client.model.animal.golem.SnowGolemModel
  • 类型:public class
  • 包:net.minecraft.client.model.animal.golem
  • 源码路径:src/main/java/net/minecraft/client/model/animal/golem/SnowGolemModel.java
  • 起始行号:L17
  • 继承:EntityModel
  • 职责:

    TODO

字段/常量

  • UPPER_BODY

    • 类型: String
    • 修饰符: private static final
    • 源码定位: L18
    • 说明:

      TODO

  • upperBody

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

      TODO

  • head

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

      TODO

  • leftArm

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

      TODO

  • rightArm

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

      TODO

内部类/嵌套类型

构造器

public SnowGolemModel(ModelPart root) @ L24

  • 构造器名:SnowGolemModel
  • 源码定位:L24
  • 修饰符:public

参数:

  • root: ModelPart

说明:

TODO

方法

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

public static LayerDefinition createBodyLayer() @ L32

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

参数:

说明:

TODO

public void setupAnim(LivingEntityRenderState state) @ L56

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

参数:

  • state: LivingEntityRenderState

说明:

TODO

public ModelPart getHead() @ L71

  • 方法名:getHead
  • 源码定位:L71
  • 返回类型:ModelPart
  • 修饰符:public

参数:

说明:

TODO

代码

@OnlyIn(Dist.CLIENT)
public class SnowGolemModel extends EntityModel<LivingEntityRenderState> {
    private static final String UPPER_BODY = "upper_body";
    private final ModelPart upperBody;
    private final ModelPart head;
    private final ModelPart leftArm;
    private final ModelPart rightArm;
 
    public SnowGolemModel(ModelPart root) {
        super(root);
        this.head = root.getChild("head");
        this.leftArm = root.getChild("left_arm");
        this.rightArm = root.getChild("right_arm");
        this.upperBody = root.getChild("upper_body");
    }
 
    public static LayerDefinition createBodyLayer() {
        MeshDefinition mesh = new MeshDefinition();
        PartDefinition root = mesh.getRoot();
        float yOffset = 4.0F;
        CubeDeformation deformation = new CubeDeformation(-0.5F);
        root.addOrReplaceChild(
            "head", CubeListBuilder.create().texOffs(0, 0).addBox(-4.0F, -8.0F, -4.0F, 8.0F, 8.0F, 8.0F, deformation), PartPose.offset(0.0F, 4.0F, 0.0F)
        );
        CubeListBuilder arm = CubeListBuilder.create().texOffs(32, 0).addBox(-1.0F, 0.0F, -1.0F, 12.0F, 2.0F, 2.0F, deformation);
        root.addOrReplaceChild("left_arm", arm, PartPose.offsetAndRotation(5.0F, 6.0F, 1.0F, 0.0F, 0.0F, 1.0F));
        root.addOrReplaceChild("right_arm", arm, PartPose.offsetAndRotation(-5.0F, 6.0F, -1.0F, 0.0F, (float) Math.PI, -1.0F));
        root.addOrReplaceChild(
            "upper_body",
            CubeListBuilder.create().texOffs(0, 16).addBox(-5.0F, -10.0F, -5.0F, 10.0F, 10.0F, 10.0F, deformation),
            PartPose.offset(0.0F, 13.0F, 0.0F)
        );
        root.addOrReplaceChild(
            "lower_body",
            CubeListBuilder.create().texOffs(0, 36).addBox(-6.0F, -12.0F, -6.0F, 12.0F, 12.0F, 12.0F, deformation),
            PartPose.offset(0.0F, 24.0F, 0.0F)
        );
        return LayerDefinition.create(mesh, 64, 64);
    }
 
    public void setupAnim(LivingEntityRenderState state) {
        super.setupAnim(state);
        this.head.yRot = state.yRot * (float) (Math.PI / 180.0);
        this.head.xRot = state.xRot * (float) (Math.PI / 180.0);
        this.upperBody.yRot = state.yRot * (float) (Math.PI / 180.0) * 0.25F;
        float sin = Mth.sin(this.upperBody.yRot);
        float cos = Mth.cos(this.upperBody.yRot);
        this.leftArm.yRot = this.upperBody.yRot;
        this.rightArm.yRot = this.upperBody.yRot + (float) Math.PI;
        this.leftArm.x = cos * 5.0F;
        this.leftArm.z = -sin * 5.0F;
        this.rightArm.x = -cos * 5.0F;
        this.rightArm.z = sin * 5.0F;
    }
 
    public ModelPart getHead() {
        return this.head;
    }
}

引用的其他类

  • EntityModel

    • 引用位置: 继承
  • ModelPart

    • 引用位置: 参数/字段/返回值
  • PartPose

    • 引用位置: 方法调用
    • 关联成员: PartPose.offset(), PartPose.offsetAndRotation()
  • CubeDeformation

    • 引用位置: 构造调用
    • 关联成员: CubeDeformation()
  • CubeListBuilder

    • 引用位置: 方法调用
    • 关联成员: CubeListBuilder.create()
  • LayerDefinition

    • 引用位置: 方法调用/返回值
    • 关联成员: LayerDefinition.create()
  • MeshDefinition

    • 引用位置: 构造调用
    • 关联成员: MeshDefinition()
  • LivingEntityRenderState

    • 引用位置: 参数
  • Mth

    • 引用位置: 方法调用
    • 关联成员: Mth.cos(), Mth.sin()