Fix that an ax wears out if you right-click another block

This commit is contained in:
NO11 2021-04-17 11:55:50 +00:00 committed by kay27
parent 05ba837de4
commit 5fd5ebe4d4
1 changed files with 20 additions and 7 deletions

View File

@ -352,7 +352,14 @@ minetest.register_tool("mcl_tools:shovel_diamond", {
}) })
-- Axes -- Axes
local make_stripped_trunk_add_wear = function(itemstack, placer)
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
local make_stripped_trunk = function(itemstack, placer, pointed_thing) local make_stripped_trunk = function(itemstack, placer, pointed_thing)
if pointed_thing.type == "node" then if pointed_thing.type == "node" then
local pos = minetest.get_pointed_thing_position(pointed_thing) local pos = minetest.get_pointed_thing_position(pointed_thing)
@ -367,36 +374,42 @@ local make_stripped_trunk = function(itemstack, placer, pointed_thing)
minetest.record_protection_violation(pointed_thing.under, placer:get_player_name()) minetest.record_protection_violation(pointed_thing.under, placer:get_player_name())
return itemstack return itemstack
end end
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
if node_name == "mcl_core:tree" then if node_name == "mcl_core:tree" then
minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_oak"}) minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_oak"})
make_stripped_trunk_add_wear(itemstack, placer)
elseif node_name == "mcl_core:darktree" then elseif node_name == "mcl_core:darktree" then
minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_dark_oak"}) minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_dark_oak"})
make_stripped_trunk_add_wear(itemstack, placer)
elseif node_name == "mcl_core:acaciatree" then elseif node_name == "mcl_core:acaciatree" then
minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_acacia"}) minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_acacia"})
make_stripped_trunk_add_wear(itemstack, placer)
elseif node_name == "mcl_core:birchtree" then elseif node_name == "mcl_core:birchtree" then
minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_birch"}) minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_birch"})
make_stripped_trunk_add_wear(itemstack, placer)
elseif node_name == "mcl_core:sprucetree" then elseif node_name == "mcl_core:sprucetree" then
minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_spruce"}) minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_spruce"})
make_stripped_trunk_add_wear(itemstack, placer)
elseif node_name == "mcl_core:jungletree" then elseif node_name == "mcl_core:jungletree" then
minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_jungle"}) minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_jungle"})
make_stripped_trunk_add_wear(itemstack, placer)
elseif node_name == "mcl_core:tree_bark" then elseif node_name == "mcl_core:tree_bark" then
minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_oak_bark"}) minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_oak_bark"})
make_stripped_trunk_add_wear(itemstack, placer)
elseif node_name == "mcl_core:darktree_bark" then elseif node_name == "mcl_core:darktree_bark" then
minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_dark_oak_bark"}) minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_dark_oak_bark"})
make_stripped_trunk_add_wear(itemstack, placer)
elseif node_name == "mcl_core:acaciatree_bark" then elseif node_name == "mcl_core:acaciatree_bark" then
minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_acacia_bark"}) minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_acacia_bark"})
make_stripped_trunk_add_wear(itemstack, placer)
elseif node_name == "mcl_core:birchtree_bark" then elseif node_name == "mcl_core:birchtree_bark" then
minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_birch_bark"}) minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_birch_bark"})
make_stripped_trunk_add_wear(itemstack, placer)
elseif node_name == "mcl_core:sprucetree_bark" then elseif node_name == "mcl_core:sprucetree_bark" then
minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_spruce_bark"}) minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_spruce_bark"})
make_stripped_trunk_add_wear(itemstack, placer)
elseif node_name == "mcl_core:jungletree_bark" then elseif node_name == "mcl_core:jungletree_bark" then
minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_jungle_bark"}) minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_jungle_bark"})
make_stripped_trunk_add_wear(itemstack, placer)
end end
end end
return itemstack return itemstack