| 1 | package net.minecraft.client.model.animal.equine;
|
| 2 |
|
| 3 | import net.fabricmc.api.EnvType;
|
| 4 | import net.fabricmc.api.Environment;
|
| 5 | import net.minecraft.client.model.geom.ModelPart;
|
| 6 | import net.minecraft.client.model.geom.PartPose;
|
| 7 | import net.minecraft.client.model.geom.builders.CubeDeformation;
|
| 8 | import net.minecraft.client.model.geom.builders.CubeListBuilder;
|
| 9 | import net.minecraft.client.model.geom.builders.LayerDefinition;
|
| 10 | import net.minecraft.client.model.geom.builders.MeshDefinition;
|
| 11 | import net.minecraft.client.model.geom.builders.PartDefinition;
|
| 12 | import net.minecraft.client.renderer.entity.state.DonkeyRenderState;
|
| 13 | import net.minecraft.util.Mth;
|
| 14 |
|
| 15 | @Environment(EnvType.CLIENT)
|
| 16 | public class BabyDonkeyModel extends DonkeyModel {
|
| 17 | public BabyDonkeyModel(final ModelPart root) {
|
| 18 | ModelPart body = root.getChild("body");
|
| 19 | ModelPart rightHindLeg = body.getChild("right_hind_leg");
|
| 20 | ModelPart leftHindLeg = body.getChild("left_hind_leg");
|
| 21 | ModelPart rightFrontLeg = body.getChild("right_front_leg");
|
| 22 | ModelPart leftFrontLeg = body.getChild("left_front_leg");
|
| 23 | ModelPart headParts = body.getChild("head_parts");
|
| 24 | ModelPart tail = body.getChild("tail");
|
| 25 | super(root, headParts, rightHindLeg, rightFrontLeg, leftHindLeg, leftFrontLeg, tail);
|
| 26 | }
|
| 27 |
|
| 28 | public static LayerDefinition createBabyLayer() {
|
| 29 | MeshDefinition meshdefinition = new MeshDefinition();
|
| 30 | PartDefinition partdefinition = meshdefinition.getRoot();
|
| 31 | PartDefinition body = partdefinition.addOrReplaceChild(
|
| 32 | "body",
|
| 33 | CubeListBuilder.create().texOffs(0, 13).addBox(-5.0F, -3.0F, -7.0F, 8.0F, 6.0F, 14.0F, new CubeDeformation(0.0F)),
|
| 34 | PartPose.offset(1.0F, 14.0F, 0.0F)
|
| 35 | );
|
| 36 | PartDefinition tail = body.addOrReplaceChild("tail", CubeListBuilder.create(), PartPose.offset(0.0F, -1.5F, 6.5F));
|
| 37 | tail.addOrReplaceChild(
|
| 38 | "tail_r1",
|
| 39 | CubeListBuilder.create().texOffs(24, 33).addBox(-2.5F, -1.0F, -0.5F, 3.0F, 3.0F, 8.0F, new CubeDeformation(0.0F)),
|
| 40 | PartPose.offsetAndRotation(0.0F, 0.0F, 0.0F, -0.7418F, 0.0F, 0.0F)
|
| 41 | );
|
| 42 | body.addOrReplaceChild(
|
| 43 | "left_hind_leg",
|
| 44 | CubeListBuilder.create().texOffs(12, 44).addBox(-2.5F, -1.5F, -1.5F, 3.0F, 8.0F, 3.0F, new CubeDeformation(0.0F)),
|
| 45 | PartPose.offset(2.25F, 3.5F, 5.25F)
|
| 46 | );
|
| 47 | body.addOrReplaceChild(
|
| 48 | "right_hind_leg",
|
| 49 | CubeListBuilder.create().texOffs(0, 44).addBox(-2.5F, -1.5F, -1.5F, 3.0F, 8.0F, 3.0F, new CubeDeformation(0.0F)),
|
| 50 | PartPose.offset(-2.4F, 3.5F, 5.4F)
|
| 51 | );
|
| 52 | body.addOrReplaceChild(
|
| 53 | "left_front_leg",
|
| 54 | CubeListBuilder.create().texOffs(12, 33).addBox(-2.5F, -1.5F, -1.5F, 3.0F, 8.0F, 3.0F, new CubeDeformation(0.0F)),
|
| 55 | PartPose.offset(2.4F, 3.5F, -5.3F)
|
| 56 | );
|
| 57 | body.addOrReplaceChild(
|
| 58 | "right_front_leg",
|
| 59 | CubeListBuilder.create().texOffs(0, 33).addBox(-2.5F, -1.5F, -1.5F, 3.0F, 8.0F, 3.0F, new CubeDeformation(0.0F)),
|
| 60 | PartPose.offset(-2.4F, 3.5F, -5.4F)
|
| 61 | );
|
| 62 | PartDefinition neck = body.addOrReplaceChild("head_parts", CubeListBuilder.create(), PartPose.offset(0.0F, -3.0F, -5.0F));
|
| 63 | neck.addOrReplaceChild(
|
| 64 | "neck_r1",
|
| 65 | CubeListBuilder.create().texOffs(30, 9).addBox(-3.0F, -6.0F, -3.0F, 4.0F, 8.0F, 4.0F, new CubeDeformation(0.0F)),
|
| 66 | PartPose.offsetAndRotation(0.0F, 0.0F, 0.0F, 0.3927F, 0.0F, 0.0F)
|
| 67 | );
|
| 68 | PartDefinition head = neck.addOrReplaceChild("head", CubeListBuilder.create(), PartPose.offset(0.0F, -5.0F, -3.0F));
|
| 69 | head.addOrReplaceChild(
|
| 70 | "head_r1",
|
| 71 | CubeListBuilder.create().texOffs(0, 0).addBox(-4.0F, -3.6F, -8.4F, 6.0F, 4.0F, 9.0F, new CubeDeformation(0.0F)),
|
| 72 | PartPose.offsetAndRotation(0.0F, -1.0F, 1.0F, 0.3927F, 0.0F, 0.0F)
|
| 73 | );
|
| 74 | head.addOrReplaceChild(
|
| 75 | "left_ear",
|
| 76 | CubeListBuilder.create().texOffs(0, 0).addBox(-2.0F, -6.5F, -0.3F, 2.0F, 7.0F, 1.0F, new CubeDeformation(0.0F)),
|
| 77 | PartPose.offsetAndRotation(2.0F, -3.5F, -1.0F, 0.48F, 0.0F, 0.48F)
|
| 78 | );
|
| 79 | head.addOrReplaceChild(
|
| 80 | "right_ear",
|
| 81 | CubeListBuilder.create().texOffs(22, 0).mirror().addBox(-2.0F, -6.5F, -0.3F, 2.0F, 7.0F, 1.0F, new CubeDeformation(0.0F)).mirror(false),
|
| 82 | PartPose.offsetAndRotation(-2.0F, -3.5F, -1.0F, 0.48F, 0.0F, -0.48F)
|
| 83 | );
|
| 84 | body.addOrReplaceChild("right_chest", CubeListBuilder.create(), PartPose.offset(-1.0F, 10.0F, 0.0F));
|
| 85 | body.addOrReplaceChild("left_chest", CubeListBuilder.create(), PartPose.offset(-1.0F, 10.0F, 0.0F));
|
| 86 | return LayerDefinition.create(meshdefinition, 64, 64);
|
| 87 | }
|
| 88 |
|
| 89 | @Override
|
| 90 | public void setupAnim(final DonkeyRenderState state) {
|
| 91 | super.setupAnim(state);
|
| 92 | state.xRot = -30.0F;
|
| 93 | float headRotXRad = state.xRot * (float) (Math.PI / 180.0);
|
| 94 | float eating = state.eatAnimation;
|
| 95 | float standing = state.standAnimation;
|
| 96 | float feedingAnim = state.feedingAnimation;
|
| 97 | float baseHeadAngle = (1.0F - Math.max(standing, eating)) * ((float) (Math.PI / 6) + headRotXRad + feedingAnim * Mth.sin(state.ageInTicks) * 0.05F);
|
| 98 | this.headParts.xRot = standing * ((float) (Math.PI / 12) + headRotXRad)
|
| 99 | + eating * ((float) (Math.PI / 2) + Mth.sin(state.ageInTicks) * 0.05F)
|
| 100 | + baseHeadAngle;
|
| 101 | }
|
| 102 |
|
| 103 | @Override
|
| 104 | protected void offsetLegPositionWhenStanding(final float standing) {
|
| 105 | this.leftHindLeg.y = Mth.lerp(standing, this.leftHindLeg.y, -0.3F);
|
| 106 | this.rightHindLeg.y = Mth.lerp(standing, this.leftHindLeg.y, -0.3F);
|
| 107 | }
|
| 108 |
|
| 109 | @Override
|
| 110 | protected float getLegStandAngle() {
|
| 111 | return (float) (Math.PI / 3);
|
| 112 | }
|
| 113 |
|
| 114 | @Override
|
| 115 | protected float getLegStandingYOffset() {
|
| 116 | return 1.0F;
|
| 117 | }
|
| 118 |
|
| 119 | @Override
|
| 120 | protected float getLegStandingZOffset() {
|
| 121 | return 0.5F;
|
| 122 | }
|
| 123 |
|
| 124 | @Override
|
| 125 | protected float getLegStandingXRotOffset() {
|
| 126 | return 0.0F;
|
| 127 | }
|
| 128 |
|
| 129 | @Override
|
| 130 | protected float getTailXRotOffset() {
|
| 131 | return (float) (-Math.PI / 4);
|
| 132 | }
|
| 133 |
|
| 134 | @Override
|
| 135 | protected void animateHeadPartsPlacement(final float eating, final float standing) {
|
| 136 | this.headParts.y = Mth.lerp(eating, this.headParts.y, -1.2F);
|
| 137 | this.headParts.z = Mth.lerp(standing, this.headParts.z, -3.6F);
|
| 138 | }
|
| 139 | }
|
| 140 |
|