How can I predict the block position without it gapping?

So I have a building system that is similar to Minecraft, and I’m wanting to predict place a block under you like in bedrock edition.

The issue is that it “gaps” or skips blocks due to it not snapping directly to the nearestBlockPosition

I’ve tried countless attempts/watched videos that tried to help me understand but nothing worked.