How can I limit the area in which players spawn? [duplicate]

Solution 1:

First set the center of the spawning area:

/setworldspawn

Then, set the spawning radius to 0 to make sure that players spawn on exactly that block:

/gamerule spawnRadius 0

Solution 2:

To move the world spawn, go to your selected area of spawn and use command setworldspawn. Now players will spawn on or near the selected spawn area (usually within 20 blocks away). If you would like it so only the specific block is spawned on (instead of the specific area) then use gamerule spawnradius <any number>. Keep in mind the gamrule command only works on certain versions of the game.

Solution 3:

As of 1.7.2, the world spawn can be set via the /setworldspawn command. Usage:

/setworldspawn (X) (Y) (Z)

Source: http://minecraft.gamepedia.com/13w43a