Commands/spreadplayers

Teleports entities to random surface locations within an area.
==Usage==
Targets are always placed on the top non-air block (whether it's solid or not) at a horizontal location (if not in under mode), and never on lava, water, bubble column, or fire.
, the entities are spread to the command's execution dimension.
, the command changes an entity's position without changing dimension. But the position is calculated in the command's execution dimension.
The command does not have a uniform distribution over the surface. It has a Gaussian distribution as the positions closer to the position set in the command have a higher chance of having an entity on them. This effect is very subtle and is not visible for short radius but can be a problem if you want a uniform random generation. This problem does not occur for the @r selector and dispensers.
==Syntax==
* Java Edition
: spreadplayers <spreadDistance> <maxRange> <respectTeams> <targets>
: spreadplayers <spreadDistance> <maxRange> under <maxHeight> <respectTeams> <targets>
:: Spreads players to resulting position under the maximum height.
* Bedrock Edition
: spreadplayers <x: value> <z: value> <spreadDistance: float> <maxRange: float> <victim: target>
==Arguments==
: 
: and 
: Specifies the center of the region to spread targets to.
: 
: Specifies the minimum distance between targets.
: , it should be at least 0.0.
: Specifies the maximum distance on each horizontal axis from the center of the area to spread targets (thus, the area is square, not circular).
: , it must be at least 1.0 greater than spreadDistance: float.
: 
: Specifies the maximum height for resulting positions.
: 
: 
: Specifies whether to keep teams together. If true, targets on the same team are teleported to the same location.
: 
: Specifies the targets to spread.
: 
==Result==
== Output ==
==Examples==
*To teleport all players by team to random surface locations in a 1,000×1,000-block area centered on (0,0), with a minimum distance between teams of 200 blocks:
** spreadplayers 0 0 200 500 true @a
* To teleport one random player from each of three teams (Red, Blue, and Green), as well as Alice and Bob, to random surface locations in a 200×200-block area centered on (0,0), with a minimum distance between players of 50 blocks:
** spreadplayers 0 0 50 100 false @r[team=Red] @r[team=Blue] @r[team=Green] Alice Bob
==See also==
* and — different commands that teleport a single player or entity to a specific position (even underground).
== History ==
== References ==
de:Befehl/spreadplayers
es:Comandos/spreadplayers
ru:Команды консоли/spreadplayers
uk:Команди консолі/spreadplayers
zh:命令/spreadplayers