mojira.dev
MC-103804

Spread player not working/bug

When I try to spread 25 entities to 25 blocks with a spread distance of 1 using: "/execute unexplosive -898 72 230 /spreadplayers ~ ~ 1 2 false @e[tag=3]"
it says: "can not spread 25 players around -898,0,230 (too many - try using spread of at most 0,00)." But there is enough space: 25 entities and 25 blocks. Also you cannot spread players with a radius of 1 and distance of 1. It says to use a distance of 0, even thou a distance of 1 is possible.

Linked issues

Attachments

Comments 28

Please do not mark unreleased versions as affected.
You don't have access to them yet.

Spread distance = empty spaces between entities

basicly I'm trying to spread all 25 players to all 25 blocks, so that there is only one entity on every block. How can i do the (command) ?

and i know that spread distance is the space between entities, but if its 0 there can be multiple entitys on one block and i don't want that

No, entities will not end up on the same block, ever.
0 means right next to each other, so use 0.

18 more comments

I don't know, that's why I've reopened it, but stop spam updating this ticket by adding worthless comments and removing them again.

Relate to MC-69357 (see comment)

But there is enough space: 25 entities and 25 blocks

Notice that the game tell you "too many people for space" this does not mean that there is no possible solution, just that the game can't find one.

@mrpingouin1 Well if there is a possible solution, shouldn't the game use that possible solution?

@@unknown
Spreading a given amount of point over a given shape is itself a pretty hard mathematical problem, and spreadplayer is supposed to find a random solution in a fixed finite time, with a shape of any size and without knowing the exact shape. Even if the shape was known this will not really help in the general case, so scanning the spread area is not a solution.
Most of the time, there is an infinite amount of solution, but on the other hand, if there is a 'bigger' infinite amount of combination that is not a solution, it's therefore it's very hard to find a solution.

Unless someone can provide a better spreadplayer algorithm, nothing can really be done to find solutions to test case like yours.

However, instead of blaming the spreadplayer command, you can use it to solve your problem by executing multiple spreadplayer in the same tick :

# Assuming the armorstands have a tag=toSpread, they don't stand on a redstone_block, and they are spread on a redstone_block.
#The following commands only need to be executed once in the same tick, no clock is needed.
 
/scoreboard players tag @e[type=ArmorStand,tag=toSpread] add spreading

/spreadplayers ~ ~ 1.42 2.5 false @e[type=ArmorStand,tag=toSpread]
/execute @e[type=ArmorStand,tag=toSpread] ~ ~ ~ detect ~ ~-1 ~ redstone_block 0 setblock ~ ~ ~ water
/execute @e[type=ArmorStand,tag=toSpread] ~ ~ ~ detect ~ ~-1 ~ redstone_block 0 /scoreboard players tag @e[type=ArmorStand,c=1] remove toSpread

/spreadplayers ~ ~ 1.42 2.5 false @e[type=ArmorStand,tag=toSpread]
/execute @e[type=ArmorStand,tag=toSpread] ~ ~ ~ detect ~ ~-1 ~ redstone_block 0 setblock ~ ~ ~ water
/execute @e[type=ArmorStand,tag=toSpread] ~ ~ ~ detect ~ ~-1 ~ redstone_block 0 /scoreboard players tag @e[type=ArmorStand,c=1] remove toSpread

# ^ Execute the 3 above commands enough time in the same tick so that the entities are spread correctly every time.

/execute @e[type=ArmorStand,tag=spreading] ~ ~ ~ detect ~ ~-1 ~ redstone_block 0 setblock ~ ~ ~ air
/scoreboard players tag @e[type=ArmorStand,tag=spreading] remove spreading

LOL LOL

(Unassigned)

Unconfirmed

command_block, spreadplayers

Minecraft 1.9.4, Minecraft 1.10

Retrieved