Search in sources :

Example 1 with EntityInteractEvent

use of cn.nukkit.event.entity.EntityInteractEvent in project Nukkit by Nukkit.

the class BlockPressurePlateBase method onEntityCollide.

@Override
public void onEntityCollide(Entity entity) {
    int power = getRedstonePower();
    if (power == 0) {
        Event ev;
        if (entity instanceof Player) {
            ev = new PlayerInteractEvent((Player) entity, null, this, null, Action.PHYSICAL);
        } else {
            ev = new EntityInteractEvent(entity, this);
        }
        this.level.getServer().getPluginManager().callEvent(ev);
        if (!ev.isCancelled()) {
            updateState(power);
        }
    }
}
Also used : Player(cn.nukkit.Player) PlayerInteractEvent(cn.nukkit.event.player.PlayerInteractEvent) PlayerInteractEvent(cn.nukkit.event.player.PlayerInteractEvent) Event(cn.nukkit.event.Event) EntityInteractEvent(cn.nukkit.event.entity.EntityInteractEvent) BlockRedstoneEvent(cn.nukkit.event.block.BlockRedstoneEvent) EntityInteractEvent(cn.nukkit.event.entity.EntityInteractEvent)

Aggregations

Player (cn.nukkit.Player)1 Event (cn.nukkit.event.Event)1 BlockRedstoneEvent (cn.nukkit.event.block.BlockRedstoneEvent)1 EntityInteractEvent (cn.nukkit.event.entity.EntityInteractEvent)1 PlayerInteractEvent (cn.nukkit.event.player.PlayerInteractEvent)1