mojira.dev
MC-108790

"spreadplayers" command counts all entities as being on one team

The bug

The /spreadplayers command treats entities on multiple teams as if they were all on the same team.

In the latest versions the command feedback also says that the spread distance is Infinity:

18w05a

Spread 1 teams around 25.751766, -20.911484 with an average distance of Infinity blocks apart

How to reproduce

  1. Create two teams

    /team add team_a
    /team add team_b
  2. Summon two armor stands which are in the teams

    /summon armor_stand ~ ~ ~ {CustomName:"\"A\"",Team:team_a}
    /summon armor_stand ~ ~ ~ {CustomName:"\"B\"",Team:team_b}
  3. Use /spreadplayers for them

    /spreadplayers ~ ~ 1 5 true @e[type=armor_stand,team=!]

    → ❌ They were both teleported to the same position

Code analysis

Based on 1.11 decompiled using MCP 9.35 rc1

Incorrect team count in start message (does not exist anymore)

The start message commands.spreadplayers.spreading. ("Spreading ... blocks around ...") uses the entity count instead of the team count.

Teams of mobs are not counted

The methods net.minecraft.command.CommandSpreadPlayers.getNumberOfTeams(List<Entity>) and net.minecraft.command.CommandSpreadPlayers.setPlayerPositions(List<Entity>, World, Position[], boolean) treat all entities which are not a player as if they were in no team.

Attachments

Comments 7

Did you make sure the 4th command doesn't put both pigs on the same team?

/scoreboard teams join blue @e[r=2]

Yes, I did. Checked several times, pigs definitely are on different teams.

Confirmed for 1.13.1.

Confirmed in 1.16.1 and 20w29a.

Can confirm in 21w03a.

Can confirm in 21w05b.

Can confirm in 1.16.5 and 21w08b.

Andrey Zhukov

(Unassigned)

Confirmed

Commands

entity, spreadplayers

Minecraft 1.10.2, Minecraft 16w41a, Minecraft 1.12.2, Minecraft 18w05a, Minecraft 1.13.1, ..., 20w29a, 21w03a, 1.16.5, 21w05b, 21w08b

Retrieved