From 8d440252a4c64bda75136c041dfae711e2d76b72 Mon Sep 17 00:00:00 2001 From: Freeman Date: Fri, 13 Oct 2023 21:07:00 +0200 Subject: [PATCH] fix crash when opening a chest that has an unknow node on it fix #3961 --- mods/ITEMS/mcl_chests/init.lua | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/mods/ITEMS/mcl_chests/init.lua b/mods/ITEMS/mcl_chests/init.lua index 59ed2ba09..6f3272149 100644 --- a/mods/ITEMS/mcl_chests/init.lua +++ b/mods/ITEMS/mcl_chests/init.lua @@ -532,9 +532,12 @@ local function register_chest(basename, desc, longdesc, usagehelp, tt_help, tile _mcl_hardness = 2.5, on_rightclick = function(pos, node, clicker) - if minetest.registered_nodes[minetest.get_node({ x = pos.x, y = pos.y + 1, z = pos.z }).name].groups.opaque == 1 then - -- won't open if there is no space from the top - return false + local topnode = minetest.get_node({ x = pos.x, y = pos.y + 1, z = pos.z }) + if topnode and topnode.name and minetest.registered_nodes[topnode.name] then + if minetest.registered_nodes[topnode.name].groups.opaque == 1 then + -- won't open if there is no space from the top + return false + end end local name = minetest.get_meta(pos):get_string("name") if name == "" then