add nether vine placement checks for top and bottom of nodes (#4129)

This adds placement checks to weeping and twisting vines, weeping vines should only be placed on bottom of nodes and twisting vines should only be placed on top of nodes.

Most of the work for this was done by JoseDouglas26. This was made with their permission, I just had to tweak the code a bit to get twisting vines to place right. Thank you Jose!

Reviewed-on: MineClone2/MineClone2#4129
Reviewed-by: the-real-herowl <the-real-herowl@noreply.git.minetest.land>
Co-authored-by: SmokeyDope <smokey@tilde.team>
Co-committed-by: SmokeyDope <smokey@tilde.team>
This commit is contained in:
SmokeyDope 2024-01-21 06:28:41 +00:00 committed by the-real-herowl
parent 8e103cf615
commit 2d2b64006b
1 changed files with 32 additions and 1 deletions

View File

@ -148,6 +148,22 @@ minetest.register_node("mcl_crimson:twisting_vines", {
end
return itemstack
end,
on_place = function(itemstack, placer, pointed_thing)
local under = pointed_thing.under
local above = pointed_thing.above
local unode = minetest.get_node(under)
if under.y < above.y then
minetest.set_node(above, {name = "mcl_crimson:twisting_vines"})
if not minetest.is_creative_enabled(placer:get_player_name()) then
itemstack:take_item()
end
else
if unode.name == "mcl_crimson:twisting_vines" then
return minetest.registered_nodes[unode.name].on_rightclick(under, unode, placer, itemstack, pointed_thing)
end
end
return itemstack
end,
on_dig = function(pos, node, digger)
local above = vector.offset(pos,0,1,0)
local abovenode = minetest.get_node(above)
@ -223,7 +239,22 @@ minetest.register_node("mcl_crimson:weeping_vines", {
end
return itemstack
end,
on_place = function(itemstack, placer, pointed_thing)
local under = pointed_thing.under
local above = pointed_thing.above
local unode = minetest.get_node(under)
if under.y > above.y then
minetest.set_node(above, {name = "mcl_crimson:weeping_vines"})
if not minetest.is_creative_enabled(placer:get_player_name()) then
itemstack:take_item()
end
else
if unode.name == "mcl_crimson:weeping_vines" then
return minetest.registered_nodes[unode.name].on_rightclick(under, unode, placer, itemstack, pointed_thing)
end
end
return itemstack
end,
on_dig = function(pos, node, digger)
local below = vector.offset(pos,0,-1,0)
local belownode = minetest.get_node(below)