Uploaded image for project: 'Minecraft (Bedrock codebase)'
  1. Minecraft (Bedrock codebase)
  2. MCPE-78355

Hotbar Slots flicker and improperly switch items when hotkeying

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • None
    • 1.18.0.24 Beta, 1.16.210.55 Beta, 1.16.210.50 Beta, 1.16.200.55 Beta, 1.16.200.53 Beta, 1.16.200.52 Beta, 1.16.200.51 Beta, 1.16.100.60 Beta, 1.16.30.53 RTX Beta, 1.16.100.58 Beta, 1.16.100.56 Beta, 1.15.0.11 RTX Beta, 1.16.100.50 Beta, 1.16.20.54 Beta, 1.15.0.9 RTX Beta, 1.16.0.68 Beta, 1.16.0.67 Beta, 1.15.0.8 RTX Beta, 1.16.0.61 Beta, 1.14.60 Hotfix, 1.16.0, 1.16.1, 1.16.10, 1.16.42 (PS4), 1.16.50 Hotfix (iOS), 1.16.40 Hotfix, 1.16.61 (PS4), 1.16.100.59 Beta, 1.16.100, 1.16.101 Hotfix, 1.16.200, 1.16.201 Hotfix, 1.16.221 Hotfix, 1.17.41 Hotfix, 1.18.12 Hotfix
    • None
    • Confirmed
    • Windows
    • 424607

       Expected Behavior: when using hotkeys or switching items rapidly, the transition between using items is seamless and the item held in hand and hotbar selected match. No desync occurs , similar to the superior inventory system on the java edition

      Actual behavior: Particularly when switching between items that can be used or interacted with, switching hotbar slots as soon as an item is used can cause a desync to occur, often leading to hotbar "flickering", causing the server to update the clients inventory to the slot previously selected, and canceling the transaction.

      The root cause of this issue is the client sending the MobEquipmentPacket after it sends the ItemStackRequestPacket (or inventoryTransactionPacket if ItemStackNetManager is disabled, issue still occurs). The server then reads this transaction as an InventoryTransactionError type SlotMismatch and treats it as such. 

      There are 2 ways this issue can be fixed. The first way is of course to change the ordering of the MobEquipmentPacket being sent so its done in the proper order. The second way, (which I tested and works fine) would be serverside, but it requires the server to trust the slot that the client uses. Here is some pseudocode:

      InventoryTransactionError ItemUseInventoryTransaction::handle(ItemUseInventoryTransaction *transaction, Player *player, bool isSenderAuthority) {
          if (transaction->mSlot != player->getInventory().mSelectedSlot) {
              setHotbarSlot(player, transaction->mSlot);
          }
          // rest of function
      }

      the same process would need to be done for ItemUseOnActorInventoryTransaction::handle

       

      How to reproduce:
      There are many ways to reproduce this bug. However, I find that the easiest and most efficient way to replicate this bug is to do the following:

      -give yourself a food item, such as a golden apple.
      -give yourself an interactable item such as a fishing rod
      -eat the golden apple, but as soon as you eat it, hotkey to your fishing rod while still holding down right click.
            -> the desync occurs, you can cast a fishing rod while holding a golden apple.

      The video below shows me doing the example. I have successfully duped some items in my hotbar while taking advantage of this bug, and I think it is important to be fixed.

      https://youtu.be/Y2n81_VYrS0

      Other examples/ways to reproduce the bug:

      https://youtu.be/DGt6o-YELvs

      In the video above, I attempt to switch to the golden apple after placing blocks. If you look closely, my hotbar slot switches to the golden apple but instantly flickers back to the blocks. The client attempts to switch to the golden apple but the server attempts to correct this by switching back to the blocks. I believe this is because the client is sending hotbar switching packets out of order, or sends a separate packet for using an item and switching items, allowing for a desync to occur. 

      https://youtu.be/KGoSmDsCHKY

      In this next video above, I give the same input to replicate the bug, but the server doesnt correct my hotbar slot instantly. Instead, it delays switching my hotbar slot back to the blocks but I am still holding a golden apple, given by the fact that it renders as an item on my screen. 

       
       

            ambient ambient
            Votes:
            40 Vote for this issue
            Watchers:
            16 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: