Skip to content

Commit 40ea705

Browse files
committed
fix explosion flash (tnt:boom node)
1 parent 0b9b43b commit 40ea705

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

mods/tnt/init.lua

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -300,10 +300,10 @@ local function tnt_explode(pos, radius, ignore_protection, ignore_on_blast, owne
300300
end
301301

302302
-- don't double-count tnt @ the center
303-
local v = a:index(pos.x, pos.y, pos.z)
304-
local c = data[v]
305-
if (c == c_tnt or c == c_tnt_boom or c == c_tnt_burning) then
306-
data[v] = c_air
303+
local vc = a:index(pos.x, pos.y, pos.z)
304+
local ccid = data[vc]
305+
if (ccid == c_tnt or ccid == c_tnt_boom or ccid == c_tnt_burning) then
306+
data[vc] = c_air
307307
end
308308

309309
for z = pos.z - 2, pos.z + 2 do
@@ -360,11 +360,23 @@ local function tnt_explode(pos, radius, ignore_protection, ignore_on_blast, owne
360360
end
361361
end
362362

363+
-- make the center of the explosion flash, if it's safe
364+
ccid = data[vc]
365+
if ccid == c_air then
366+
data[vc] = c_tnt_boom
367+
end
368+
363369
vm:set_data(data)
364370
vm:write_to_map()
365371
vm:update_map()
366372
vm:update_liquids()
367373

374+
-- make the center of the explosion flash, if it's safe
375+
-- have to set the timer *after* data is written to the map
376+
if ccid == c_air then
377+
minetest.get_node_timer(pos):start(0)
378+
end
379+
368380
-- call check_single_for_falling for everything within 1.5x blast radius
369381
for y = -radius * 1.5, radius * 1.5 do
370382
for z = -radius * 1.5, radius * 1.5 do
@@ -432,6 +444,13 @@ minetest.register_node("tnt:boom", {
432444
groups = {dig_immediate = 3, not_in_creative_inventory = 1},
433445
-- unaffected by explosions
434446
on_blast = function() end,
447+
on_timer = function(pos, elapsed)
448+
if elapsed > 0 then
449+
minetest.remove_node(pos)
450+
else
451+
return true
452+
end
453+
end,
435454
})
436455

437456
minetest.register_node("tnt:gunpowder", {

0 commit comments

Comments
 (0)