ShulkerModel.java

net.minecraft.client.model.monster.shulker.ShulkerModel

信息

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

    TODO

字段/常量

  • LID

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

      TODO

  • BASE

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

      TODO

  • lid

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

      TODO

  • head

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

      TODO

内部类/嵌套类型

构造器

public ShulkerModel(ModelPart root) @ L23

  • 构造器名:ShulkerModel
  • 源码定位:L23
  • 修饰符:public

参数:

  • root: ModelPart

说明:

TODO

方法

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

private static MeshDefinition createShellMesh() @ L29

  • 方法名:createShellMesh
  • 源码定位:L29
  • 返回类型:MeshDefinition
  • 修饰符:private static

参数:

说明:

TODO

public static LayerDefinition createBodyLayer() @ L41

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

参数:

说明:

TODO

public static LayerDefinition createBoxLayer() @ L48

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

参数:

说明:

TODO

public void setupAnim(ShulkerRenderState state) @ L53

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

参数:

  • state: ShulkerRenderState

说明:

TODO

代码

@OnlyIn(Dist.CLIENT)
public class ShulkerModel extends EntityModel<ShulkerRenderState> {
    public static final String LID = "lid";
    private static final String BASE = "base";
    private final ModelPart lid;
    private final ModelPart head;
 
    public ShulkerModel(ModelPart root) {
        super(root, RenderTypes::entityCutoutZOffset);
        this.lid = root.getChild("lid");
        this.head = root.getChild("head");
    }
 
    private static MeshDefinition createShellMesh() {
        MeshDefinition mesh = new MeshDefinition();
        PartDefinition root = mesh.getRoot();
        root.addOrReplaceChild(
            "lid", CubeListBuilder.create().texOffs(0, 0).addBox(-8.0F, -16.0F, -8.0F, 16.0F, 12.0F, 16.0F), PartPose.offset(0.0F, 24.0F, 0.0F)
        );
        root.addOrReplaceChild(
            "base", CubeListBuilder.create().texOffs(0, 28).addBox(-8.0F, -8.0F, -8.0F, 16.0F, 8.0F, 16.0F), PartPose.offset(0.0F, 24.0F, 0.0F)
        );
        return mesh;
    }
 
    public static LayerDefinition createBodyLayer() {
        MeshDefinition mesh = createShellMesh();
        mesh.getRoot()
            .addOrReplaceChild("head", CubeListBuilder.create().texOffs(0, 52).addBox(-3.0F, 0.0F, -3.0F, 6.0F, 6.0F, 6.0F), PartPose.offset(0.0F, 12.0F, 0.0F));
        return LayerDefinition.create(mesh, 64, 64);
    }
 
    public static LayerDefinition createBoxLayer() {
        MeshDefinition mesh = createShellMesh();
        return LayerDefinition.create(mesh, 64, 64);
    }
 
    public void setupAnim(ShulkerRenderState state) {
        super.setupAnim(state);
        float bs = (0.5F + state.peekAmount) * (float) Math.PI;
        float q = -1.0F + Mth.sin(bs);
        float extra = 0.0F;
        if (bs > (float) Math.PI) {
            extra = Mth.sin(state.ageInTicks * 0.1F) * 0.7F;
        }
 
        this.lid.setPos(0.0F, 16.0F + Mth.sin(bs) * 8.0F + extra, 0.0F);
        if (state.peekAmount > 0.3F) {
            this.lid.yRot = q * q * q * q * (float) Math.PI * 0.125F;
        } else {
            this.lid.yRot = 0.0F;
        }
 
        this.head.xRot = state.xRot * (float) (Math.PI / 180.0);
        this.head.yRot = (state.yHeadRot - 180.0F - state.yBodyRot) * (float) (Math.PI / 180.0);
    }
}

引用的其他类

  • EntityModel

    • 引用位置: 继承
  • ModelPart

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

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

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

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

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

    • 引用位置: 参数
  • Mth

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