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" )
@@ -304,10 +299,6 @@ local function tnt_explode(pos, radius, ignore_protection, ignore_on_blast, owne
304299 else
305300 c_tnt = c_tnt_burning -- tnt is not registered if disabled
306301 end
307- -- make sure we still have explosion even when centre node isnt tnt related
308- if explode_center then
309- count = 1
310- end
311302
312303 for z = pos .z - 2 , pos .z + 2 do
313304 for y = pos .y - 2 , pos .y + 2 do
@@ -352,7 +343,7 @@ local function tnt_explode(pos, radius, ignore_protection, ignore_on_blast, owne
352343 if (radius * radius ) / (r * r ) >= (pr :next (80 , 125 ) / 100 ) then
353344 local cid = data [vi ]
354345 local p = {x = pos .x + x , y = pos .y + y , z = pos .z + z }
355- if cid ~= c_air and cid ~= c_ignore then
346+ if cid ~= c_air and cid ~= c_ignore and ( ignore_protection or not minetest . is_protected ( p , owner )) then
356347 data [vi ] = destroy (drops , p , cid , c_air , c_fire ,
357348 on_blast_queue , on_construct_queue ,
358349 ignore_protection , ignore_on_blast , owner )
@@ -409,14 +400,11 @@ function tnt.boom(pos, def)
409400 def .damage_radius = def .damage_radius or def .radius * 2
410401 local meta = minetest .get_meta (pos )
411402 local owner = meta :get_string (" owner" )
412- if not def .explode_center and def .ignore_protection ~= true then
413- minetest .set_node (pos , {name = " tnt:boom" })
414- end
415403 local sound = def .sound or " tnt_explode"
416404 minetest .sound_play (sound , {pos = pos , gain = 2.5 ,
417405 max_hear_distance = math.min (def .radius * 20 , 128 )}, true )
418406 local drops , radius = tnt_explode (pos , def .radius , def .ignore_protection ,
419- def .ignore_on_blast , owner , def . explode_center )
407+ def .ignore_on_blast , owner )
420408 -- append entity drops
421409 local damage_radius = (radius / math.max (1 , def .radius )) * def .damage_radius
422410 entity_physics (pos , damage_radius , drops )
0 commit comments