mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-12 20:07:32 +00:00
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:
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user