I was wondering if it is possible for you to make a command block spawn hostile mobs in random places in a specified area?

I need the mobs spawned on different Y coordinates too because you need to fight your way up a tower to the top and I want the mobs to vary on each level to have specialty to each floor every time you play the mini game.

  • 3
    Why not use mob spawners? This might be some good reading for you. – Batophobia Mar 3 '14 at 20:37

I'm not sure if this would fit your needs, but you could try the spreadplayers command. Despite it's name, it is also capable of spreading mobs, with the in Minecraft 1.8 newly introduced @e selector.

/spreadplayers x z distance radius false @e[type=Creeper]

x z: The coordinates of where the mobs should go.
distance: The approximate distance the mobs should have.
radius: The radius of the area in which the mobs are spread (not a circle, but a square).
false: Just leave this at false, it is intended to respect teams when spreading players.
@e[type=Creeper]: The mob selector, the type=Creeper is very important. You can write other mobs name in this, but do not leave it out, as that would spread itemframes, signs, minecarts... And that would be a mess.

Of course this only spreads the mobs, but you have to summon them first, but i think that is no problem, just use command blocks with /summon Creeper x y z and you're good to go ;)

  • I'm pretty sure /spreadplayers uses player spawn rules for determining where to put players, meaning you can't specify a y coordinate. This means the creepers will always spawn on a level with a view to the sky. – MBraedley Mar 4 '14 at 16:42
  • Could you then chain that with a teleport? (Spawn them on the top floor, then teleport down?) I really need to play with command blocks more. – Allen Gould Mar 4 '14 at 17:19
  • 1
    @AllenGould Yeah, I though about that, and it should be possible. The challenge comes in when including the logic to teleport them to the proper level, but that should be easy to overcome. – MBraedley Mar 4 '14 at 18:38
  • @MBraedley I think the trick might be to have several teleporters (one for each floor), and have them running on slightly different timing loops. It won't be Really Random, but varied enough that players shouldn't spot the pattern easily. – Allen Gould Mar 4 '14 at 19:12
  • "You can write other mobs name in this" - How? I asked a question about that and people said no. – James Of Da Peach Mar 4 '14 at 19:25

How about using creative mode and dispensers? You put spawn eggs in the dispensers then you place a pressure plate in front of it. Viola you now have a working mob spawner!

  • that wouldnt work first because i need it automated and second the eggs would run out soon because about 1,000 people are going to try the game – LFM Mar 3 '14 at 21:47
  • This doesn't help to randomize the spawning at all. – James Of Da Peach Mar 4 '14 at 19:23

Well, I use this command:

/summon @e[type=creeper, zombie, skeleton, spider, r=1, r=10, r=20, r=30, distance="40"]}]}]}] 

Then type:

/tp @e[type=creeper, zombie, skeleton, spider] <x> <y> <z> {execute @e[type="mob"/, r=20] setblock <x> <y> <z> redstone_block}]}]}]}]}]}]}]}]

This command will teleport all creepers, zombies, skeletons, and spiders to a location. Then it should place a redstone block next to another command block. This is optionel, if you want this command to say something when it works, bur if you do want that. Type in that command block:

/tellraw @a {rawtext/"text"[color:"<color>", text="<your text>"}]}
New contributor
ColiJGaming is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

/spreadplayers x z distance radius false @e[type=Creeper]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.