use of cn.nukkit.event.vehicle.VehicleDestroyEvent in project Nukkit by Nukkit.
the class EntityBoat method attack.
@Override
public boolean attack(EntityDamageEvent source) {
if (invulnerable) {
return false;
} else {
// Event start
VehicleDamageEvent event = new VehicleDamageEvent(this, source.getEntity(), source.getFinalDamage());
getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return false;
}
// Event stop
performHurtAnimation((int) event.getDamage());
boolean instantKill = false;
if (source instanceof EntityDamageByEntityEvent) {
Entity damager = ((EntityDamageByEntityEvent) source).getDamager();
instantKill = damager instanceof Player && ((Player) damager).isCreative();
}
if (instantKill || getDamage() > 40) {
// Event start
VehicleDestroyEvent event2 = new VehicleDestroyEvent(this, source.getEntity());
getServer().getPluginManager().callEvent(event2);
if (event2.isCancelled()) {
return false;
}
// Event stop
if (linkedEntity != null) {
mountEntity(linkedEntity);
}
if (instantKill && (!hasCustomName())) {
kill();
} else {
if (level.getGameRules().getBoolean(GameRule.DO_ENTITY_DROPS)) {
this.level.dropItem(this, new ItemBoat());
}
close();
}
}
}
return true;
}
Aggregations