From 691a4eec13e358f00d34fb3b7f68f65ed0fcaea2 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Wed, 26 Jul 2017 19:07:57 +0200 Subject: [PATCH] Soften mcl_beds dependencies --- mods/ITEMS/mcl_beds/api.lua | 19 +++++++++++++------ mods/ITEMS/mcl_beds/beds.lua | 27 +++++++++++++++++---------- mods/ITEMS/mcl_beds/depends.txt | 7 +++---- 3 files changed, 33 insertions(+), 20 deletions(-) diff --git a/mods/ITEMS/mcl_beds/api.lua b/mods/ITEMS/mcl_beds/api.lua index 9e4c8e04a..944a259c0 100644 --- a/mods/ITEMS/mcl_beds/api.lua +++ b/mods/ITEMS/mcl_beds/api.lua @@ -35,6 +35,11 @@ else beddesc = beddesc .. "Going into bed seems to make time pass faster: The night will be skipped when you go sleep and you're alone in this world. If you're not alone, the night is skipped when all players in this world went to sleep." end +local default_sounds +if minetest.get_modpath("mcl_sounds") then + default_sounds = mcl_sounds.node_sound_wood_defaults() +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 @@ -62,7 +67,7 @@ function mcl_beds.register_bed(name, def) groups = {handy=1, flammable = 3, bed = 1, dig_by_piston=1, bouncy=66, fall_damage_add_percent=-50}, _mcl_hardness = 0.2, _mcl_blast_resistance = 1, - sounds = def.sounds or mcl_sounds.node_sound_wood_defaults(), + sounds = def.sounds or default_sounds, node_box = node_box_bottom, selection_box = selection_box_bottom, collision_box = collision_box_bottom, @@ -184,7 +189,7 @@ function mcl_beds.register_bed(name, def) groups = {handy = 1, flammable = 3, bed = 2, dig_by_piston=1, bouncy=33, fall_damage_add_percent=-50}, _mcl_hardness = 0.2, _mcl_blast_resistance = 1, - sounds = def.sounds or mcl_sounds.node_sound_wood_defaults(), + sounds = def.sounds or default_sounds, drop = name .. "_bottom", node_box = node_box_top, selection_box = selection_box_top, @@ -201,10 +206,12 @@ function mcl_beds.register_bed(name, def) minetest.register_alias(name, name .. "_bottom") - minetest.register_craft({ - output = name, - recipe = def.recipe - }) + if def.recipe then + minetest.register_craft({ + output = name, + recipe = def.recipe + }) + end doc.add_entry_alias("nodes", name.."_bottom", "nodes", name.."_top") end diff --git a/mods/ITEMS/mcl_beds/beds.lua b/mods/ITEMS/mcl_beds/beds.lua index 4720121e8..40deac70a 100644 --- a/mods/ITEMS/mcl_beds/beds.lua +++ b/mods/ITEMS/mcl_beds/beds.lua @@ -37,11 +37,22 @@ for c=1, #colors do local colorid = colors[c][1] -- Recoloring recipe for white bed - minetest.register_craft({ - type = "shapeless", - output = "mcl_beds:bed_"..colorid.."_bottom", - recipe = { "mcl_beds:bed_white_bottom", colors[c][4] }, - }) + if minetest.get_modpath("mcl_dye") then + minetest.register_craft({ + type = "shapeless", + output = "mcl_beds:bed_"..colorid.."_bottom", + recipe = { "mcl_beds:bed_white_bottom", colors[c][4] }, + }) + end + + -- Main bed recipe + local main_recipe + if minetest.get_modpath("mcl_wool") then + main_recipe = { + {colors[c][3], colors[c][3], colors[c][3]}, + {"group:wood", "group:wood", "group:wood"} + } + end -- Register bed mcl_beds.register_bed("mcl_beds:bed_"..colorid, { @@ -76,11 +87,7 @@ 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}, }, - -- Main bed recipe - recipe = { - {colors[c][3], colors[c][3], colors[c][3]}, - {"group:wood", "group:wood", "group:wood"} - }, + recipe = main_recipe, }) end diff --git a/mods/ITEMS/mcl_beds/depends.txt b/mods/ITEMS/mcl_beds/depends.txt index 5e96060cd..53f5b7c50 100644 --- a/mods/ITEMS/mcl_beds/depends.txt +++ b/mods/ITEMS/mcl_beds/depends.txt @@ -1,4 +1,3 @@ -mcl_core -mcl_sounds -mcl_wool -mcl_dye +mcl_sounds? +mcl_wool? +mcl_dye?