Skip to content

Commit

Permalink
Fix TNT explosions not removing metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
appgurueu committed Jan 18, 2025
1 parent 9bcf2d4 commit 5af19f7
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion mods/tnt/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,14 @@ local function tnt_explode(pos, radius, ignore_protection, ignore_on_blast, owne
local on_construct_queue = {}
basic_flame_on_construct = minetest.registered_nodes["fire:basic_flame"].on_construct

-- Used to efficiently remove metadata of nodes that were destroyed.
-- Metadata is probably sparse, so this may save us some work.
local poses_with_meta = minetest.find_nodes_with_meta(p1, p2)
local has_meta = {}
for _, p in ipairs(poses_with_meta) do
has_meta[a:indexp(p)] = true
end

local c_fire = minetest.get_content_id("fire:basic_flame")
for z = -radius, radius do
for y = -radius, radius do
Expand All @@ -355,9 +363,16 @@ local function tnt_explode(pos, radius, ignore_protection, ignore_on_blast, owne
local cid = data[vi]
local p = {x = pos.x + x, y = pos.y + y, z = pos.z + z}
if cid ~= c_air and cid ~= c_ignore then
data[vi] = destroy(drops, p, cid, c_air, c_fire,
local new_cid = destroy(drops, p, cid, c_air, c_fire,
on_blast_queue, on_construct_queue,
ignore_protection, ignore_on_blast, owner)

if new_cid ~= data[vi] then
data[vi] = new_cid
if has_meta[vi] then
minetest.get_meta(p):from_table(nil)
end
end
end
end
vi = vi + 1
Expand Down

0 comments on commit 5af19f7

Please sign in to comment.