| 1 | package net.minecraft.client.model.animal.feline;
|
| 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.CubeListBuilder;
|
| 8 | import net.minecraft.client.model.geom.builders.LayerDefinition;
|
| 9 | import net.minecraft.client.model.geom.builders.MeshDefinition;
|
| 10 | import net.minecraft.client.model.geom.builders.PartDefinition;
|
| 11 | import net.minecraft.client.renderer.entity.state.FelineRenderState;
|
| 12 | import net.minecraft.util.Mth;
|
| 13 |
|
| 14 | @Environment(EnvType.CLIENT)
|
| 15 | public class BabyFelineModel<S extends FelineRenderState> extends AbstractFelineModel<S> {
|
| 16 | protected BabyFelineModel(final ModelPart root) {
|
| 17 | super(root);
|
| 18 | }
|
| 19 |
|
| 20 | public static LayerDefinition createBabyLayer() {
|
| 21 | MeshDefinition meshdefinition = new MeshDefinition();
|
| 22 | PartDefinition partdefinition = meshdefinition.getRoot();
|
| 23 | partdefinition.addOrReplaceChild(
|
| 24 | "head",
|
| 25 | CubeListBuilder.create()
|
| 26 | .texOffs(0, 0)
|
| 27 | .addBox(-2.5F, -3.0F, -2.875F, 5.0F, 4.0F, 4.0F)
|
| 28 | .texOffs(18, 0)
|
| 29 | .addBox(-2.0F, -4.0F, -0.875F, 1.0F, 1.0F, 2.0F)
|
| 30 | .texOffs(24, 0)
|
| 31 | .addBox(1.0F, -4.0F, -0.875F, 1.0F, 1.0F, 2.0F)
|
| 32 | .texOffs(18, 3)
|
| 33 | .addBox(-1.5F, -1.0F, -3.875F, 3.0F, 2.0F, 1.0F),
|
| 34 | PartPose.offset(0.0F, 20.0F, -3.125F)
|
| 35 | );
|
| 36 | partdefinition.addOrReplaceChild(
|
| 37 | "left_front_leg", CubeListBuilder.create().texOffs(18, 18).addBox(-0.5F, 0.0F, -1.0F, 1.0F, 2.0F, 2.0F), PartPose.offset(1.0F, 22.0F, -1.5F)
|
| 38 | );
|
| 39 | partdefinition.addOrReplaceChild(
|
| 40 | "right_front_leg", CubeListBuilder.create().texOffs(12, 18).addBox(-0.5F, 0.0F, -1.0F, 1.0F, 2.0F, 2.0F), PartPose.offset(-1.0F, 22.0F, -1.5F)
|
| 41 | );
|
| 42 | partdefinition.addOrReplaceChild(
|
| 43 | "left_hind_leg", CubeListBuilder.create().texOffs(18, 22).addBox(-0.5F, 0.0F, -1.0F, 1.0F, 2.0F, 2.0F), PartPose.offset(1.0F, 22.0F, 2.5F)
|
| 44 | );
|
| 45 | partdefinition.addOrReplaceChild(
|
| 46 | "body", CubeListBuilder.create().texOffs(0, 8).addBox(-2.0F, -1.5F, -3.5F, 4.0F, 3.0F, 7.0F), PartPose.offset(0.0F, 20.5F, 0.5F)
|
| 47 | );
|
| 48 | partdefinition.addOrReplaceChild(
|
| 49 | "right_hind_leg", CubeListBuilder.create().texOffs(12, 22).addBox(-0.5F, 0.0F, -1.0F, 1.0F, 2.0F, 2.0F), PartPose.offset(-1.0F, 22.0F, 2.5F)
|
| 50 | );
|
| 51 | partdefinition.addOrReplaceChild(
|
| 52 | "tail1",
|
| 53 | CubeListBuilder.create().texOffs(0, 18).addBox(-0.5F, -0.107F, 0.0849F, 1.0F, 1.0F, 5.0F),
|
| 54 | PartPose.offsetAndRotation(0.0F, 19.107F, 3.9151F, -0.567232F, 0.0F, 0.0F)
|
| 55 | );
|
| 56 | partdefinition.addOrReplaceChild("tail2", CubeListBuilder.create(), PartPose.ZERO);
|
| 57 | return LayerDefinition.create(meshdefinition, 32, 32);
|
| 58 | }
|
| 59 |
|
| 60 | public void setupAnim(final S state) {
|
| 61 | super.setupAnim(state);
|
| 62 | float ageScale = state.ageScale;
|
| 63 | if (state.isCrouching) {
|
| 64 | this.body.y += 1.0F * ageScale;
|
| 65 | this.head.y += 2.0F * ageScale;
|
| 66 | this.tail1.y += 1.0F * ageScale;
|
| 67 | this.tail2.y += -4.0F * ageScale;
|
| 68 | this.tail2.z += 2.0F * ageScale;
|
| 69 | this.tail1.xRot = (float) (Math.PI / 2);
|
| 70 | this.tail2.xRot = (float) (Math.PI / 2);
|
| 71 | } else if (state.isSprinting) {
|
| 72 | this.tail2.y = this.tail1.y;
|
| 73 | this.tail2.z += 2.0F * ageScale;
|
| 74 | this.tail1.xRot = (float) (Math.PI / 2);
|
| 75 | this.tail2.xRot = (float) (Math.PI / 2);
|
| 76 | }
|
| 77 |
|
| 78 | this.head.xRot = state.xRot * (float) (Math.PI / 180.0);
|
| 79 | this.head.yRot = state.yRot * (float) (Math.PI / 180.0);
|
| 80 | if (!state.isSitting) {
|
| 81 | float animationSpeed = state.walkAnimationSpeed;
|
| 82 | float animationPos = state.walkAnimationPos;
|
| 83 | if (state.isSprinting) {
|
| 84 | this.leftHindLeg.xRot = Mth.cos(animationPos * 0.6662F) * animationSpeed;
|
| 85 | this.rightHindLeg.xRot = Mth.cos(animationPos * 0.6662F + 0.3F) * animationSpeed;
|
| 86 | this.leftFrontLeg.xRot = Mth.cos(animationPos * 0.6662F + (float) Math.PI + 0.3F) * animationSpeed;
|
| 87 | this.rightFrontLeg.xRot = Mth.cos(animationPos * 0.6662F + (float) Math.PI) * animationSpeed;
|
| 88 | this.tail2.xRot = 1.7278761F + (float) (Math.PI / 10) * Mth.cos(animationPos) * animationSpeed;
|
| 89 | } else {
|
| 90 | this.leftHindLeg.xRot = Mth.cos(animationPos * 0.6662F) * animationSpeed;
|
| 91 | this.rightHindLeg.xRot = Mth.cos(animationPos * 0.6662F + (float) Math.PI) * animationSpeed;
|
| 92 | this.leftFrontLeg.xRot = Mth.cos(animationPos * 0.6662F + (float) Math.PI) * animationSpeed;
|
| 93 | this.rightFrontLeg.xRot = Mth.cos(animationPos * 0.6662F) * animationSpeed;
|
| 94 | if (!state.isCrouching) {
|
| 95 | this.tail2.xRot = 1.7278761F + (float) (Math.PI / 4) * Mth.cos(animationPos) * animationSpeed;
|
| 96 | } else {
|
| 97 | this.tail2.xRot = 1.7278761F + 0.47123894F * Mth.cos(animationPos) * animationSpeed;
|
| 98 | }
|
| 99 | }
|
| 100 | } else if (state.isSitting) {
|
| 101 | this.body.xRot += -0.43633232F;
|
| 102 | this.body.y += 1.25F;
|
| 103 | this.head.z += 0.75F;
|
| 104 | this.tail1.xRot += 0.5454154F;
|
| 105 | this.tail1.y += 4.0F;
|
| 106 | this.tail1.z -= 0.9F;
|
| 107 | this.leftHindLeg.z -= 0.9F;
|
| 108 | this.rightHindLeg.z -= 0.9F;
|
| 109 | }
|
| 110 |
|
| 111 | if (state.lieDownAmount > 0.0F) {
|
| 112 | this.body.x++;
|
| 113 | this.head.xRot = Mth.rotLerp(state.lieDownAmount, this.head.xRot, (float) (Math.PI / 18));
|
| 114 | this.head.zRot = Mth.rotLerp(state.lieDownAmount, this.head.zRot, (float) (-Math.PI * 5.0 / 12.0));
|
| 115 | this.head.x += 1.5F;
|
| 116 | this.head.y += 0.75F;
|
| 117 | this.head.z -= 0.5F;
|
| 118 | this.rightFrontLeg.xRot = (float) (-Math.PI / 4);
|
| 119 | this.rightFrontLeg.x += 3.5F;
|
| 120 | this.rightFrontLeg.y -= 0.5F;
|
| 121 | this.rightFrontLeg.z += 0.0F;
|
| 122 | this.leftFrontLeg.xRot = (float) (-Math.PI / 2);
|
| 123 | this.leftFrontLeg.x += 1.5F;
|
| 124 | this.leftFrontLeg.y--;
|
| 125 | this.leftFrontLeg.z -= 2.0F;
|
| 126 | this.rightHindLeg.xRot = (float) (Math.PI * 2.0 / 9.0);
|
| 127 | this.rightHindLeg.yRot = (float) (Math.PI / 9);
|
| 128 | this.rightHindLeg.zRot = (float) (-Math.PI / 9);
|
| 129 | this.rightHindLeg.x += 2.5F;
|
| 130 | this.rightHindLeg.y -= 0.25F;
|
| 131 | this.rightHindLeg.z += 0.5F;
|
| 132 | this.leftHindLeg.x += 1.5F;
|
| 133 | this.leftHindLeg.z--;
|
| 134 | this.tail1.xRot = this.tail1.xRot + Mth.rotLerp(state.lieDownAmountTail, this.tail1.xRot, (float) (-Math.PI / 6));
|
| 135 | this.tail1.yRot = this.tail1.yRot + Mth.rotLerp(state.lieDownAmountTail, this.tail1.yRot, 0.0F);
|
| 136 | this.tail1.zRot = this.tail1.zRot + Mth.rotLerp(state.lieDownAmountTail, this.tail1.zRot, (float) (-Math.PI / 18));
|
| 137 | this.tail1.x++;
|
| 138 | this.tail1.y += 0.5F;
|
| 139 | this.tail1.z -= 0.25F;
|
| 140 | }
|
| 141 |
|
| 142 | if (state.relaxStateOneAmount > 0.0F) {
|
| 143 | this.head.xRot = Mth.rotLerp(state.relaxStateOneAmount, this.head.xRot, -0.58177644F);
|
| 144 | }
|
| 145 | }
|
| 146 | }
|
| 147 |
|