Merge pull request 'mcl_explosions fixes' (#2830) from mcl-explosions-fixes into master

Reviewed-on: https://git.minetest.land/MineClone2/MineClone2/pulls/2830
Reviewed-by: cora <cora@noreply.git.minetest.land>
This commit is contained in:
cora 2022-10-23 16:37:01 +00:00
commit bbe4224b79

View File

@ -130,10 +130,10 @@ local function add_particles(pos, radius)
time = 0.125, time = 0.125,
minpos = pos, minpos = pos,
maxpos = pos, maxpos = pos,
minvel = {x = -radius, y = -radius, z = -radius}, minvel = vector.new(-radius, -radius, -radius),
maxvel = {x = radius, y = radius, z = radius}, maxvel = vector.new(radius, radius, radius),
minacc = vector.new(), minacc = vector.zero(),
maxacc = vector.new(), maxacc = vector.zero(),
minexptime = 0.5, minexptime = 0.5,
maxexptime = 1.0, maxexptime = 1.0,
minsize = radius * 0.5, minsize = radius * 0.5,
@ -333,7 +333,8 @@ local function trace_explode(pos, strength, raydirs, radius, info, direct, sourc
end end
if sleep_formspec_doesnt_close_mt53 then if sleep_formspec_doesnt_close_mt53 then
minetest.after(0.3, function() -- 0.2 is minimum delay for closing old formspec and open died formspec -- TODO: REMOVE THIS IN THE FUTURE minetest.after(0.3,
function() -- 0.2 is minimum delay for closing old formspec and open died formspec -- TODO: REMOVE THIS IN THE FUTURE
if not obj:is_player() then if not obj:is_player() then
return return
end end
@ -396,15 +397,16 @@ local function trace_explode(pos, strength, raydirs, radius, info, direct, sourc
-- Update falling nodes -- Update falling nodes
for a = 1, #airs do for a = 1, #airs do
local p = airs[a] local p = airs[a]
check_for_falling({x=p.x, y=p.y+1, z=p.z}) check_for_falling(vector.offset(p, 0, 1, 0))
end end
for f = 1, #fires do for f = 1, #fires do
local p = fires[f] local p = fires[f]
check_for_falling({x=p.x, y=p.y+1, z=p.z}) check_for_falling(vector.offset(p, 0, 1, 0))
end end
-- Log explosion -- Log explosion
minetest.log("action", "Explosion at "..pos_to_string(pos).." with strength "..strength.." and radius "..radius) minetest.log("action", "Explosion at " .. pos_to_string(pos) .. " with strength " .. strength .. " and radius " ..
radius)
end end
-- Create an explosion with strength at pos. -- Create an explosion with strength at pos.
@ -428,6 +430,11 @@ end
-- griefing - If true, the explosion will destroy nodes (default: true) -- griefing - If true, the explosion will destroy nodes (default: true)
-- grief_protected - If true, the explosion will also destroy nodes which have -- grief_protected - If true, the explosion will also destroy nodes which have
-- been protected (default: false) -- been protected (default: false)
---@param pos Vector
---@param strength number
---@param info {drop_chance: number, max_blast_resistance: number, sound: boolean, particles: boolean, fire: boolean, griefing: boolean, grief_protected: boolean}
---@param direct? ObjectRef
---@param source? ObjectRef
function mcl_explosions.explode(pos, strength, info, direct, source) function mcl_explosions.explode(pos, strength, info, direct, source)
if info == nil then if info == nil then
info = {} info = {}