From 2d2b64006bda25f187b793e5d10b02ecdeb59998 Mon Sep 17 00:00:00 2001 From: SmokeyDope Date: Sun, 21 Jan 2024 06:28:41 +0000 Subject: [PATCH] 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: https://git.minetest.land/MineClone2/MineClone2/pulls/4129 Reviewed-by: the-real-herowl Co-authored-by: SmokeyDope Co-committed-by: SmokeyDope --- mods/ITEMS/mcl_crimson/init.lua | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/mods/ITEMS/mcl_crimson/init.lua b/mods/ITEMS/mcl_crimson/init.lua index 87f1b63bf..b6e6b44e8 100644 --- a/mods/ITEMS/mcl_crimson/init.lua +++ b/mods/ITEMS/mcl_crimson/init.lua @@ -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)