From 4c0bc279af9372cc58966ff3ed3c41e46be35c25 Mon Sep 17 00:00:00 2001 From: teknomunk Date: Tue, 18 Jun 2024 19:35:03 -0500 Subject: [PATCH] Implement respawnBlocksExplode gamerule --- mods/CORE/vl_tuning/settings.lua | 6 ++++++ mods/ITEMS/mcl_beds/functions.lua | 4 +++- mods/ITEMS/mcl_beds/mod.conf | 2 +- mods/ITEMS/mcl_beds/respawn_anchor.lua | 3 ++- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/mods/CORE/vl_tuning/settings.lua b/mods/CORE/vl_tuning/settings.lua index 238c4faa4..1a6d15c61 100644 --- a/mods/CORE/vl_tuning/settings.lua +++ b/mods/CORE/vl_tuning/settings.lua @@ -1,6 +1,12 @@ +local modname = minetest.get_current_modname() +local S = minetest.get_translator(modname) local mod = vl_tuning mod.keep_inventory = vl_tuning.setting("gamerule:keepInventory", "bool", { default = minetest.settings:get_bool("mcl_keepInventory", false), }) +mod.respawn_blocks_explode = vl_tuning.setting("gamerule:respawnBlocksExplode", "bool", { + description = S("Prevents beds/respawn anchors from exploding in other dimensions."), + default = true, +}) diff --git a/mods/ITEMS/mcl_beds/functions.lua b/mods/ITEMS/mcl_beds/functions.lua index b1c3f0830..6b4724ed0 100644 --- a/mods/ITEMS/mcl_beds/functions.lua +++ b/mods/ITEMS/mcl_beds/functions.lua @@ -10,6 +10,8 @@ local explosions_mod = minetest.get_modpath("mcl_explosions") local spawn_mod = minetest.get_modpath("mcl_spawn") local pos_to_dim = minetest.get_modpath("mcl_worlds") and mcl_worlds.pos_to_dimension or function(pos) return "overworld" end +local gamerule_respawnBlocksExplode = vl_tuning.respawn_blocks_explode + local function mcl_log (message) mcl_util.mcl_log (message, "[Beds]") end @@ -384,7 +386,7 @@ function mcl_beds.on_rightclick(pos, player, is_top) minetest.remove_node(pos) minetest.remove_node(string.sub(node.name, -4) == "_top" and vector.subtract(pos, dir) or vector.add(pos, dir)) - if explosions_mod then + if explosions_mod and gamerule_respawnBlocksExplode[1] then mcl_explosions.explode(pos, 5, {drop_chance = 1.0, fire = true}) end return diff --git a/mods/ITEMS/mcl_beds/mod.conf b/mods/ITEMS/mcl_beds/mod.conf index fd54cd7e1..03683c38d 100644 --- a/mods/ITEMS/mcl_beds/mod.conf +++ b/mods/ITEMS/mcl_beds/mod.conf @@ -1,5 +1,5 @@ name = mcl_beds author = BlockMen description = -depends = playerphysics +depends = playerphysics, vl_tuning optional_depends = mcl_sounds, mcl_worlds, mcl_wool, mcl_dye, mcl_explosions, mcl_weather, mcl_spawn, doc, mesecons, mesecons_mvps diff --git a/mods/ITEMS/mcl_beds/respawn_anchor.lua b/mods/ITEMS/mcl_beds/respawn_anchor.lua index 781a82953..0ba408cda 100644 --- a/mods/ITEMS/mcl_beds/respawn_anchor.lua +++ b/mods/ITEMS/mcl_beds/respawn_anchor.lua @@ -4,6 +4,7 @@ --Nether roof at y -28933 local S = minetest.get_translator(minetest.get_current_modname()) --local mod_doc = minetest.get_modpath("doc") -> maybe add documentation ? +local gamerule_respawnBlocksExplode = vl_tuning.respawn_blocks_explode for i=0,4 do @@ -12,7 +13,7 @@ for i=0,4 do minetest.set_node(pos, {name="mcl_beds:respawn_anchor_charged_" .. i+1}) itemstack:take_item() elseif mcl_worlds.pos_to_dimension(pos) ~= "nether" then - if node.name ~= "mcl_beds:respawn_anchor" then --only charged respawn anchors are exploding in the overworld & end in minecraft + if gamerule_respawnBlocksExplode[1] and node.name ~= "mcl_beds:respawn_anchor" then --only charged respawn anchors are exploding in the overworld & end in minecraft mcl_explosions.explode(pos, 5, {drop_chance = 0, fire = true}) end elseif string.match(node.name, "mcl_beds:respawn_anchor_charged_") then