Minecraft – How to have players spawn within a range – Minecraft 1.11.2

minecraft-commandsminecraft-java-editionminecraft-java-edition-server

I am working on a Minecraft build that I might eventually publish to a server. Anyway, there is a spawning area, and I would like players to spawn within a certain area, not just on one block.

If anyone knows the answer, it would be most appreciated.

Best Answer

well, vanilla spawning is normally in a radius of 10 around the worldspawn anyway, so they are basically spawning in an area already.

there even is a gamerule for it, which lets you manipulate the spawnradius:

/gamerule spawnRadius <number of blocks>

if you can't move the worldspawn however, /spreadplayers might be what you're looking for. you can use this to e.g spread anyone that spawns at a predetermined area (which is their actual spawnpoint) and then just instantly gets teleported around the place.

/spreadplayers <x> <z> <spreadDistance> <maxRange> <respectTeams> <players>  

be aware that this, like the worldspawn, will put players always on the top level block at whatever they got spread to, so it can't be used in a cavesystem or some sort of building with a roof (unless you have a level ground and after spreading, then you can just teleport them to that y position while keeping the x and z position.

/tp @a[...] ~ <y> ~  

the last way that is possible in vanilla without too much hassle would be to predefine multiple spawninglocations marked by some entities (I'd suggest Area Effect Clouds) and just teleport them to one of those random entities, so it feels random to them, but isn't really.

/teleport @a[...] @r[type=area_effect_cloud,name=spawnMarker,...]