From 0ec411b8689641f4abeb35b66f666b0c2bdc07f4 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sat, 12 May 2018 15:10:34 +0200 Subject: [PATCH] Fix arrows getting stuck in impossible ways --- mods/ITEMS/mcl_bows/arrow.lua | 31 +++---------------------------- 1 file changed, 3 insertions(+), 28 deletions(-) diff --git a/mods/ITEMS/mcl_bows/arrow.lua b/mods/ITEMS/mcl_bows/arrow.lua index 1b4871fa9..a94233ecb 100644 --- a/mods/ITEMS/mcl_bows/arrow.lua +++ b/mods/ITEMS/mcl_bows/arrow.lua @@ -239,36 +239,11 @@ ARROW_ENTITY.on_step = function(self, dtime) self._stuckin = nil if self._deflection_cooloff <= 0 then -- Lose 1/3 of velocity on deflection - self.object:set_velocity(vector.multiply(vel, 0.6667)) + local newvel = vector.multiply(vel, 0.6667) - -- Just some dirty hack to make sure the arrow has a minimum direction to - -- avoid triggering the stuck detection again. - vel = self.object:get_velocity() - if math.abs(vel.x) < 0.0001 then - if pos.x < self._lastpos.x then - vel.x = 0.01 - else - vel.x = -0.01 - end - end - if math.abs(vel.z) < 0.0001 then - if pos.z < self._lastpos.z then - vel.z = 0.01 - else - vel.z = -0.01 - end - end - if math.abs(vel.y) < 0.00001 then - if pos.y < self._lastpos.y then - vel.y = 0.001 - else - vel.y = -0.001 - end - end - self.object:set_velocity(vel) - self.object:set_yaw(minetest.dir_to_yaw(vel)+YAW_OFFSET) + self.object:set_velocity(newvel) -- Reset deflection cooloff timer to prevent many deflections happening in quick succession - self._deflection_cooloff = 0.2 + self._deflection_cooloff = 1.0 end else