diff --git a/mods/ITEMS/mcl_shields/init.lua b/mods/ITEMS/mcl_shields/init.lua index 04bb42db3..cfcd721fb 100644 --- a/mods/ITEMS/mcl_shields/init.lua +++ b/mods/ITEMS/mcl_shields/init.lua @@ -21,18 +21,11 @@ local interact_priv = minetest.registered_privileges.interact interact_priv.give_to_singleplayer = false interact_priv.give_to_admin = false +local is_player = mcl_playerplus.is_player + local overlay = mcl_enchanting.overlay local hud = "mcl_shield_hud.png" -local function is_player_for_real(obj) - if not obj then return end - if not obj:is_player() then return end - local name = obj:get_player_name() - if not name then return end - if possible_hackers[name] then return end - return true -end - minetest.register_tool("mcl_shields:shield", { description = S("Shield"), _doc_items_longdesc = S("A shield is a tool used for protecting the player against attacks."), @@ -132,7 +125,7 @@ mcl_damage.register_modifier(function(obj, damage, reason) local type = reason.type local damager = reason.direct local blocking, shieldstack = mcl_shields.is_blocking(obj) - if is_player_for_real(obj) and blocking and mcl_shields.types[type] and damager then + if is_player(obj) and blocking and mcl_shields.types[type] and damager then local entity = damager:get_luaentity() if entity and (type == "arrow" or type == "generic") then damager = entity._shooter diff --git a/mods/PLAYER/mcl_playerplus/init.lua b/mods/PLAYER/mcl_playerplus/init.lua index 88107442e..1616e3e68 100644 --- a/mods/PLAYER/mcl_playerplus/init.lua +++ b/mods/PLAYER/mcl_playerplus/init.lua @@ -17,6 +17,8 @@ local is_sprinting = mcl_sprint.is_sprinting local exhaust = mcl_hunger.exhaust local playerphysics = playerphysics +local is_player = mcl_player.is_player + local vector = vector local math = math -- Internal player state @@ -25,6 +27,17 @@ local mcl_playerplus_internal = {} local time = 0 local look_pitch = 0 +function mcl_playerplus.is_player(obj) + if not obj then return end + if not obj:is_player() then return end + local name = obj:get_player_name() + if not name then return end + if possible_hackers[name] then return end + return true +end + +local is_player = mcl_playerplus.is_player + local function player_collision(player) local pos = player:get_pos() @@ -35,7 +48,7 @@ local function player_collision(player) for _,object in pairs(minetest.get_objects_inside_radius(pos, width)) do - if object and (object:is_player() + if object and (is_player(object) or (object:get_luaentity()._cmi_is_mob == true and object ~= player)) then local pos2 = object:get_pos()