Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-102018

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

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • None
    • Minecraft 1.9.4, Minecraft 17w06a, Minecraft 1.12.2, Minecraft 18w11a, Minecraft 1.13.1, 19w44a, 21w05b
    • Confirmed
    • (Unassigned)

      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.

            Unassigned Unassigned
            draconicus draconicus
            Votes:
            5 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              CHK: