From e9c9f151de8d922f20c77e7fbfd2cc978c6f6512 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Sat, 14 Jan 2023 09:56:24 +0100 Subject: [PATCH] Let user dig light blocks when wielding a light block --- mods/ITEMS/mcl_core/nodes_misc.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/mods/ITEMS/mcl_core/nodes_misc.lua b/mods/ITEMS/mcl_core/nodes_misc.lua index bf5300510..679810a5e 100644 --- a/mods/ITEMS/mcl_core/nodes_misc.lua +++ b/mods/ITEMS/mcl_core/nodes_misc.lua @@ -252,6 +252,9 @@ minetest.register_node("mcl_core:realm_barrier", { --- Light blocks --- TODO: make node only pointable when wielding it +local light_block_pattern = "^mcl_core:light_(%d+)$" + + for i = 0, 14 do --minetest.LIGHT_MAX minetest.register_node("mcl_core:light_" .. i, { description = S("Light"), @@ -271,11 +274,15 @@ for i = 0, 14 do --minetest.LIGHT_MAX groups = {creative_breakable = 1, not_solid = 1, light_block = i + 1}, on_blast = function(pos, intensity) end, on_use = function(itemstack, user, pointed_thing) + if pointed_thing.type == "node" and string.match(minetest.get_node(pointed_thing.under).name, light_block_pattern) and not user:get_player_control().sneak then + minetest.dig_node(pointed_thing.under) + return + end itemstack:set_name("mcl_core:light_" .. ((i == 14) and 0 or i + 1)) return itemstack end, on_place = mcl_util.bypass_buildable_to(function(node_name) - return string.match(node_name, "^mcl_core:light_(%d+)$") + return string.match(node_name, light_block_pattern) end), after_place_node = function(pos, placer, itemstack, pointed_thing) if placer == nil then