Add guard to prevent crash when converting old mobs and the minetest fails to create the new entity

This commit is contained in:
teknomunk 2024-06-09 08:38:47 -05:00 committed by the-real-herowl
parent 8aa65f85f2
commit bc343769ee
1 changed files with 4 additions and 2 deletions

View File

@ -346,8 +346,10 @@ function mcl_mobs.register_conversion(old_name, new_name)
minetest.register_entity(old_name, {
on_activate = function(self, staticdata, dtime)
local obj = minetest.add_entity(self.object:get_pos(), new_name, staticdata)
local hook = (obj:get_luaentity() or {})._on_after_convert
if hook then hook(obj) end
if obj then
local hook = (obj:get_luaentity() or {})._on_after_convert
if hook then hook(obj) end
end
self.object:remove()
end,
_convert_to = new_name,