mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-22 18:41:09 +01:00
Merge pull request 'Add ability for shovels to turn grass paths into dirt on shift+right click' (#3932) from add-dirty-shovel-function into master
Reviewed-on: https://git.minetest.land/MineClone2/MineClone2/pulls/3932 Reviewed-by: the-real-herowl <the-real-herowl@noreply.git.minetest.land>
This commit is contained in:
commit
8789411ab7
2 changed files with 28 additions and 4 deletions
|
@ -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,
|
||||
|
@ -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},
|
||||
}),
|
||||
|
|
|
@ -165,12 +165,36 @@ 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
|
||||
|
||||
if (minetest.get_item_group(node.name, "path_creation_possible") == 1) then
|
||||
-- Remove grass paths
|
||||
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
|
||||
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) 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
|
||||
|
|
Loading…
Reference in a new issue