From 8ce9ec357cf5b96bc4c77e8c5e2d097d1d0ce61d Mon Sep 17 00:00:00 2001 From: fullwall Date: Mon, 29 May 2023 01:01:08 +0800 Subject: [PATCH] Check for attack damage attribute for mob attacks --- .../java/net/citizensnpcs/nms/v1_19_R3/util/NMSImpl.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/v1_19_R3/src/main/java/net/citizensnpcs/nms/v1_19_R3/util/NMSImpl.java b/v1_19_R3/src/main/java/net/citizensnpcs/nms/v1_19_R3/util/NMSImpl.java index a8dfc1787..8ad766d46 100644 --- a/v1_19_R3/src/main/java/net/citizensnpcs/nms/v1_19_R3/util/NMSImpl.java +++ b/v1_19_R3/src/main/java/net/citizensnpcs/nms/v1_19_R3/util/NMSImpl.java @@ -426,13 +426,12 @@ public class NMSImpl implements NMSBridge { PlayerAnimation.ARM_SWING.play((Player) source.getBukkitEntity()); return; } - if (source instanceof Mob) { + boolean hasAttackDamage = source.getAttributes().hasAttribute(Attributes.ATTACK_DAMAGE); + if (source instanceof Mob && hasAttackDamage) { ((Mob) source).doHurtTarget(target); return; } - float f = (float) (source.getAttributes().hasAttribute(Attributes.ATTACK_DAMAGE) - ? source.getAttributeValue(Attributes.ATTACK_DAMAGE) - : 1f); + float f = (float) (hasAttackDamage ? source.getAttributeValue(Attributes.ATTACK_DAMAGE) : 1f); int i = 0; f += EnchantmentHelper.getDamageBonus(source.getMainHandItem(), target.getMobType()); i += EnchantmentHelper.getKnockbackBonus(source);