How can I keep mobs from being too close together with /spreadplayers and /execute?

How can I keep mobs from being too close together with /spreadplayers and /execute? - From below of anonymous female and male in warm clothes standing near railing together and hugging in cold weather

I want to summon multiple Slimes, then make sure that they are never in the same block. (If it's not possible to keep them from being in the same block, having them be at least 1 block from each other would work too.)

To do this I tried nesting execute commands like this:

execute @e[type=Slime,name=explore1] ~ ~ ~ execute @e[type=Slime,name=explore1,r=0,c=1] ~ ~ ~ spreadplayers ~.5 ~.5 0 1 false @e[type=Slime,name=explore1,r=1,c=1]

But that didn't work. I also tried

execute @e[type=Slime,name=explore1] ~ ~ ~ spreadplayers ~.5 ~.5 0 1 false @e[type=Slime,name=explore1,c=1,r=0]

I figured the r=0 tag might be off but I also tried with r=1 and it still didn't work.

The first command groups all the Slimes together and randomly teleports them, and the second command just does nothing.

Any ideas on how to do this?



Best Answer

The following command should work:

execute @e[type=Slime,name=explore1] ~ ~ ~ spreadplayers ~ ~ 2 3 false @e[type=Slime,rm=0,r=1,name=explore1]

All slimes will try to spread nearby (r=1) slimes that aren't themselves (rm=0) a maximum of 3 blocks around them.




Pictures about "How can I keep mobs from being too close together with /spreadplayers and /execute?"

How can I keep mobs from being too close together with /spreadplayers and /execute? - Loving couple of dolls sitting close against plants
How can I keep mobs from being too close together with /spreadplayers and /execute? - High angle of crop anonymous delicate female cuddling crying girlfriend suffering from misfortune and grief
How can I keep mobs from being too close together with /spreadplayers and /execute? - Crying black baby in turban in mother hands



How far do command blocks go?

Commands can be entered in the top text pane. The text limit for commands in a command block is 32,500 characters, but the text pane can show only a small portion of this amount at a time.

How do you spread entities in Minecraft?

You can use the /spreadplayers command to teleport all targeted players to random locations in a specified region.



Spreadplayers command on Mobs!




Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.

Images: Kristina Nor, Tara Winstead, Liza Summer, William Fortunato