/spreadplayers

/spreadplayers
Permission level
required
  • 2 ‌
  • 1 ‌
Restrictions

Cheat only‌

Example of the /spreadplayer command used on zombies. The /spreadplayer command spreads the entities in a square. This example uses 10 as the radius.

Teleports entities to random surface locations within an area.

Usage

In Java Edition, targets are always placed on the highest non-air block at a horizontal position. If in under mode, targets are always placed on the highest non-air block that is under the specified maximum height and with two air blocks above it. The horizontal coordinates are invalid if there's no such non-air block.

In Bedrock Edition, targets are always placed one block above the highest solid block at a horizonal position. If with maxHeight: value argument, targets are always placed one block above the highest solid block that is under the specified maximum height. The horizontal coordinates are invalid if there's no such solid block, or if the solid block does not have two air blocks above it.

Targets are never placed on lava, water, bubble column, or fire. Positions above these blocks are invalid. In Bedrock Edition, magma block, wither rose, campfire, soul campfire, sweet berry bush, nether portal, end portal, and end gateway are also invalid positions.

In Java Edition, the entities are spread into the command's execution dimension.

In Bedrock Edition, the command changes an entity's position without changing dimension. But the valid position is calculated in the command's execution dimension.

If there are no valid position, or the targets are too many to satisfy the minimum distance (<spreadDistance> or spreadDistance: float) requirement within valid positions, no entities are spread.

Syntax

  • Java Edition
spreadplayers <center> <spreadDistance> <maxRange> <respectTeams> <targets>
Spreads players to positions on the top non-air block.
spreadplayers <center> <spreadDistance> <maxRange> under <maxHeight> <respectTeams> <targets>
Spreads players to positions under the maximum height, on the highest non-air block with two air blocks above it.
  • Bedrock Edition
spreadplayers <x: value> <z: value> <spreadDistance: float> <maxRange: float> <victim: target> [maxHeight: value]

Arguments

JE: <center>: vec2
BE: x: value: RelativeFloat and z: value: RelativeFloat

Specifies the center of the region to spread targets to.
Must be two-dimensional coordinates with double-precision floating-point number‌ or single-precision floating-point number‌ elements. Accepts tilde notations.

JE<spreadDistance>: float
BE: spreadDistance: float: float

Specifies the minimum distance between each two targets.
Must be a [Float]Single-precision floating-point number (from -(2-2-23)×2127 (≈-3.4×1038) to (2-2-23)2×127 (≈3.4×1038) ). And it should be at least 0.0.

JE<maxRange>: float
BE: maxRange: float: float

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 a [Float]Single-precision floating-point number (from -(2-2-23)×2127 (≈-3.4×1038) to (2-2-23)2×127 (≈3.4×1038) ). In Java Edition, it must be greater than or equal to 1.0. In Bedrock Edition, it should be at least 1.0 greater than spreadDistance: float.

JE: <maxHeight>: integer

BEmaxHeight: value: RelativeFloat

Specifies the maximum height for the target positions.
In Java Edition, must be a [Int]32-bit integer number (from -2147483648 (-231) to 2147483647 (231-1) ).
In Bedrock Edition, must be a [Float] float. Accepts tilde notation.

JE: <respectTeams>: bool

Specifies whether to keep entities on the same team together. If true, targets on the same team are teleported to the same position.
Must be a [Boolean]Boolean (either true or false).

JE<targets>: entity
BE: victim: target: CommandSelector<Actor>

Specifies the targets to spread.
Must be a player name, a target selector or a UUID‌.

Result

CommandTriggerJava EditionBedrock Edition
AnyThe command is incomplete, or any argument is not specified correctly. Unparseable Unparseable
spreadDistance: float is lower than 0.0. N/A Failed
maxRange: float is lower than spreadDistance: float plus one.
<targets> or player: target fails to resolve to one or more entities (named players must be online). Failed
There is not valid position (lava, water, etc. are invalid) to spread to.
/spreadplayers ... under ...There is no valid position (two air block above a non-air block that is not lava, water, bubble column or fire) under <maxHeight> to spread to. N/A
AnyThough there are valid positions, but the targets are too many to satisfy the <spreadDistance> or spreadDistance: float requirement within these valid positions. Failed
AnyOtherwiseSuccessful

Output

CommandEditionSituationSuccess Count/execute store success .../execute store result ...
AnyJava EditionOn fail000
/spreadplayers ... true ...On success11the number of teams that these targets are in
/spreadplayers ... false ...On success11the number of targeted entities
AnyBedrock EditionOn fail0N/AN/A
On success1N/AN/A

Examples

  • In Java Edition, 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
  • In Java Edition, 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

History

This section needs expansion.
 
You can help by expanding it.
Java Edition
1.6.113w23aAdded /spreadplayers.
1.1620w21aAdded an optional <maxHeight> argument to specify maximum height.
1.19.422w03aNow entities are spread to the command's execution dimension.[1]
Pocket Edition
1.0.5alpha 1.0.5.0Added /spreadplayers.
Bedrock Edition
1.21.20beta 1.21.10.23Added an optional maxHeight: value argument.

See also

  • /tp and /teleport — different commands that teleport a single player or entity to a specific position (even underground).

References

  1. MC-181832 — resolved as "Fixed".

Navigation