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

/teleport does not update chunk positions of entities

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • None
    • 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, 19w40a, 19w41a
    • Confirmed
    • Chunk loading, Commands, Entities

      The bug

      Chunk positions of entities are not updated when they are moved to another chunk by /teleport/data modify or /execute store until entity ticking.

      Steps to reproduce

      1. /summon minecraft:armor_stand 0 0 0 {UUIDMost: 0L, UUIDLeast: 0L, Marker: true}
      2. /teleport 0-0-0-0-0 1000000 0 0
      3. Reopen the world.
        The following warning message is printed, and the level fails to load the entity. 
        Wrong location! (62500, 0) should be (0, 0), avh['Armor Stand'/5, l='world', x=1000000.50, y=0.00, z=0.50]

         

      Code analysis

      net.minecraft.server.level.ServerLevel#updateChunkPos should be called to update entities among entity sections, but it's not called in the above commands. Entities moved to another chunk will not be re-added to the proper entity section until ServerLevel#tickNonPassenger that includes updateChunkPos is called.
      In the reproduction steps, the entity teleported to the chunk [62500, 0] has Pos=[1000000.5d, 0.0d, 0.5d], but it's still in the chunk [0, 0] since the chunk [62500, 0] is not an entity ticking chunk. This inconsistency causes the failure on entity loading.

      Comparison with /spreadplayers

      No inconsistency occurs in /spreadplayers since it calls Entity#teleportToWithTicket on success. Entity#teleportToWithTicket adds a region ticket with level 0, updates tickets, and then calls Entity#teleportTo that includes ServerLevel#updateChunkPos.

      Possible solutions

      • Load the destination chunk.
      • Throw an exception and don't move the target entities if the destination chunk is not loaded.

            Unassigned Unassigned
            intsuc intsuc
            Votes:
            5 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: