From a1ab325920c818a083557a2ccc136438d89fb982 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Mon, 9 Dec 2019 21:06:08 +0100 Subject: [PATCH] Add on_blast support --- mods/ITEMS/mcl_tnt/init.lua | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/mods/ITEMS/mcl_tnt/init.lua b/mods/ITEMS/mcl_tnt/init.lua index 6fa0728f..342e0c58 100644 --- a/mods/ITEMS/mcl_tnt/init.lua +++ b/mods/ITEMS/mcl_tnt/init.lua @@ -221,14 +221,21 @@ 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) - minetest.remove_node(np) - core.check_for_falling(np) - if n.name ~= "mcl_tnt:tnt" and math.random() > 0.9 then - local drop = minetest.get_node_drops(n.name, "") - for _,item in ipairs(drop) do - if type(item) == "string" then - if math.random(1,100) > 40 then - local obj = minetest.add_item(np, item) + -- Custom blast function defined by node. + -- Node removal and drops must be handled manually. + if def.on_blast then + def.on_blast(np, 1.0) + -- Default destruction handling: Remove nodes, drop items + else + minetest.remove_node(np) + core.check_for_falling(np) + if n.name ~= "mcl_tnt:tnt" and math.random() > 0.9 then + local drop = minetest.get_node_drops(n.name, "") + for _,item in ipairs(drop) do + if type(item) == "string" then + if math.random(1,100) > 40 then + local obj = minetest.add_item(np, item) + end end end end