Minecraft – How to teleport players in a ring around a specific spot

minecraft-commandsminecraft-java-edition

Let's say I have a 18×18 circle, surrounded by a 3×3 ring of a different material. I want to teleport players randomly along the 3×3 ring all the way along the outside. I have tried experimenting with the

/spreadplayers

command, as I have used it to teleport players randomly along a line, like so:

tp @a -317 35 58

spreadplayers -317 -58 1 11 false @a

tp @a ~ 35 58

however, I can't seem to think how you would apply this logic to a ring. I understand that I can set the 'x' and 'z' as the centerpoint, but there is no mixrange argument, only maxrange, so how would I ensure that the players are a minimum of 18 blocks and a maximum of 21 blocks from the centerpoint?

Best Answer

The easiest way to do this would be to repeat the command a few times and target all players who are either within the inner circle or outside of the outer circle (which is possible due to /spreadplayers' spread area being a square). If you let this run for 5 seconds in a repeating command block, you have 100 attempts to get them out, which should make it sure enough that nobody's left there.

If you know the number of players (or teams), you can also play around with the spreadDistance parameter by setting it high enough that players can only end up in a ring. For example the command /spreadplayers ~ ~ 11 9 false @e[type=armor_stand] does a pretty good job of spreading five armor stands evenly in a ring.