diff --git a/mods/PLAYER/mcl_playerplus/init.lua b/mods/PLAYER/mcl_playerplus/init.lua index 83ea1a1aa..99230bf9a 100644 --- a/mods/PLAYER/mcl_playerplus/init.lua +++ b/mods/PLAYER/mcl_playerplus/init.lua @@ -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)