Call custom `on_punched` functions w/ `hitter = nil` too

This commit is contained in:
Niklp 2024-03-18 20:06:43 +01:00
parent 25369e5165
commit 691036dae5
No known key found for this signature in database
GPG Key ID: 05D6F5035E66267A
1 changed files with 8 additions and 7 deletions

View File

@ -394,14 +394,15 @@ end
if armor.config.punch_damage == true then
minetest.register_on_punchplayer(function(player, hitter,
time_from_last_punch, tool_capabilities)
if hitter == nil then
return
end
local name = player:get_player_name()
local hit_ip = hitter:is_player()
if name and hit_ip and minetest.is_protected(player:get_pos(), "") then
return
elseif name then
if hitter then
local hit_ip = hitter:is_player()
if name and hit_ip and minetest.is_protected(player:get_pos(), "") then
return
end
end
if name then
armor:punch(player, hitter, time_from_last_punch, tool_capabilities)
last_punch_time[name] = minetest.get_gametime()
end