Add wood stripping function to axe

This commit is contained in:
SmokeyDope 2023-02-08 20:04:20 +00:00
parent f68b5e1095
commit 6d1ac3281e
1 changed files with 30 additions and 0 deletions

View File

@ -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"),