What I want to do is use the execute command to randomly pick a custom named mob or entity. I already have this command:

execute @r[type=Boat] ~ ~ ~ setblock ~ ~-2 ~ redstone_block

which I am using to place a redstone block and select one of five categories, but then if I want to use the same command on a sheep, for example, I want it to select from the ones I summon and not randomly find one in the wild (which I figure that's what it's doing, because it was saying that the command was executed properly). The problem is that I have no idea how to go about making that work. I've tried a couple of things, but it either came back with an error or executed it on a random mob in the wild.

2 Answers 2


You could summon the sheep with something like a custom name or scoreboard tag, then specify that name/tag in your selector:

summon Sheep ~ ~ ~ {Tags:["Summoned"]}


execute @r[type=Sheep,tag=Summoned] ~ ~ ~ setblock ~ ~-2 ~ redstone_block

You could summon the sheep (or boat) with a custom name using /summon Sheep ~ ~ ~ {CustomName:Bob} then pick a random sheep named Bob using /execute @r[type=Sheep,name=Bob] ~ ~ ~ Hope this helps!

You must log in to answer this question.

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