Minecraft – how do you hide command blocks

minecraft-commandsminecraft-java-edition

I am making a server, and I want to teleport the closest player to a certain area. But I don't know how to make the command blocks invisible, so the players don't see them. Does anyone know how?

Best Answer

You can have commandblocks somewhere else (however prefered in same chunk to have it loaded), then use alternative command syntax.

/tp @p[x=100,y=64,z=100,r=3] ~0 ~30 ~0

..this commandblock will look at given XYZ coordinates and will search for nearest player in radius of 3 blocks. Then it will teleport him 30 block up (relative to player in case of /tp - but you can use also hard-coded coordinates)

For activating the commandblock, you can make it always active (via CB settings or redstone clock), thus it will teleport players whenever they enter the scanned area. Or you can make some redstone circiut, or wireless redstone (via mods, plugins, or via another commandblocks - if you need some advanced computing and have only sparse space, you can use only one CB (with button-like activation) to just place redstone block on another place, then activating the circuits)

For more study how this works, you can read the wiki article about command syntax, what other target selectors you can use etc, here.