9191
9292local basic_flame_on_construct -- cached value
9393local function destroy (drops , npos , cid , c_air , c_fire ,
94- on_blast_queue , on_construct_queue ,
95- ignore_protection , ignore_on_blast , owner )
96- if not ignore_protection and minetest .is_protected (npos , owner ) then
97- return cid
98- end
99-
94+ on_blast_queue , on_construct_queue , ignore_on_blast )
10095 local def = cid_data [cid ]
10196
10297 if not def then
@@ -284,7 +279,7 @@ function tnt.burn(pos, nodename)
284279 end
285280end
286281
287- local function tnt_explode (pos , radius , ignore_protection , ignore_on_blast , owner , explode_center )
282+ local function tnt_explode (pos , radius , ignore_protection , ignore_on_blast , owner )
288283 pos = vector .round (pos )
289284 -- scan for adjacent TNT nodes first, and enlarge the explosion
290285 local vm1 = VoxelManip ()
@@ -293,7 +288,7 @@ local function tnt_explode(pos, radius, ignore_protection, ignore_on_blast, owne
293288 local minp , maxp = vm1 :read_from_map (p1 , p2 )
294289 local a = VoxelArea :new ({MinEdge = minp , MaxEdge = maxp })
295290 local data = vm1 :get_data ()
296- local count = 0
291+ local count = 1
297292 local c_tnt
298293 local c_tnt_burning = minetest .get_content_id (" tnt:tnt_burning" )
299294 local c_tnt_boom = minetest .get_content_id (" tnt:boom" )
@@ -303,10 +298,6 @@ local function tnt_explode(pos, radius, ignore_protection, ignore_on_blast, owne
303298 else
304299 c_tnt = c_tnt_burning -- tnt is not registered if disabled
305300 end
306- -- make sure we still have explosion even when centre node isnt tnt related
307- if explode_center then
308- count = 1
309- end
310301
311302 for z = pos .z - 2 , pos .z + 2 do
312303 for y = pos .y - 2 , pos .y + 2 do
@@ -351,7 +342,7 @@ local function tnt_explode(pos, radius, ignore_protection, ignore_on_blast, owne
351342 if (radius * radius ) / (r * r ) >= (pr :next (80 , 125 ) / 100 ) then
352343 local cid = data [vi ]
353344 local p = {x = pos .x + x , y = pos .y + y , z = pos .z + z }
354- if cid ~= c_air then
345+ if cid ~= c_air and ( ignore_protection or not minetest . is_protected ( p , owner )) then
355346 data [vi ] = destroy (drops , p , cid , c_air , c_fire ,
356347 on_blast_queue , on_construct_queue ,
357348 ignore_protection , ignore_on_blast , owner )
@@ -408,14 +399,11 @@ function tnt.boom(pos, def)
408399 def .damage_radius = def .damage_radius or def .radius * 2
409400 local meta = minetest .get_meta (pos )
410401 local owner = meta :get_string (" owner" )
411- if not def .explode_center and def .ignore_protection ~= true then
412- minetest .set_node (pos , {name = " tnt:boom" })
413- end
414402 local sound = def .sound or " tnt_explode"
415403 minetest .sound_play (sound , {pos = pos , gain = 2.5 ,
416404 max_hear_distance = math.min (def .radius * 20 , 128 )}, true )
417405 local drops , radius = tnt_explode (pos , def .radius , def .ignore_protection ,
418- def .ignore_on_blast , owner , def . explode_center )
406+ def .ignore_on_blast , owner )
419407 -- append entity drops
420408 local damage_radius = (radius / math.max (1 , def .radius )) * def .damage_radius
421409 entity_physics (pos , damage_radius , drops )
0 commit comments