Commands/spreadplayers

Teleports entities to random surface locations within an area.

Syntax

 * Java Edition


 * Bedrock Edition

Arguments
(BE:  and  )
 * Specifies the center of the region to spread targets to. May use tilde and caret notation to specify coordinates relative to the command's execution.

(BE: )
 * Specifies the minimum distance between targets. Must be at least 0.0.

(BE: )
 * Specifies the maximum distance on each horizontal axis from the center of the area to spread targets (thus, the area is square, not circular). $$, must be at least 1.0. $$, must be at least 1.0 greater than.


 * Specifies whether to keep teams together. Must be  or  . If , targets on the same team will be teleported to the same location.

(BE: )
 * Specifies the targets to spread. Must be player names, a tilde and caret notation, or a UUID.
 * Permits entities other than players.

Result
Fails if the arguments are not specified correctly, or if there are too many targets to satisfy the  requirement within the specified area.

On success, teleports targets to random surface locations within the specified area. Targets will always be placed on the top block at a location, and never on lava.

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:
 * 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:
 * 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:

Note
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.

History
Befehl/spreadplayers 命令/spreadplayers