/* * Decompiled with CFR 0.152. */ package net.minecraft.client.model; import java.util.Set; import net.minecraft.client.model.BabyModelTransform; import net.minecraft.client.model.EntityModel; import net.minecraft.client.model.geom.ModelPart; import net.minecraft.client.model.geom.PartPose; import net.minecraft.client.model.geom.builders.CubeDeformation; import net.minecraft.client.model.geom.builders.CubeListBuilder; import net.minecraft.client.model.geom.builders.LayerDefinition; import net.minecraft.client.model.geom.builders.MeshDefinition; import net.minecraft.client.model.geom.builders.MeshTransformer; import net.minecraft.client.model.geom.builders.PartDefinition; import net.minecraft.client.renderer.entity.state.FoxRenderState; import net.minecraft.util.Mth; public class FoxModel extends EntityModel { public static final MeshTransformer BABY_TRANSFORMER = new BabyModelTransform(true, 8.0f, 3.35f, Set.of("head")); public final ModelPart head; private final ModelPart body; private final ModelPart rightHindLeg; private final ModelPart leftHindLeg; private final ModelPart rightFrontLeg; private final ModelPart leftFrontLeg; private final ModelPart tail; private static final int LEG_SIZE = 6; private static final float HEAD_HEIGHT = 16.5f; private static final float LEG_POS = 17.5f; private float legMotionPos; public FoxModel(ModelPart root) { super(root); this.head = root.getChild("head"); this.body = root.getChild("body"); this.rightHindLeg = root.getChild("right_hind_leg"); this.leftHindLeg = root.getChild("left_hind_leg"); this.rightFrontLeg = root.getChild("right_front_leg"); this.leftFrontLeg = root.getChild("left_front_leg"); this.tail = this.body.getChild("tail"); } public static LayerDefinition createBodyLayer() { MeshDefinition mesh = new MeshDefinition(); PartDefinition root = mesh.getRoot(); PartDefinition head = root.addOrReplaceChild("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)); head.addOrReplaceChild("right_ear", CubeListBuilder.create().texOffs(8, 1).addBox(-3.0f, -4.0f, -4.0f, 2.0f, 2.0f, 1.0f), PartPose.ZERO); head.addOrReplaceChild("left_ear", CubeListBuilder.create().texOffs(15, 1).addBox(3.0f, -4.0f, -4.0f, 2.0f, 2.0f, 1.0f), PartPose.ZERO); head.addOrReplaceChild("nose", CubeListBuilder.create().texOffs(6, 18).addBox(-1.0f, 2.01f, -8.0f, 4.0f, 2.0f, 3.0f), PartPose.ZERO); PartDefinition body = root.addOrReplaceChild("body", CubeListBuilder.create().texOffs(24, 15).addBox(-3.0f, 3.999f, -3.5f, 6.0f, 11.0f, 6.0f), PartPose.offsetAndRotation(0.0f, 16.0f, -6.0f, 1.5707964f, 0.0f, 0.0f)); CubeDeformation fudge = new CubeDeformation(0.001f); CubeListBuilder leftLeg = CubeListBuilder.create().texOffs(4, 24).addBox(2.0f, 0.5f, -1.0f, 2.0f, 6.0f, 2.0f, fudge); CubeListBuilder rightLeg = CubeListBuilder.create().texOffs(13, 24).addBox(2.0f, 0.5f, -1.0f, 2.0f, 6.0f, 2.0f, fudge); root.addOrReplaceChild("right_hind_leg", rightLeg, PartPose.offset(-5.0f, 17.5f, 7.0f)); root.addOrReplaceChild("left_hind_leg", leftLeg, PartPose.offset(-1.0f, 17.5f, 7.0f)); root.addOrReplaceChild("right_front_leg", rightLeg, PartPose.offset(-5.0f, 17.5f, 0.0f)); root.addOrReplaceChild("left_front_leg", leftLeg, PartPose.offset(-1.0f, 17.5f, 0.0f)); body.addOrReplaceChild("tail", CubeListBuilder.create().texOffs(30, 0).addBox(2.0f, 0.0f, -1.0f, 4.0f, 9.0f, 5.0f), PartPose.offsetAndRotation(-4.0f, 15.0f, -1.0f, -0.05235988f, 0.0f, 0.0f)); return LayerDefinition.create(mesh, 48, 32); } @Override public void setupAnim(FoxRenderState state) { super.setupAnim(state); float animationSpeed = state.walkAnimationSpeed; float animationPos = state.walkAnimationPos; this.rightHindLeg.xRot = Mth.cos(animationPos * 0.6662f) * 1.4f * animationSpeed; this.leftHindLeg.xRot = Mth.cos(animationPos * 0.6662f + (float)Math.PI) * 1.4f * animationSpeed; this.rightFrontLeg.xRot = Mth.cos(animationPos * 0.6662f + (float)Math.PI) * 1.4f * animationSpeed; this.leftFrontLeg.xRot = Mth.cos(animationPos * 0.6662f) * 1.4f * animationSpeed; this.head.zRot = state.headRollAngle; this.rightHindLeg.visible = true; this.leftHindLeg.visible = true; this.rightFrontLeg.visible = true; this.leftFrontLeg.visible = true; float ageScale = state.ageScale; if (state.isCrouching) { this.body.xRot += 0.10471976f; float crouch = state.crouchAmount; this.body.y += crouch * ageScale; this.head.y += crouch * ageScale; } else if (state.isSleeping) { this.body.zRot = -1.5707964f; this.body.y += 5.0f * ageScale; this.tail.xRot = -2.6179938f; if (state.isBaby) { this.tail.xRot = -2.1816616f; this.body.z += 2.0f; } this.head.x += 2.0f * ageScale; this.head.y += 2.99f * ageScale; this.head.yRot = -2.0943952f; this.head.zRot = 0.0f; this.rightHindLeg.visible = false; this.leftHindLeg.visible = false; this.rightFrontLeg.visible = false; this.leftFrontLeg.visible = false; } else if (state.isSitting) { this.body.xRot = 0.5235988f; this.body.y -= 7.0f * ageScale; this.body.z += 3.0f * ageScale; this.tail.xRot = 0.7853982f; this.tail.z -= 1.0f * ageScale; this.head.xRot = 0.0f; this.head.yRot = 0.0f; if (state.isBaby) { this.head.y -= 1.75f; this.head.z -= 0.375f; } else { this.head.y -= 6.5f; this.head.z += 2.75f; } this.rightHindLeg.xRot = -1.3089969f; this.rightHindLeg.y += 4.0f * ageScale; this.rightHindLeg.z -= 0.25f * ageScale; this.leftHindLeg.xRot = -1.3089969f; this.leftHindLeg.y += 4.0f * ageScale; this.leftHindLeg.z -= 0.25f * ageScale; this.rightFrontLeg.xRot = -0.2617994f; this.leftFrontLeg.xRot = -0.2617994f; } if (!(state.isSleeping || state.isFaceplanted || state.isCrouching)) { this.head.xRot = state.xRot * ((float)Math.PI / 180); this.head.yRot = state.yRot * ((float)Math.PI / 180); } if (state.isSleeping) { this.head.xRot = 0.0f; this.head.yRot = -2.0943952f; this.head.zRot = Mth.cos(state.ageInTicks * 0.027f) / 22.0f; } if (state.isCrouching) { float wiggleAmount; this.body.yRot = wiggleAmount = Mth.cos(state.ageInTicks) * 0.01f; this.rightHindLeg.zRot = wiggleAmount; this.leftHindLeg.zRot = wiggleAmount; this.rightFrontLeg.zRot = wiggleAmount / 2.0f; this.leftFrontLeg.zRot = wiggleAmount / 2.0f; } if (state.isFaceplanted) { float legMoveFactor = 0.1f; this.legMotionPos += 0.67f; this.rightHindLeg.xRot = Mth.cos(this.legMotionPos * 0.4662f) * 0.1f; this.leftHindLeg.xRot = Mth.cos(this.legMotionPos * 0.4662f + (float)Math.PI) * 0.1f; this.rightFrontLeg.xRot = Mth.cos(this.legMotionPos * 0.4662f + (float)Math.PI) * 0.1f; this.leftFrontLeg.xRot = Mth.cos(this.legMotionPos * 0.4662f) * 0.1f; } } }