mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-25 12:01:06 +01:00
Fix a potential bug that could bypass attack reach limit when a stronger attack breaches the invul
This commit is contained in:
parent
96aaf89036
commit
b0e33793ec
1 changed files with 9 additions and 9 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue