Compare commits

...

1 Commits

Author SHA1 Message Date
teknomunk 844cc5cb72 Fix chest crashes when unknown nodes are above chests 2024-05-14 18:53:48 +00:00
1 changed files with 8 additions and 6 deletions

View File

@ -526,7 +526,8 @@ local function register_chest(basename, desc, longdesc, usagehelp, tt_help, tile
on_rightclick = function(pos, node, clicker) on_rightclick = function(pos, node, clicker)
local topnode = minetest.get_node({ x = pos.x, y = pos.y + 1, z = pos.z }) 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 topnode and topnode.name and minetest.registered_nodes[topnode.name] then
if minetest.registered_nodes[topnode.name].groups.opaque == 1 then local nodedef = minetest.registered_nodes[topnode.name]
if not nodedef or nodedef.groups.opaque == 1 then
-- won't open if there is no space from the top -- won't open if there is no space from the top
return false return false
end end
@ -882,10 +883,10 @@ local function register_chest(basename, desc, longdesc, usagehelp, tt_help, tile
on_rightclick = function(pos, node, clicker) on_rightclick = function(pos, node, clicker)
local pos_other = mcl_util.get_double_container_neighbor_pos(pos, node.param2, "right") local pos_other = mcl_util.get_double_container_neighbor_pos(pos, node.param2, "right")
if minetest.registered_nodes[minetest.get_node(vector.offset(pos, 0, 1, 0)).name].groups.opaque == 1 local nodedef_1 = minetest.registered_nodes[minetest.get_node(vector.offset(pos, 0, 1, 0)).name]
or local nodedef_2 = minetest.registered_nodes[minetest.get_node(vector.offset(pos_other, 0, 1, 0)).name]
minetest.registered_nodes[minetest.get_node(vector.offset(pos_other, 0, 1, 0)).name].groups.opaque
== 1 then if not node_def1 or not nodedef_2 or nodedef_1.groups.opaque == 1 or nodedef_2.groups.opaque == 1 then
-- won't open if there is no space from the top -- won't open if there is no space from the top
return false return false
end end
@ -1201,7 +1202,8 @@ minetest.register_node("mcl_chests:ender_chest_small", {
"mcl_chests_enderchest", "mcl_chests_chest", "chest") "mcl_chests_enderchest", "mcl_chests_chest", "chest")
end, end,
on_rightclick = function(pos, node, clicker) on_rightclick = function(pos, node, clicker)
if minetest.registered_nodes[minetest.get_node(vector.offset(pos, 0, 1, 0)).name].groups.opaque == 1 then local nodedef = minetest.registered_nodes[minetest.get_node(vector.offset(pos, 0, 1, 0)).name]
if not nodedef or nodedef.groups.opaque == 1 then
-- won't open if there is no space from the top -- won't open if there is no space from the top
return false return false
end end