From 5365dec19a8a088263916a3686f27859be51e870 Mon Sep 17 00:00:00 2001 From: jordan4ibanez Date: Sat, 17 Apr 2021 12:01:27 -0400 Subject: [PATCH] Adjust "flying" vector checks for mobs --- mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua | 9 ++------- mods/ENTITIES/mcl_mobs/api/mob_functions/movement.lua | 4 ++++ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua index 4a19d00670..fe091b5d2e 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua @@ -205,18 +205,13 @@ end --this is to swap the built in engine acceleration modifier local fly_physics_swapper = function(self,inside_fly_node) - --push non-existing physics switch to new mobs - self.fly_physics_switch = self.fly_physics_switch or not inside_fly_node - --should be flying, gravity is applied, switch to floating - if inside_fly_node and not self.fly_physics_switch then + if inside_fly_node and self.object:get_acceleration().y ~= 0 then self.object:set_acceleration(vector_new(0,0,0)) - self.fly_physics_switch = true --not be flying, gravity isn't applied, switch to falling - elseif not inside_fly_node and self.fly_physics_switch then + elseif not inside_fly_node and self.object:get_acceleration().y == 0 then self.pitch = 0 self.object:set_acceleration(vector_new(0,-self.gravity,0)) - self.fly_physics_switch = false end end diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/movement.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/movement.lua index 681d97a1e0..72f93ea242 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/movement.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/movement.lua @@ -111,6 +111,10 @@ mobs.set_fly_velocity = function(self, v) local yaw = (self.yaw or 0) local pitch = (self.pitch or 0) + if v == 0 then + pitch = 0 + end + local current_velocity = self.object:get_velocity() local goal_velocity = {