| 1 | package net.minecraft.client.model.animal.fox;
|
| 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.FoxRenderState;
|
| 13 | import net.minecraft.util.Mth;
|
| 14 |
|
| 15 | @Environment(EnvType.CLIENT)
|
| 16 | public class AdultFoxModel extends FoxModel {
|
| 17 | private static final int LEG_SIZE = 6;
|
| 18 | private static final float HEAD_HEIGHT = 16.5F;
|
| 19 | private static final float LEG_POS = 17.5F;
|
| 20 |
|
| 21 | public AdultFoxModel(final ModelPart root) {
|
| 22 | super(root);
|
| 23 | }
|
| 24 |
|
| 25 | public static LayerDefinition createBodyLayer() {
|
| 26 | MeshDefinition mesh = new MeshDefinition();
|
| 27 | PartDefinition root = mesh.getRoot();
|
| 28 | PartDefinition head = root.addOrReplaceChild(
|
| 29 | "head", CubeListBuilder.create().texOffs(1, 5).addBox(-3.0F, -2.0F, -5.0F, 8.0F, 6.0F, 6.0F), PartPose.offset(-1.0F, 16.5F, -3.0F)
|
| 30 | );
|
| 31 | head.addOrReplaceChild("right_ear", CubeListBuilder.create().texOffs(8, 1).addBox(-3.0F, -4.0F, -4.0F, 2.0F, 2.0F, 1.0F), PartPose.ZERO);
|
| 32 | head.addOrReplaceChild("left_ear", CubeListBuilder.create().texOffs(15, 1).addBox(3.0F, -4.0F, -4.0F, 2.0F, 2.0F, 1.0F), PartPose.ZERO);
|
| 33 | head.addOrReplaceChild("nose", CubeListBuilder.create().texOffs(6, 18).addBox(-1.0F, 2.01F, -8.0F, 4.0F, 2.0F, 3.0F), PartPose.ZERO);
|
| 34 | PartDefinition body = root.addOrReplaceChild(
|
| 35 | "body",
|
| 36 | CubeListBuilder.create().texOffs(24, 15).addBox(-3.0F, 3.999F, -3.5F, 6.0F, 11.0F, 6.0F),
|
| 37 | PartPose.offsetAndRotation(0.0F, 16.0F, -6.0F, (float) (Math.PI / 2), 0.0F, 0.0F)
|
| 38 | );
|
| 39 | CubeDeformation fudge = new CubeDeformation(0.001F);
|
| 40 | CubeListBuilder leftLeg = CubeListBuilder.create().texOffs(4, 24).addBox(2.0F, 0.5F, -1.0F, 2.0F, 6.0F, 2.0F, fudge);
|
| 41 | CubeListBuilder rightLeg = CubeListBuilder.create().texOffs(13, 24).addBox(2.0F, 0.5F, -1.0F, 2.0F, 6.0F, 2.0F, fudge);
|
| 42 | root.addOrReplaceChild("right_hind_leg", rightLeg, PartPose.offset(-5.0F, 17.5F, 7.0F));
|
| 43 | root.addOrReplaceChild("left_hind_leg", leftLeg, PartPose.offset(-1.0F, 17.5F, 7.0F));
|
| 44 | root.addOrReplaceChild("right_front_leg", rightLeg, PartPose.offset(-5.0F, 17.5F, 0.0F));
|
| 45 | root.addOrReplaceChild("left_front_leg", leftLeg, PartPose.offset(-1.0F, 17.5F, 0.0F));
|
| 46 | body.addOrReplaceChild(
|
| 47 | "tail",
|
| 48 | CubeListBuilder.create().texOffs(30, 0).addBox(2.0F, 0.0F, -1.0F, 4.0F, 9.0F, 5.0F),
|
| 49 | PartPose.offsetAndRotation(-4.0F, 15.0F, -1.0F, -0.05235988F, 0.0F, 0.0F)
|
| 50 | );
|
| 51 | return LayerDefinition.create(mesh, 48, 32);
|
| 52 | }
|
| 53 |
|
| 54 | @Override
|
| 55 | protected void setSittingPose(final FoxRenderState state) {
|
| 56 | super.setSittingPose(state);
|
| 57 | this.body.xRot = (float) (Math.PI / 6);
|
| 58 | this.body.y -= 7.0F;
|
| 59 | this.body.z += 3.0F;
|
| 60 | this.tail.xRot = (float) (Math.PI / 4);
|
| 61 | this.head.y -= 6.5F;
|
| 62 | this.head.z += 2.75F;
|
| 63 | this.rightFrontLeg.xRot = (float) (-Math.PI / 12);
|
| 64 | this.leftFrontLeg.xRot = (float) (-Math.PI / 12);
|
| 65 | this.rightHindLeg.xRot = (float) (-Math.PI * 5.0 / 12.0);
|
| 66 | this.rightHindLeg.y += 4.0F;
|
| 67 | this.rightHindLeg.z -= 0.25F;
|
| 68 | this.leftHindLeg.xRot = (float) (-Math.PI * 5.0 / 12.0);
|
| 69 | this.leftHindLeg.y += 4.0F;
|
| 70 | this.leftHindLeg.z -= 0.25F;
|
| 71 | this.tail.z--;
|
| 72 | }
|
| 73 |
|
| 74 | @Override
|
| 75 | protected void setSleepingPose(final FoxRenderState state) {
|
| 76 | super.setSleepingPose(state);
|
| 77 | this.body.zRot = (float) (-Math.PI / 2);
|
| 78 | this.body.y += 5.0F;
|
| 79 | this.tail.xRot = (float) (-Math.PI * 5.0 / 6.0);
|
| 80 | this.head.x += 2.0F;
|
| 81 | this.head.y += 2.99F;
|
| 82 | this.head.yRot = (float) (-Math.PI * 2.0 / 3.0);
|
| 83 | this.head.zRot = 0.0F;
|
| 84 | }
|
| 85 |
|
| 86 | @Override
|
| 87 | protected void setWalkingPose(final FoxRenderState state) {
|
| 88 | super.setWalkingPose(state);
|
| 89 | float animationSpeed = state.walkAnimationSpeed;
|
| 90 | float animationPos = state.walkAnimationPos;
|
| 91 | this.rightHindLeg.xRot = Mth.cos(animationPos * 0.6662F) * 1.4F * animationSpeed;
|
| 92 | this.leftHindLeg.xRot = Mth.cos(animationPos * 0.6662F + (float) Math.PI) * 1.4F * animationSpeed;
|
| 93 | this.rightFrontLeg.xRot = Mth.cos(animationPos * 0.6662F + (float) Math.PI) * 1.4F * animationSpeed;
|
| 94 | this.leftFrontLeg.xRot = Mth.cos(animationPos * 0.6662F) * 1.4F * animationSpeed;
|
| 95 | }
|
| 96 |
|
| 97 | @Override
|
| 98 | protected void setCrouchingPose(final FoxRenderState state) {
|
| 99 | super.setCrouchingPose(state);
|
| 100 | this.body.y = this.body.y + state.crouchAmount;
|
| 101 | }
|
| 102 |
|
| 103 | @Override
|
| 104 | protected void setPouncingPose(final FoxRenderState state) {
|
| 105 | super.setPouncingPose(state);
|
| 106 | float crouch = state.crouchAmount / 2.0F;
|
| 107 | this.body.y -= crouch;
|
| 108 | this.head.y -= crouch;
|
| 109 | }
|
| 110 | }
|
| 111 |
|