From a3ff108cd4b71cd823518eae0186cbf1d819267e Mon Sep 17 00:00:00 2001 From: jordan4ibanez Date: Sun, 25 Apr 2021 04:03:06 -0400 Subject: [PATCH] Make mobs walk up stairs/slabs properly, yet not glitch out when jumping over solid nodes --- mods/ENTITIES/mcl_mobs/api/api.lua | 1 + .../mcl_mobs/api/mob_functions/ai.lua | 5 +++- .../mcl_mobs/api/mob_functions/head_logic.lua | 23 +++++++++++++++---- .../mcl_mobs/api/mob_functions/movement.lua | 12 ++++++++++ 4 files changed, 36 insertions(+), 5 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/api/api.lua b/mods/ENTITIES/mcl_mobs/api/api.lua index 3b34ec58ce..8850a238de 100644 --- a/mods/ENTITIES/mcl_mobs/api/api.lua +++ b/mods/ENTITIES/mcl_mobs/api/api.lua @@ -200,6 +200,7 @@ function mobs:register_mob(name, def) use_texture_alpha = def.use_texture_alpha, stepheight = def.stepheight or 0.6, + stepheight_backup = def.stepheight or 0.6, name = name, type = def.type, attack_type = def.attack_type, diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua index a1c5feb031..87a7a1ed0c 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua @@ -822,7 +822,7 @@ mobs.mob_step = function(self, dtime) --DEBUG TIME! - mobs.do_head_logic(self) + --mobs.do_head_logic(self,dtime) @@ -844,6 +844,9 @@ mobs.mob_step = function(self, dtime) end end + --make it so mobs do not glitch out when walking around/jumping + mobs.swap_auto_step_height_adjust(self) + --color modifier which coincides with the pause_timer if self.old_health and self.health < self.old_health then self.object:set_texture_mod("^[colorize:red:120") diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/head_logic.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/head_logic.lua index fe75a5b195..a294f5528c 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/head_logic.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/head_logic.lua @@ -1,8 +1,23 @@ -mobs.do_head_logic = function(self) - local yaw = self.object:get_yaw() +local vector_new = vector.new - +mobs.do_head_logic = function(self,dtime) + + --local yaw = self.object:get_yaw() - + + --local bone_pos = vector_new(0,5,0) + + --print(yaw) + + --local _, bone_rot = self.object:get_bone_position("head") + + --bone_rot.x = bone_rot.x + (dtime * 10) + --bone_rot.z = bone_rot.z + (dtime * 10) + + --self.object:set_bone_position("head", bone_pos, bone_rot) + + + + --set_bone_position([bone, position, rotation]) end \ No newline at end of file diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/movement.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/movement.lua index 81f78d161d..9a5fd9ea10 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/movement.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/movement.lua @@ -376,4 +376,16 @@ mobs.jump_move = function(self, velocity) if vector_length(new_velocity_addition) >= 0.0001 then self.object:add_velocity(new_velocity_addition) end +end + +--make it so mobs do not glitch out and freak out +--when moving around over nodes +mobs.swap_auto_step_height_adjust = function(self) + local y_vel = self.object:get_velocity().y + + if y_vel == 0 and self.stepheight ~= self.stepheight_backup then + self.stepheight = self.stepheight_backup + elseif y_vel ~= 0 and self.stepheight ~= 0 then + self.stepheight = 0 + end end \ No newline at end of file