From 95cfa43483021f480378abc19aeb9dc0dc903a08 Mon Sep 17 00:00:00 2001 From: kabou Date: Wed, 9 Mar 2022 02:15:33 +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/blaze.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mods/ENTITIES/mobs_mc/blaze.lua b/mods/ENTITIES/mobs_mc/blaze.lua index 79f0887cb..577ed7107 100644 --- a/mods/ENTITIES/mobs_mc/blaze.lua +++ b/mods/ENTITIES/mobs_mc/blaze.lua @@ -189,9 +189,10 @@ mobs:register_arrow("mobs_mc:blaze_fireball", { local v = vector.normalize(self.object:get_velocity()) local crashpos = vector.subtract(pos, v) local crashnode = minetest.get_node(crashpos) + local cndef = minetest.registered_nodes[crashnode.name] -- Set fire if node is air, or a replacable flammable node (e.g. a plant) if crashnode.name == "air" or - (minetest.registered_nodes[crashnode.name].buildable_to and minetest.get_item_group(crashnode.name, "flammable") >= 1) then + (cndef and cndef.buildable_to and minetest.get_item_group(crashnode.name, "flammable") >= 1) then minetest.set_node(crashpos, {name = mobs_mc.items.fire}) end end