From 37b9b6fbfc18ffeb2c2b871aa610461aac8daa9b Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Wed, 6 Feb 2019 08:51:09 +0100 Subject: [PATCH] If mob jumped against wall 4 times, turn around --- mods/ENTITIES/mcl_mobs/api.lua | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/mods/ENTITIES/mcl_mobs/api.lua b/mods/ENTITIES/mcl_mobs/api.lua index b508b23a6d..3f1eeeb0bc 100644 --- a/mods/ENTITIES/mcl_mobs/api.lua +++ b/mods/ENTITIES/mcl_mobs/api.lua @@ -805,6 +805,22 @@ local do_jump = function(self) self.facing_fence = true end + -- if we jumped against a block/wall 4 times then turn + if self.object:get_velocity().x ~= 0 + and self.object:get_velocity().z ~= 0 then + + self.jump_count = (self.jump_count or 0) + 1 + + if self.jump_count == 4 then + + local yaw = self.object:get_yaw() or 0 + + yaw = set_yaw(self, yaw + 1.35, 8) + + self.jump_count = 0 + end + end + return true end