Simplify debarking
This commit is contained in:
parent
49f6ccaa4a
commit
aa533edda2
|
@ -360,55 +360,39 @@ local make_stripped_trunk_add_wear = function(itemstack, placer)
|
|||
itemstack:add_wear(wear)
|
||||
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)
|
||||
if pointed_thing.type == "node" then
|
||||
local pos = minetest.get_pointed_thing_position(pointed_thing)
|
||||
local node = minetest.get_node(pos)
|
||||
local node_name = node.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
|
||||
return minetest.registered_nodes[node_name].on_rightclick(pointed_thing.under, node, placer, itemstack) or itemstack
|
||||
end
|
||||
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 node_name == "mcl_core:tree" then
|
||||
minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_oak", param2=node.param2})
|
||||
make_stripped_trunk_add_wear(itemstack, placer)
|
||||
elseif node_name == "mcl_core:darktree" then
|
||||
minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_dark_oak", param2=node.param2})
|
||||
make_stripped_trunk_add_wear(itemstack, placer)
|
||||
elseif node_name == "mcl_core:acaciatree" then
|
||||
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"})
|
||||
|
||||
for _, st in pairs(stripped_table) do
|
||||
if noddef.name == st[1] then
|
||||
minetest.swap_node(pointed_thing.under, {name=st[2], param2=node.param2})
|
||||
make_stripped_trunk_add_wear(itemstack, placer)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user