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;