Fix problems with bed collision

This commit is contained in:
Wuzzy 2017-05-09 19:02:24 +02:00
parent 48af25ebed
commit e9c8d33c6f
2 changed files with 32 additions and 16 deletions

@ -36,6 +36,16 @@ else
end end
function mcl_beds.register_bed(name, def) function mcl_beds.register_bed(name, def)
local node_box_bottom, selection_box_bottom, collision_box_bottom
if def.nodebox and def.nodebox.bottom then
node_box_bottom = { type = "fixed", fixed = def.nodebox.bottom }
end
if def.selectionbox and def.selectionbox.bottom then
selection_box_bottom = { type = "fixed", fixed = def.selectionbox.bottom }
end
if def.collisionbox and def.collisionbox.bottom then
collision_box_bottom = { type = "fixed", fixed = def.collisionbox.bottom }
end
minetest.register_node(name .. "_bottom", { minetest.register_node(name .. "_bottom", {
description = def.description, description = def.description,
_doc_items_longdesc = def._doc_items_longdesc or beddesc, _doc_items_longdesc = def._doc_items_longdesc or beddesc,
@ -53,14 +63,9 @@ function mcl_beds.register_bed(name, def)
_mcl_hardness = 0.2, _mcl_hardness = 0.2,
_mcl_blast_resistance = 1, _mcl_blast_resistance = 1,
sounds = def.sounds or mcl_sounds.node_sound_wood_defaults(), sounds = def.sounds or mcl_sounds.node_sound_wood_defaults(),
node_box = { node_box = node_box_bottom,
type = "fixed", selection_box = selection_box_bottom,
fixed = def.nodebox.bottom, collision_box = collision_box_bottom,
},
selection_box = {
type = "fixed",
fixed = def.selectionbox.bottom,
},
on_place = function(itemstack, placer, pointed_thing) on_place = function(itemstack, placer, pointed_thing)
local under = pointed_thing.under local under = pointed_thing.under
@ -156,6 +161,17 @@ function mcl_beds.register_bed(name, def)
end, end,
}) })
local node_box_top, selection_box_top, collision_box_top
if def.nodebox and def.nodebox.top then
node_box_top = { type = "fixed", fixed = def.nodebox.top }
end
if def.selectionbox and def.selectionbox.top then
selection_box_top = { type = "fixed", fixed = def.selectionbox.top }
end
if def.collisionbox and def.collisionbox.top then
collision_box_top = { type = "fixed", fixed = def.collisionbox.top }
end
minetest.register_node(name .. "_top", { minetest.register_node(name .. "_top", {
drawtype = "nodebox", drawtype = "nodebox",
tiles = def.tiles.top, tiles = def.tiles.top,
@ -168,14 +184,9 @@ function mcl_beds.register_bed(name, def)
_mcl_blast_resistance = 1, _mcl_blast_resistance = 1,
sounds = def.sounds or mcl_sounds.node_sound_wood_defaults(), sounds = def.sounds or mcl_sounds.node_sound_wood_defaults(),
drop = name .. "_bottom", drop = name .. "_bottom",
node_box = { node_box = node_box_top,
type = "fixed", selection_box = selection_box_top,
fixed = def.nodebox.top, collision_box = collision_box_top,
},
selection_box = {
type = "fixed",
fixed = def.selectionbox.top,
},
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing) on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
mcl_beds.on_rightclick(pos, clicker) mcl_beds.on_rightclick(pos, clicker)
return itemstack return itemstack

@ -48,6 +48,11 @@ for c=1, #colors do
bottom = {-0.5, -0.5, -0.5, 0.5, 0.06, 0.5}, bottom = {-0.5, -0.5, -0.5, 0.5, 0.06, 0.5},
top = {-0.5, -0.5, -0.5, 0.5, 0.06, 0.5}, top = {-0.5, -0.5, -0.5, 0.5, 0.06, 0.5},
}, },
-- Simplified collision box because Minetest acts weird if we use the nodebox one
collisionbox = {
bottom = {-0.5, -0.5, -0.5, 0.5, 0.06, 0.5},
top = {-0.5, -0.5, -0.5, 0.5, 0.06, 0.5},
},
recipe = { recipe = {
{colors[c][3], colors[c][3], colors[c][3]}, {colors[c][3], colors[c][3], colors[c][3]},
{"group:wood", "group:wood", "group:wood"} {"group:wood", "group:wood", "group:wood"}