diff --git a/mods/ITEMS/mcl_tnt/init.lua b/mods/ITEMS/mcl_tnt/init.lua index db32726ea..c9904f97e 100644 --- a/mods/ITEMS/mcl_tnt/init.lua +++ b/mods/ITEMS/mcl_tnt/init.lua @@ -1,14 +1,22 @@ local S = minetest.get_translator(minetest.get_current_modname()) local explosions_griefing = minetest.settings:get_bool("mcl_explosions_griefing", true) +local gamerule_tntExplodes = true +vl_tuning.setting("gamerule:tntExplodes", "bool", { + set = function(value) gamerule_tntExplodes = value end, + get = function() return gamerule_tntExplodes end, + default = true, + description = S("Whether TNT explodes after activation."), +}) + tnt = {} tnt.BOOMTIMER = 4 tnt.BLINKTIMER = 0.25 ----@param pos Vector +---@param pos vector.Vector ---@param entname string ----@return ObjectRef? +---@return core.ObjectRef? local function spawn_tnt(pos, entname) minetest.sound_play("tnt_ignite", { pos = pos, gain = 1.0, max_hear_distance = 15 }, true) local ent = minetest.add_entity(pos, entname) @@ -18,8 +26,8 @@ local function spawn_tnt(pos, entname) return ent end ----@param pos Vector ----@return ObjectRef? +---@param pos vector.Vector +---@return core.ObjectRef? function tnt.ignite(pos) minetest.remove_node(pos) local e = spawn_tnt(pos, "mcl_tnt:tnt") @@ -30,7 +38,7 @@ end ---Add smoke particle of entity at pos. --- ---Intended to be called every step. ----@param pos Vector +---@param pos vector.Vector function tnt.smoke_step(pos) minetest.add_particle({ pos = vector.offset(pos, 0, 0.5, 0), @@ -201,6 +209,8 @@ end end]] function TNT:on_step(dtime, _) + if self._removed then return end + local pos = self.object:get_pos() tnt.smoke_step(pos) self.timer = self.timer + dtime @@ -215,8 +225,10 @@ function TNT:on_step(dtime, _) self.blinkstatus = not self.blinkstatus end if self.timer > tnt.BOOMTIMER then - mcl_explosions.explode(self.object:get_pos(), 4, {}, self.object) - self.object:remove() + if gamerule_tntExplodes then + mcl_explosions.explode(self.object:get_pos(), 4, {}, self.object) + end + mcl_util.remove_entity(self) end end diff --git a/mods/ITEMS/mcl_tnt/locale/template.txt b/mods/ITEMS/mcl_tnt/locale/template.txt index 79f43d145..e9d9de572 100644 --- a/mods/ITEMS/mcl_tnt/locale/template.txt +++ b/mods/ITEMS/mcl_tnt/locale/template.txt @@ -1,4 +1,5 @@ # textdomain: mcl_tnt +Whether TNT explodes after activation.= An explosive device. When it explodes, it will hurt living beings and destroy blocks around it. TNT has an explosion radius of @1. With a small chance, blocks may drop as an item (as if being mined) rather than being destroyed. TNT can be ignited by tools, explosions, fire, lava and redstone signals.= An explosive device. When it explodes, it will hurt living beings. TNT has an explosion radius of @1. TNT can be ignited by tools, explosions, fire, lava and redstone signals.= TNT= diff --git a/mods/ITEMS/mcl_tnt/mod.conf b/mods/ITEMS/mcl_tnt/mod.conf index 2e90ddb80..91fc6af9c 100644 --- a/mods/ITEMS/mcl_tnt/mod.conf +++ b/mods/ITEMS/mcl_tnt/mod.conf @@ -1,3 +1,3 @@ name = mcl_tnt -depends = mcl_explosions, mcl_particles +depends = mcl_explosions, mcl_particles, vl_tuning optional_depends = mcl_sounds, mcl_mobitems, doc_identifier, mesecons