Implement respawnBlocksExplode gamerule

This commit is contained in:
teknomunk 2024-06-18 19:35:03 -05:00
parent 2553f681a0
commit 4c0bc279af
4 changed files with 12 additions and 3 deletions

View file

@ -1,6 +1,12 @@
local modname = minetest.get_current_modname()
local S = minetest.get_translator(modname)
local mod = vl_tuning local mod = vl_tuning
mod.keep_inventory = vl_tuning.setting("gamerule:keepInventory", "bool", { mod.keep_inventory = vl_tuning.setting("gamerule:keepInventory", "bool", {
default = minetest.settings:get_bool("mcl_keepInventory", false), 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,
})

View file

@ -10,6 +10,8 @@ local explosions_mod = minetest.get_modpath("mcl_explosions")
local spawn_mod = minetest.get_modpath("mcl_spawn") 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 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) local function mcl_log (message)
mcl_util.mcl_log (message, "[Beds]") mcl_util.mcl_log (message, "[Beds]")
end end
@ -384,7 +386,7 @@ function mcl_beds.on_rightclick(pos, player, is_top)
minetest.remove_node(pos) minetest.remove_node(pos)
minetest.remove_node(string.sub(node.name, -4) == "_top" and vector.subtract(pos, dir) or vector.add(pos, dir)) 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}) mcl_explosions.explode(pos, 5, {drop_chance = 1.0, fire = true})
end end
return return

View file

@ -1,5 +1,5 @@
name = mcl_beds name = mcl_beds
author = BlockMen author = BlockMen
description = 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 optional_depends = mcl_sounds, mcl_worlds, mcl_wool, mcl_dye, mcl_explosions, mcl_weather, mcl_spawn, doc, mesecons, mesecons_mvps

View file

@ -4,6 +4,7 @@
--Nether roof at y -28933 --Nether roof at y -28933
local S = minetest.get_translator(minetest.get_current_modname()) local S = minetest.get_translator(minetest.get_current_modname())
--local mod_doc = minetest.get_modpath("doc") -> maybe add documentation ? --local mod_doc = minetest.get_modpath("doc") -> maybe add documentation ?
local gamerule_respawnBlocksExplode = vl_tuning.respawn_blocks_explode
for i=0,4 do 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}) minetest.set_node(pos, {name="mcl_beds:respawn_anchor_charged_" .. i+1})
itemstack:take_item() itemstack:take_item()
elseif mcl_worlds.pos_to_dimension(pos) ~= "nether" then 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}) mcl_explosions.explode(pos, 5, {drop_chance = 0, fire = true})
end end
elseif string.match(node.name, "mcl_beds:respawn_anchor_charged_") then elseif string.match(node.name, "mcl_beds:respawn_anchor_charged_") then