mojira.dev
MCPE-78355

Hotbar Slots flicker and improperly switch items when hotkeying

 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. 

 
 

Linked issues

Attachments

Comments 25

[media][media][media]

i lost a uhc because of this bug. i couldn't hot  key from my bow to my sword and i had to fight with my bow. i would truly appreciate it if you fixed this.

i lost a uhc because of this bug. i couldn't hot  key from my bow to my sword and i had to fight with my bow. i would truly appreciate it if you fixed this.

Yeah this is a pretty prominent issue on Bedrock. These type of problems don't even exist on Java

Yeah this is a pretty prominent issue on Bedrock. These type of problems don't even exist on Java

15 more comments

From my own testing you can do this glitch without a food item

Thank you for your report!

However, this issue has been closed as Won't Fix.

If you'd like to post a suggestion or give further feedback, please visit the Minecraft Feedback Site or choose a link below.

Quick Links:
📓 Issue Guidelines – 💬 Mojang Support – 📓 Project Summary – 📧 Suggestions – 📖 Minecraft Wiki

Thank you for your report!

However, this issue has been closed as Won't Fix.

If you'd like to post a suggestion or give further feedback, please visit the Minecraft Feedback Site or choose a link below.

Quick Links:
📓 Issue Guidelines – 💬 Mojang Support – 📓 Project Summary – 📧 Suggestions – 📖 Minecraft Wiki

Why on earth is this "won't fix"?  This is a pretty significant (and annoying) bug, especially since OP said that they could DUP stuff!

Why on earth is this "won't fix"?  This is a pretty significant (and annoying) bug, especially since OP said that they could DUP stuff!

user-6d71e

ambient

(Unassigned)

424607

Confirmed

Windows

windows 10

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, 1.16.201 Hotfix, 1.16.221 Hotfix, 1.17.41 Hotfix, 1.18.12 Hotfix

Retrieved