Fix saplings placement

This commit is contained in:
oilboi 2020-04-09 21:37:36 -04:00
parent 2708d9a70f
commit b636cfef52

View File

@ -16,16 +16,25 @@ minetest.register_node("main:sapling", {
type = "fixed",
fixed = {-4 / 16, -0.5, -4 / 16, 4 / 16, 7 / 16, 4 / 16}
},
on_place = function(itemstack, placer, pointed_thing)
on_place = on_rightclick or function(itemstack, placer, pointed_thing)
if not pointed_thing.type == "node" then
return
end
local buildable = minetest.registered_nodes[minetest.get_node(pointed_thing.under).name].buildable_to
--replace buildable
if buildable and minetest.get_node_group(minetest.get_node(vector.new(pointed_thing.under.x,pointed_thing.under.y-1,pointed_thing.under.z)).name, "soil") > 0 then
return(minetest.item_place(itemstack, placer, pointed_thing))
end
local buildable = minetest.registered_nodes[minetest.get_node(pointed_thing.above).name].buildable_to
if buildable and minetest.get_node_group(minetest.get_node(vector.new(pointed_thing.above.x,pointed_thing.above.y-1,pointed_thing.above.z)).name, "soil") > 0 then
return(minetest.item_place(itemstack, placer, pointed_thing))
end
--place sapling
local pos = pointed_thing.above
if minetest.get_node_group(minetest.get_node(vector.new(pos.x,pos.y-1,pos.z)).name, "soil") > 0 and minetest.get_node(pointed_thing.above).name == "air" then
minetest.set_node(pointed_thing.above, {name="main:sapling"})
minetest.sound_play("leaves",{pos=pointed_thing.above})
itemstack:take_item(1)
--print(minetest.get_node(pointed_thing.above).param1)
return(itemstack)
end
end,