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:
Switch to hotbar slot 1 via hotkey 1.
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
.
Linked issues
relates to 1
Attachments
Comments 3
Confirmed in 23w44a. The block no longer stays broken client-side (it reappears), but the switch-slot desync still happens. This is essentially the same issue as MC-186770 but in survival.
There are similar issues reported, but i couldn't find an exact duplicate of this one so... can confirm here.