| 1 | package net.minecraft.client.model.animal.wolf;
|
| 2 |
|
| 3 | import net.fabricmc.api.EnvType;
|
| 4 | import net.fabricmc.api.Environment;
|
| 5 | import net.minecraft.client.model.EntityModel;
|
| 6 | import net.minecraft.client.model.geom.ModelPart;
|
| 7 | import net.minecraft.client.renderer.entity.state.WolfRenderState;
|
| 8 | import net.minecraft.util.Mth;
|
| 9 |
|
| 10 | @Environment(EnvType.CLIENT)
|
| 11 | public abstract class WolfModel extends EntityModel<WolfRenderState> {
|
| 12 | protected final ModelPart head;
|
| 13 | protected final ModelPart body;
|
| 14 | protected final ModelPart rightHindLeg;
|
| 15 | protected final ModelPart leftHindLeg;
|
| 16 | protected final ModelPart rightFrontLeg;
|
| 17 | protected final ModelPart leftFrontLeg;
|
| 18 | protected final ModelPart tail;
|
| 19 |
|
| 20 | public WolfModel(final ModelPart root) {
|
| 21 | super(root);
|
| 22 | this.head = root.getChild("head");
|
| 23 | this.body = root.getChild("body");
|
| 24 | this.rightHindLeg = root.getChild("right_hind_leg");
|
| 25 | this.leftHindLeg = root.getChild("left_hind_leg");
|
| 26 | this.rightFrontLeg = root.getChild("right_front_leg");
|
| 27 | this.leftFrontLeg = root.getChild("left_front_leg");
|
| 28 | this.tail = root.getChild("tail");
|
| 29 | }
|
| 30 |
|
| 31 | public void setupAnim(final WolfRenderState state) {
|
| 32 | super.setupAnim(state);
|
| 33 | float animationPos = state.walkAnimationPos;
|
| 34 | float animationSpeed = state.walkAnimationSpeed;
|
| 35 | if (state.isAngry) {
|
| 36 | this.tail.yRot = 0.0F;
|
| 37 | } else {
|
| 38 | this.tail.yRot = Mth.cos(animationPos * 0.6662F) * 1.4F * animationSpeed;
|
| 39 | }
|
| 40 |
|
| 41 | if (state.isSitting) {
|
| 42 | this.setSittingPose(state);
|
| 43 | } else {
|
| 44 | this.rightHindLeg.xRot = Mth.cos(animationPos * 0.6662F) * 1.4F * animationSpeed;
|
| 45 | this.leftHindLeg.xRot = Mth.cos(animationPos * 0.6662F + (float) Math.PI) * 1.4F * animationSpeed;
|
| 46 | this.rightFrontLeg.xRot = Mth.cos(animationPos * 0.6662F + (float) Math.PI) * 1.4F * animationSpeed;
|
| 47 | this.leftFrontLeg.xRot = Mth.cos(animationPos * 0.6662F) * 1.4F * animationSpeed;
|
| 48 | }
|
| 49 |
|
| 50 | this.shakeOffWater(state);
|
| 51 | this.head.xRot = state.xRot * (float) (Math.PI / 180.0);
|
| 52 | this.head.yRot = state.yRot * (float) (Math.PI / 180.0);
|
| 53 | this.tail.xRot = state.tailAngle;
|
| 54 | }
|
| 55 |
|
| 56 | protected void shakeOffWater(final WolfRenderState state) {
|
| 57 | this.body.zRot = state.getBodyRollAngle(-0.16F);
|
| 58 | }
|
| 59 |
|
| 60 | protected void setSittingPose(final WolfRenderState state) {
|
| 61 | float ageScale = state.ageScale;
|
| 62 | this.body.y += 4.0F * ageScale;
|
| 63 | this.body.z -= 2.0F * ageScale;
|
| 64 | this.body.xRot = (float) (Math.PI / 4);
|
| 65 | this.tail.y += 9.0F * ageScale;
|
| 66 | this.tail.z -= 2.0F * ageScale;
|
| 67 | this.rightHindLeg.y += 6.7F * ageScale;
|
| 68 | this.rightHindLeg.z -= 5.0F * ageScale;
|
| 69 | this.rightHindLeg.xRot = (float) (Math.PI * 3.0 / 2.0);
|
| 70 | this.leftHindLeg.y += 6.7F * ageScale;
|
| 71 | this.leftHindLeg.z -= 5.0F * ageScale;
|
| 72 | this.leftHindLeg.xRot = (float) (Math.PI * 3.0 / 2.0);
|
| 73 | this.rightFrontLeg.xRot = 5.811947F;
|
| 74 | this.rightFrontLeg.x += 0.01F * ageScale;
|
| 75 | this.rightFrontLeg.y += 1.0F * ageScale;
|
| 76 | this.leftFrontLeg.xRot = 5.811947F;
|
| 77 | this.leftFrontLeg.x -= 0.01F * ageScale;
|
| 78 | this.leftFrontLeg.y += 1.0F * ageScale;
|
| 79 | }
|
| 80 | }
|
| 81 |
|