diff --git a/init.lua b/init.lua index cd5381e..d2f7565 100644 --- a/init.lua +++ b/init.lua @@ -106,21 +106,26 @@ if lavastuff.enable_tool_fire == true and lavastuff.fire_node then function lavastuff.tool_fire_func(itemstack, user, pointed) local name = user:get_player_name() - if pointed.type == "node" then - local node = minetest.get_node(pointed.under) - local def = minetest.registered_nodes[node.name] + if pointed.type ~= "node" then + return + end - if def.on_rightclick then - return def.on_rightclick(pointed.under, node, user, itemstack, pointed) - end + local node = minetest.get_node(pointed.under) + local def = minetest.registered_nodes[node.name] + if not def then + return -- Unknown node + end - if minetest.is_protected(pointed.under, name) then return end + if def.on_rightclick then + return def.on_rightclick(pointed.under, node, user, itemstack, pointed) + end - -- Only allow fire every 1+ second(s) - if not COOLDOWN:get(user) then - activate_func(user, node.name, def, pointed) - COOLDOWN:set(user, 1) - end + if minetest.is_protected(pointed.under, name) then return end + + -- Only allow fire every 1+ second(s) + if not COOLDOWN:get(user) then + activate_func(user, node.name, def, pointed) + COOLDOWN:set(user, 1) end end end diff --git a/items/nodecore.lua b/items/nodecore.lua index b4900c4..69dbd14 100644 --- a/items/nodecore.lua +++ b/items/nodecore.lua @@ -74,6 +74,9 @@ minetest.override_item("lavastuff:shovel", { local node = minetest.get_node(pointed_thing.under) local def = minetest.registered_nodes[node.name] + if not def then + return -- Unknown node + end if not cooldown:get(user) and (def.groups.sand or (def.groups.silica_molten and def.liquidtype == "source")) then cooldown:set(user, 0)