1
0
Fork 0

Set correct facedir of placed cocoas

This commit is contained in:
Wuzzy 2017-02-18 18:28:33 +01:00
parent a2e06543a1
commit 4f5c625072
1 changed files with 11 additions and 3 deletions

View File

@ -24,14 +24,22 @@ function mcl_cocoas.place_cocoa(itemstack, placer, pointed_thing, plantname)
return def.on_rightclick(pt.under, under, placer, itemstack) return def.on_rightclick(pt.under, under, placer, itemstack)
end end
-- check if pointing at jungletree -- Check if pointing at jungle tree
if under.name ~= "mcl_core:jungletree" if under.name ~= "mcl_core:jungletree"
or minetest.get_node(pt.above).name ~= "air" then or minetest.get_node(pt.above).name ~= "air" then
return return
end end
-- add the node and remove 1 item from the itemstack -- Determine cocoa direction
minetest.set_node(pt.above, {name = plantname}) 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}) minetest.sound_play("default_place_node", {pos = pt.above, gain = 1.0})