本文整理汇总了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;
}