From ae2bb7fd6bed2ebb461b5ba1b892c721a5b9f817 Mon Sep 17 00:00:00 2001 From: stujones11 Date: Sat, 23 Mar 2019 22:09:17 +0000 Subject: [PATCH] Fix crash for nil entity references --- shooter/api.lua | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/shooter/api.lua b/shooter/api.lua index a20e45e..8ad7ce8 100644 --- a/shooter/api.lua +++ b/shooter/api.lua @@ -207,11 +207,13 @@ end shooter.punch_object = function(object, tool_caps, dir, on_blast) local do_damage = true - if on_blast then + if on_blast and not object:is_player() then local ent = object:get_luaentity() - local def = minetest.registered_entities[ent.name] - if def.on_blast then - do_damage = def.on_blast(ent, tool_caps.fleshy) + if ent then + local def = minetest.registered_entities[ent.name] or {} + if def.on_blast then + do_damage = def.on_blast(ent, tool_caps.fleshy) + end end end if do_damage then