From 9bae39894672f08f6bfbfd35f1ff9a1f1ff751bd Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Tue, 15 Aug 2017 14:02:21 +0200 Subject: [PATCH] Update cart direction after punch --- mods/ENTITIES/mcl_minecarts/init.lua | 31 ++++++++++++++-------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/mods/ENTITIES/mcl_minecarts/init.lua b/mods/ENTITIES/mcl_minecarts/init.lua index f1e57a9cc0..6766e8436a 100644 --- a/mods/ENTITIES/mcl_minecarts/init.lua +++ b/mods/ENTITIES/mcl_minecarts/init.lua @@ -229,30 +229,31 @@ function mcl_minecarts.cart:on_step(dtime) end end - if self._punched then - self._punched = false - end - -- Give achievement when player reached a distance of 1000 nodes from the start position if self._driver and (vector.distance(self._start_pos, pos) >= 1000) then awards.unlock(self._driver, "mcl:onARail") end + + if update.pos or self._punched then + local yaw = 0 + if dir.x < 0 then + yaw = 0.5 + elseif dir.x > 0 then + yaw = 1.5 + elseif dir.z < 0 then + yaw = 1 + end + self.object:setyaw(yaw * math.pi) + end + + if self._punched then + self._punched = false + end if not (update.vel or update.pos) then return end - local yaw = 0 - if dir.x < 0 then - yaw = 0.5 - elseif dir.x > 0 then - yaw = 1.5 - elseif dir.z < 0 then - yaw = 1 - end - if update.pos then - self.object:setyaw(yaw * math.pi) - end local anim = {x=0, y=0} if dir.y == -1 then