1
0
mirror of https://github.com/minetest/minetest_game.git synced 2025-01-21 04:50:17 +01:00

Fix TNT explosions not removing metadata (#3180)

Co-authored-by: sfan5 <sfan5@live.de>
This commit is contained in:
Lars Müller 2025-01-19 23:00:40 +01:00 committed by GitHub
parent 1f4291ff09
commit 672b63f9dc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -345,6 +345,13 @@ local function tnt_explode(pos, radius, ignore_protection, ignore_on_blast, owne
local on_construct_queue = {} local on_construct_queue = {}
basic_flame_on_construct = minetest.registered_nodes["fire:basic_flame"].on_construct 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 has_meta = {}
for _, p in ipairs(minetest.find_nodes_with_meta(p1, p2)) do
has_meta[a:indexp(p)] = true
end
local c_fire = minetest.get_content_id("fire:basic_flame") local c_fire = minetest.get_content_id("fire:basic_flame")
for z = -radius, radius do for z = -radius, radius do
for y = -radius, radius do for y = -radius, radius do
@ -355,9 +362,16 @@ local function tnt_explode(pos, radius, ignore_protection, ignore_on_blast, owne
local cid = data[vi] local cid = data[vi]
local p = {x = pos.x + x, y = pos.y + y, z = pos.z + z} local p = {x = pos.x + x, y = pos.y + y, z = pos.z + z}
if cid ~= c_air and cid ~= c_ignore then 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, on_blast_queue, on_construct_queue,
ignore_protection, ignore_on_blast, owner) 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
end end
vi = vi + 1 vi = vi + 1