From e4f26a4688e8182013d90ddfd5ad48db64ec1b52 Mon Sep 17 00:00:00 2001 From: ancientmarinerdev Date: Mon, 23 Jan 2023 01:44:52 +0000 Subject: [PATCH] Fix self object checks for check suspend --- mods/ENTITIES/mcl_mobs/physics.lua | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/physics.lua b/mods/ENTITIES/mcl_mobs/physics.lua index e5364c88a..c7ea98c57 100644 --- a/mods/ENTITIES/mcl_mobs/physics.lua +++ b/mods/ENTITIES/mcl_mobs/physics.lua @@ -987,17 +987,22 @@ function mob_class:check_dying() end function mob_class:check_suspend() - if not self:player_in_active_range() then - local pos = self.object:get_pos() + local pos = self.object:get_pos() + + if pos and not self:player_in_active_range() then local node_under = node_ok(vector.offset(pos,0,-1,0)).name - local acc = self.object:get_acceleration() + self:set_animation( "stand", true) - if acc.y > 0 or node_under ~= "air" then - self.object:set_acceleration(vector.new(0,0,0)) - self.object:set_velocity(vector.new(0,0,0)) - end - if acc.y == 0 and node_under == "air" then - self:falling(pos) + + local acc = self.object:get_acceleration() + if acc then + if acc.y > 0 or node_under ~= "air" then + self.object:set_acceleration(vector.new(0,0,0)) + self.object:set_velocity(vector.new(0,0,0)) + end + if acc.y == 0 and node_under == "air" then + self:falling(pos) + end end return true end