Beds: Check for buildable_to for bottom half

We properly checked top half already, just not the top half
target location.

Assure both checked positions are not unknown nodes.

Fixes #991
This commit is contained in:
Auke Kok 2016-03-31 07:21:40 -07:00 committed by paramat
parent 1977ae19ae
commit 874b1ae326
1 changed files with 7 additions and 1 deletions

View File

@ -59,6 +59,11 @@ function beds.register_bed(name, def)
return itemstack return itemstack
end end
local def = minetest.registered_nodes[minetest.get_node(pos).name]
if not def or not def.buildable_to then
return itemstack
end
local dir = minetest.dir_to_facedir(placer:get_look_dir()) local dir = minetest.dir_to_facedir(placer:get_look_dir())
local botpos = vector.add(pos, minetest.facedir_to_dir(dir)) local botpos = vector.add(pos, minetest.facedir_to_dir(dir))
@ -68,7 +73,8 @@ function beds.register_bed(name, def)
return itemstack return itemstack
end end
if not minetest.registered_nodes[minetest.get_node(botpos).name].buildable_to then local botdef = minetest.registered_nodes[minetest.get_node(botpos).name]
if not botdef or not botdef.buildable_to then
return itemstack return itemstack
end end