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

Teleporting players with relative arguments still teleports them when arguments are set to 0

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • None
    • 1.19.2
    • None
    • Windows 10 21H1, Java 17.0.5
    • Plausible
    • Commands, Networking
    • Normal
    • Platform

      Describe the bug:
      When teleporting players with relative arguments, players are still teleported despite the x, y, and z arguments being set to 0. This causes the camera to jerk/stutter, when it should not be moved at all. This bug is seemingly only present in 1.14 and above.

       

      Discovery:
      While working on a gun server, I implemented a recoil effect for shooting guns using teleports with relative arguments to move a player's camera yaw/pitch. Because the teleport arguments are relative, sending a packet with only yaw/pitch having non-zero values should result in only yaw/pitch changing. However, if a player moves while this packet is sent, they seem to be teleported to slightly different x, y, and z coordinates despite them being zero.

       

      Code to reproduce:

      ServerPlayer serverPlayer = this.player;
      // All arguments should be relative as we only want to change their yaw/pitch position
      Set<ClientboundPlayerPositionPacket.RelativeArgument> relativeArguments = EnumSet.allOf(ClientboundPlayerPositionPacket.RelativeArgument.class);
      // Do not change x, y, or z coordinates
      double x = 0.0D;
      double y = 0.0D;
      double z = 0.0D;
      // Move yaw and pitch by 0.1
      float yaw = 0.1F;
      float pitch = 0.1F;
      // Create and send the packet
      ClientboundPlayerPositionPacket packet = new ClientboundPlayerPositionPacket(x, y, z, yaw, pitch, relativeArguments, 0, false);
      serverPlayer.connection.send(packet);

      Send the player this packet every tick while the player is moving to observe stuttering/teleporting.

       

      Video demonstrations (watch in 60 FPS):
      Bugged/incorrect outcome (stuttering while being teleported while moving) (1.19.2):
      Video

      Expected/correct outcome (no stuttering while being teleported while moving) (1.13.2):
      Video

            Unassigned Unassigned
            spensic Coords
            Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              CHK: