diff --git a/mods/ENTITIES/mcl_mobs/api.lua b/mods/ENTITIES/mcl_mobs/api.lua index f02d5b4336..58fee205ff 100644 --- a/mods/ENTITIES/mcl_mobs/api.lua +++ b/mods/ENTITIES/mcl_mobs/api.lua @@ -228,6 +228,9 @@ end -- move mob in facing direction +--this has been modified to be internal +--internal = lua (self.yaw) +--engine = c++ (self.object:get_yaw()) local set_velocity = function(self, v) local yaw = (self.yaw or 0) @@ -271,37 +274,6 @@ local get_velocity = function(self) return 0 end - --- set and return valid yaw -local set_yaw = function(self, yaw, delay, dtime) - - if not yaw or yaw ~= yaw then - yaw = 0 - end - - delay = delay or 0 - - if delay == 0 then - if self.shaking and dtime then - yaw = yaw + (math_random() * 2 - 1) * 5 * dtime - end - self.yaw(yaw) - update_roll(self) - return yaw - end - - self.target_yaw = yaw - self.delay = delay - - return self.target_yaw -end - --- global function to set mob yaw -function mobs:yaw(self, yaw, delay, dtime) - set_yaw(self, yaw, delay, dtime) -end - - -- set defined animation local set_animation = function(self, anim, fixed_frame) if not self.animation or not anim then diff --git a/mods/ENTITIES/mcl_mobs/backup_code_api.lua b/mods/ENTITIES/mcl_mobs/backup_code_api.lua index 97036fab81..eb1389e371 100644 --- a/mods/ENTITIES/mcl_mobs/backup_code_api.lua +++ b/mods/ENTITIES/mcl_mobs/backup_code_api.lua @@ -3266,4 +3266,34 @@ local create_mob_on_rightclick = function(on_rightclick) on_rightclick(self, clicker) end end -end \ No newline at end of file +end + +-- set and return valid yaw +local set_yaw = function(self, yaw, delay, dtime) + + if not yaw or yaw ~= yaw then + yaw = 0 + end + + delay = delay or 0 + + if delay == 0 then + if self.shaking and dtime then + yaw = yaw + (math_random() * 2 - 1) * 5 * dtime + end + self.yaw(yaw) + update_roll(self) + return yaw + end + + self.target_yaw = yaw + self.delay = delay + + return self.target_yaw +end + + +-- global function to set mob yaw +function mobs:yaw(self, yaw, delay, dtime) + set_yaw(self, yaw, delay, dtime) +end