| 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.EntityModel;
|
| 6 | import net.minecraft.client.model.geom.ModelPart;
|
| 7 | import net.minecraft.client.renderer.entity.state.FoxRenderState;
|
| 8 | import net.minecraft.util.Mth;
|
| 9 |
|
| 10 | @Environment(EnvType.CLIENT)
|
| 11 | public abstract class FoxModel extends EntityModel<FoxRenderState> {
|
| 12 | public 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 | private float legMotionPos;
|
| 20 |
|
| 21 | public FoxModel(final ModelPart root) {
|
| 22 | super(root);
|
| 23 | this.head = root.getChild("head");
|
| 24 | this.body = root.getChild("body");
|
| 25 | this.rightHindLeg = root.getChild("right_hind_leg");
|
| 26 | this.leftHindLeg = root.getChild("left_hind_leg");
|
| 27 | this.rightFrontLeg = root.getChild("right_front_leg");
|
| 28 | this.leftFrontLeg = root.getChild("left_front_leg");
|
| 29 | this.tail = this.body.getChild("tail");
|
| 30 | }
|
| 31 |
|
| 32 | public void setupAnim(final FoxRenderState state) {
|
| 33 | super.setupAnim(state);
|
| 34 | this.setWalkingPose(state);
|
| 35 | if (state.isCrouching) {
|
| 36 | this.setCrouchingPose(state);
|
| 37 | } else if (state.isSleeping) {
|
| 38 | this.setSleepingPose(state);
|
| 39 | } else if (state.isSitting) {
|
| 40 | this.setSittingPose(state);
|
| 41 | }
|
| 42 |
|
| 43 | if (state.isPouncing) {
|
| 44 | this.setPouncingPose(state);
|
| 45 | }
|
| 46 |
|
| 47 | if (!state.isSleeping && !state.isFaceplanted && !state.isCrouching) {
|
| 48 | this.head.xRot = state.xRot * (float) (Math.PI / 180.0);
|
| 49 | this.head.yRot = state.yRot * (float) (Math.PI / 180.0);
|
| 50 | }
|
| 51 |
|
| 52 | if (state.isSleeping) {
|
| 53 | this.head.xRot = 0.0F;
|
| 54 | this.head.yRot = (float) (-Math.PI * 2.0 / 3.0);
|
| 55 | this.head.zRot = Mth.cos(state.ageInTicks * 0.027F) / 22.0F;
|
| 56 | }
|
| 57 |
|
| 58 | if (state.isFaceplanted) {
|
| 59 | float legMoveFactor = 0.1F;
|
| 60 | this.legMotionPos += 0.67F;
|
| 61 | this.rightHindLeg.xRot = Mth.cos(this.legMotionPos * 0.4662F) * 0.1F;
|
| 62 | this.leftHindLeg.xRot = Mth.cos(this.legMotionPos * 0.4662F + (float) Math.PI) * 0.1F;
|
| 63 | this.rightFrontLeg.xRot = Mth.cos(this.legMotionPos * 0.4662F + (float) Math.PI) * 0.1F;
|
| 64 | this.leftFrontLeg.xRot = Mth.cos(this.legMotionPos * 0.4662F) * 0.1F;
|
| 65 | }
|
| 66 | }
|
| 67 |
|
| 68 | protected void setSittingPose(final FoxRenderState state) {
|
| 69 | this.head.xRot = 0.0F;
|
| 70 | this.head.yRot = 0.0F;
|
| 71 | }
|
| 72 |
|
| 73 | protected void setSleepingPose(final FoxRenderState state) {
|
| 74 | this.rightHindLeg.visible = false;
|
| 75 | this.leftHindLeg.visible = false;
|
| 76 | this.rightFrontLeg.visible = false;
|
| 77 | this.leftFrontLeg.visible = false;
|
| 78 | }
|
| 79 |
|
| 80 | protected void setWalkingPose(final FoxRenderState state) {
|
| 81 | this.head.zRot = state.headRollAngle;
|
| 82 | this.rightHindLeg.visible = true;
|
| 83 | this.leftHindLeg.visible = true;
|
| 84 | this.rightFrontLeg.visible = true;
|
| 85 | this.leftFrontLeg.visible = true;
|
| 86 | }
|
| 87 |
|
| 88 | protected void setCrouchingPose(final FoxRenderState state) {
|
| 89 | this.body.xRot += 0.10471976F;
|
| 90 | this.head.y = this.head.y + state.crouchAmount * state.ageScale;
|
| 91 | float wiggleAmount = Mth.cos(state.ageInTicks) * 0.05F;
|
| 92 | this.body.yRot = wiggleAmount;
|
| 93 | this.rightHindLeg.zRot = wiggleAmount;
|
| 94 | this.leftHindLeg.zRot = wiggleAmount;
|
| 95 | this.rightFrontLeg.zRot = wiggleAmount / 2.0F;
|
| 96 | this.leftFrontLeg.zRot = wiggleAmount / 2.0F;
|
| 97 | }
|
| 98 |
|
| 99 | protected void setPouncingPose(final FoxRenderState state) {
|
| 100 | }
|
| 101 | }
|
| 102 |
|