From fb8c5300cda575dae921a59d2be23fc4cd6cf50f Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Tue, 8 May 2018 00:02:07 +0200 Subject: [PATCH] Slow down arrows in liquids This is a rought first implementation, very basic. --- mods/ITEMS/mcl_bows/arrow.lua | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/mods/ITEMS/mcl_bows/arrow.lua b/mods/ITEMS/mcl_bows/arrow.lua index 8273fb721..0eda86895 100644 --- a/mods/ITEMS/mcl_bows/arrow.lua +++ b/mods/ITEMS/mcl_bows/arrow.lua @@ -135,6 +135,21 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime) minetest.add_item(self._lastpos, 'mcl_bows:arrow') end self.object:remove() + elseif (def and def.liquidtype ~= "none") then + -- Slow down arrow in liquids + local v = def.liquid_viscosity + if not v then + v = 0 + end + local vpenalty = math.max(0.1, 0.98 - 0.1 * v) + local vel = self.object:get_velocity() + if math.abs(vel.x) > 0.001 then + vel.x = vel.x * vpenalty + end + if math.abs(vel.z) > 0.001 then + vel.z = vel.z * vpenalty + end + self.object:set_velocity(vel) end end