mojira.dev
MC-102018

Team NBT tag adds entity to team even if it was not spawned in the world

The bug

The Team tag directly adds the entity to the provided team even if the entity is not spawned in the world. This should not happen because the entities are sometimes created to test if they can be spawned in the world before actually spawning them, for example to test if they collide with blocks or other entities.

How to reproduce

  1. Create a scoreboard team

    /team add testTeam
  2. Set the time to night

    /time set night
  3. Place a spawner which would spawn a mob and add it to a team

    /setblock ~ ~ ~ spawner{Delay:0s,MinSpawnDelay:0s,MaxSpawnDelay:0s,MaxNearbyEntities:0s,SpawnRange:10s,RequiredPlayerRange:32s,SpawnCount:10s,SpawnData:{id:"zombie",Team:"testTeam"}}
  4. Look at the team size

    /team list testTeam

    → You should see that the number of entities in the team is greater than 0 even though no entity was spawned

Note: The reproduction steps changed slightly. Previously all spawning conditions were checked after loading the entity, now all spawning checks are performed before loading the entity, except the MaxNearbyEntities check.

Code analysis

Based on 1.11.2 decompiled using MCP 9.35 rc1

The method net.minecraft.entity.EntityLivingBase.readEntityFromNBT(NBTTagCompound) directly adds the entity to the team. This could be solved for example with a new method onEntityAddedToWorld which could be called when an entity was actually spawned in the world. Then the method readEntityFromNBT could store the team temporarily in a field until the method onEntityAddedToWorld is called.

Linked issues

Comments 4

Is this still an issue in the most recent versions (currently that is 1.10.2, or 16w43a) of Minecraft? If so, please update the affected versions and help us keeping this ticket updated from time to time. If you are the owner/reporter of this ticket, you can modify the affected version(s) yourself.

Changed report to be about the general problem.

Confirmed for 1.13.1.

Can confirm that this is still an issue in 21w05b.

draconicus

(Unassigned)

Confirmed

(Unassigned)

NBT, Team, scoreboard-teams, spawn, team, world

Minecraft 1.9.4, Minecraft 17w06a, Minecraft 1.12.2, Minecraft 18w11a, Minecraft 1.13.1, 19w44a, 21w05b

Retrieved