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 the maximum height for resulting positions. Must be an integer between -2,147,483,648 through 2,147,483,647 (inclusive).


 * 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, if there are too many targets to satisfy the  requirement within the specified area, or if there is no space under   to spread.

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