From 01c69855b0af700ad5ce1a6940b964654b490bed Mon Sep 17 00:00:00 2001 From: teknomunk Date: Sun, 1 Dec 2024 07:43:13 -0600 Subject: [PATCH] Fix bug in solid node collision code (not updating _last_velocity, making delta_v larger if length was small) --- mods/ITEMS/vl_projectile/init.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mods/ITEMS/vl_projectile/init.lua b/mods/ITEMS/vl_projectile/init.lua index 8d33b372a..6aa725091 100644 --- a/mods/ITEMS/vl_projectile/init.lua +++ b/mods/ITEMS/vl_projectile/init.lua @@ -359,11 +359,13 @@ function mod.collides_with_solids(self, dtime, entity_def, projectile_def) return end - local delta_v = (vel - self._last_velocity) / vector.length(vel) + local delta_v = (vel - self._last_velocity) + local vel_length = vector.length(vel) + if vel_length > 1 then delta_v = delta_v / vel_length end + self._last_velocity = vel if math.abs(delta_v.x) <= 0.1 and math.abs(delta_v.z) <= 0.1 and math.abs(delta_v.y) <= 0.2 then return end - self._last_velocity = vel else if node_def and not node_def.walkable and (not collides_with or not mcl_util.match_node_to_filter(node.name, collides_with)) then return