How to make a modified mob spawn randomly on the map?

I'm doing a RPG in minecraft with some friends but we don't know how to make a modified mob spawn randomly on the map. We have a mob, and we have set it’s name, attributes, and other data. But we don’t know how to get it in a random location.

We are playing in Minecraft JE 1.16.1.


Use /summon to summon the entity normally. But immediately after, run the following /spreadplayers command:

/spreadplayers <centerX> <centerZ> 0.0 <maxRange> false @e[name="THE_MOB_TO_ACT_UPON"]

Replace the following things:

  • centerX and centerZ: The centre of your arena.
  • maxRange: How far from the centre can your entity be? The area is a square radius.
  • The target selector at the end: Replace with a target selector that will target the entity that you've already summoned.