001    package net.minecraft.src;
002    
003    public abstract class EntityFlying extends EntityLiving
004    {
005        public EntityFlying(World par1World)
006        {
007            super(par1World);
008        }
009    
010        /**
011         * Called when the mob is falling. Calculates and applies fall damage.
012         */
013        protected void fall(float par1) {}
014    
015        /**
016         * Moves the entity based on the specified heading.  Args: strafe, forward
017         */
018        public void moveEntityWithHeading(float par1, float par2)
019        {
020            if (this.isInWater())
021            {
022                this.moveFlying(par1, par2, 0.02F);
023                this.moveEntity(this.motionX, this.motionY, this.motionZ);
024                this.motionX *= 0.800000011920929D;
025                this.motionY *= 0.800000011920929D;
026                this.motionZ *= 0.800000011920929D;
027            }
028            else if (this.handleLavaMovement())
029            {
030                this.moveFlying(par1, par2, 0.02F);
031                this.moveEntity(this.motionX, this.motionY, this.motionZ);
032                this.motionX *= 0.5D;
033                this.motionY *= 0.5D;
034                this.motionZ *= 0.5D;
035            }
036            else
037            {
038                float var3 = 0.91F;
039    
040                if (this.onGround)
041                {
042                    var3 = 0.54600006F;
043                    int var4 = this.worldObj.getBlockId(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.boundingBox.minY) - 1, MathHelper.floor_double(this.posZ));
044    
045                    if (var4 > 0)
046                    {
047                        var3 = Block.blocksList[var4].slipperiness * 0.91F;
048                    }
049                }
050    
051                float var8 = 0.16277136F / (var3 * var3 * var3);
052                this.moveFlying(par1, par2, this.onGround ? 0.1F * var8 : 0.02F);
053                var3 = 0.91F;
054    
055                if (this.onGround)
056                {
057                    var3 = 0.54600006F;
058                    int var5 = this.worldObj.getBlockId(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.boundingBox.minY) - 1, MathHelper.floor_double(this.posZ));
059    
060                    if (var5 > 0)
061                    {
062                        var3 = Block.blocksList[var5].slipperiness * 0.91F;
063                    }
064                }
065    
066                this.moveEntity(this.motionX, this.motionY, this.motionZ);
067                this.motionX *= (double)var3;
068                this.motionY *= (double)var3;
069                this.motionZ *= (double)var3;
070            }
071    
072            this.prevLegYaw = this.legYaw;
073            double var10 = this.posX - this.prevPosX;
074            double var9 = this.posZ - this.prevPosZ;
075            float var7 = MathHelper.sqrt_double(var10 * var10 + var9 * var9) * 4.0F;
076    
077            if (var7 > 1.0F)
078            {
079                var7 = 1.0F;
080            }
081    
082            this.legYaw += (var7 - this.legYaw) * 0.4F;
083            this.legSwing += this.legYaw;
084        }
085    
086        /**
087         * returns true if this entity is by a ladder, false otherwise
088         */
089        public boolean isOnLadder()
090        {
091            return false;
092        }
093    }