Fix making paths and stripping wood with emerald tools
big thanks to SmokeyDope!
This commit is contained in:
parent
54043a730b
commit
7897d90daf
71
tools.lua
71
tools.lua
|
@ -11,6 +11,76 @@ local shovel_use = S("To turn a grass block into a grass path, hold the shovel i
|
|||
|
||||
local wield_scale = mcl_vars.tool_wield_scale
|
||||
|
||||
-- SmokeyDope code BEGIN (thank you SmokeyDope)
|
||||
|
||||
-- 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
|
||||
|
||||
-- Shovel path making function
|
||||
local make_grass_path = function(itemstack, placer, pointed_thing)
|
||||
-- Use pointed node's on_rightclick function first, if present
|
||||
local node = minetest.get_node(pointed_thing.under)
|
||||
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
|
||||
end
|
||||
|
||||
-- Only make grass path if tool used on side or top of target node
|
||||
if pointed_thing.above.y < pointed_thing.under.y then
|
||||
return itemstack
|
||||
end
|
||||
|
||||
if (minetest.get_item_group(node.name, "path_creation_possible") == 1) then
|
||||
local above = table.copy(pointed_thing.under)
|
||||
above.y = above.y + 1
|
||||
if minetest.get_node(above).name == "air" then
|
||||
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 not minetest.is_creative_enabled(placer:get_player_name()) then
|
||||
-- Add wear (as if digging a shovely node)
|
||||
local toolname = itemstack:get_name()
|
||||
local wear = mcl_autogroup.get_wear(toolname, "shovely")
|
||||
itemstack:add_wear(wear)
|
||||
end
|
||||
minetest.sound_play({name="default_grass_footstep", gain=1}, {pos = above}, true)
|
||||
minetest.swap_node(pointed_thing.under, {name="mcl_core:grass_path"})
|
||||
end
|
||||
end
|
||||
return itemstack
|
||||
end
|
||||
|
||||
-- SmokeyDope code END
|
||||
|
||||
-- Registering tools
|
||||
minetest.register_tool("mcl_emerald_stuff:pick", {
|
||||
description = S("Emerald Pickaxe"),
|
||||
|
@ -149,3 +219,4 @@ minetest.register_craft({
|
|||
{"mcl_core:stick"},
|
||||
}
|
||||
})
|
||||
|
||||
|
|
Reference in New Issue