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

Client-Server desync when switching selected hotbar and breaking block at the same time

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • None
    • 1.17.1, 22w11a, 23w44a
    • None
    • Community Consensus
    • (Unassigned)

      Bug

      The client does not syncronize the selected hotbar slot with the server before performing block breaking action, causing client-server desync if the target block interacts differently between items before/after switching.

      To Reproduce

      With default hotkeys

      1. take an efficiency V diamond pickaxe in your hotbar slot 1.
      2. Switch your selected hotbar slot into any non-diamond-pickaxe slot, let's say hotbar slot 2.
      3. Be in survival mode, take haste II effect, pointing towards a stone block.
      4. Perform the following steps in order at the same time:

      1. Switch to hotbar slot 1 via hotkey 1.
      2. Left click to mine the stone block.

      5. Observer the stone block.

      Expected behavior: the stone block breaks, because you switched to the diamond pickaxe before mining the block, and with efficiency V diamond pickaxe + haste II you can instant mine a stone block.
      Actual behavior: the stone block breaks only at the client side. At the server side the stone block remains since the server considered you were mining the stone with the previous hotbar slot item.

      The video in the attachment is an example of the steps above. Recorded in vanilla 1.17.1 single player.

      Code analyze

      Method net.minecraft.client.multiplayer.MultiPlayerGameMode#ensureHasSentCarriedItem is not invoked at the beginning of mining related methods e.g. net.minecraft.client.multiplayer.MultiPlayerGameMode#startDestroyBlock.

            Unassigned Unassigned
            Fallen_Breath Nellaforax
            Votes:
            5 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              CHK: