ArmorStandModel.java

net.minecraft.client.model.object.armorstand.ArmorStandModel

信息

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

    TODO

字段/常量

  • RIGHT_BODY_STICK

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

      TODO

  • LEFT_BODY_STICK

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

      TODO

  • SHOULDER_STICK

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

      TODO

  • BASE_PLATE

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

      TODO

  • rightBodyStick

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

      TODO

  • leftBodyStick

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

      TODO

  • shoulderStick

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

      TODO

  • basePlate

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

      TODO

内部类/嵌套类型

构造器

public ArmorStandModel(ModelPart root) @ L28

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

参数:

  • root: ModelPart

说明:

TODO

方法

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

public static LayerDefinition createBodyLayer() @ L37

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

参数:

说明:

TODO

public void setupAnim(ArmorStandRenderState state) @ L63

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

参数:

  • state: ArmorStandRenderState

说明:

TODO

public void translateToHand(ArmorStandRenderState state, HumanoidArm arm, PoseStack poseStack) @ L81

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

参数:

  • state: ArmorStandRenderState
  • arm: HumanoidArm
  • poseStack: PoseStack

说明:

TODO

代码

@OnlyIn(Dist.CLIENT)
public class ArmorStandModel extends ArmorStandArmorModel {
    private static final String RIGHT_BODY_STICK = "right_body_stick";
    private static final String LEFT_BODY_STICK = "left_body_stick";
    private static final String SHOULDER_STICK = "shoulder_stick";
    private static final String BASE_PLATE = "base_plate";
    private final ModelPart rightBodyStick;
    private final ModelPart leftBodyStick;
    private final ModelPart shoulderStick;
    private final ModelPart basePlate;
 
    public ArmorStandModel(ModelPart root) {
        super(root);
        this.rightBodyStick = root.getChild("right_body_stick");
        this.leftBodyStick = root.getChild("left_body_stick");
        this.shoulderStick = root.getChild("shoulder_stick");
        this.basePlate = root.getChild("base_plate");
        this.hat.visible = false;
    }
 
    public static LayerDefinition createBodyLayer() {
        MeshDefinition mesh = HumanoidModel.createMesh(CubeDeformation.NONE, 0.0F);
        PartDefinition root = mesh.getRoot();
        root.addOrReplaceChild("head", CubeListBuilder.create().texOffs(0, 0).addBox(-1.0F, -7.0F, -1.0F, 2.0F, 7.0F, 2.0F), PartPose.offset(0.0F, 1.0F, 0.0F));
        root.addOrReplaceChild("body", CubeListBuilder.create().texOffs(0, 26).addBox(-6.0F, 0.0F, -1.5F, 12.0F, 3.0F, 3.0F), PartPose.ZERO);
        root.addOrReplaceChild(
            "right_arm", CubeListBuilder.create().texOffs(24, 0).addBox(-2.0F, -2.0F, -1.0F, 2.0F, 12.0F, 2.0F), PartPose.offset(-5.0F, 2.0F, 0.0F)
        );
        root.addOrReplaceChild(
            "left_arm", CubeListBuilder.create().texOffs(32, 16).mirror().addBox(0.0F, -2.0F, -1.0F, 2.0F, 12.0F, 2.0F), PartPose.offset(5.0F, 2.0F, 0.0F)
        );
        root.addOrReplaceChild(
            "right_leg", CubeListBuilder.create().texOffs(8, 0).addBox(-1.0F, 0.0F, -1.0F, 2.0F, 11.0F, 2.0F), PartPose.offset(-1.9F, 12.0F, 0.0F)
        );
        root.addOrReplaceChild(
            "left_leg", CubeListBuilder.create().texOffs(40, 16).mirror().addBox(-1.0F, 0.0F, -1.0F, 2.0F, 11.0F, 2.0F), PartPose.offset(1.9F, 12.0F, 0.0F)
        );
        root.addOrReplaceChild("right_body_stick", CubeListBuilder.create().texOffs(16, 0).addBox(-3.0F, 3.0F, -1.0F, 2.0F, 7.0F, 2.0F), PartPose.ZERO);
        root.addOrReplaceChild("left_body_stick", CubeListBuilder.create().texOffs(48, 16).addBox(1.0F, 3.0F, -1.0F, 2.0F, 7.0F, 2.0F), PartPose.ZERO);
        root.addOrReplaceChild("shoulder_stick", CubeListBuilder.create().texOffs(0, 48).addBox(-4.0F, 10.0F, -1.0F, 8.0F, 2.0F, 2.0F), PartPose.ZERO);
        root.addOrReplaceChild(
            "base_plate", CubeListBuilder.create().texOffs(0, 32).addBox(-6.0F, 11.0F, -6.0F, 12.0F, 1.0F, 12.0F), PartPose.offset(0.0F, 12.0F, 0.0F)
        );
        return LayerDefinition.create(mesh, 64, 64);
    }
 
    @Override
    public void setupAnim(ArmorStandRenderState state) {
        super.setupAnim(state);
        this.basePlate.yRot = (float) (Math.PI / 180.0) * -state.yRot;
        this.leftArm.visible = state.showArms;
        this.rightArm.visible = state.showArms;
        this.basePlate.visible = state.showBasePlate;
        this.rightBodyStick.xRot = (float) (Math.PI / 180.0) * state.bodyPose.x();
        this.rightBodyStick.yRot = (float) (Math.PI / 180.0) * state.bodyPose.y();
        this.rightBodyStick.zRot = (float) (Math.PI / 180.0) * state.bodyPose.z();
        this.leftBodyStick.xRot = (float) (Math.PI / 180.0) * state.bodyPose.x();
        this.leftBodyStick.yRot = (float) (Math.PI / 180.0) * state.bodyPose.y();
        this.leftBodyStick.zRot = (float) (Math.PI / 180.0) * state.bodyPose.z();
        this.shoulderStick.xRot = (float) (Math.PI / 180.0) * state.bodyPose.x();
        this.shoulderStick.yRot = (float) (Math.PI / 180.0) * state.bodyPose.y();
        this.shoulderStick.zRot = (float) (Math.PI / 180.0) * state.bodyPose.z();
    }
 
    public void translateToHand(ArmorStandRenderState state, HumanoidArm arm, PoseStack poseStack) {
        ModelPart modelPart = this.getArm(arm);
        boolean handVisible = modelPart.visible;
        modelPart.visible = true;
        super.translateToHand(state, arm, poseStack);
        modelPart.visible = handVisible;
    }
}

引用的其他类