TransWikia.com

Is it possible to spawn mobs in random places?

Arqade Asked by LFM on March 20, 2021

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.

6 Answers

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!

Answered by Vespermole on March 20, 2021

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

Answered by Lars on March 20, 2021

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

Answered by annonynomys on March 20, 2021

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

Answered by Don'tTalkToMe1528 on March 20, 2021

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

Answered by AidenQvD on March 20, 2021

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.

Answered by Balistic 6 on March 20, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP