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