Search in sources :

Example 1 with EntityCombustByBlockEvent

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

the class BlockLava method onEntityCollide.

@Override
public void onEntityCollide(Entity entity) {
    entity.highestPosition -= (entity.highestPosition - entity.y) * 0.5;
    if (!entity.hasEffect(Effect.FIRE_RESISTANCE)) {
        entity.attack(new EntityDamageByBlockEvent(this, entity, DamageCause.LAVA, 4));
    }
    // Always setting the duration to 15 seconds? TODO
    EntityCombustByBlockEvent ev = new EntityCombustByBlockEvent(this, entity, 15);
    Server.getInstance().getPluginManager().callEvent(ev);
    if (!ev.isCancelled() && // Making sure the entity is acutally alive and not invulnerable.
    entity.isAlive() && entity.noDamageTicks == 0) {
        entity.setOnFire(ev.getDuration());
    }
    super.onEntityCollide(entity);
}
Also used : EntityCombustByBlockEvent(cn.nukkit.event.entity.EntityCombustByBlockEvent) EntityDamageByBlockEvent(cn.nukkit.event.entity.EntityDamageByBlockEvent)

Example 2 with EntityCombustByBlockEvent

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

the class BlockFire method onEntityCollide.

@Override
public void onEntityCollide(Entity entity) {
    if (!entity.hasEffect(Effect.FIRE_RESISTANCE)) {
        entity.attack(new EntityDamageByBlockEvent(this, entity, DamageCause.FIRE, 1));
    }
    EntityCombustByBlockEvent ev = new EntityCombustByBlockEvent(this, entity, 8);
    if (entity instanceof EntityArrow) {
        ev.setCancelled();
    }
    Server.getInstance().getPluginManager().callEvent(ev);
    if (!ev.isCancelled() && entity instanceof Player && !((Player) entity).isCreative()) {
        entity.setOnFire(ev.getDuration());
    }
}
Also used : EntityArrow(cn.nukkit.entity.projectile.EntityArrow) EntityCombustByBlockEvent(cn.nukkit.event.entity.EntityCombustByBlockEvent) Player(cn.nukkit.Player) EntityDamageByBlockEvent(cn.nukkit.event.entity.EntityDamageByBlockEvent)

Aggregations

EntityCombustByBlockEvent (cn.nukkit.event.entity.EntityCombustByBlockEvent)2 EntityDamageByBlockEvent (cn.nukkit.event.entity.EntityDamageByBlockEvent)2 Player (cn.nukkit.Player)1 EntityArrow (cn.nukkit.entity.projectile.EntityArrow)1