use of cn.nukkit.block.BlockDirt in project Nukkit by Nukkit.
the class Entity method fall.
public void fall(float fallDistance) {
float damage = (float) Math.floor(fallDistance - 3 - (this.hasEffect(Effect.JUMP) ? this.getEffect(Effect.JUMP).getAmplifier() + 1 : 0));
if (damage > 0) {
this.attack(new EntityDamageEvent(this, DamageCause.FALL, damage));
}
if (fallDistance > 0.75) {
Block down = this.level.getBlock(this.floor().down());
if (down.getId() == Item.FARMLAND) {
Event ev;
if (this instanceof Player) {
ev = new PlayerInteractEvent((Player) this, null, down, null, Action.PHYSICAL);
} else {
ev = new EntityInteractEvent(this, down);
}
this.server.getPluginManager().callEvent(ev);
if (ev.isCancelled()) {
return;
}
this.level.setBlock(down, new BlockDirt(), false, true);
}
}
}
Aggregations