From e9c8d33c6ff41a7c1e8a06a291efbcdf7b97b08f Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Tue, 9 May 2017 19:02:24 +0200 Subject: [PATCH] Fix problems with bed collision --- mods/ITEMS/mcl_beds/api.lua | 43 ++++++++++++++++++++++-------------- mods/ITEMS/mcl_beds/beds.lua | 5 +++++ 2 files changed, 32 insertions(+), 16 deletions(-) diff --git a/mods/ITEMS/mcl_beds/api.lua b/mods/ITEMS/mcl_beds/api.lua index d4c61bf4d0..7eb36c7775 100644 --- a/mods/ITEMS/mcl_beds/api.lua +++ b/mods/ITEMS/mcl_beds/api.lua @@ -36,6 +36,16 @@ else end 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", { description = def.description, _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_blast_resistance = 1, sounds = def.sounds or mcl_sounds.node_sound_wood_defaults(), - node_box = { - type = "fixed", - fixed = def.nodebox.bottom, - }, - selection_box = { - type = "fixed", - fixed = def.selectionbox.bottom, - }, + node_box = node_box_bottom, + selection_box = selection_box_bottom, + collision_box = collision_box_bottom, on_place = function(itemstack, placer, pointed_thing) local under = pointed_thing.under @@ -156,6 +161,17 @@ function mcl_beds.register_bed(name, def) 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", { drawtype = "nodebox", tiles = def.tiles.top, @@ -168,14 +184,9 @@ function mcl_beds.register_bed(name, def) _mcl_blast_resistance = 1, sounds = def.sounds or mcl_sounds.node_sound_wood_defaults(), drop = name .. "_bottom", - node_box = { - type = "fixed", - fixed = def.nodebox.top, - }, - selection_box = { - type = "fixed", - fixed = def.selectionbox.top, - }, + node_box = node_box_top, + selection_box = selection_box_top, + collision_box = collision_box_top, on_rightclick = function(pos, node, clicker, itemstack, pointed_thing) mcl_beds.on_rightclick(pos, clicker) return itemstack diff --git a/mods/ITEMS/mcl_beds/beds.lua b/mods/ITEMS/mcl_beds/beds.lua index 15fbfc9f90..a58ca5fd8a 100644 --- a/mods/ITEMS/mcl_beds/beds.lua +++ b/mods/ITEMS/mcl_beds/beds.lua @@ -48,6 +48,11 @@ for c=1, #colors do 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}, }, + -- 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 = { {colors[c][3], colors[c][3], colors[c][3]}, {"group:wood", "group:wood", "group:wood"}