Search in sources :

Example 1 with BlockDirt

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);
        }
    }
}
Also used : Player(cn.nukkit.Player) PlayerInteractEvent(cn.nukkit.event.player.PlayerInteractEvent) Block(cn.nukkit.block.Block) PlayerInteractEvent(cn.nukkit.event.player.PlayerInteractEvent) Event(cn.nukkit.event.Event) PlayerTeleportEvent(cn.nukkit.event.player.PlayerTeleportEvent) BlockDirt(cn.nukkit.block.BlockDirt)

Aggregations

Player (cn.nukkit.Player)1 Block (cn.nukkit.block.Block)1 BlockDirt (cn.nukkit.block.BlockDirt)1 Event (cn.nukkit.event.Event)1 PlayerInteractEvent (cn.nukkit.event.player.PlayerInteractEvent)1 PlayerTeleportEvent (cn.nukkit.event.player.PlayerTeleportEvent)1