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 f2 = 0.91F; 049 050 if (this.onGround) 051 { 052 f2 = 0.54600006F; 053 int i = this.worldObj.getBlockId(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.boundingBox.minY) - 1, MathHelper.floor_double(this.posZ)); 054 055 if (i > 0) 056 { 057 f2 = Block.blocksList[i].slipperiness * 0.91F; 058 } 059 } 060 061 float f3 = 0.16277136F / (f2 * f2 * f2); 062 this.moveFlying(par1, par2, this.onGround ? 0.1F * f3 : 0.02F); 063 f2 = 0.91F; 064 065 if (this.onGround) 066 { 067 f2 = 0.54600006F; 068 int j = this.worldObj.getBlockId(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.boundingBox.minY) - 1, MathHelper.floor_double(this.posZ)); 069 070 if (j > 0) 071 { 072 f2 = Block.blocksList[j].slipperiness * 0.91F; 073 } 074 } 075 076 this.moveEntity(this.motionX, this.motionY, this.motionZ); 077 this.motionX *= (double)f2; 078 this.motionY *= (double)f2; 079 this.motionZ *= (double)f2; 080 } 081 082 this.prevLimbYaw = this.limbYaw; 083 double d0 = this.posX - this.prevPosX; 084 double d1 = this.posZ - this.prevPosZ; 085 float f4 = MathHelper.sqrt_double(d0 * d0 + d1 * d1) * 4.0F; 086 087 if (f4 > 1.0F) 088 { 089 f4 = 1.0F; 090 } 091 092 this.limbYaw += (f4 - this.limbYaw) * 0.4F; 093 this.limbSwing += this.limbYaw; 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}