    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 var1 = this.theLiving.posX - this.theLiving.prevPosX;
    020        double var3 = this.theLiving.posZ - this.theLiving.prevPosZ;
    021
    022        if (var1 * var1 + var3 * var3 > 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 var5 = 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                    var5 = 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, var5);
    049        }
    050    }
    051
    052    private float func_75665_a(float par1, float par2, float par3)
    053    {
    054        float var4 = MathHelper.wrapAngleTo180_float(par1 - par2);
    055
    056        if (var4 < -par3)
    057        {
    058            var4 = -par3;
    059        }
    060
    061        if (var4 >= par3)
    062        {
    063            var4 = par3;
    064        }
    065
    066        return par1 - var4;
    067    }
    068}