From 2e01180fc87026b844418275dceb40751d35f71d Mon Sep 17 00:00:00 2001 From: cora Date: Sun, 16 Oct 2022 23:59:39 +0200 Subject: [PATCH] Fix "hibernating" mobs flying upwards --- mods/ENTITIES/mcl_mobs/api.lua | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/api.lua b/mods/ENTITIES/mcl_mobs/api.lua index c4ef046ea..23b3b4997 100644 --- a/mods/ENTITIES/mcl_mobs/api.lua +++ b/mods/ENTITIES/mcl_mobs/api.lua @@ -3865,18 +3865,25 @@ local mob_step = function(self, dtime) self.object:set_rotation(rot) end + if not player_in_active_range(self) then + set_animation(self, "stand", true) + local node_under = node_ok(vector.offset(pos,0,-1,0)).name + local acc = self.object:get_acceleration() + 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 + falling(self, pos) + end + return + end + if v then --diffuse object velocity self.object:set_velocity({x = v.x*d, y = v.y, z = v.z*d}) end - - if not player_in_active_range(self) then - set_animation(self, "stand", true) - self.object:set_velocity(vector.new(0,0,0)) - falling(self, pos) - return - end check_item_pickup(self) check_aggro(self,dtime) particlespawner_check(self,dtime)