mojira.dev
MC-4686

Client movement when teleported

The bug

Currently, when teleporting a player (either relatively or absolutely) the motion of the teleport is visible sometimes, but not always. This behaviour is inconsistent even at 60fps.

How to reproduce

  1. Make two identical buildings 16 blocks apart from each other on the worlds X axis

  2. Keep executing the following two commands

    /tp ~16 ~ ~
    /tp ~-16 ~ ~

    → Note the occasional flash in between the teleports

Results

When a teleportation occurs, a flash is sometimes seen. Sometimes blocks even disappear until you move your mouse.

This flash is caused by extra frames generated during the teleportation. Causing an image to be rendered from the position in between the start position and the destination. The disappearing blocks is a different issue that deserves its own ticket.

Expected

To either not see a flash at all, or see it all the time (at 60fps).

Possible fix

It appears that this happens because only one of the two previous position fields is updated when teleporting. Specifically, setPositionAndRotation updates prevPosX/Y/Z, but leaves lastTickX/Y/Z alone. Both of these fields are used to interpolate position (each in different contexts), and only using one causes this bug. (Side note: I'm not entirely sure why there are two fields that have more or less the same purpose - perhaps they can be merged).

This is my (@unknown) fix (in NetHandlerPlayClient.handlePlayerPosLook):

EntityPlayer player = this.gameController.player;
double x = packetIn.getX();
double y = packetIn.getY();
double z = packetIn.getZ();
float yaw = packetIn.getYaw();
float pitch = packetIn.getPitch();

if (packetIn.getFlags().contains(SPacketPlayerPosLook.EnumFlags.X))
{
    player.lastTickPosX += x;
    player.chasingPosX += x;
    player.prevChasingPosX += x;
    x += player.posX;
}
else
{
    player.lastTickPosX = x;
    player.chasingPosX = x;
    player.prevChasingPosX = x;
    player.motionX = 0.0D;
}

if (packetIn.getFlags().contains(SPacketPlayerPosLook.EnumFlags.Y))
{
    player.lastTickPosY += y;
    player.chasingPosY += y;
    player.prevChasingPosY += y;
    y += player.posY;
}
else
{
    player.lastTickPosY = y;
    player.chasingPosY = y;
    player.prevChasingPosY = y;
    player.motionY = 0.0D;
}

if (packetIn.getFlags().contains(SPacketPlayerPosLook.EnumFlags.Z))
{
    player.lastTickPosZ += z;
    player.chasingPosZ += z;
    player.prevChasingPosZ += z;
    z += player.posZ;
}
else
{
    player.lastTickPosZ = z;
    player.chasingPosZ = z;
    player.prevChasingPosZ = z;
    player.motionZ = 0.0D;
}

I update lastTickPosX/Y/Z by the delta if it is a relative teleport, and set it directly if it is an absolute teleport. Changing it by the delta is important - if we just set it to the new position, then there actually is a (subtle) pause as the camera stays in the new position for the entire tick rather than moving between the offset old position and the new position.

I also update prevChasingPos/chasingPosX/Y/Z, which are used to render capes. This keeps capes from spazing out when teleporting (but isn't too important to the core problem).

I don't touch prevPosX/Y/Z at all in this code, simply because any changes made would be overwritten by the call to setPositionAndRotation. It may be better to also adjust prevPosX/Y/Z by the delta, but I couldn't detect a significant difference and that would require tweaking setPositionAndRotation.

(note that MC-120545 needs to also be fixed for seamless teleporting)

Linked issues

Attachments

Comments 106

Yoann Petremann

Still in 13w10a

Is this still a concern in the current Minecraft version? If so, please update the affected versions in order to best aid Mojang ensuring bugs are still valid in the latest releases/pre-releases.

Ian Fiveonethreethree

It's still in existence in 1.5.1. It's actually causing problems in a custom map that I'm making. I frequently need to teleport the player to rooms that look almost the same as the room they were in. It's supposed to be unnoticeable, but since this bug exists there is somewhat of a 'flash' when they teleport.

In my opinion, teleportation should be seamless, without rendering of the space between the start and end locations in-between the two ticks.

Jesper the End

my issue might be related/a duplicate of this issue: MC-14861

Jesper the End

confirmed for 13w17a

If you want to fix this you have to fixt these 3 things:
-stop the hand from moving when teleported
-make sure you don't see any frames during the teleportation
-make sure the velocity stays the same when you teleport

96 more comments

confirmed for 1.13 release

Jesper the End

Fixed :O
I guess I'll have to make the Code IV now 🤔

Still getting this in 1.13.2

How??????

18w43a is the first snapshot for 1.14. I've added 1.13.2 to the list since it is still affected, though.

Emre Kisacikoglu

holy crap, they fixed it!

Yoann Petremann

Jesper the End

migrated

Confirmed

/tp, movement, teleport, visual

Minecraft 1.4.5, Snapshot 12w50b, Snapshot 13w10a, Minecraft 1.5, Snapshot 13w11a, ..., Minecraft 18w32a, Minecraft 1.13.1-pre1, Minecraft 1.13.1-pre2, Minecraft 1.13.1, Minecraft 1.13.2

Minecraft 1.7.10, Minecraft 18w43a

Retrieved