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

Incorrect knockback direction

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Awaiting Response
    • None
    • 1.20.1
    • Minecraft 1.8 - 1.20.1, Java 20, Debian 12
    • Unconfirmed
    • (Unassigned)

      While testing my AntiCheat, I encountered an issue with the Minecraft code that results in inaccurate knockback. Specifically, when attacking entities, the knockback does not occur in the direction the player intended. Upon careful examination of the code, I have identified the following problem:

      In Minecraft, the ServerboundInteractPacket is utilized when attacking an entity. This packet relies on the player's look vector to apply velocity to the opponent. However, the look vector is only updated by the ServerboundMovePlayerPacket during the world-tick phase. The Minecraft tick process typically follows this sequence: Raytrace, Interaction, World-Tick. As a result, there is a one-tick delay in updating the look vector, which ultimately determines the direction of the knockback during an attack.

      Consequently, the knockback does not get applied accurately in the desired direction, creating the perception that the player is striking in a different direction than intended.

      To address this issue, I propose implementing a solution similar to the one used for the ServerboundUseItemPacket, which synchronizes the position. This can be achieved by sending a ServerboundMovePlayerPacket before the ServerboundInteractPacket. This adjustment will ensure that the look vector is updated in a timely manner, resulting in correct knockback direction.

      I strongly advise making the necessary modifications to the code and thoroughly testing these changes to ensure proper functionality of the knockback mechanism.

            Unassigned Unassigned
            OPNsense OPNsense
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: