From 3f4dafc68fd3c4a79863c42c7eeb5a7226150401 Mon Sep 17 00:00:00 2001 From: kabou Date: Wed, 9 Mar 2022 14:14:45 +0100 Subject: [PATCH] Add check for unknown nodes. * Check if node has a definition table before attempting to evaluate its attributes. * Define local variable to cache multiple accesses to `registered_nodes[]` and improve readability. --- mods/ITEMS/mcl_core/functions.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mods/ITEMS/mcl_core/functions.lua b/mods/ITEMS/mcl_core/functions.lua index d2ff3690a..6cb727d51 100644 --- a/mods/ITEMS/mcl_core/functions.lua +++ b/mods/ITEMS/mcl_core/functions.lua @@ -210,7 +210,8 @@ minetest.register_abm({ end local posses = { { 1, 0 }, { -1, 0 }, { 0, 1 }, { 0, -1 } } for _, p in pairs(posses) do - if minetest.registered_nodes[minetest.get_node(vector.new(pos.x + p[1], pos.y, pos.z + p[2])).name].walkable then + local ndef = minetest.registered_nodes[minetest.get_node(vector.new(pos.x + p[1], pos.y, pos.z + p[2])).name] + if ndef and ndef.walkable then local posy = pos.y while minetest.get_node(vector.new(pos.x, posy, pos.z)).name == "mcl_core:cactus" do local pos = vector.new(pos.x, posy, pos.z) @@ -841,7 +842,7 @@ minetest.register_abm({ -- If this was mycelium, uproot plant above if n2.name == "mcl_core:mycelium" then local tad = minetest.registered_nodes[minetest.get_node(above).name] - if tad.groups and tad.groups.non_mycelium_plant then + if tad and tad.groups and tad.groups.non_mycelium_plant then minetest.dig_node(above) end end @@ -1333,7 +1334,7 @@ minetest.register_abm({ function mcl_core.supports_vines(nodename) local def = minetest.registered_nodes[nodename] -- Rules: 1) walkable 2) full cube - return def.walkable and + return def and def.walkable and (def.node_box == nil or def.node_box.type == "regular") and (def.collision_box == nil or def.collision_box.type == "regular") end