diff --git a/mcl_copper_stuff/tools.lua b/mcl_copper_stuff/tools.lua index bead307..ede702d 100644 --- a/mcl_copper_stuff/tools.lua +++ b/mcl_copper_stuff/tools.lua @@ -33,6 +33,36 @@ minetest.register_tool("mcl_copper_stuff:pick", { pickaxey = { speed = 5, level = 3, uses = 192 } }, }) + +-- Axe stripping wood logic +local function make_stripped_trunk(itemstack, placer, pointed_thing) + if pointed_thing.type ~= "node" then return end + + local node = minetest.get_node(pointed_thing.under) + local noddef = minetest.registered_nodes[minetest.get_node(pointed_thing.under).name] + + if not placer:get_player_control().sneak and noddef.on_rightclick then + return minetest.item_place(itemstack, placer, pointed_thing) + end + if minetest.is_protected(pointed_thing.under, placer:get_player_name()) then + minetest.record_protection_violation(pointed_thing.under, placer:get_player_name()) + return itemstack + end + + if noddef._mcl_stripped_variant == nil then + return itemstack + else + minetest.swap_node(pointed_thing.under, {name=noddef._mcl_stripped_variant, param2=node.param2}) + if not minetest.is_creative_enabled(placer:get_player_name()) then + -- Add wear (as if digging a axey node) + local toolname = itemstack:get_name() + local wear = mcl_autogroup.get_wear(toolname, "axey") + itemstack:add_wear(wear) + end + end + return itemstack +end + -- Copper Axe minetest.register_tool("mcl_copper_stuff:axe", { description = S("Copper Axe"),