From 4f5c62507286bceffd4d4bcdf68f8cca3bbcfceb Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sat, 18 Feb 2017 18:28:33 +0100 Subject: [PATCH] Set correct facedir of placed cocoas --- mods/ITEMS/mcl_cocoas/init.lua | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/mods/ITEMS/mcl_cocoas/init.lua b/mods/ITEMS/mcl_cocoas/init.lua index be14c64e..166d21ce 100644 --- a/mods/ITEMS/mcl_cocoas/init.lua +++ b/mods/ITEMS/mcl_cocoas/init.lua @@ -24,14 +24,22 @@ function mcl_cocoas.place_cocoa(itemstack, placer, pointed_thing, plantname) return def.on_rightclick(pt.under, under, placer, itemstack) end - -- check if pointing at jungletree + -- Check if pointing at jungle tree if under.name ~= "mcl_core:jungletree" or minetest.get_node(pt.above).name ~= "air" then return end - -- add the node and remove 1 item from the itemstack - minetest.set_node(pt.above, {name = plantname}) + -- Determine cocoa direction + local clickdir = vector.subtract(pt.under, pt.above) + + -- Did user click on the SIDE of a jungle tree? + if clickdir.y ~= 0 then + return + end + + -- Add the node, set facedir and remove 1 item from the itemstack + minetest.set_node(pt.above, {name = plantname, param2 = minetest.dir_to_facedir(clickdir)}) minetest.sound_play("default_place_node", {pos = pt.above, gain = 1.0})