1
0
Fork 0

Adjust make_grass_path function to let shovels turn grass paths back to dirt with shift+rightclick

hollow_logs_ref_recovery
SmokeyDope 2023-09-11 18:04:07 +00:00 committed by the-real-herowl
parent 35bb569ee1
commit 5e194b33bd
1 changed files with 25 additions and 1 deletions

View File

@ -165,11 +165,35 @@ local make_grass_path = function(itemstack, placer, pointed_thing)
end
end
-- Only make grass path if tool used on side or top of target node
-- Only make or remove 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
-- Remove grass paths
if (minetest.get_item_group(node.name, "path_remove_possible") == 1) and placer:get_player_control().sneak == true 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")
if wear then
itemstack:add_wear(wear)
end
end
minetest.sound_play({name="default_grass_footstep", gain=1}, {pos = above, max_hear_distance = 16}, true)
minetest.swap_node(pointed_thing.under, {name="mcl_core:dirt"})
end
end
-- Make grass paths
if (minetest.get_item_group(node.name, "path_creation_possible") == 1) then
local above = table.copy(pointed_thing.under)
above.y = above.y + 1