Best way to place a trail of blocks behind the player?

Hello! I'm currently trying to figure out a fix to something that's bugged me for a while. In my datapack, I have a feature that places blocks behind a player. To figure out where to place the block, I am just using North, South, East, and West directions: If facing North -> place the block ~ ~ ~0.5 If facing South -> place the block ~ ~ ~-0.5 If facing East -> place the block ~-0.5 ~ ~ If facing West -> place the block ~0.5 ~ ~ The reason I did it his way is because I've intentionally limited the movement of the player to only go in north, south, east, and west positions. What's happening here is functionally like snake, where there is a constant trail following the player. After some trial and error, I found 0.5 to be the best. If the number is too low, the blocks prevent the player from moving forward. If the number is too high, the problem gets worse. The error happens when 0.5 blocks behind them is a different block. Essentially it places an extra block, as shown in the first image. It should look like the second image. I'm not sure the best way to go about fixing my issue here. There are multiple solutions, but I'm searching for the best one. My current idea is to store the player's X and Z, then floor the numbers to get the exact block. When placing the blocks behind the player, I can possibly make some kind of value predicate that determines if it is acceptable to place the block. I'm sure there's a better solution, though. I appreciate any help 😄
Continue to help post