| 1 | package net.minecraft.client.model.object.armorstand;
|
| 2 |
|
| 3 | import net.fabricmc.api.EnvType;
|
| 4 | import net.fabricmc.api.Environment;
|
| 5 | import net.minecraft.client.model.HumanoidModel;
|
| 6 | import net.minecraft.client.model.geom.ModelPart;
|
| 7 | import net.minecraft.client.model.geom.PartPose;
|
| 8 | import net.minecraft.client.model.geom.builders.CubeDeformation;
|
| 9 | import net.minecraft.client.model.geom.builders.CubeListBuilder;
|
| 10 | import net.minecraft.client.model.geom.builders.LayerDefinition;
|
| 11 | import net.minecraft.client.model.geom.builders.MeshDefinition;
|
| 12 | import net.minecraft.client.model.geom.builders.PartDefinition;
|
| 13 | import net.minecraft.client.renderer.entity.ArmorModelSet;
|
| 14 | import net.minecraft.client.renderer.entity.state.ArmorStandRenderState;
|
| 15 |
|
| 16 | @Environment(EnvType.CLIENT)
|
| 17 | public class ArmorStandArmorModel extends HumanoidModel<ArmorStandRenderState> {
|
| 18 | public ArmorStandArmorModel(final ModelPart root) {
|
| 19 | super(root);
|
| 20 | }
|
| 21 |
|
| 22 | public static ArmorModelSet<LayerDefinition> createArmorLayerSet(final CubeDeformation innerDeformation, final CubeDeformation outerDeformation) {
|
| 23 | return createArmorMeshSet(ArmorStandArmorModel::createBaseMesh, ADULT_ARMOR_PARTS_PER_SLOT, innerDeformation, outerDeformation)
|
| 24 | .map(mesh -> LayerDefinition.create(mesh, 64, 32));
|
| 25 | }
|
| 26 |
|
| 27 | private static MeshDefinition createBaseMesh(final CubeDeformation g) {
|
| 28 | MeshDefinition mesh = HumanoidModel.createMesh(g, 0.0F);
|
| 29 | PartDefinition root = mesh.getRoot();
|
| 30 | PartDefinition head = root.addOrReplaceChild(
|
| 31 | "head", CubeListBuilder.create().texOffs(0, 0).addBox(-4.0F, -8.0F, -4.0F, 8.0F, 8.0F, 8.0F, g), PartPose.offset(0.0F, 1.0F, 0.0F)
|
| 32 | );
|
| 33 | head.addOrReplaceChild("hat", CubeListBuilder.create().texOffs(32, 0).addBox(-4.0F, -8.0F, -4.0F, 8.0F, 8.0F, 8.0F, g.extend(0.5F)), PartPose.ZERO);
|
| 34 | root.addOrReplaceChild(
|
| 35 | "right_leg", CubeListBuilder.create().texOffs(0, 16).addBox(-2.0F, 0.0F, -2.0F, 4.0F, 12.0F, 4.0F, g.extend(-0.1F)), PartPose.offset(-1.9F, 11.0F, 0.0F)
|
| 36 | );
|
| 37 | root.addOrReplaceChild(
|
| 38 | "left_leg",
|
| 39 | CubeListBuilder.create().texOffs(0, 16).mirror().addBox(-2.0F, 0.0F, -2.0F, 4.0F, 12.0F, 4.0F, g.extend(-0.1F)),
|
| 40 | PartPose.offset(1.9F, 11.0F, 0.0F)
|
| 41 | );
|
| 42 | return mesh;
|
| 43 | }
|
| 44 |
|
| 45 | public void setupAnim(final ArmorStandRenderState state) {
|
| 46 | super.setupAnim(state);
|
| 47 | this.head.xRot = (float) (Math.PI / 180.0) * state.headPose.x();
|
| 48 | this.head.yRot = (float) (Math.PI / 180.0) * state.headPose.y();
|
| 49 | this.head.zRot = (float) (Math.PI / 180.0) * state.headPose.z();
|
| 50 | this.body.xRot = (float) (Math.PI / 180.0) * state.bodyPose.x();
|
| 51 | this.body.yRot = (float) (Math.PI / 180.0) * state.bodyPose.y();
|
| 52 | this.body.zRot = (float) (Math.PI / 180.0) * state.bodyPose.z();
|
| 53 | this.leftArm.xRot = (float) (Math.PI / 180.0) * state.leftArmPose.x();
|
| 54 | this.leftArm.yRot = (float) (Math.PI / 180.0) * state.leftArmPose.y();
|
| 55 | this.leftArm.zRot = (float) (Math.PI / 180.0) * state.leftArmPose.z();
|
| 56 | this.rightArm.xRot = (float) (Math.PI / 180.0) * state.rightArmPose.x();
|
| 57 | this.rightArm.yRot = (float) (Math.PI / 180.0) * state.rightArmPose.y();
|
| 58 | this.rightArm.zRot = (float) (Math.PI / 180.0) * state.rightArmPose.z();
|
| 59 | this.leftLeg.xRot = (float) (Math.PI / 180.0) * state.leftLegPose.x();
|
| 60 | this.leftLeg.yRot = (float) (Math.PI / 180.0) * state.leftLegPose.y();
|
| 61 | this.leftLeg.zRot = (float) (Math.PI / 180.0) * state.leftLegPose.z();
|
| 62 | this.rightLeg.xRot = (float) (Math.PI / 180.0) * state.rightLegPose.x();
|
| 63 | this.rightLeg.yRot = (float) (Math.PI / 180.0) * state.rightLegPose.y();
|
| 64 | this.rightLeg.zRot = (float) (Math.PI / 180.0) * state.rightLegPose.z();
|
| 65 | }
|
| 66 | }
|
| 67 |
|