1
0
Fork 0

Fix crash when opening a chest with an unknown node on top

new_mapgen_api
Elias Fleckenstein 2021-11-17 18:25:12 +01:00
parent bd14918543
commit 30528b0a2c
No known key found for this signature in database
GPG Key ID: 06927A5199D6C9B2
1 changed files with 6 additions and 4 deletions

View File

@ -608,10 +608,12 @@ local function register_chest(basename, desc, longdesc, usagehelp, tt_help, tile
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
local above_def = minetest.registered_nodes[minetest.get_node({x = pos.x, y = pos.y + 1, z = pos.z}).name]
local above_def_other = minetest.registered_nodes[minetest.get_node({x = pos_other.x, y = pos_other.y + 1, z = pos_other.z}).name]
if not above_def or above_def.groups.opaque == 1 or not above_def_other or above_def_other.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")