AbstractEquineModel.java

net.minecraft.client.model.animal.equine.AbstractEquineModel

信息

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

    TODO

字段/常量

  • DEG_125

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

      TODO

  • DEG_60

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

      TODO

  • DEG_45

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

      TODO

  • DEG_30

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

      TODO

  • DEG_15

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

      TODO

  • HEAD_PARTS

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

      TODO

  • body

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

      TODO

  • headParts

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

      TODO

  • rightHindLeg

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

      TODO

  • leftHindLeg

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

      TODO

  • rightFrontLeg

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

      TODO

  • leftFrontLeg

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

      TODO

  • tail

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

      TODO

内部类/嵌套类型

构造器

public AbstractEquineModel(ModelPart root) @ L31

  • 构造器名:AbstractEquineModel
  • 源码定位:L31
  • 修饰符:public

参数:

  • root: ModelPart

说明:

TODO

public AbstractEquineModel(ModelPart root, ModelPart headParts, ModelPart rightHindLeg, ModelPart rightFrontLeg, ModelPart leftHindLeg, ModelPart leftFrontLeg, ModelPart tail) @ L42

  • 构造器名:AbstractEquineModel
  • 源码定位:L42
  • 修饰符:public

参数:

  • root: ModelPart
  • headParts: ModelPart
  • rightHindLeg: ModelPart
  • rightFrontLeg: ModelPart
  • leftHindLeg: ModelPart
  • leftFrontLeg: ModelPart
  • tail: ModelPart

说明:

TODO

方法

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

public static MeshDefinition createBodyMesh(CubeDeformation g) @ L55

  • 方法名:createBodyMesh
  • 源码定位:L55
  • 返回类型:MeshDefinition
  • 修饰符:public static

参数:

  • g: CubeDeformation

说明:

TODO

public void setupAnim(T state) @ L105

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

参数:

  • state: T

说明:

TODO

protected void offsetLegPositionWhenStanding(float standing) @ L155

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

参数:

  • standing: float

说明:

TODO

protected float getLegStandAngle() @ L158

  • 方法名:getLegStandAngle
  • 源码定位:L158
  • 返回类型:float
  • 修饰符:protected

参数:

说明:

TODO

protected float getLegStandingYOffset() @ L162

  • 方法名:getLegStandingYOffset
  • 源码定位:L162
  • 返回类型:float
  • 修饰符:protected

参数:

说明:

TODO

protected float getLegStandingZOffset() @ L166

  • 方法名:getLegStandingZOffset
  • 源码定位:L166
  • 返回类型:float
  • 修饰符:protected

参数:

说明:

TODO

protected float getLegStandingXRotOffset() @ L170

  • 方法名:getLegStandingXRotOffset
  • 源码定位:L170
  • 返回类型:float
  • 修饰符:protected

参数:

说明:

TODO

protected float getTailXRotOffset() @ L174

  • 方法名:getTailXRotOffset
  • 源码定位:L174
  • 返回类型:float
  • 修饰符:protected

参数:

说明:

TODO

protected void animateHeadPartsPlacement(float eating, float standing) @ L178

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

参数:

  • eating: float
  • standing: float

说明:

TODO

代码

@OnlyIn(Dist.CLIENT)
public abstract class AbstractEquineModel<T extends EquineRenderState> extends EntityModel<T> {
    private static final float DEG_125 = 2.1816616F;
    private static final float DEG_60 = (float) (Math.PI / 3);
    private static final float DEG_45 = (float) (Math.PI / 4);
    private static final float DEG_30 = (float) (Math.PI / 6);
    private static final float DEG_15 = (float) (Math.PI / 12);
    protected static final String HEAD_PARTS = "head_parts";
    protected final ModelPart body;
    protected final ModelPart headParts;
    protected final ModelPart rightHindLeg;
    protected final ModelPart leftHindLeg;
    protected final ModelPart rightFrontLeg;
    protected final ModelPart leftFrontLeg;
    private final ModelPart tail;
 
    public AbstractEquineModel(ModelPart root) {
        super(root);
        this.body = root.getChild("body");
        this.headParts = root.getChild("head_parts");
        this.rightHindLeg = root.getChild("right_hind_leg");
        this.leftHindLeg = root.getChild("left_hind_leg");
        this.rightFrontLeg = root.getChild("right_front_leg");
        this.leftFrontLeg = root.getChild("left_front_leg");
        this.tail = this.body.getChild("tail");
    }
 
    public AbstractEquineModel(
        ModelPart root, ModelPart headParts, ModelPart rightHindLeg, ModelPart rightFrontLeg, ModelPart leftHindLeg, ModelPart leftFrontLeg, ModelPart tail
    ) {
        super(root);
        this.body = root.getChild("body");
        this.headParts = headParts;
        this.rightHindLeg = rightHindLeg;
        this.leftHindLeg = leftHindLeg;
        this.rightFrontLeg = rightFrontLeg;
        this.leftFrontLeg = leftFrontLeg;
        this.tail = tail;
    }
 
    public static MeshDefinition createBodyMesh(CubeDeformation g) {
        MeshDefinition mesh = new MeshDefinition();
        PartDefinition root = mesh.getRoot();
        PartDefinition body = root.addOrReplaceChild(
            "body",
            CubeListBuilder.create().texOffs(0, 32).addBox(-5.0F, -8.0F, -17.0F, 10.0F, 10.0F, 22.0F, new CubeDeformation(0.05F)),
            PartPose.offset(0.0F, 11.0F, 5.0F)
        );
        PartDefinition headParts = root.addOrReplaceChild(
            "head_parts",
            CubeListBuilder.create().texOffs(0, 35).addBox(-2.05F, -6.0F, -2.0F, 4.0F, 12.0F, 7.0F),
            PartPose.offsetAndRotation(0.0F, 4.0F, -12.0F, (float) (Math.PI / 6), 0.0F, 0.0F)
        );
        PartDefinition head = headParts.addOrReplaceChild(
            "head", CubeListBuilder.create().texOffs(0, 13).addBox(-3.0F, -11.0F, -2.0F, 6.0F, 5.0F, 7.0F, g), PartPose.ZERO
        );
        headParts.addOrReplaceChild("mane", CubeListBuilder.create().texOffs(56, 36).addBox(-1.0F, -11.0F, 5.01F, 2.0F, 16.0F, 2.0F, g), PartPose.ZERO);
        headParts.addOrReplaceChild("upper_mouth", CubeListBuilder.create().texOffs(0, 25).addBox(-2.0F, -11.0F, -7.0F, 4.0F, 5.0F, 5.0F, g), PartPose.ZERO);
        root.addOrReplaceChild(
            "left_hind_leg",
            CubeListBuilder.create().texOffs(48, 21).mirror().addBox(-3.0F, -1.01F, -1.0F, 4.0F, 11.0F, 4.0F, g),
            PartPose.offset(4.0F, 14.0F, 7.0F)
        );
        root.addOrReplaceChild(
            "right_hind_leg", CubeListBuilder.create().texOffs(48, 21).addBox(-1.0F, -1.01F, -1.0F, 4.0F, 11.0F, 4.0F, g), PartPose.offset(-4.0F, 14.0F, 7.0F)
        );
        root.addOrReplaceChild(
            "left_front_leg",
            CubeListBuilder.create().texOffs(48, 21).mirror().addBox(-3.0F, -1.01F, -1.9F, 4.0F, 11.0F, 4.0F, g),
            PartPose.offset(4.0F, 14.0F, -10.0F)
        );
        root.addOrReplaceChild(
            "right_front_leg",
            CubeListBuilder.create().texOffs(48, 21).addBox(-1.0F, -1.01F, -1.9F, 4.0F, 11.0F, 4.0F, g),
            PartPose.offset(-4.0F, 14.0F, -10.0F)
        );
        body.addOrReplaceChild(
            "tail",
            CubeListBuilder.create().texOffs(42, 36).addBox(-1.5F, 0.0F, 0.0F, 3.0F, 14.0F, 4.0F, g),
            PartPose.offsetAndRotation(0.0F, -5.0F, 2.0F, (float) (Math.PI / 6), 0.0F, 0.0F)
        );
        head.addOrReplaceChild(
            "left_ear", CubeListBuilder.create().texOffs(19, 16).addBox(0.55F, -13.0F, 4.0F, 2.0F, 3.0F, 1.0F, new CubeDeformation(-0.001F)), PartPose.ZERO
        );
        head.addOrReplaceChild(
            "right_ear", CubeListBuilder.create().texOffs(19, 16).addBox(-2.55F, -13.0F, 4.0F, 2.0F, 3.0F, 1.0F, new CubeDeformation(-0.001F)), PartPose.ZERO
        );
        return mesh;
    }
 
    public void setupAnim(T state) {
        super.setupAnim(state);
        float clampedYRot = Mth.clamp(state.yRot, -20.0F, 20.0F);
        float headRotXRad = state.xRot * (float) (Math.PI / 180.0);
        float animationSpeed = state.walkAnimationSpeed;
        float animationPos = state.walkAnimationPos;
        if (animationSpeed > 0.2F) {
            headRotXRad += Mth.cos(animationPos * 0.8F) * 0.15F * animationSpeed;
        }
 
        float eating = state.eatAnimation;
        float standing = state.standAnimation;
        float iStanding = 1.0F - standing;
        float feedingAnim = state.feedingAnimation;
        boolean animateTail = state.animateTail;
        this.headParts.xRot = (float) (Math.PI / 6) + headRotXRad;
        this.headParts.yRot = clampedYRot * (float) (Math.PI / 180.0);
        float waterMultiplier = state.isInWater ? 0.2F : 1.0F;
        float legAnim1 = Mth.cos(waterMultiplier * animationPos * 0.6662F + (float) Math.PI);
        float legXRotAnim = legAnim1 * 0.8F * animationSpeed;
        float baseHeadAngle = (1.0F - Math.max(standing, eating)) * ((float) (Math.PI / 6) + headRotXRad + feedingAnim * Mth.sin(state.ageInTicks) * 0.05F);
        this.headParts.xRot = standing * ((float) (Math.PI / 12) + headRotXRad) + eating * (2.1816616F + Mth.sin(state.ageInTicks) * 0.05F) + baseHeadAngle;
        this.headParts.yRot = standing * clampedYRot * (float) (Math.PI / 180.0) + (1.0F - Math.max(standing, eating)) * this.headParts.yRot;
        this.animateHeadPartsPlacement(eating, standing);
        this.body.xRot = standing * (float) (-Math.PI / 4) + iStanding * this.body.xRot;
        this.leftFrontLeg.y = this.leftFrontLeg.y - this.getLegStandingYOffset() * standing;
        this.leftFrontLeg.z = this.leftFrontLeg.z + this.getLegStandingZOffset() * standing;
        this.rightFrontLeg.y = this.leftFrontLeg.y;
        this.rightFrontLeg.z = this.leftFrontLeg.z;
        float standAngle = this.getLegStandAngle() * standing;
        float bobValue = Mth.cos(state.ageInTicks * 0.6F + (float) Math.PI);
        float legStandingXRotOffset = this.getLegStandingXRotOffset();
        float rlegRot = (legStandingXRotOffset + bobValue) * standing + legXRotAnim * iStanding;
        float llegRot = (legStandingXRotOffset - bobValue) * standing - legXRotAnim * iStanding;
        this.leftHindLeg.xRot = standAngle - legAnim1 * 0.5F * animationSpeed * iStanding;
        this.rightHindLeg.xRot = standAngle + legAnim1 * 0.5F * animationSpeed * iStanding;
        this.leftFrontLeg.xRot = rlegRot;
        this.rightFrontLeg.xRot = llegRot;
        this.offsetLegPositionWhenStanding(standing);
        float ageScale = state.ageScale;
        this.tail.xRot = this.getTailXRotOffset() + (float) (Math.PI / 6) + animationSpeed * 0.75F;
        this.tail.y += animationSpeed * ageScale;
        this.tail.z += animationSpeed * 2.0F * ageScale;
        if (animateTail) {
            this.tail.yRot = Mth.cos(state.ageInTicks * 0.7F);
        } else {
            this.tail.yRot = 0.0F;
        }
    }
 
    protected void offsetLegPositionWhenStanding(float standing) {
    }
 
    protected float getLegStandAngle() {
        return (float) (Math.PI / 12);
    }
 
    protected float getLegStandingYOffset() {
        return 12.0F;
    }
 
    protected float getLegStandingZOffset() {
        return 4.0F;
    }
 
    protected float getLegStandingXRotOffset() {
        return (float) (-Math.PI / 3);
    }
 
    protected float getTailXRotOffset() {
        return 0.0F;
    }
 
    protected void animateHeadPartsPlacement(float eating, float standing) {
        this.headParts.y = this.headParts.y + Mth.lerp(eating, Mth.lerp(standing, 0.0F, -8.0F), 7.0F);
        this.headParts.z = Mth.lerp(standing, this.headParts.z, -4.0F);
    }
}

引用的其他类

  • EntityModel

    • 引用位置: 继承
  • ModelPart

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

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

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

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

    • 引用位置: 构造调用/返回值
    • 关联成员: MeshDefinition()
  • Mth

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