/* * Decompiled with CFR 0.152. */ package net.minecraft.client.model; import net.minecraft.client.animation.KeyframeAnimation; import net.minecraft.client.animation.definitions.CamelAnimation; 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.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.CamelRenderState; import net.minecraft.util.Mth; public class CamelModel extends EntityModel { private static final float MAX_WALK_ANIMATION_SPEED = 2.0f; private static final float WALK_ANIMATION_SCALE_FACTOR = 2.5f; public static final MeshTransformer BABY_TRANSFORMER = MeshTransformer.scaling(0.45f); protected final ModelPart head; private final KeyframeAnimation walkAnimation; private final KeyframeAnimation sitAnimation; private final KeyframeAnimation sitPoseAnimation; private final KeyframeAnimation standupAnimation; private final KeyframeAnimation idleAnimation; private final KeyframeAnimation dashAnimation; public CamelModel(ModelPart root) { super(root); ModelPart body = root.getChild("body"); this.head = body.getChild("head"); this.walkAnimation = CamelAnimation.CAMEL_WALK.bake(root); this.sitAnimation = CamelAnimation.CAMEL_SIT.bake(root); this.sitPoseAnimation = CamelAnimation.CAMEL_SIT_POSE.bake(root); this.standupAnimation = CamelAnimation.CAMEL_STANDUP.bake(root); this.idleAnimation = CamelAnimation.CAMEL_IDLE.bake(root); this.dashAnimation = CamelAnimation.CAMEL_DASH.bake(root); } public static LayerDefinition createBodyLayer() { return LayerDefinition.create(CamelModel.createBodyMesh(), 128, 128); } protected static MeshDefinition createBodyMesh() { MeshDefinition mesh = new MeshDefinition(); PartDefinition root = mesh.getRoot(); PartDefinition body = root.addOrReplaceChild("body", CubeListBuilder.create().texOffs(0, 25).addBox(-7.5f, -12.0f, -23.5f, 15.0f, 12.0f, 27.0f), PartPose.offset(0.0f, 4.0f, 9.5f)); body.addOrReplaceChild("hump", CubeListBuilder.create().texOffs(74, 0).addBox(-4.5f, -5.0f, -5.5f, 9.0f, 5.0f, 11.0f), PartPose.offset(0.0f, -12.0f, -10.0f)); body.addOrReplaceChild("tail", CubeListBuilder.create().texOffs(122, 0).addBox(-1.5f, 0.0f, 0.0f, 3.0f, 14.0f, 0.0f), PartPose.offset(0.0f, -9.0f, 3.5f)); PartDefinition head = body.addOrReplaceChild("head", CubeListBuilder.create().texOffs(60, 24).addBox(-3.5f, -7.0f, -15.0f, 7.0f, 8.0f, 19.0f).texOffs(21, 0).addBox(-3.5f, -21.0f, -15.0f, 7.0f, 14.0f, 7.0f).texOffs(50, 0).addBox(-2.5f, -21.0f, -21.0f, 5.0f, 5.0f, 6.0f), PartPose.offset(0.0f, -3.0f, -19.5f)); head.addOrReplaceChild("left_ear", CubeListBuilder.create().texOffs(45, 0).addBox(-0.5f, 0.5f, -1.0f, 3.0f, 1.0f, 2.0f), PartPose.offset(2.5f, -21.0f, -9.5f)); head.addOrReplaceChild("right_ear", CubeListBuilder.create().texOffs(67, 0).addBox(-2.5f, 0.5f, -1.0f, 3.0f, 1.0f, 2.0f), PartPose.offset(-2.5f, -21.0f, -9.5f)); root.addOrReplaceChild("left_hind_leg", CubeListBuilder.create().texOffs(58, 16).addBox(-2.5f, 2.0f, -2.5f, 5.0f, 21.0f, 5.0f), PartPose.offset(4.9f, 1.0f, 9.5f)); root.addOrReplaceChild("right_hind_leg", CubeListBuilder.create().texOffs(94, 16).addBox(-2.5f, 2.0f, -2.5f, 5.0f, 21.0f, 5.0f), PartPose.offset(-4.9f, 1.0f, 9.5f)); root.addOrReplaceChild("left_front_leg", CubeListBuilder.create().texOffs(0, 0).addBox(-2.5f, 2.0f, -2.5f, 5.0f, 21.0f, 5.0f), PartPose.offset(4.9f, 1.0f, -10.5f)); root.addOrReplaceChild("right_front_leg", CubeListBuilder.create().texOffs(0, 26).addBox(-2.5f, 2.0f, -2.5f, 5.0f, 21.0f, 5.0f), PartPose.offset(-4.9f, 1.0f, -10.5f)); return mesh; } @Override public void setupAnim(CamelRenderState state) { super.setupAnim(state); this.applyHeadRotation(state, state.yRot, state.xRot); this.walkAnimation.applyWalk(state.walkAnimationPos, state.walkAnimationSpeed, 2.0f, 2.5f); this.sitAnimation.apply(state.sitAnimationState, state.ageInTicks); this.sitPoseAnimation.apply(state.sitPoseAnimationState, state.ageInTicks); this.standupAnimation.apply(state.sitUpAnimationState, state.ageInTicks); this.idleAnimation.apply(state.idleAnimationState, state.ageInTicks); this.dashAnimation.apply(state.dashAnimationState, state.ageInTicks); } private void applyHeadRotation(CamelRenderState state, float yRot, float xRot) { yRot = Mth.clamp(yRot, -30.0f, 30.0f); xRot = Mth.clamp(xRot, -25.0f, 45.0f); if (state.jumpCooldown > 0.0f) { float headRotation = 45.0f * state.jumpCooldown / 55.0f; xRot = Mth.clamp(xRot + headRotation, -25.0f, 70.0f); } this.head.yRot = yRot * ((float)Math.PI / 180); this.head.xRot = xRot * ((float)Math.PI / 180); } }