NautilusModel.java

net.minecraft.client.model.animal.nautilus.NautilusModel

信息

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

    TODO

字段/常量

  • SWIM_ANIMATION_SPEED_MAX

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

      TODO

  • SWIM_ANIMATION_SCALE_FACTOR

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

      TODO

  • IDLE_SWIM_ANIMATION_SPEED

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

      TODO

  • IDLE_SWIM_ANIMATION_SCALE

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

      TODO

  • body

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

      TODO

  • nautilus

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

      TODO

  • swimAnimation

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

      TODO

内部类/嵌套类型

构造器

public NautilusModel(ModelPart root) @ L28

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

参数:

  • root: ModelPart

说明:

TODO

方法

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

public static LayerDefinition createBodyLayer() @ L35

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

参数:

说明:

TODO

public static MeshDefinition createBodyMesh() @ L39

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

参数:

说明:

TODO

public static LayerDefinition createBabyBodyLayer() @ L81

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

参数:

说明:

TODO

public void setupAnim(NautilusRenderState state) @ L123

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

参数:

  • state: NautilusRenderState

说明:

TODO

private void applyBodyRotation(float yRot, float xRot) @ L129

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

参数:

  • yRot: float
  • xRot: float

说明:

TODO

代码

@OnlyIn(Dist.CLIENT)
public class NautilusModel extends EntityModel<NautilusRenderState> {
    private static final float SWIM_ANIMATION_SPEED_MAX = 2.0F;
    private static final float SWIM_ANIMATION_SCALE_FACTOR = 3.0F;
    private static final float IDLE_SWIM_ANIMATION_SPEED = 0.2F;
    private static final float IDLE_SWIM_ANIMATION_SCALE = 5.0F;
    protected final ModelPart body;
    protected final ModelPart nautilus;
    private final KeyframeAnimation swimAnimation;
 
    public NautilusModel(ModelPart root) {
        super(root);
        this.nautilus = root.getChild("root");
        this.body = this.nautilus.getChild("body");
        this.swimAnimation = NautilusAnimation.SWIMMING.bake(root);
    }
 
    public static LayerDefinition createBodyLayer() {
        return LayerDefinition.create(createBodyMesh(), 128, 128);
    }
 
    public static MeshDefinition createBodyMesh() {
        MeshDefinition meshdefinition = new MeshDefinition();
        PartDefinition partdefinition = meshdefinition.getRoot();
        PartDefinition nautilus = partdefinition.addOrReplaceChild("root", CubeListBuilder.create(), PartPose.offset(0.0F, 29.0F, -6.0F));
        nautilus.addOrReplaceChild(
            "shell",
            CubeListBuilder.create()
                .texOffs(0, 0)
                .addBox(-7.0F, -10.0F, -7.0F, 14.0F, 10.0F, 16.0F, new CubeDeformation(0.0F))
                .texOffs(0, 26)
                .addBox(-7.0F, 0.0F, -7.0F, 14.0F, 8.0F, 20.0F, new CubeDeformation(0.0F))
                .texOffs(48, 26)
                .addBox(-7.0F, 0.0F, 6.0F, 14.0F, 8.0F, 0.0F, new CubeDeformation(0.0F)),
            PartPose.offset(0.0F, -13.0F, 5.0F)
        );
        PartDefinition body = nautilus.addOrReplaceChild(
            "body",
            CubeListBuilder.create()
                .texOffs(0, 54)
                .addBox(-5.0F, -4.51F, -3.0F, 10.0F, 8.0F, 14.0F, new CubeDeformation(0.0F))
                .texOffs(0, 76)
                .addBox(-5.0F, -4.51F, 7.0F, 10.0F, 8.0F, 0.0F, new CubeDeformation(0.0F)),
            PartPose.offset(0.0F, -8.5F, 12.3F)
        );
        body.addOrReplaceChild(
            "upper_mouth",
            CubeListBuilder.create().texOffs(54, 54).addBox(-5.0F, -2.0F, 0.0F, 10.0F, 4.0F, 4.0F, new CubeDeformation(-0.001F)),
            PartPose.offset(0.0F, -2.51F, 7.0F)
        );
        body.addOrReplaceChild(
            "inner_mouth",
            CubeListBuilder.create().texOffs(54, 70).addBox(-3.0F, -2.0F, -0.5F, 6.0F, 4.0F, 4.0F, new CubeDeformation(0.0F)),
            PartPose.offset(0.0F, -0.51F, 7.5F)
        );
        body.addOrReplaceChild(
            "lower_mouth",
            CubeListBuilder.create().texOffs(54, 62).addBox(-5.0F, -1.98F, 0.0F, 10.0F, 4.0F, 4.0F, new CubeDeformation(-0.001F)),
            PartPose.offset(0.0F, 1.49F, 7.0F)
        );
        return meshdefinition;
    }
 
    public static LayerDefinition createBabyBodyLayer() {
        MeshDefinition meshdefinition = new MeshDefinition();
        PartDefinition partdefinition = meshdefinition.getRoot();
        PartDefinition nautilus = partdefinition.addOrReplaceChild("root", CubeListBuilder.create(), PartPose.offset(-0.5F, 28.0F, -0.5F));
        nautilus.addOrReplaceChild(
            "shell",
            CubeListBuilder.create()
                .texOffs(0, 0)
                .addBox(-6.0F, -4.0F, -1.0F, 7.0F, 4.0F, 7.0F, new CubeDeformation(0.0F))
                .texOffs(0, 11)
                .addBox(-6.0F, 0.0F, -1.0F, 7.0F, 4.0F, 9.0F, new CubeDeformation(0.0F))
                .texOffs(23, 11)
                .addBox(-6.0F, 0.0F, 5.0F, 7.0F, 4.0F, 0.0F, new CubeDeformation(0.0F)),
            PartPose.offset(3.0F, -8.0F, -2.0F)
        );
        PartDefinition body = nautilus.addOrReplaceChild(
            "body",
            CubeListBuilder.create()
                .texOffs(0, 24)
                .addBox(-2.5F, -3.01F, -1.0F, 5.0F, 4.0F, 7.0F, new CubeDeformation(0.0F))
                .texOffs(0, 35)
                .addBox(-2.5F, -3.01F, 4.1F, 5.0F, 4.0F, 0.0F, new CubeDeformation(0.0F)),
            PartPose.offset(0.5F, -5.0F, 3.0F)
        );
        body.addOrReplaceChild(
            "upper_mouth",
            CubeListBuilder.create().texOffs(24, 24).addBox(-2.5F, -1.0F, 0.0F, 5.0F, 2.0F, 2.0F, new CubeDeformation(-0.001F)),
            PartPose.offset(0.0F, -2.01F, 3.9F)
        );
        body.addOrReplaceChild(
            "inner_mouth",
            CubeListBuilder.create().texOffs(24, 32).addBox(-1.5F, -1.0F, -1.0F, 3.0F, 2.0F, 2.0F, new CubeDeformation(0.0F)),
            PartPose.offset(0.0F, -1.01F, 4.9F)
        );
        body.addOrReplaceChild(
            "lower_mouth",
            CubeListBuilder.create().texOffs(24, 28).addBox(-2.5F, -1.0F, 0.0F, 5.0F, 2.0F, 2.0F, new CubeDeformation(-0.001F)),
            PartPose.offset(0.0F, -0.01F, 3.9F)
        );
        return LayerDefinition.create(meshdefinition, 64, 64);
    }
 
    public void setupAnim(NautilusRenderState state) {
        super.setupAnim(state);
        this.applyBodyRotation(state.yRot, state.xRot);
        this.swimAnimation.applyWalk(state.walkAnimationPos + state.ageInTicks / 5.0F, state.walkAnimationSpeed + 0.2F, 2.0F, 3.0F);
    }
 
    private void applyBodyRotation(float yRot, float xRot) {
        yRot = Mth.clamp(yRot, -10.0F, 10.0F);
        xRot = Mth.clamp(xRot, -10.0F, 10.0F);
        this.body.yRot = yRot * (float) (Math.PI / 180.0);
        this.body.xRot = xRot * (float) (Math.PI / 180.0);
    }
}

引用的其他类