Place doors correctly on buildable_to nodes

This commit is contained in:
Wuzzy 2017-03-30 04:14:36 +02:00
parent 3c22b582a0
commit 384462369e
1 changed files with 9 additions and 6 deletions

View File

@ -71,7 +71,7 @@ function mcl_doors:register_door(name, def)
stack_max = 64, stack_max = 64,
groups = { mesecon_conductor_craftable = 1 }, groups = { mesecon_conductor_craftable = 1 },
on_place = function(itemstack, placer, pointed_thing) on_place = function(itemstack, placer, pointed_thing)
if not pointed_thing.type == "node" then if not pointed_thing.type == "node" or not placer or not placer:is_player() then
return itemstack return itemstack
end end
local pn = placer:get_player_name() local pn = placer:get_player_name()
@ -84,14 +84,17 @@ function mcl_doors:register_door(name, def)
return minetest.registered_nodes[nu.name].on_rightclick(ptu, nu, placer, itemstack) return minetest.registered_nodes[nu.name].on_rightclick(ptu, nu, placer, itemstack)
end end
local pt = pointed_thing.above local pt
if minetest.registered_nodes[minetest.get_node(ptu).name].buildable_to then
pt = pointed_thing.under
else
pt = pointed_thing.above
end
local pt2 = {x=pt.x, y=pt.y, z=pt.z} local pt2 = {x=pt.x, y=pt.y, z=pt.z}
pt2.y = pt2.y+1 pt2.y = pt2.y+1
if if
not minetest.registered_nodes[minetest.get_node(pt).name].buildable_to or (not minetest.registered_nodes[minetest.get_node(pt).name].buildable_to) or
not minetest.registered_nodes[minetest.get_node(pt2).name].buildable_to or (not minetest.registered_nodes[minetest.get_node(pt2).name].buildable_to)
not placer or
not placer:is_player()
then then
return itemstack return itemstack
end end