Check for attack damage attribute for mob attacks

This commit is contained in:
fullwall 2023-05-29 01:01:08 +08:00
parent 5dc627ab49
commit 8ce9ec357c

View File

@ -426,13 +426,12 @@ public class NMSImpl implements NMSBridge {
PlayerAnimation.ARM_SWING.play((Player) source.getBukkitEntity()); PlayerAnimation.ARM_SWING.play((Player) source.getBukkitEntity());
return; return;
} }
if (source instanceof Mob) { boolean hasAttackDamage = source.getAttributes().hasAttribute(Attributes.ATTACK_DAMAGE);
if (source instanceof Mob && hasAttackDamage) {
((Mob) source).doHurtTarget(target); ((Mob) source).doHurtTarget(target);
return; return;
} }
float f = (float) (source.getAttributes().hasAttribute(Attributes.ATTACK_DAMAGE) float f = (float) (hasAttackDamage ? source.getAttributeValue(Attributes.ATTACK_DAMAGE) : 1f);
? source.getAttributeValue(Attributes.ATTACK_DAMAGE)
: 1f);
int i = 0; int i = 0;
f += EnchantmentHelper.getDamageBonus(source.getMainHandItem(), target.getMobType()); f += EnchantmentHelper.getDamageBonus(source.getMainHandItem(), target.getMobType());
i += EnchantmentHelper.getKnockbackBonus(source); i += EnchantmentHelper.getKnockbackBonus(source);