mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-01-14 20:21:19 +01:00
Fix damage event cancellation
This commit is contained in:
parent
2517a5629d
commit
64b2396e07
@ -160,7 +160,7 @@ public class EventListen implements Listener {
|
|||||||
npc = npcRegistry.getNPC(((EntityDamageByEntityEvent) event).getDamager());
|
npc = npcRegistry.getNPC(((EntityDamageByEntityEvent) event).getDamager());
|
||||||
if (npc == null)
|
if (npc == null)
|
||||||
return;
|
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);
|
NPCDamageEntityEvent damageEvent = new NPCDamageEntityEvent(npc, (EntityDamageByEntityEvent) event);
|
||||||
Bukkit.getPluginManager().callEvent(damageEvent);
|
Bukkit.getPluginManager().callEvent(damageEvent);
|
||||||
}
|
}
|
||||||
|
@ -117,7 +117,6 @@ public class MCTargetStrategy implements PathStrategy, EntityTarget {
|
|||||||
if (cancelReason != null) {
|
if (cancelReason != null) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
setPath();
|
setPath();
|
||||||
NMS.look(handle, target);
|
NMS.look(handle, target);
|
||||||
if (aggro && canAttack()) {
|
if (aggro && canAttack()) {
|
||||||
|
@ -87,9 +87,9 @@ public class NMS {
|
|||||||
}
|
}
|
||||||
|
|
||||||
boolean success = target.damageEntity(DamageSource.mobAttack(handle), damage);
|
boolean success = target.damageEntity(DamageSource.mobAttack(handle), damage);
|
||||||
|
|
||||||
if (!success)
|
if (!success)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (knockbackLevel > 0) {
|
if (knockbackLevel > 0) {
|
||||||
target.g(-Math.sin(handle.yaw * Math.PI / 180.0F) * knockbackLevel * 0.5F, 0.1D,
|
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);
|
Math.cos(handle.yaw * Math.PI / 180.0F) * knockbackLevel * 0.5F);
|
||||||
|
Loading…
Reference in New Issue
Block a user