From 71c34823bc87b0892d4450b877fb1c78cd6ad416 Mon Sep 17 00:00:00 2001 From: jordan4ibanez Date: Wed, 21 Apr 2021 12:56:36 -0400 Subject: [PATCH] Make tilt flying/swimming dynamic --- mods/ENTITIES/mcl_mobs/api/api.lua | 2 ++ .../mcl_mobs/api/mob_functions/ai.lua | 25 ++++++++++++++----- .../attack_type_instructions.lua | 1 + mods/ENTITIES/mobs_mc/blaze.lua | 1 + 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/api/api.lua b/mods/ENTITIES/mcl_mobs/api/api.lua index d9e02f46d..c08b81186 100644 --- a/mods/ENTITIES/mcl_mobs/api/api.lua +++ b/mods/ENTITIES/mcl_mobs/api/api.lua @@ -349,6 +349,8 @@ function mobs:register_mob(name, def) eye_height = def.eye_height or 1.5, defuse_reach = def.defuse_reach or 4, hostile_cooldown = def.hostile_cooldown or 15, + tilt_fly = def.tilt_fly or true, + tilt_swim = def.tilt_swim or true, -- End of MCL2 extensions on_spawn = def.on_spawn, diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua index 347471be3..4c85d9b3a 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua @@ -271,7 +271,9 @@ local swim_state_execution = function(self,dtime) mobs.set_swim_velocity(self,0) - mobs.set_static_pitch(self) + if self.tilt_swim then + mobs.set_static_pitch(self) + end elseif self.state == "swim" then @@ -301,7 +303,10 @@ local swim_state_execution = function(self,dtime) mobs.set_swim_velocity(self,self.walk_velocity) - mobs.set_dynamic_pitch(self) + --only enable tilt swimming if enabled + if self.tilt_swim then + mobs.set_dynamic_pitch(self) + end end --flop around if not inside swim node else @@ -310,7 +315,9 @@ local swim_state_execution = function(self,dtime) mobs.flop(self) - mobs.set_static_pitch(self) + if self.tilt_swim then + mobs.set_static_pitch(self) + end end end @@ -398,7 +405,9 @@ local fly_state_execution = function(self,dtime) mobs.set_fly_velocity(self,0) - mobs.set_static_pitch(self) + if self.tilt_fly then + mobs.set_static_pitch(self) + end elseif self.state == "fly" then @@ -426,7 +435,9 @@ local fly_state_execution = function(self,dtime) quick_rotate(self,dtime) end - mobs.set_dynamic_pitch(self) + if self.tilt_fly then + mobs.set_dynamic_pitch(self) + end mobs.set_fly_velocity(self,self.walk_velocity) end @@ -437,7 +448,9 @@ local fly_state_execution = function(self,dtime) mobs.float(self) - mobs.set_static_pitch(self) + if self.tilt_fly then + mobs.set_static_pitch(self) + end end end end diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/attack_type_instructions.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/attack_type_instructions.lua index 452aa3ec2..13aeea087 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/attack_type_instructions.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/attack_type_instructions.lua @@ -195,6 +195,7 @@ mobs.projectile_attack_walk = function(self,dtime) self.projectile_timer = self.projectile_cooldown end + --run projectile timer if self.projectile_timer > 0 then self.projectile_timer = self.projectile_timer - dtime diff --git a/mods/ENTITIES/mobs_mc/blaze.lua b/mods/ENTITIES/mobs_mc/blaze.lua index d7e0a5c48..6bc67300f 100644 --- a/mods/ENTITIES/mobs_mc/blaze.lua +++ b/mods/ENTITIES/mobs_mc/blaze.lua @@ -17,6 +17,7 @@ mobs:register_mob("mobs_mc:blaze", { hp_max = 20, xp_min = 10, xp_max = 10, + tilt_fly = false, collisionbox = {-0.3, -0.01, -0.3, 0.3, 1.79, 0.3}, rotate = -180, visual = "mesh",