From 4a1b93bbfadb5b2b701d8510b2acd6840cffd352 Mon Sep 17 00:00:00 2001 From: kabou Date: Wed, 9 Mar 2022 02:05:38 +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/ENTITIES/mobs_mc/enderman.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mods/ENTITIES/mobs_mc/enderman.lua b/mods/ENTITIES/mobs_mc/enderman.lua index 7c55b34d65..6ab3763664 100644 --- a/mods/ENTITIES/mobs_mc/enderman.lua +++ b/mods/ENTITIES/mobs_mc/enderman.lua @@ -478,7 +478,8 @@ mobs:register_mob("mobs_mc:enderman", { -- Selected node needs to have 3 nodes of free space above for u=1, 3 do local node = minetest.get_node({x=nodepos.x, y=nodepos.y+u, z=nodepos.z}) - if minetest.registered_nodes[node.name].walkable then + local ndef = minetest.registered_nodes[node.name] + if ndef and ndef.walkable then node_ok = false break end @@ -512,7 +513,8 @@ mobs:register_mob("mobs_mc:enderman", { node_ok = true for u=1, 3 do local node = minetest.get_node({x=nodepos.x, y=nodepos.y+u, z=nodepos.z}) - if minetest.registered_nodes[node.name].walkable then + local ndef = minetest.registered_nodes[node.name] + if ndef and ndef.walkable then node_ok = false break end