Fix attack speed formula to check elapsed time properly

Instead of blindly resetting hurtResistantTime for fast weapons, now
checks if enough time has elapsed based on the weapon's attackSpeed:
- timeElapsed = maxHurtResistantTime - hurtResistantTime
- Allow attack when: hurtResistantTime <= maxHurtResistantTime - attackSpeed

Example: attackSpeed=10, maxHurtResistantTime=20
- Allows attack when hurtResistantTime <= 10 (10 ticks elapsed)
This commit is contained in:
Claude committed 2025-12-31 00:52:06 +00:00
1 parent 185a8bc917
commit d06e680350
1 file changed
+1 -2
@@ -554,9 +554,8 @@ public class ScriptPlayerEventHandler {
if (itemStack instanceof ScriptCustomizableItem) {
ScriptCustomizableItem sci = (ScriptCustomizableItem) itemStack;
int attackSpeed = sci.getAttackSpeed();
if (attackSpeed < 20) {
if (event.entityLiving.hurtResistantTime <= event.entityLiving.maxHurtResistantTime - attackSpeed) {
event.entityLiving.hurtResistantTime = 0;
event.entityLiving.hurtTime = attackSpeed;
}
}
}