Fix damage event cancellation

This commit is contained in:
fullwall 2013-12-05 23:04:18 +08:00
parent 2517a5629d
commit 64b2396e07
3 changed files with 2 additions and 3 deletions

View File

@ -160,7 +160,7 @@ public class EventListen implements Listener {
npc = npcRegistry.getNPC(((EntityDamageByEntityEvent) event).getDamager());
if (npc == null)
return;
event.setCancelled(npc.data().get(NPC.DAMAGE_OTHERS_METADATA, true));
event.setCancelled(!npc.data().get(NPC.DAMAGE_OTHERS_METADATA, true));
NPCDamageEntityEvent damageEvent = new NPCDamageEntityEvent(npc, (EntityDamageByEntityEvent) event);
Bukkit.getPluginManager().callEvent(damageEvent);
}

View File

@ -117,7 +117,6 @@ public class MCTargetStrategy implements PathStrategy, EntityTarget {
if (cancelReason != null) {
return true;
}
setPath();
NMS.look(handle, target);
if (aggro && canAttack()) {

View File

@ -87,9 +87,9 @@ public class NMS {
}
boolean success = target.damageEntity(DamageSource.mobAttack(handle), damage);
if (!success)
return;
if (knockbackLevel > 0) {
target.g(-Math.sin(handle.yaw * Math.PI / 180.0F) * knockbackLevel * 0.5F, 0.1D,
Math.cos(handle.yaw * Math.PI / 180.0F) * knockbackLevel * 0.5F);