Distance raycast innacurate

If I teleport myself exactly 3.29999 blocks away from another player, and I hit them while standing still, the raycast gives 3 blocks away, which is perfectly accurate (since a player's hitbox is .3 blocks wide). However, if I do this while in motion, e.g. moving right/left or a jump while hitting, it gives abnormal results like 3.7 (impossible since the player's entity interaction range attribute is 3.0). I used execute if entity @a[distance=3.1..] run say distance incorrect and it said. This is in a single player world using a mod that allows you to spawn fake players, so there are no other players in the world. The function is activated by an advancement. I'm assuming the bug is caused because the player moves 1 tick extra before the advancement triggers. Any ideas on how the bug is caused and how to fix it would be appreciated!
Continue to help post