How to place block on click in gridmap?

Godot Version

v4.2.1.stable.mono.official [b09f793f5]

Question

My code here: PasteBin

How to make a system that places a cube on gridmap where the user clicked? I’ve gotten far enough to get where the user clicked but can’t figure out how to only place to the sides of the block… It either gives me some weird result or sometimes places a diaganol. Please help