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

Chunk-wise entity lists often don't get updated correctly (Entities disappear)


    • Icon: Bug Bug
    • Resolution: Fixed
    • 20w45a
    • Minecraft 1.10.2, Minecraft 16w40a, Minecraft 16w43a, Minecraft 16w44a, Minecraft 1.11 Pre-Release 1, Minecraft 1.11, Minecraft 1.11.2, Minecraft 1.12, Minecraft 1.12.1 Pre-Release 1, Minecraft 1.12.1, Minecraft 1.12.2, Minecraft 17w50a, Minecraft 18w20a, Minecraft 18w20b, Minecraft 1.13-pre1, Minecraft 1.13-pre2, Minecraft 1.13-pre3, Minecraft 1.13-pre4, Minecraft 1.13-pre6, Minecraft 1.13-pre7, Minecraft 1.13-pre8, Minecraft 1.13, Minecraft 1.13.2, Minecraft 18w48a, Minecraft 18w48b, Minecraft 18w49a, Minecraft 18w50a, Minecraft 19w02a, Minecraft 19w03c, Minecraft 19w04a, Minecraft 19w04b, Minecraft 19w05a, Minecraft 19w06a, Minecraft 19w07a, Minecraft 19w08b, Minecraft 19w11b, Minecraft 19w12b, Minecraft 1.14.2, Minecraft 1.14.3 Pre-Release 1, Minecraft 1.14.3 Pre-Release 2, Minecraft 1.14.3 Pre-Release 3, Minecraft 1.14.3 Pre-Release 4, Minecraft 1.14.3, Minecraft 1.14.4 Pre-Release 1, Minecraft 1.14.4 Pre-Release 2, Minecraft 1.14.4 Pre-Release 3, Minecraft 1.14.4 Pre-Release 4, 1.14.4, 19w36a, 19w37a, 19w40a, 19w41a, 1.15 Pre-release 1, 1.15.1, 1.15.2 Pre-Release 1
    • Confirmed
    • Chunk loading, Entities
    • Important

      The bug

      In many cases when entities are moved into another chunk they are not added to the new chunks entity lists rightaway.
      Instead they get added when the entity receives the next update tick. Until that happens the entity will not be found by some searches that use the chunk-wise lists.
      In some cases (like in lazy chunks) it can even happen that the entity is not ticked and doesn't get added to the new list at all. Upon unloading the world the entity will not get saved in the correct chunk and be deleted upon the next reload.

      Two cases where this bug can happen are teleport commands and pistons. It's likely that there are more cases though.

      How to reproduce

      1. Create a superflat world.
      2. /setworldspawn 0 0 0
      3. /tp 1000 100 0
      4. Reload the world to make sure only the right chunks are loaded.
      5. /summon minecraft:armor_stand 0 100 0 {NoGravity:1,Tags:["MC-108469"]}
      6. /tp @e[tag=MC-108469,x=0,y=100,z=0,distance=..10] 200 100 0

        Notice that the target position is still a loaded chunk, just not one in which entities get ticked.

      7. If you now unload and reload the world the armour stand will be gone only leaving the following messages in the launcher:
        [INFO] 01:58:46.893 Preparing spawn area: 0%
        [WARN] 01:58:46.919 Wrong location! (12, 0) should be (0, 0), avm['Armor Stand'/22, l='19w46b', x=200.50, y=100.00, z=0.50]
        [INFO] 01:58:46.960 Changing view distance to 31, from 10

      Alternatively to reloading the world, the error can be shown using these commands. They are not able to find the entity.

      /say @e[tag=MC-108469]
      /say @e[tag=MC-108469,x=200,y=100,z=0,distance=..100]

      In contrast this one does find the entity:

      /say @e[tag=MC-108469,x=200,y=100,z=0,distance=..1000]

      Given the position of the armorstand all of the above commands should be able to find it, however, since it is not constantly updated across different entity lists, only the third one will find it (as off 1.15pre1).
      Also note that the behaviour of these commands is highly dependant on performance decisions of entity selectors and might not behave the same under all conditions.

      This issue affects survival (pistons) as well as creative/map making (teleport commands).
      Another way this issue shows is when trying to teleport an entity twice in the same tick through several chunks, using selectors that make use of the chunk entity lists. The second selector will then not be able to find the entity.

      Code analysis

      Code analysis and suggested fix by Xcom6000 can be found here and there. Additional minor optimization here.

            Unassigned Unassigned
            panda4994 [Mojang] Panda
            153 Vote for this issue
            60 Start watching this issue