Add on_blast support

This commit is contained in:
Wuzzy 2019-12-09 21:06:08 +01:00
parent b71cf5e9c2
commit a1ab325920

View File

@ -221,14 +221,21 @@ tnt.boom = function(pos, info)
-- TODO: Implement the real blast resistance algorithm -- 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 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) activate_if_tnt(n.name, np, pos, 3)
minetest.remove_node(np) -- Custom blast function defined by node.
core.check_for_falling(np) -- Node removal and drops must be handled manually.
if n.name ~= "mcl_tnt:tnt" and math.random() > 0.9 then if def.on_blast then
local drop = minetest.get_node_drops(n.name, "") def.on_blast(np, 1.0)
for _,item in ipairs(drop) do -- Default destruction handling: Remove nodes, drop items
if type(item) == "string" then else
if math.random(1,100) > 40 then minetest.remove_node(np)
local obj = minetest.add_item(np, item) 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 end
end end