    001package net.minecraft.entity;
    002
    003import net.minecraft.util.MathHelper;
    004
    005public class EntityBodyHelper
    006{
    007    /** Instance of EntityLiving. */
    008    private EntityLiving theLiving;
    009    private int field_75666_b = 0;
    010    private float field_75667_c = 0.0F;
    011
    012    public EntityBodyHelper(EntityLiving par1EntityLiving)
    013    {
    014        this.theLiving = par1EntityLiving;
    015    }
    016
    017    public void func_75664_a()
    018    {
    019        double d0 = this.theLiving.posX - this.theLiving.prevPosX;
    020        double d1 = this.theLiving.posZ - this.theLiving.prevPosZ;
    021
    022        if (d0 * d0 + d1 * d1 > 2.500000277905201E-7D)
    023        {
    024            this.theLiving.renderYawOffset = this.theLiving.rotationYaw;
    025            this.theLiving.rotationYawHead = this.func_75665_a(this.theLiving.renderYawOffset, this.theLiving.rotationYawHead, 75.0F);
    026            this.field_75667_c = this.theLiving.rotationYawHead;
    027            this.field_75666_b = 0;
    028        }
    029        else
    030        {
    031            float f = 75.0F;
    032
    033            if (Math.abs(this.theLiving.rotationYawHead - this.field_75667_c) > 15.0F)
    034            {
    035                this.field_75666_b = 0;
    036                this.field_75667_c = this.theLiving.rotationYawHead;
    037            }
    038            else
    039            {
    040                ++this.field_75666_b;
    041
    042                if (this.field_75666_b > 10)
    043                {
    044                    f = Math.max(1.0F - (float)(this.field_75666_b - 10) / 10.0F, 0.0F) * 75.0F;
    045                }
    046            }
    047
    048            this.theLiving.renderYawOffset = this.func_75665_a(this.theLiving.rotationYawHead, this.theLiving.renderYawOffset, f);
    049        }
    050    }
    051
    052    private float func_75665_a(float par1, float par2, float par3)
    053    {
    054        float f3 = MathHelper.wrapAngleTo180_float(par1 - par2);
    055
    056        if (f3 < -par3)
    057        {
    058            f3 = -par3;
    059        }
    060
    061        if (f3 >= par3)
    062        {
    063            f3 = par3;
    064        }
    065
    066        return par1 - f3;
    067    }
    068}