1
0
Fork 0

Fix a potential bug that could bypass attack reach limit when a stronger attack breaches the invul

This commit is contained in:
Eliy21 2023-12-13 20:04:15 +00:00
parent 96aaf89036
commit b0e33793ec
1 changed files with 9 additions and 9 deletions

View File

@ -730,6 +730,15 @@ mcl_damage.register_modifier(function(obj, damage, reason)
end, -200)
minetest.register_on_punchplayer(function(player, hitter, time_from_last_punch, tool_capabilities, dir, damage)
-- attack reach limit
if hitter and hitter:is_player() then
local player_pos = player:get_pos()
local hitter_pos = hitter:get_pos()
if vector.distance(player_pos, hitter_pos) > 3 then
damage = 0
return damage
end
end
-- damage invulnerability
if hitter then
local name = player:get_player_name()
@ -748,15 +757,6 @@ minetest.register_on_punchplayer(function(player, hitter, time_from_last_punch,
mcl_playerplus_internal[name].invul_timestamp = time_now
end
end
-- attack reach limit
if hitter and hitter:is_player() then
local player_pos = player:get_pos()
local hitter_pos = hitter:get_pos()
if vector.distance(player_pos, hitter_pos) > 3 then
damage = 0
return damage
end
end
end)
minetest.register_on_respawnplayer(function(player)