Implement respawnBlocksExplode gamerule

This commit is contained in:
teknomunk 2024-06-18 19:35:03 -05:00
parent 96eac616b0
commit ce3a7aa0da
4 changed files with 13 additions and 4 deletions

View File

@ -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,
})

View File

@ -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

View File

@ -1,5 +1,5 @@
name = mcl_beds
author = BlockMen
description =
depends = playerphysics
optional_depends = mcl_sounds, mcl_worlds, mcl_wool, mcl_dye, mcl_explosions, mcl_weather, mcl_spawn, doc, mesecons
depends = playerphysics, vl_tuning
optional_depends = mcl_sounds, mcl_worlds, mcl_wool, mcl_dye, mcl_explosions, mcl_weather, mcl_spawn, doc, mesecons

View File

@ -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