Fix crash when skeleton tries to jock when there is no pos, maybe because pos is unloaded.

This commit is contained in:
ancientmarinerdev 2023-03-24 23:05:16 +00:00 committed by Gitea
parent 924d999ec2
commit 049406162e
2 changed files with 5 additions and 2 deletions

View file

@ -62,8 +62,11 @@ function mob_class:update_tag() --update nametag and/or the debug box
end end
function mob_class:jock_to(mob, reletive_pos, rot) function mob_class:jock_to(mob, reletive_pos, rot)
local pos = self.object:get_pos()
if not pos then return end
self.jockey = mob self.jockey = mob
local jock = minetest.add_entity(self.object:get_pos(), mob) local jock = minetest.add_entity(pos, mob)
if not jock then return end if not jock then return end
jock:get_luaentity().docile_by_day = false jock:get_luaentity().docile_by_day = false
jock:get_luaentity().riden_by_jock = true jock:get_luaentity().riden_by_jock = true

View file

@ -91,7 +91,7 @@ local skeleton = {
}, },
on_spawn = function(self) on_spawn = function(self)
if math.random(100) == 1 then if math.random(100) == 1 then
self:jock_to("mobs_mc:spider", vector.new(0,0,0), vector.new(0,0,0)) self:jock_to("mobs_mc:spider", vector.zero(), vector.zero())
end end
return true return true
end, end,