1
0
Fork 0

Fix a bug that prevents continuous attacks on mobs when the attack key is held

This commit is contained in:
Eliy21 2023-11-11 16:20:06 +00:00
parent 91a3f11689
commit 107fb0b082
1 changed files with 6 additions and 1 deletions

View File

@ -603,6 +603,11 @@ function mob_class:on_punch(hitter, tflp, tool_capabilities, dir)
end end
end end
-- check for invulnerability
if tflp <= invul_time then
return
end
-- healing -- healing
if damage <= -1 then if damage <= -1 then
self.health = self.health - math.floor(damage) self.health = self.health - math.floor(damage)
@ -638,7 +643,7 @@ function mob_class:on_punch(hitter, tflp, tool_capabilities, dir)
if damage >= 0 then if damage >= 0 then
-- only play hit sound and show blood effects if damage is 1 or over; lower to 0.1 to ensure armor works appropriately. -- only play hit sound and show blood effects if damage is 1 or over; lower to 0.1 to ensure armor works appropriately.
if damage >= 0.1 and tflp > invul_time then if damage >= 0.1 then
-- weapon sounds -- weapon sounds
if weapon:get_definition().sounds ~= nil then if weapon:get_definition().sounds ~= nil then