From 9b654621e8ec96bd247d25719096fa2cce856756 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 31 Dec 2025 01:00:33 +0000 Subject: [PATCH] Add attack speed check to NPC's attackEntityFrom before immunity check The LivingAttackEvent handler was firing too late for NPCs because EntityNPCInterface.attackEntityFrom() has its own immunity check that runs BEFORE calling super (which fires LivingAttackEvent). Now the attack speed bypass is checked directly in the NPC's attackEntityFrom() method, before the immunity check at line 658. --- .../noppes/npcs/entity/EntityNPCInterface.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/main/java/noppes/npcs/entity/EntityNPCInterface.java b/src/main/java/noppes/npcs/entity/EntityNPCInterface.java index 94f26acaa..bf382e768 100644 --- a/src/main/java/noppes/npcs/entity/EntityNPCInterface.java +++ b/src/main/java/noppes/npcs/entity/EntityNPCInterface.java @@ -159,6 +159,7 @@ import noppes.npcs.roles.RoleInterface; import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.entity.ScriptNpc; import noppes.npcs.scripted.event.NpcEvent; +import noppes.npcs.scripted.item.ScriptCustomizableItem; import noppes.npcs.util.GameProfileAlt; import noppes.npcs.util.NPCMountUtil; @@ -638,6 +639,22 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti reset(); } + // Check for custom weapon attack speed - bypass immunity if enough time has passed + Entity sourceEntity = damagesource.getEntity(); + if (sourceEntity instanceof EntityPlayer) { + EntityPlayer player = (EntityPlayer) sourceEntity; + ItemStack heldItem = player.getHeldItem(); + if (heldItem != null) { + IItemStack itemStack = NpcAPI.Instance().getIItemStack(heldItem); + if (itemStack instanceof ScriptCustomizableItem) { + int attackSpeed = ((ScriptCustomizableItem) itemStack).getAttackSpeed(); + if (this.hurtResistantTime <= this.maxHurtResistantTime - attackSpeed) { + this.hurtResistantTime = 0; + } + } + } + } + if ((float) this.hurtResistantTime > (float) this.maxHurtResistantTime / 2.0F && i <= this.lastDamage) return false;