Simplify debarking

This commit is contained in:
NO11 2021-04-18 18:28:39 +00:00
parent 49f6ccaa4a
commit aa533edda2
1 changed files with 36 additions and 52 deletions

View File

@ -360,59 +360,43 @@ local make_stripped_trunk_add_wear = function(itemstack, placer)
itemstack:add_wear(wear) itemstack:add_wear(wear)
end end
end end
local stripped_table = {
{"mcl_core:tree", "mcl_core:stripped_oak"},
{"mcl_core:darktree", "mcl_core:stripped_dark_oak"},
{"mcl_core:acaciatree", "mcl_core:stripped_acacia"},
{"mcl_core:birchtree", "mcl_core:stripped_birch"},
{"mcl_core:sprucetree", "mcl_core:stripped_spruce"},
{"mcl_core:jungletree", "mcl_core:stripped_jungle"},
{"mcl_core:tree_bark", "mcl_core:stripped_oak_bark"},
{"mcl_core:darktree_bark", "mcl_core:stripped_dark_oak_bark"},
{"mcl_core:acaciatree_bark", "mcl_core:stripped_acacia_bark"},
{"mcl_core:birchtree_bark", "mcl_core:stripped_birch_bark"},
{"mcl_core:sprucetree_bark", "mcl_core:stripped_spruce_bark"},
{"mcl_core:jungletree_bark", "mcl_core:stripped_jungle_bark"},
}
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 return end
local pos = minetest.get_pointed_thing_position(pointed_thing)
local node = minetest.get_node(pos) local node = minetest.get_node(pointed_thing.under)
local node_name = node.name local noddef = minetest.registered_nodes[minetest.get_node(pointed_thing.under).name]
if placer and not placer:get_player_control().sneak then
if minetest.registered_nodes[node_name] and minetest.registered_nodes[node_name].on_rightclick then if not placer:get_player_control().sneak and noddef.on_rightclick then
return minetest.registered_nodes[node_name].on_rightclick(pointed_thing.under, node, placer, itemstack) or itemstack return minetest.item_place(itemstack, placer, pointed_thing)
end end
end if minetest.is_protected(pointed_thing.under, placer:get_player_name()) then
if minetest.is_protected(pointed_thing.under, placer:get_player_name()) then 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 node_name == "mcl_core:tree" then for _, st in pairs(stripped_table) do
minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_oak", param2=node.param2}) if noddef.name == st[1] then
make_stripped_trunk_add_wear(itemstack, placer) minetest.swap_node(pointed_thing.under, {name=st[2], param2=node.param2})
elseif node_name == "mcl_core:darktree" then make_stripped_trunk_add_wear(itemstack, placer)
minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_dark_oak", param2=node.param2}) end
make_stripped_trunk_add_wear(itemstack, placer) end
elseif node_name == "mcl_core:acaciatree" then return itemstack
minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_acacia", param2=node.param2})
make_stripped_trunk_add_wear(itemstack, placer)
elseif node_name == "mcl_core:birchtree" then
minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_birch", param2=node.param2})
make_stripped_trunk_add_wear(itemstack, placer)
elseif node_name == "mcl_core:sprucetree" then
minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_spruce", param2=node.param2})
make_stripped_trunk_add_wear(itemstack, placer)
elseif node_name == "mcl_core:jungletree" then
minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_jungle", param2=node.param2})
make_stripped_trunk_add_wear(itemstack, placer)
elseif node_name == "mcl_core:tree_bark" then
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
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
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
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
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
minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_jungle_bark"})
make_stripped_trunk_add_wear(itemstack, placer)
end
end
return itemstack
end end
minetest.register_tool("mcl_tools:axe_wood", { minetest.register_tool("mcl_tools:axe_wood", {