QuadrupedModel.java

net.minecraft.client.model.QuadrupedModel

信息

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

    TODO

字段/常量

  • head

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

      TODO

  • body

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

      TODO

  • rightHindLeg

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

      TODO

  • leftHindLeg

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

      TODO

  • rightFrontLeg

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

      TODO

  • leftFrontLeg

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

      TODO

内部类/嵌套类型

构造器

protected QuadrupedModel(ModelPart root) @ L27

  • 构造器名:QuadrupedModel
  • 源码定位:L27
  • 修饰符:protected

参数:

  • root: ModelPart

说明:

TODO

protected QuadrupedModel(ModelPart root, Function<Identifier,RenderType> renderType) @ L31

  • 构造器名:QuadrupedModel
  • 源码定位:L31
  • 修饰符:protected

参数:

  • root: ModelPart
  • renderType: Function<Identifier,RenderType>

说明:

TODO

方法

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

public static MeshDefinition createBodyMesh(int legSize, boolean mirrorLeftLeg, boolean mirrorRightLeg, CubeDeformation g) @ L41

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

参数:

  • legSize: int
  • mirrorLeftLeg: boolean
  • mirrorRightLeg: boolean
  • g: CubeDeformation

说明:

TODO

static void createLegs(PartDefinition root, boolean mirrorLeftLeg, boolean mirrorRightLeg, int legSize, CubeDeformation g) @ L56

  • 方法名:createLegs
  • 源码定位:L56
  • 返回类型:void
  • 修饰符:static

参数:

  • root: PartDefinition
  • mirrorLeftLeg: boolean
  • mirrorRightLeg: boolean
  • legSize: int
  • g: CubeDeformation

说明:

TODO

public void setupAnim(T state) @ L65

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

参数:

  • state: T

说明:

TODO

代码

@OnlyIn(Dist.CLIENT)
public class QuadrupedModel<T extends LivingEntityRenderState> extends EntityModel<T> {
    protected final ModelPart head;
    protected final ModelPart body;
    protected final ModelPart rightHindLeg;
    protected final ModelPart leftHindLeg;
    protected final ModelPart rightFrontLeg;
    protected final ModelPart leftFrontLeg;
 
    protected QuadrupedModel(ModelPart root) {
        this(root, RenderTypes::entityCutout);
    }
 
    protected QuadrupedModel(ModelPart root, Function<Identifier, RenderType> renderType) {
        super(root, renderType);
        this.head = root.getChild("head");
        this.body = root.getChild("body");
        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");
    }
 
    public static MeshDefinition createBodyMesh(int legSize, boolean mirrorLeftLeg, boolean mirrorRightLeg, CubeDeformation g) {
        MeshDefinition mesh = new MeshDefinition();
        PartDefinition root = mesh.getRoot();
        root.addOrReplaceChild(
            "head", CubeListBuilder.create().texOffs(0, 0).addBox(-4.0F, -4.0F, -8.0F, 8.0F, 8.0F, 8.0F, g), PartPose.offset(0.0F, 18 - legSize, -6.0F)
        );
        root.addOrReplaceChild(
            "body",
            CubeListBuilder.create().texOffs(28, 8).addBox(-5.0F, -10.0F, -7.0F, 10.0F, 16.0F, 8.0F, g),
            PartPose.offsetAndRotation(0.0F, 17 - legSize, 2.0F, (float) (Math.PI / 2), 0.0F, 0.0F)
        );
        createLegs(root, mirrorLeftLeg, mirrorRightLeg, legSize, g);
        return mesh;
    }
 
    static void createLegs(PartDefinition root, boolean mirrorLeftLeg, boolean mirrorRightLeg, int legSize, CubeDeformation g) {
        CubeListBuilder rightLeg = CubeListBuilder.create().mirror(mirrorRightLeg).texOffs(0, 16).addBox(-2.0F, 0.0F, -2.0F, 4.0F, (float)legSize, 4.0F, g);
        CubeListBuilder leftLeg = CubeListBuilder.create().mirror(mirrorLeftLeg).texOffs(0, 16).addBox(-2.0F, 0.0F, -2.0F, 4.0F, (float)legSize, 4.0F, g);
        root.addOrReplaceChild("right_hind_leg", rightLeg, PartPose.offset(-3.0F, 24 - legSize, 7.0F));
        root.addOrReplaceChild("left_hind_leg", leftLeg, PartPose.offset(3.0F, 24 - legSize, 7.0F));
        root.addOrReplaceChild("right_front_leg", rightLeg, PartPose.offset(-3.0F, 24 - legSize, -5.0F));
        root.addOrReplaceChild("left_front_leg", leftLeg, PartPose.offset(3.0F, 24 - legSize, -5.0F));
    }
 
    public void setupAnim(T state) {
        super.setupAnim(state);
        this.head.xRot = state.xRot * (float) (Math.PI / 180.0);
        this.head.yRot = state.yRot * (float) (Math.PI / 180.0);
        float animationPos = state.walkAnimationPos;
        float animationSpeed = state.walkAnimationSpeed;
        this.rightHindLeg.xRot = Mth.cos(animationPos * 0.6662F) * 1.4F * animationSpeed;
        this.leftHindLeg.xRot = Mth.cos(animationPos * 0.6662F + (float) Math.PI) * 1.4F * animationSpeed;
        this.rightFrontLeg.xRot = Mth.cos(animationPos * 0.6662F + (float) Math.PI) * 1.4F * animationSpeed;
        this.leftFrontLeg.xRot = Mth.cos(animationPos * 0.6662F) * 1.4F * animationSpeed;
    }
}

引用的其他类