    001    package net.minecraft.src;
    002
    003    public class EntityMoveHelper
    004    {
    005        /** The EntityLiving that is being moved */
    006        private EntityLiving entity;
    007        private double posX;
    008        private double posY;
    009        private double posZ;
    010
    011        /** The speed at which the entity should move */
    012        private float speed;
    013        private boolean field_75643_f = false;
    014
    015        public EntityMoveHelper(EntityLiving par1EntityLiving)
    016        {
    017            this.entity = par1EntityLiving;
    018            this.posX = par1EntityLiving.posX;
    019            this.posY = par1EntityLiving.posY;
    020            this.posZ = par1EntityLiving.posZ;
    021        }
    022
    023        public boolean func_75640_a()
    024        {
    025            return this.field_75643_f;
    026        }
    027
    028        public float getSpeed()
    029        {
    030            return this.speed;
    031        }
    032
    033        /**
    034         * Sets the speed and location to move to
    035         */
    036        public void setMoveTo(double par1, double par3, double par5, float par7)
    037        {
    038            this.posX = par1;
    039            this.posY = par3;
    040            this.posZ = par5;
    041            this.speed = par7;
    042            this.field_75643_f = true;
    043        }
    044
    045        public void onUpdateMoveHelper()
    046        {
    047            this.entity.setMoveForward(0.0F);
    048
    049            if (this.field_75643_f)
    050            {
    051                this.field_75643_f = false;
    052                int var1 = MathHelper.floor_double(this.entity.boundingBox.minY + 0.5D);
    053                double var2 = this.posX - this.entity.posX;
    054                double var4 = this.posZ - this.entity.posZ;
    055                double var6 = this.posY - (double)var1;
    056                double var8 = var2 * var2 + var6 * var6 + var4 * var4;
    057
    058                if (var8 >= 2.500000277905201E-7D)
    059                {
    060                    float var10 = (float)(Math.atan2(var4, var2) * 180.0D / Math.PI) - 90.0F;
    061                    this.entity.rotationYaw = this.func_75639_a(this.entity.rotationYaw, var10, 30.0F);
    062                    this.entity.setAIMoveSpeed(this.speed * this.entity.getSpeedModifier());
    063
    064                    if (var6 > 0.0D && var2 * var2 + var4 * var4 < 1.0D)
    065                    {
    066                        this.entity.getJumpHelper().setJumping();
    067                    }
    068                }
    069            }
    070        }
    071
    072        private float func_75639_a(float par1, float par2, float par3)
    073        {
    074            float var4 = MathHelper.wrapAngleTo180_float(par2 - par1);
    075
    076            if (var4 > par3)
    077            {
    078                var4 = par3;
    079            }
    080
    081            if (var4 < -par3)
    082            {
    083                var4 = -par3;
    084            }
    085
    086            return par1 + var4;
    087        }
    088    }