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
- Create a scoreboard team
/team add testTeam
- Set the time to night
/time set night
- 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"}}
- 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.
- relates to
-
MC-113935 onInitialSpawn modifies world even if mob was not spawned
- Resolved