From 6dc359c8809fa3c6dda8145bd455bac574e8fffe Mon Sep 17 00:00:00 2001 From: teknomunk Date: Sat, 31 Aug 2024 10:09:20 -0500 Subject: [PATCH] Give arrows a maximum lifetime to prevent them from getting stuck in mid-air forever --- mods/ITEMS/mcl_bows/arrow.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mods/ITEMS/mcl_bows/arrow.lua b/mods/ITEMS/mcl_bows/arrow.lua index ba2edf811..b16cc7b91 100644 --- a/mods/ITEMS/mcl_bows/arrow.lua +++ b/mods/ITEMS/mcl_bows/arrow.lua @@ -124,7 +124,7 @@ local arrow_entity = { _fire_damage_resistant = true, _save_fields = { - "last_pos", "startpos", "damage", "is_critical", "stuck", "stuckin", "stuckin_player", + "last_pos", "startpos", "damage", "is_critical", "stuck", "stuckin", "stuckin_player", "time_in_air", }, _startpos=nil, @@ -307,6 +307,12 @@ local arrow_entity = { self._time_in_air = self._time_in_air + dtime + -- Give the arrows a maximum flight time + if self._time_in_air > ARROW_TIMEOUT then + self._removed = true + self.object:remove() + end + local pos = self.object:get_pos() --local dpos = vector.round(vector.new(pos)) -- digital pos --local node = minetest.get_node(dpos)