From bed0849bb096cf1af4030148e132b441831fa2a2 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Wed, 5 Feb 2020 03:11:32 +0100 Subject: [PATCH] Add setting: mcl_tnt_griefing --- mods/ENTITIES/mcl_mobs/api.lua | 2 ++ mods/ITEMS/mcl_beds/functions.lua | 2 +- mods/ITEMS/mcl_tnt/init.lua | 18 ++++++++++++++++-- mods/ITEMS/mcl_tnt/locale/mcl_tnt.de.tr | 1 + mods/ITEMS/mcl_tnt/locale/template.txt | 3 ++- settingtypes.txt | 3 +++ 6 files changed, 25 insertions(+), 4 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/api.lua b/mods/ENTITIES/mcl_mobs/api.lua index b07dd00a2..153ac6ae7 100644 --- a/mods/ENTITIES/mcl_mobs/api.lua +++ b/mods/ENTITIES/mcl_mobs/api.lua @@ -2179,6 +2179,7 @@ local do_states = function(self, dtime) radius = node_break_radius, damage_radius = entity_damage_radius, sound = self.sounds.explode, + is_tnt = false, }) else @@ -3740,6 +3741,7 @@ function mobs:boom(self, pos, radius) damage_radius = radius, sound = self.sounds and self.sounds.explode, explode_center = true, + is_tnt = false, }) else mobs:safe_boom(self, pos, radius) diff --git a/mods/ITEMS/mcl_beds/functions.lua b/mods/ITEMS/mcl_beds/functions.lua index 30c4004a1..f62e68e64 100644 --- a/mods/ITEMS/mcl_beds/functions.lua +++ b/mods/ITEMS/mcl_beds/functions.lua @@ -308,7 +308,7 @@ function mcl_beds.on_rightclick(pos, player, is_top) -- Bed goes BOOM in the Nether or End. minetest.remove_node(pos) if minetest.get_modpath("mcl_tnt") then - tnt.boom(pos, {radius = 4, damage_radius = 4}) + tnt.boom(pos, {radius = 4, damage_radius = 4, is_tnt = false}) end return end diff --git a/mods/ITEMS/mcl_tnt/init.lua b/mods/ITEMS/mcl_tnt/init.lua index 62f3710ae..a2758d0a0 100644 --- a/mods/ITEMS/mcl_tnt/init.lua +++ b/mods/ITEMS/mcl_tnt/init.lua @@ -1,4 +1,5 @@ local S = minetest.get_translator("mcl_tnt") +local tnt_griefing = minetest.settings:get_bool("mcl_tnt_griefing", true) local mod_death_messages = minetest.get_modpath("mcl_death_messages") @@ -78,6 +79,14 @@ if minetest.get_modpath("mesecons") then rules = mesecon.rules.alldirs, }} end + +local longdesc +if tnt_griefing then + longdesc = S("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.", TNT_RANGE) +else + longdesc = S("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_RANGE) +end + minetest.register_node("mcl_tnt:tnt", { tiles = {"default_tnt_top.png", "default_tnt_bottom.png", "default_tnt_side.png", "default_tnt_side.png", @@ -87,7 +96,7 @@ minetest.register_node("mcl_tnt:tnt", { description = S("TNT"), paramtype = "light", sunlight_propagates = true, - _doc_items_longdesc = S("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.", TNT_RANGE), + _doc_items_longdesc = longdesc, _doc_items_usagehelp = S("Place the TNT and ignite it with one of the methods above. Quickly get in safe distance. The TNT will start to be affected by gravity and explodes in 4 seconds."), groups = { dig_immediate = 3, tnt = 1, enderman_takable=1 }, mesecons = tnt_mesecons, @@ -213,6 +222,9 @@ tnt.boom = function(pos, info) else sound = info.sound end + if info.is_tnt == nil then + info.is_tnt = true + end minetest.sound_play(sound, {pos = pos,gain = 1.0,max_hear_distance = 16,}) local node = minetest.get_node(pos) if minetest.get_item_group("water") == 1 or minetest.get_item_group("lava") == 1 then @@ -230,9 +242,11 @@ tnt.boom = function(pos, info) -- TODO: Implement the real blast resistance algorithm if def and n.name ~= "air" and n.name ~= "ignore" and (def._mcl_blast_resistance == nil or def._mcl_blast_resistance < 1000) then activate_if_tnt(n.name, np, pos, 3) + if (not tnt_griefing) and info.is_tnt ~= false then + -- No-op -- Custom blast function defined by node. -- Node removal and drops must be handled manually. - if def.on_blast then + elseif def.on_blast then def.on_blast(np, 1.0) -- Default destruction handling: Remove nodes, drop items else diff --git a/mods/ITEMS/mcl_tnt/locale/mcl_tnt.de.tr b/mods/ITEMS/mcl_tnt/locale/mcl_tnt.de.tr index d2378a8a9..6f85f4cfc 100644 --- a/mods/ITEMS/mcl_tnt/locale/mcl_tnt.de.tr +++ b/mods/ITEMS/mcl_tnt/locale/mcl_tnt.de.tr @@ -2,4 +2,5 @@ @1 was caught in an explosion.=@1 wurde Opfer einer Explosion. TNT=TNT 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.=Ein Sprengstoff. Wenn er explodiert, wird er Lebewesen verletzen und Blöcke in der Nähe zerstören. TNT hat einen Explosionsradius von @1. Mit einer geringen Wahrscheinlichkeit werden Blöcke als Gegenstand abfallen (als ob sie abgebaut worden wären), anstatt völlig zerstört zu werden. TNT kann mit Werkzeugen, Explosionen, Feuer, Lava und Redstone-Signalen angezündet werden. +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.=Ein Sprengstoff. Wenn er explodiert, wird er Lebewesen verletzen. TNT hat einen Explosionsradius von @1. TNT kann mit Werkzeugen, Explosionen, Feuer, Lava und Redstone-Signalen angezündet werden. Place the TNT and ignite it with one of the methods above. Quickly get in safe distance. The TNT will start to be affected by gravity and explodes in 4 seconds.=Platizeren sie das TNT und zünden Sie es mit einer der obigen Methoden an. Begeben Sie sich rasch in eine sichere Entfernung. Das TNT wird anfangen, von der Schwerkraft beeinflusst zu sein und explodiert in 4 Sekunden. diff --git a/mods/ITEMS/mcl_tnt/locale/template.txt b/mods/ITEMS/mcl_tnt/locale/template.txt index fc3ae612c..c2c3c47e4 100644 --- a/mods/ITEMS/mcl_tnt/locale/template.txt +++ b/mods/ITEMS/mcl_tnt/locale/template.txt @@ -1,5 +1,6 @@ # textdomain: mcl_tnt @1 was caught in an explosion.= TNT= -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 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.= Place the TNT and ignite it with one of the methods above. Quickly get in safe distance. The TNT will start to be affected by gravity and explodes in 4 seconds.= diff --git a/settingtypes.txt b/settingtypes.txt index a71c9a5c1..ba2714f90 100644 --- a/settingtypes.txt +++ b/settingtypes.txt @@ -24,6 +24,9 @@ mcl_doWeatherCycle (Change weather) bool true # Note that blocks never have drops when in Creative Mode. mcl_doTileDrops (Blocks have drops) bool true +# If enabled, TNT explosions destroy blocks. +mcl_tnt_griefing (TNT destroys blocks) bool true + [Players] # If enabled, players respawn at the bed they last lay on instead of normal # spawn.