Add tnt_knockback flag for entities

When set to true, entities will be knocked back when affected by TNT
explosions.  Also ignore '__builtin:item' entities to reduce lag, and
replace tabs with spaces in 'mcl_explosions/init.lua'.
This commit is contained in:
Elias Åström 2020-04-18 14:16:32 +02:00
parent cdea2eeabf
commit b4ea2afe77
1 changed files with 92 additions and 89 deletions

View File

@ -253,16 +253,17 @@ local function trace_explode(pos, strength, raydirs, radius, drop_chance)
-- Trace rays for entity damage
for _, obj in pairs(objs) do
-- Object position and direction to explosion center
local opos = obj:get_pos()
local ent = obj:get_luaentity()
if obj:get_luaentity() ~= nil or obj:is_player() then
-- Ignore items to lower lag
if obj:is_player() or (ent and ent.name ~= '__builtin.item') then
local opos = obj:get_pos()
local collisionbox = nil
if obj:is_player() then
collisionbox = { -0.3, 0.0, -0.3, 0.3, 1.77, 0.3 }
elseif obj:get_luaentity().name then
local def = minetest.registered_entities[obj:get_luaentity().name]
elseif ent.name then
local def = minetest.registered_entities[ent.name]
collisionbox = def.collisionbox
end
@ -334,6 +335,8 @@ local function trace_explode(pos, strength, raydirs, radius, drop_chance)
if obj:is_player() then
obj:add_player_velocity(vector.multiply(punch_dir, impact * 20))
elseif ent.tnt_knockback then
obj:add_velocity(vector.multiply(punch_dir, impact * 20))
end
end
end