From 5e194b33bd612cc1cc088c0aa42e4366ee79ac31 Mon Sep 17 00:00:00 2001 From: SmokeyDope Date: Mon, 11 Sep 2023 18:04:07 +0000 Subject: [PATCH 1/4] Adjust make_grass_path function to let shovels turn grass paths back to dirt with shift+rightclick --- mods/ITEMS/mcl_tools/init.lua | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/mods/ITEMS/mcl_tools/init.lua b/mods/ITEMS/mcl_tools/init.lua index e60fd11b2..01040477b 100644 --- a/mods/ITEMS/mcl_tools/init.lua +++ b/mods/ITEMS/mcl_tools/init.lua @@ -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 From d2a4a6d042c1837b45bfc0bf91266a7a8b06e707 Mon Sep 17 00:00:00 2001 From: SmokeyDope Date: Mon, 11 Sep 2023 18:07:16 +0000 Subject: [PATCH 2/4] add group 'path_remove_possible' to grass paths --- mods/ITEMS/mcl_core/nodes_base.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ITEMS/mcl_core/nodes_base.lua b/mods/ITEMS/mcl_core/nodes_base.lua index 01de997d5..db2b78641 100644 --- a/mods/ITEMS/mcl_core/nodes_base.lua +++ b/mods/ITEMS/mcl_core/nodes_base.lua @@ -419,7 +419,7 @@ minetest.register_node("mcl_core:grass_path", { {-0.5, -0.5, -0.5, 0.5, 0.4375, 0.5}, } }, - groups = {handy=1,shovely=1, cultivatable=2, dirtifies_below_solid=1, dirtifier=1, deco_block=1 }, + groups = {handy=1,shovely=1, cultivatable=2, dirtifies_below_solid=1, dirtifier=1, deco_block=1, path_remove_possible=1 }, sounds = mcl_sounds.node_sound_dirt_defaults({ footstep = {name="default_grass_footstep", gain=0.1}, }), From fa1d8dfc4749e90a994b93cfadab400b3cc73d18 Mon Sep 17 00:00:00 2001 From: SmokeyDope Date: Mon, 11 Sep 2023 18:10:25 +0000 Subject: [PATCH 3/4] Adjust grass path long description to inform players of new way to turn paths back to dirt. --- mods/ITEMS/mcl_core/nodes_base.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ITEMS/mcl_core/nodes_base.lua b/mods/ITEMS/mcl_core/nodes_base.lua index db2b78641..f36d5cabd 100644 --- a/mods/ITEMS/mcl_core/nodes_base.lua +++ b/mods/ITEMS/mcl_core/nodes_base.lua @@ -406,7 +406,7 @@ mcl_core.register_snowed_node("mcl_core:dirt_with_grass_snow", "mcl_core:dirt_wi minetest.register_node("mcl_core:grass_path", { tiles = {"mcl_core_grass_path_top.png", "default_dirt.png", "mcl_core_grass_path_side.png"}, description = S("Grass Path"), - _doc_items_longdesc = S("Grass paths are a decorative variant of grass blocks. Their top has a different color and they are a bit lower than grass blocks, making them useful to build footpaths. Grass paths can be created with a shovel. A grass path turns into dirt when it is below a solid block."), + _doc_items_longdesc = S("Grass paths are a decorative variant of grass blocks. Their top has a different color and they are a bit lower than grass blocks, making them useful to build footpaths. Grass paths can be created by right clicking with a shovel. A grass path turns into dirt when it is below a solid block or when shift+right clicked with a shovel."), drop = "mcl_core:dirt", is_ground_content = true, use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "opaque" or false, From 5b1deedaf0c7e315096d5ee5fc407550f01f0c78 Mon Sep 17 00:00:00 2001 From: the-real-herowl Date: Thu, 2 Nov 2023 19:59:51 +0100 Subject: [PATCH 4/4] Disabled grass path making when sneaking --- mods/ITEMS/mcl_tools/init.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mods/ITEMS/mcl_tools/init.lua b/mods/ITEMS/mcl_tools/init.lua index 01040477b..6282da5c3 100644 --- a/mods/ITEMS/mcl_tools/init.lua +++ b/mods/ITEMS/mcl_tools/init.lua @@ -171,7 +171,7 @@ local make_grass_path = function(itemstack, placer, pointed_thing) end -- Remove grass paths - if (minetest.get_item_group(node.name, "path_remove_possible") == 1) and placer:get_player_control().sneak == true then + if (minetest.get_item_group(node.name, "path_remove_possible") == 1) and placer:get_player_control().sneak then local above = table.copy(pointed_thing.under) above.y = above.y + 1 if minetest.get_node(above).name == "air" then @@ -194,7 +194,7 @@ local make_grass_path = function(itemstack, placer, pointed_thing) end -- Make grass paths - if (minetest.get_item_group(node.name, "path_creation_possible") == 1) then + if (minetest.get_item_group(node.name, "path_creation_possible") == 1) and not placer:get_player_control().sneak then local above = table.copy(pointed_thing.under) above.y = above.y + 1 if minetest.get_node(above).name == "air" then