/spreadplayers Command
Teleports entities to random surface locations within a square region centered on the given 2D coordinate, with a minimum separation between them. The 'under' variant places entities under a maximum Y height.
Syntax
spreadplayers <center> <spreadDistance> <maxRange> <respectTeams> <targets>
spreadplayers <center> <spreadDistance> <maxRange> under <maxHeight> <respectTeams> <targets>Permission: 2 (gamemaster / cheats enabled)Edition: Both
Examples
/spreadplayers 0 0 5 50 false @a/spreadplayers ~ ~ 10 100 true @a/spreadplayers 0 0 2 30 under 200 false @e[type=minecraft:player]/spreadplayers 500 500 0 200 false @aNotes
center is a 2D (X Z) coordinate. spreadDistance is the minimum blocks between each teleported entity. maxRange is the maximum blocks from center. respectTeams true means teammates are placed at the same location. The 'under' sub-syntax (Java only) limits vertical placement to below maxHeight Y, requiring two air blocks above. Targets are always placed on the highest non-air block unless the 'under' variant restricts the height.