| 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.animation.KeyframeAnimation;
|
| 6 | import net.minecraft.client.animation.definitions.FoxBabyAnimation;
|
| 7 | import net.minecraft.client.model.geom.ModelPart;
|
| 8 | import net.minecraft.client.model.geom.PartPose;
|
| 9 | import net.minecraft.client.model.geom.builders.CubeDeformation;
|
| 10 | import net.minecraft.client.model.geom.builders.CubeListBuilder;
|
| 11 | import net.minecraft.client.model.geom.builders.LayerDefinition;
|
| 12 | import net.minecraft.client.model.geom.builders.MeshDefinition;
|
| 13 | import net.minecraft.client.model.geom.builders.PartDefinition;
|
| 14 | import net.minecraft.client.renderer.entity.state.FoxRenderState;
|
| 15 |
|
| 16 | @Environment(EnvType.CLIENT)
|
| 17 | public class BabyFoxModel extends FoxModel {
|
| 18 | private static final float MAX_WALK_ANIMATION_SPEED = 1.0F;
|
| 19 | private static final float WALK_ANIMATION_SCALE_FACTOR = 2.5F;
|
| 20 | private final KeyframeAnimation babyWalkAnimation;
|
| 21 |
|
| 22 | public BabyFoxModel(final ModelPart root) {
|
| 23 | super(root);
|
| 24 | this.babyWalkAnimation = FoxBabyAnimation.FOX_BABY_WALK.bake(root);
|
| 25 | }
|
| 26 |
|
| 27 | public static LayerDefinition createBodyLayer() {
|
| 28 | MeshDefinition meshdefinition = new MeshDefinition();
|
| 29 | PartDefinition root = meshdefinition.getRoot();
|
| 30 | root.addOrReplaceChild(
|
| 31 | "head",
|
| 32 | CubeListBuilder.create()
|
| 33 | .texOffs(0, 0)
|
| 34 | .addBox(-3.0F, -2.125F, -5.125F, 6.0F, 5.0F, 5.0F, new CubeDeformation(0.0F))
|
| 35 | .texOffs(18, 20)
|
| 36 | .addBox(-1.0F, 0.875F, -7.125F, 2.0F, 2.0F, 2.0F, new CubeDeformation(0.0F))
|
| 37 | .texOffs(22, 8)
|
| 38 | .addBox(-3.0F, -4.125F, -4.125F, 2.0F, 2.0F, 1.0F, new CubeDeformation(0.0F))
|
| 39 | .texOffs(22, 11)
|
| 40 | .addBox(1.0F, -4.125F, -4.125F, 2.0F, 2.0F, 1.0F, new CubeDeformation(0.0F)),
|
| 41 | PartPose.offset(0.0F, 18.125F, 0.125F)
|
| 42 | );
|
| 43 | root.addOrReplaceChild(
|
| 44 | "right_hind_leg",
|
| 45 | CubeListBuilder.create().texOffs(22, 4).addBox(-1.0F, 0.0F, -1.0F, 2.0F, 2.0F, 2.0F, new CubeDeformation(0.0F)),
|
| 46 | PartPose.offset(-1.5F, 22.0F, 4.0F)
|
| 47 | );
|
| 48 | root.addOrReplaceChild(
|
| 49 | "left_hind_leg",
|
| 50 | CubeListBuilder.create().texOffs(22, 0).addBox(-1.0F, 0.0F, -1.0F, 2.0F, 2.0F, 2.0F, new CubeDeformation(0.0F)),
|
| 51 | PartPose.offset(1.5F, 22.0F, 4.0F)
|
| 52 | );
|
| 53 | root.addOrReplaceChild(
|
| 54 | "right_front_leg",
|
| 55 | CubeListBuilder.create().texOffs(22, 4).addBox(-1.0F, 0.0F, -1.0F, 2.0F, 2.0F, 2.0F, new CubeDeformation(0.0F)),
|
| 56 | PartPose.offset(-1.5F, 22.0F, 0.0F)
|
| 57 | );
|
| 58 | root.addOrReplaceChild(
|
| 59 | "left_front_leg",
|
| 60 | CubeListBuilder.create().texOffs(22, 0).addBox(-1.0F, 0.0F, -1.0F, 2.0F, 2.0F, 2.0F, new CubeDeformation(0.0F)),
|
| 61 | PartPose.offset(1.5F, 22.0F, 0.0F)
|
| 62 | );
|
| 63 | PartDefinition body = root.addOrReplaceChild(
|
| 64 | "body", CubeListBuilder.create().texOffs(0, 10).addBox(-2.5F, -2.0F, -3.0F, 5.0F, 4.0F, 6.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, 20.0F, 2.0F)
|
| 65 | );
|
| 66 | body.addOrReplaceChild(
|
| 67 | "tail",
|
| 68 | CubeListBuilder.create().texOffs(0, 20).addBox(-1.5F, -1.48F, -1.0F, 3.0F, 3.0F, 6.0F, new CubeDeformation(0.0F)),
|
| 69 | PartPose.offset(0.0F, -0.5F, 3.0F)
|
| 70 | );
|
| 71 | return LayerDefinition.create(meshdefinition, 32, 32);
|
| 72 | }
|
| 73 |
|
| 74 | @Override
|
| 75 | protected void setSittingPose(final FoxRenderState state) {
|
| 76 | super.setSittingPose(state);
|
| 77 | this.body.xRot = -0.959931F;
|
| 78 | this.body.z = this.body.z - 4.5F * state.ageScale;
|
| 79 | this.body.y = this.body.y + 3.0F * state.ageScale;
|
| 80 | this.tail.y -= 0.6F;
|
| 81 | this.tail.z = this.tail.z - 2.0F * state.ageScale;
|
| 82 | this.tail.xRot = 0.95993114F;
|
| 83 | this.head.y -= 0.75F;
|
| 84 | this.head.z += 0.0F;
|
| 85 | this.rightFrontLeg.xRot = (float) (-Math.PI / 12);
|
| 86 | this.leftFrontLeg.xRot = (float) (-Math.PI / 12);
|
| 87 | this.rightFrontLeg.z -= 1.5F;
|
| 88 | this.leftFrontLeg.z -= 1.5F;
|
| 89 | this.rightFrontLeg.x += 0.01F;
|
| 90 | this.leftFrontLeg.x -= 0.01F;
|
| 91 | this.rightHindLeg.z -= 3.75F;
|
| 92 | this.leftHindLeg.z -= 3.75F;
|
| 93 | this.rightHindLeg.x += 0.01F;
|
| 94 | this.leftHindLeg.x -= 0.01F;
|
| 95 | }
|
| 96 |
|
| 97 | @Override
|
| 98 | protected void setSleepingPose(final FoxRenderState state) {
|
| 99 | super.setSleepingPose(state);
|
| 100 | this.body.zRot = (float) (-Math.PI / 2);
|
| 101 | this.body.xRot = (float) (-Math.PI / 18);
|
| 102 | this.body.y += 1.5F;
|
| 103 | this.body.z -= 1.5F;
|
| 104 | this.body.x -= 1.5F;
|
| 105 | this.tail.xRot = (float) (-Math.PI * 5.0 / 6.0);
|
| 106 | this.tail.xRot = -2.1816616F;
|
| 107 | this.tail.x -= 0.7F;
|
| 108 | this.tail.z += 0.6F;
|
| 109 | this.tail.y += 0.9F;
|
| 110 | this.head.x -= 2.0F;
|
| 111 | this.head.y += 2.8F;
|
| 112 | this.head.z -= 4.0F;
|
| 113 | this.head.yRot = (float) (-Math.PI * 2.0 / 3.0);
|
| 114 | this.head.zRot = 0.0F;
|
| 115 | }
|
| 116 |
|
| 117 | @Override
|
| 118 | protected void setWalkingPose(final FoxRenderState state) {
|
| 119 | super.setWalkingPose(state);
|
| 120 | this.babyWalkAnimation.applyWalk(state.walkAnimationPos, state.walkAnimationSpeed, 1.0F, 2.5F);
|
| 121 | }
|
| 122 |
|
| 123 | @Override
|
| 124 | protected void setCrouchingPose(final FoxRenderState state) {
|
| 125 | super.setCrouchingPose(state);
|
| 126 | this.body.y = this.body.y + state.crouchAmount / 6.0F;
|
| 127 | }
|
| 128 | }
|
| 129 |
|