User:Libxfs/fallDamageBug

Falling in lava causes damage to lava immune entities
Living entities can fall. When they fall to the ground, they suffer from falling damage. But there is a bug when they fall in lava.

This is how they fall: EntityLiving.java public void moveEntity(double motionX, double motionY, double motionZ) { ...	onGround = dy != motionY && dy < 0; colliding = horizontallyColliding || verticallyColliding; fallToGround(motionY, onGround); ... } protected void fall(float distance) {	int i = (int)Math.ceil(distance - 3); if (i > 0) { canAttackEntity(null, i); ...	} }

Entity.java: protected void fallToGround(double d, boolean onGround)//func_9279_a {       if (onGround) { if (fallDistance > 0) { fall(fallDistance); fallDistance = 0; }       } else if (d < 0) { fallDistance -= d;       } }

When they are moving downwards but not reaching the ground, their fallDistance accumulates. When their vertical motion is affected by outside factors, it's counted as reaching the ground and the fallDistance is applied as falling damage.

Entities won't receive falling damage when falling into deep enough water because fallDistance is set to zero: Entity.java: public void func_391_y {...

if (handleWaterMovement) { ...           fallDistance = 0; field_9307_bi = true; fire = 0; } else ... where func_391_y is referenced in: Entity.java: public void onUpdate {       func_391_y; } But fallDistance is not set to zero when falling in lava: EntityLiving.java: ...       if (handleLavaMovement) { double d1 = posY; func_351_a(f, f1, 0.02F); moveEntity(motionX, motionY, motionZ); motionX *= 0.5D; motionY *= 0.5D; motionZ *= 0.5D; motionY -= 0.02D; if(field_9297_aI && func_403_b(motionX, ((motionY + 0.60000002384185791D) - posY) + d1, motionZ)) { motionY = 0.30000001192092896D; }       } else ... and the fallDistance is still applied as falling damage because of the slowdown.