HoglinModel.java

net.minecraft.client.model.monster.hoglin.HoglinModel

信息

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

    TODO

字段/常量

  • DEFAULT_HEAD_X_ROT

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

      TODO

  • ATTACK_HEAD_X_ROT_END

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

      TODO

  • head

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

      TODO

  • rightEar

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

      TODO

  • leftEar

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

      TODO

  • rightFrontLeg

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

      TODO

  • leftFrontLeg

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

      TODO

  • rightHindLeg

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

      TODO

  • leftHindLeg

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

      TODO

内部类/嵌套类型

构造器

public HoglinModel(ModelPart root) @ L28

  • 构造器名:HoglinModel
  • 源码定位:L28
  • 修饰符:public

参数:

  • root: ModelPart

说明:

TODO

方法

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

public static LayerDefinition createBodyLayer() @ L39

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

参数:

说明:

TODO

public void setupAnim(HoglinRenderState state) @ L88

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

参数:

  • state: HoglinRenderState

说明:

TODO

protected void animateHeadbutt(float headbuttLerpFactor) @ L104

  • 方法名:animateHeadbutt
  • 源码定位:L104
  • 返回类型:void
  • 修饰符:protected

参数:

  • headbuttLerpFactor: float

说明:

TODO

代码

@OnlyIn(Dist.CLIENT)
public class HoglinModel extends EntityModel<HoglinRenderState> {
    private static final float DEFAULT_HEAD_X_ROT = 0.87266463F;
    private static final float ATTACK_HEAD_X_ROT_END = (float) (-Math.PI / 9);
    protected final ModelPart head;
    private final ModelPart rightEar;
    private final ModelPart leftEar;
    private final ModelPart rightFrontLeg;
    private final ModelPart leftFrontLeg;
    private final ModelPart rightHindLeg;
    private final ModelPart leftHindLeg;
 
    public HoglinModel(ModelPart root) {
        super(root);
        this.head = root.getChild("head");
        this.rightEar = this.head.getChild("right_ear");
        this.leftEar = this.head.getChild("left_ear");
        this.rightFrontLeg = root.getChild("right_front_leg");
        this.leftFrontLeg = root.getChild("left_front_leg");
        this.rightHindLeg = root.getChild("right_hind_leg");
        this.leftHindLeg = root.getChild("left_hind_leg");
    }
 
    public static LayerDefinition createBodyLayer() {
        MeshDefinition mesh = new MeshDefinition();
        PartDefinition root = mesh.getRoot();
        PartDefinition body = root.addOrReplaceChild(
            "body", CubeListBuilder.create().texOffs(1, 1).addBox(-8.0F, -7.0F, -13.0F, 16.0F, 14.0F, 26.0F), PartPose.offset(0.0F, 7.0F, 0.0F)
        );
        body.addOrReplaceChild(
            "mane",
            CubeListBuilder.create().texOffs(90, 33).addBox(0.0F, 0.0F, -9.0F, 0.0F, 10.0F, 19.0F, new CubeDeformation(0.001F)),
            PartPose.offset(0.0F, -14.0F, -7.0F)
        );
        PartDefinition head = root.addOrReplaceChild(
            "head",
            CubeListBuilder.create().texOffs(61, 1).addBox(-7.0F, -3.0F, -19.0F, 14.0F, 6.0F, 19.0F),
            PartPose.offsetAndRotation(0.0F, 2.0F, -12.0F, 0.87266463F, 0.0F, 0.0F)
        );
        head.addOrReplaceChild(
            "right_ear",
            CubeListBuilder.create().texOffs(1, 1).addBox(-6.0F, -1.0F, -2.0F, 6.0F, 1.0F, 4.0F),
            PartPose.offsetAndRotation(-6.0F, -2.0F, -3.0F, 0.0F, 0.0F, (float) (-Math.PI * 2.0 / 9.0))
        );
        head.addOrReplaceChild(
            "left_ear",
            CubeListBuilder.create().texOffs(1, 6).addBox(0.0F, -1.0F, -2.0F, 6.0F, 1.0F, 4.0F),
            PartPose.offsetAndRotation(6.0F, -2.0F, -3.0F, 0.0F, 0.0F, (float) (Math.PI * 2.0 / 9.0))
        );
        head.addOrReplaceChild(
            "right_horn", CubeListBuilder.create().texOffs(10, 13).addBox(-1.0F, -11.0F, -1.0F, 2.0F, 11.0F, 2.0F), PartPose.offset(-7.0F, 2.0F, -12.0F)
        );
        head.addOrReplaceChild(
            "left_horn", CubeListBuilder.create().texOffs(1, 13).addBox(-1.0F, -11.0F, -1.0F, 2.0F, 11.0F, 2.0F), PartPose.offset(7.0F, 2.0F, -12.0F)
        );
        int frontLegHeight = 14;
        int backLegHeight = 11;
        root.addOrReplaceChild(
            "right_front_leg", CubeListBuilder.create().texOffs(66, 42).addBox(-3.0F, 0.0F, -3.0F, 6.0F, 14.0F, 6.0F), PartPose.offset(-4.0F, 10.0F, -8.5F)
        );
        root.addOrReplaceChild(
            "left_front_leg", CubeListBuilder.create().texOffs(41, 42).addBox(-3.0F, 0.0F, -3.0F, 6.0F, 14.0F, 6.0F), PartPose.offset(4.0F, 10.0F, -8.5F)
        );
        root.addOrReplaceChild(
            "right_hind_leg", CubeListBuilder.create().texOffs(21, 45).addBox(-2.5F, 0.0F, -2.5F, 5.0F, 11.0F, 5.0F), PartPose.offset(-5.0F, 13.0F, 10.0F)
        );
        root.addOrReplaceChild(
            "left_hind_leg", CubeListBuilder.create().texOffs(0, 45).addBox(-2.5F, 0.0F, -2.5F, 5.0F, 11.0F, 5.0F), PartPose.offset(5.0F, 13.0F, 10.0F)
        );
        return LayerDefinition.create(mesh, 128, 64);
    }
 
    public void setupAnim(HoglinRenderState state) {
        super.setupAnim(state);
        float animationSpeed = state.walkAnimationSpeed;
        float animationPos = state.walkAnimationPos;
        this.rightEar.zRot = (float) (-Math.PI * 2.0 / 9.0) - animationSpeed * Mth.sin(animationPos);
        this.leftEar.zRot = (float) (Math.PI * 2.0 / 9.0) + animationSpeed * Mth.sin(animationPos);
        this.head.yRot = state.yRot * (float) (Math.PI / 180.0);
        float headbuttLerpFactor = 1.0F - Mth.abs(10 - 2 * state.attackAnimationRemainingTicks) / 10.0F;
        this.animateHeadbutt(headbuttLerpFactor);
        float amplitudeMultiplier = 1.2F;
        this.rightFrontLeg.xRot = Mth.cos(animationPos) * 1.2F * animationSpeed;
        this.leftFrontLeg.xRot = Mth.cos(animationPos + (float) Math.PI) * 1.2F * animationSpeed;
        this.rightHindLeg.xRot = this.leftFrontLeg.xRot;
        this.leftHindLeg.xRot = this.rightFrontLeg.xRot;
    }
 
    protected void animateHeadbutt(float headbuttLerpFactor) {
        this.head.xRot = Mth.lerp(headbuttLerpFactor, 0.87266463F, (float) (-Math.PI / 9));
    }
}

引用的其他类

  • EntityModel

    • 引用位置: 继承
  • ModelPart

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

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

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

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

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

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

    • 引用位置: 参数
  • Mth

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