Fix crash for nil entity references

This commit is contained in:
stujones11 2019-03-23 22:09:17 +00:00
parent 0eb5049218
commit ae2bb7fd6b

View file

@ -207,13 +207,15 @@ end
shooter.punch_object = function(object, tool_caps, dir, on_blast) shooter.punch_object = function(object, tool_caps, dir, on_blast)
local do_damage = true local do_damage = true
if on_blast then if on_blast and not object:is_player() then
local ent = object:get_luaentity() local ent = object:get_luaentity()
local def = minetest.registered_entities[ent.name] if ent then
local def = minetest.registered_entities[ent.name] or {}
if def.on_blast then if def.on_blast then
do_damage = def.on_blast(ent, tool_caps.fleshy) do_damage = def.on_blast(ent, tool_caps.fleshy)
end end
end end
end
if do_damage then if do_damage then
object:punch(object, nil, tool_caps, dir) object:punch(object, nil, tool_caps, dir)
return true return true