ParrotModel.java

net.minecraft.client.model.animal.parrot.ParrotModel

信息

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

    TODO

字段/常量

  • FEATHER

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

      TODO

  • body

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

      TODO

  • tail

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

      TODO

  • leftWing

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

      TODO

  • rightWing

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

      TODO

  • head

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

      TODO

  • leftLeg

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

      TODO

  • rightLeg

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

      TODO

内部类/嵌套类型

  • net.minecraft.client.model.animal.parrot.ParrotModel.Pose
    • 类型: enum
    • 修饰符: public static
    • 源码定位: L171
    • 说明:

      TODO

构造器

public ParrotModel(ModelPart root) @ L27

  • 构造器名:ParrotModel
  • 源码定位:L27
  • 修饰符:public

参数:

  • root: ModelPart

说明:

TODO

方法

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

public static LayerDefinition createBodyLayer() @ L38

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

参数:

说明:

TODO

public void setupAnim(ParrotRenderState state) @ L84

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

参数:

  • state: ParrotRenderState

说明:

TODO

private void prepare(ParrotModel.Pose pose) @ L130

  • 方法名:prepare
  • 源码定位:L130
  • 返回类型:void
  • 修饰符:private

参数:

  • pose: ParrotModel.Pose

说明:

TODO

public static ParrotModel.Pose getPose(Parrot entity) @ L160

  • 方法名:getPose
  • 源码定位:L160
  • 返回类型:ParrotModel.Pose
  • 修饰符:public static

参数:

  • entity: Parrot

说明:

TODO

代码

@OnlyIn(Dist.CLIENT)
public class ParrotModel extends EntityModel<ParrotRenderState> {
    private static final String FEATHER = "feather";
    private final ModelPart body;
    private final ModelPart tail;
    private final ModelPart leftWing;
    private final ModelPart rightWing;
    private final ModelPart head;
    private final ModelPart leftLeg;
    private final ModelPart rightLeg;
 
    public ParrotModel(ModelPart root) {
        super(root);
        this.body = root.getChild("body");
        this.tail = root.getChild("tail");
        this.leftWing = root.getChild("left_wing");
        this.rightWing = root.getChild("right_wing");
        this.head = root.getChild("head");
        this.leftLeg = root.getChild("left_leg");
        this.rightLeg = root.getChild("right_leg");
    }
 
    public static LayerDefinition createBodyLayer() {
        MeshDefinition mesh = new MeshDefinition();
        PartDefinition root = mesh.getRoot();
        root.addOrReplaceChild(
            "body",
            CubeListBuilder.create().texOffs(2, 8).addBox(-1.5F, 0.0F, -1.5F, 3.0F, 6.0F, 3.0F),
            PartPose.offsetAndRotation(0.0F, 16.5F, -3.0F, 0.4937F, 0.0F, 0.0F)
        );
        root.addOrReplaceChild(
            "tail",
            CubeListBuilder.create().texOffs(22, 1).addBox(-1.5F, -1.0F, -1.0F, 3.0F, 4.0F, 1.0F),
            PartPose.offsetAndRotation(0.0F, 21.07F, 1.16F, 1.015F, 0.0F, 0.0F)
        );
        root.addOrReplaceChild(
            "left_wing",
            CubeListBuilder.create().texOffs(19, 8).addBox(-0.5F, 0.0F, -1.5F, 1.0F, 5.0F, 3.0F),
            PartPose.offsetAndRotation(1.5F, 16.94F, -2.76F, -0.6981F, (float) -Math.PI, 0.0F)
        );
        root.addOrReplaceChild(
            "right_wing",
            CubeListBuilder.create().texOffs(19, 8).addBox(-0.5F, 0.0F, -1.5F, 1.0F, 5.0F, 3.0F),
            PartPose.offsetAndRotation(-1.5F, 16.94F, -2.76F, -0.6981F, (float) -Math.PI, 0.0F)
        );
        PartDefinition head = root.addOrReplaceChild(
            "head", CubeListBuilder.create().texOffs(2, 2).addBox(-1.0F, -1.5F, -1.0F, 2.0F, 3.0F, 2.0F), PartPose.offset(0.0F, 15.69F, -2.76F)
        );
        head.addOrReplaceChild(
            "head2", CubeListBuilder.create().texOffs(10, 0).addBox(-1.0F, -0.5F, -2.0F, 2.0F, 1.0F, 4.0F), PartPose.offset(0.0F, -2.0F, -1.0F)
        );
        head.addOrReplaceChild(
            "beak1", CubeListBuilder.create().texOffs(11, 7).addBox(-0.5F, -1.0F, -0.5F, 1.0F, 2.0F, 1.0F), PartPose.offset(0.0F, -0.5F, -1.5F)
        );
        head.addOrReplaceChild(
            "beak2", CubeListBuilder.create().texOffs(16, 7).addBox(-0.5F, 0.0F, -0.5F, 1.0F, 2.0F, 1.0F), PartPose.offset(0.0F, -1.75F, -2.45F)
        );
        head.addOrReplaceChild(
            "feather",
            CubeListBuilder.create().texOffs(2, 18).addBox(0.0F, -4.0F, -2.0F, 0.0F, 5.0F, 4.0F),
            PartPose.offsetAndRotation(0.0F, -2.15F, 0.15F, -0.2214F, 0.0F, 0.0F)
        );
        CubeListBuilder leg = CubeListBuilder.create().texOffs(14, 18).addBox(-0.5F, 0.0F, -0.5F, 1.0F, 2.0F, 1.0F);
        root.addOrReplaceChild("left_leg", leg, PartPose.offsetAndRotation(1.0F, 22.0F, -1.05F, -0.0299F, 0.0F, 0.0F));
        root.addOrReplaceChild("right_leg", leg, PartPose.offsetAndRotation(-1.0F, 22.0F, -1.05F, -0.0299F, 0.0F, 0.0F));
        return LayerDefinition.create(mesh, 32, 32);
    }
 
    public void setupAnim(ParrotRenderState state) {
        super.setupAnim(state);
        this.prepare(state.pose);
        this.head.xRot = state.xRot * (float) (Math.PI / 180.0);
        this.head.yRot = state.yRot * (float) (Math.PI / 180.0);
        switch (state.pose) {
            case STANDING:
                this.leftLeg.xRot = this.leftLeg.xRot + Mth.cos(state.walkAnimationPos * 0.6662F) * 1.4F * state.walkAnimationSpeed;
                this.rightLeg.xRot = this.rightLeg.xRot + Mth.cos(state.walkAnimationPos * 0.6662F + (float) Math.PI) * 1.4F * state.walkAnimationSpeed;
            case FLYING:
            case ON_SHOULDER:
            default:
                float bobbingBody = state.flapAngle * 0.3F;
                this.head.y += bobbingBody;
                this.tail.xRot = this.tail.xRot + Mth.cos(state.walkAnimationPos * 0.6662F) * 0.3F * state.walkAnimationSpeed;
                this.tail.y += bobbingBody;
                this.body.y += bobbingBody;
                this.leftWing.zRot = -0.0873F - state.flapAngle;
                this.leftWing.y += bobbingBody;
                this.rightWing.zRot = 0.0873F + state.flapAngle;
                this.rightWing.y += bobbingBody;
                this.leftLeg.y += bobbingBody;
                this.rightLeg.y += bobbingBody;
            case SITTING:
                break;
            case PARTY:
                float xPos = Mth.cos(state.ageInTicks);
                float yPos = Mth.sin(state.ageInTicks);
                this.head.x += xPos;
                this.head.y += yPos;
                this.head.xRot = 0.0F;
                this.head.yRot = 0.0F;
                this.head.zRot = Mth.sin(state.ageInTicks) * 0.4F;
                this.body.x += xPos;
                this.body.y += yPos;
                this.leftWing.zRot = -0.0873F - state.flapAngle;
                this.leftWing.x += xPos;
                this.leftWing.y += yPos;
                this.rightWing.zRot = 0.0873F + state.flapAngle;
                this.rightWing.x += xPos;
                this.rightWing.y += yPos;
                this.tail.x += xPos;
                this.tail.y += yPos;
        }
    }
 
    private void prepare(ParrotModel.Pose pose) {
        switch (pose) {
            case FLYING:
                this.leftLeg.xRot += (float) (Math.PI * 2.0 / 9.0);
                this.rightLeg.xRot += (float) (Math.PI * 2.0 / 9.0);
            case STANDING:
            case ON_SHOULDER:
            default:
                break;
            case SITTING:
                float sittingYOffset = 1.9F;
                this.head.y++;
                this.tail.xRot += (float) (Math.PI / 6);
                this.tail.y++;
                this.body.y++;
                this.leftWing.zRot = -0.0873F;
                this.leftWing.y++;
                this.rightWing.zRot = 0.0873F;
                this.rightWing.y++;
                this.leftLeg.y++;
                this.rightLeg.y++;
                this.leftLeg.xRot++;
                this.rightLeg.xRot++;
                break;
            case PARTY:
                this.leftLeg.zRot = (float) (-Math.PI / 9);
                this.rightLeg.zRot = (float) (Math.PI / 9);
        }
    }
 
    public static ParrotModel.Pose getPose(Parrot entity) {
        if (entity.isPartyParrot()) {
            return ParrotModel.Pose.PARTY;
        } else if (entity.isInSittingPose()) {
            return ParrotModel.Pose.SITTING;
        } else {
            return entity.isFlying() ? ParrotModel.Pose.FLYING : ParrotModel.Pose.STANDING;
        }
    }
 
    @OnlyIn(Dist.CLIENT)
    public static enum Pose {
        FLYING,
        STANDING,
        SITTING,
        PARTY,
        ON_SHOULDER;
    }
}

引用的其他类

  • EntityModel

    • 引用位置: 继承
  • ModelPart

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

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

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

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

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

    • 引用位置: 参数
  • Mth

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

    • 引用位置: 参数