From e2688c03e36f61700f2d1ede898df2fe6c152ea3 Mon Sep 17 00:00:00 2001 From: ancientmarinerdev Date: Sun, 14 May 2023 22:48:33 +0100 Subject: [PATCH] Zombie piglin no longer prevent sleep unless hostile. --- mods/ITEMS/mcl_beds/functions.lua | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/mods/ITEMS/mcl_beds/functions.lua b/mods/ITEMS/mcl_beds/functions.lua index 07ad1cba5..fdb4f8f41 100644 --- a/mods/ITEMS/mcl_beds/functions.lua +++ b/mods/ITEMS/mcl_beds/functions.lua @@ -117,19 +117,23 @@ local function lay_down(player, pos, bed_pos, state, skip) end -- No sleeping if monsters nearby. - -- The exceptions above apply. - -- Zombie piglin only prevent sleep while they are hostle. for _, obj in pairs(minetest.get_objects_inside_radius(bed_pos, 8)) do if obj and not obj:is_player() then local ent = obj:get_luaentity() local mobname = ent.name local def = minetest.registered_entities[mobname] -- Approximation of monster detection range - if def.is_mob and ((mobname ~= "mobs_mc:pigman" and def.type == "monster" and not monster_exceptions[mobname]) or (mobname == "mobs_mc:pigman" and ent.state == "attack")) then - if math.abs(bed_pos.y - obj:get_pos().y) <= 5 then - return false, S("You can't sleep now, monsters are nearby!") + if def.is_mob and (def.type == "monster" or mobname == "mobs_mc:zombified_piglin") then + if monster_exceptions[mobname] or + (mobname == "mobs_mc:zombified_piglin" and ent.state ~= "attack") then + -- Some exceptions do not prevent sleep. Zombie piglin only prevent sleep while they are hostile. + else + if math.abs(bed_pos.y - obj:get_pos().y) <= 5 then + return false, S("You can't sleep now, monsters are nearby!") + end end end + end end end