Revert unreliable bugfix

There are times when the continuous damage when punching players does not happen so will not fix at the moment as using other weapons does still work.
This commit is contained in:
Eliy21 2023-12-15 15:42:49 +00:00
parent 6b439fd1de
commit 60367cdbe0
1 changed files with 7 additions and 7 deletions

View File

@ -664,7 +664,6 @@ minetest.register_on_joinplayer(function(player)
swimDistance = 0,
jump_cooldown = -1, -- Cooldown timer for jumping, we need this to prevent the jump exhaustion to increase rapidly
last_damage = 0,
invul_timestamp = 0,
}
mcl_playerplus.elytra[player] = {active = false, rocketing = 0, speed = 0}
@ -742,11 +741,9 @@ minetest.register_on_punchplayer(function(player, hitter, time_from_last_punch,
-- damage invulnerability
if hitter then
local name = player:get_player_name()
local time_now = minetest.get_us_time()
local invul_timestamp = mcl_playerplus_internal[name].invul_timestamp
local time_diff = time_now - invul_timestamp
-- check for invulnerability time in microseconds (0.5 second)
if time_diff <= 500000 and time_diff >= 0 then
-- check for invulnerability time for 0.5 second
local invul = player:get_meta():get_int("mcl_damage:invulnerable")
if invul > 0 then
damage = damage - mcl_playerplus_internal[name].last_damage
if damage < 0 then
damage = 0
@ -754,7 +751,10 @@ minetest.register_on_punchplayer(function(player, hitter, time_from_last_punch,
return damage
else
mcl_playerplus_internal[name].last_damage = damage
mcl_playerplus_internal[name].invul_timestamp = time_now
player:get_meta():set_int("mcl_damage:invulnerable", 1)
minetest.after(0.5, function()
player:get_meta():set_int("mcl_damage:invulnerable", 0)
end)
end
end
end)