From c01c53af491f3e1937c1217477f5b26bcf2b7ae3 Mon Sep 17 00:00:00 2001 From: kay27 Date: Wed, 30 Sep 2020 16:42:52 +0400 Subject: [PATCH] Prevent opening double chests with solid block(s) on the top --- mods/ITEMS/mcl_chests/init.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/mods/ITEMS/mcl_chests/init.lua b/mods/ITEMS/mcl_chests/init.lua index 61b7a4df23..d1966e190a 100644 --- a/mods/ITEMS/mcl_chests/init.lua +++ b/mods/ITEMS/mcl_chests/init.lua @@ -360,6 +360,12 @@ minetest.register_node("mcl_chests:"..basename.."_left", { on_rightclick = function(pos, node, clicker) local pos_other = mcl_util.get_double_container_neighbor_pos(pos, node.param2, "left") + if minetest.registered_nodes[minetest.get_node({x = pos.x, y = pos.y + 1, z = pos.z}).name].groups.opaque == 1 + or minetest.registered_nodes[minetest.get_node({x = pos_other.x, y = pos_other.y + 1, z = pos_other.z}).name].groups.opaque == 1 then + -- won't open if there is no space from the top + return false + end + local name = minetest.get_meta(pos):get_string("name") if name == "" then name = minetest.get_meta(pos_other):get_string("name") @@ -494,6 +500,12 @@ minetest.register_node("mcl_chests:"..basename.."_right", { on_rightclick = function(pos, node, clicker) local pos_other = mcl_util.get_double_container_neighbor_pos(pos, node.param2, "right") + if minetest.registered_nodes[minetest.get_node({x = pos.x, y = pos.y + 1, z = pos.z}).name].groups.opaque == 1 + or minetest.registered_nodes[minetest.get_node({x = pos_other.x, y = pos_other.y + 1, z = pos_other.z}).name].groups.opaque == 1 then + -- won't open if there is no space from the top + return false + end + local name = minetest.get_meta(pos_other):get_string("name") if name == "" then name = minetest.get_meta(pos):get_string("name")