Add griefing option to mcl_explosions.explode

When set to false explosions will only affect entities and not destroy
nodes.
This commit is contained in:
Elias Åström 2021-01-26 16:33:45 +01:00
parent e3d2284485
commit 34274486c7
1 changed files with 31 additions and 26 deletions

View File

@ -141,6 +141,7 @@ end
-- Values in info:
-- drop_chance - The chance that destroyed nodes will drop their items
-- fire - If true, 1/3 nodes become fire
-- griefing - If true, the explosion will destroy nodes (default: true)
--
-- Note that this function has been optimized, it contains code which has been
-- inlined to avoid function calls and unnecessary table creation. This was
@ -171,6 +172,7 @@ local function trace_explode(pos, strength, raydirs, radius, info, puncher)
local fire = info.fire
-- Trace rays for environment destruction
if info.griefing then
for i = 1, #raydirs do
local rpos_x = pos.x
local rpos_y = pos.y
@ -206,6 +208,7 @@ local function trace_explode(pos, strength, raydirs, radius, info, puncher)
end
end
end
end
-- Entities in radius of explosion
local punch_radius = 2 * strength
@ -399,6 +402,7 @@ end
-- sound - If true, the explosion will play a sound (default: true)
-- particles - If true, the explosion will create particles (default: true)
-- fire - If true, 1/3 nodes become fire (default: false)
-- griefing - If true, the explosion will destroy nodes (default: true)
function mcl_explosions.explode(pos, strength, info, puncher)
if info == nil then
info = {}
@ -417,6 +421,7 @@ function mcl_explosions.explode(pos, strength, info, puncher)
if info.particles == nil then info.particles = true end
if info.sound == nil then info.sound = true end
if info.fire == nil then info.fire = false end
if info.griefing == nil then info.griefing = true end
-- For backwards compatability
if info.no_particle then info.particles = false end