本文整理匯總了Java中cn.nukkit.event.vehicle.VehicleDestroyEvent類的典型用法代碼示例。如果您正苦於以下問題:Java VehicleDestroyEvent類的具體用法?Java VehicleDestroyEvent怎麽用?Java VehicleDestroyEvent使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
VehicleDestroyEvent類屬於cn.nukkit.event.vehicle包,在下文中一共展示了VehicleDestroyEvent類的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: attack
import cn.nukkit.event.vehicle.VehicleDestroyEvent; //導入依賴的package包/類
@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("doEntityDrops")) {
this.level.dropItem(this, new ItemBoat());
}
close();
}
}
}
return true;
}