2

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.

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

6 Answers 6

4

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 ;)

8
  • 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, 2014 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. Mar 4, 2014 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, 2014 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. Mar 4, 2014 at 19:12
  • "You can write other mobs name in this" - How? I asked a question about that and people said no. Mar 4, 2014 at 19:25
0

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!

2
  • 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, 2014 at 21:47
  • This doesn't help to randomize the spawning at all. Mar 4, 2014 at 19:23
0

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>"}]}
0

I don't know if this helps but let's say you have a platform from 0 80 0 to 10 80 10 (centre is 5 80 5). If you would want for example a creeper to be randomly summoned on one of the blocks this should work. Set up a command block that summons a creeper with the tag {PersistenceRequired} (this makes it so the creeper won't despawn) like this:

summon minecraft:creeper ~ ~2 ~ {PersistenceRequired:1b}

(I did ~2 so it spawns on top of the chain command block that will be placed above it)

then a chain command block which spreads the creeper on your platform:

spreadplayers 5 5 0 5 false @e[type=minecraft:creeper,distance=..3]

the first 5 and second 5 are the x and z coords, 0 is the minimum distance between entities (only applies if 2 or more entities are affected by this command at the same time, the third 5 is the distance from the centre you want the entities to spread (it's a square). If you want a "custom shape" you can place water above the block you don't want the creeper to spawn on, just make sure the water is the top block above the block you don't want the creepers to go, now onto the initial question: separate y levels, this is easily done by using

spreadplayers 105 5 0 5 under 81 false @e[type=minecraft:creeper,distance=..3]

This will teleport the creeper to the top block under y=81 however with this you can't place water 50 blocks above the platform for a custom shape anymore with water, but if your under y coord is set directly 1 block above the platform you can place string on places you don't want them to spawn, this however might be annoying since it's in the way. There is probably a work around for this but I feel like there is enough stuff here. I hope this helps at least someone checking this question looking for a good answer

0

Actually didn't take that long to figure out. Command:

/spreadplayers ~ ~ 20 20 false @e[type=!minecraft:player,distance=..5]

Just have to get the players out of the equation and then get any entity within a distance of 5. The only problem is you can't get a specific entity.

-1

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .