I think I know what your looking for
To find the grid square closest to the player, let’s first take set the position to that of the player’s
this.x=player.x
this.y=player.y
Next step is to divide the value by the size of the grid squares (in this case, it’s 48 I’m guessing)
Then, if the X and Y values are a multiple of 48, you should get a whole number, otherwise, your gonna get a decimal value, so make sure to round the results.
this.x=Math.round(player.x/48)
this.y=Math.round(player.y/48)
Lastly, the values should be easily multiplied again by 48 to get an X and Y value that is a multiple of 48… in other words, an accepted X and Y on the grid
this.x=Math.round(player.x/48)*48;
this.y=Math.round(player.y/48)*48;
This should work, and you could add more to the X/Y results and play with these numbers to suit this project
As a side note, the point (0,0) is a center for a square, so you may need to make some adjustments to the code to make it suit the minecraft blocks (such as add 48/2 aka 24)
If this wasn’t what your looking for, then do let me know