From 691036dae55e3796dd2fe35720ec368e14ace115 Mon Sep 17 00:00:00 2001 From: Niklp Date: Mon, 18 Mar 2024 20:06:43 +0100 Subject: [PATCH] Call custom `on_punched` functions w/ `hitter = nil` too --- 3d_armor/init.lua | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/3d_armor/init.lua b/3d_armor/init.lua index 1a4028a..1d67c63 100644 --- a/3d_armor/init.lua +++ b/3d_armor/init.lua @@ -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