Teleported entities can end up being displayed at a wrong location if the viewing player is near the entity-tracking range

XMLWordPrintable

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Minor
    • None
    • Affects Version/s: None
    • None
    • Environment:

      git-Spigot-2086bb0-d0a3620 (MC: 1.12.2) (Implementing API version 1.12.2-R0.1-SNAPSHOT)

      I was only able to reproduce this on both Spigot and Craftbukkit. I haven't tested vanilla yet.

      Spigot comes with configurable tracking ranges for mobs: During debugging of this I used a tracking range of 16 (makes it easier to quickly reproduce), however I was also able to reproduce this at Spigot's default (48), at which I noticed this first in some other context. And I was also able to reproduce it on craftbukkit (which uses an even higher default tracking range).

      To test and reproduce this I used this simple plugin: https://pastebin.com/rBUX5HaC

      • By right clicking a block with an empty hand it will spawn a villager with NoAI (no gravity) at the clicked block face.
      • The entity is spawned slightly above the ground, just to make sure that this issue is not due to some edge case.
      • After 2 seconds (just enough time to get out of the tracking range of 16, which I used during testing), it will start to rapidly teleport the entity 1 block down until it finds a sold block below it.
      • If the viewing player leaves the tracking area and re-enters it again while the entity is currently getting teleported downwards, there is a high chance of the entity visually appearing inside (or even below) the block it is meant to end up on top of instead. However, on the server the entity is at the correct location (the testing plugin checks if the entity is inside a block after every teleport, and it also prints the end location of the entity).

      I have no idea yet on what is the issue behind this. As far as I understand it right now: When re-entering the tracking area, the server sends a spawn-mob packet with the entity's absolute location data. And I believe that the individual position update packets are relative to the entity's last position most of the time (they submit delta distance).

      My current guess is that maybe the client receives/handles position update packets from teleports that happened before the spawn-mob packet (with the entity's absolute position data) was sent out/handled, causing the client to apply more relative-position-updates to the entity than would be correct and causing the entity to end up at the wrong position by that.
      When leaving the tracking range and entering it again, after the villager appeared to be inside the block and the teleporting ended, the villager ends up at the correct position.

      Maybe someone with more knowledge about the minecraft internals has an idea on what the issue behind this is, and whether this is actually limited to Spigot/Craftbukkit or maybe even a vanilla or client issue.

      Use case for some justification for the rapid teleporting:
      I experimented with this in order to manually simulate gravity for custom entities with the NoAI flag set.
      In case this is indeed a client/vanilla issue: Is there a way for force an absolute position update with bukkit (which doesn't involve removing and respawning the entity)?

            Assignee:
            Unassigned
            Reporter:
            blablubbabc
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: