pmmp / PocketMine-MP

A server software for Minecraft: Bedrock Edition in PHP
https://pmmp.io
GNU Lesser General Public License v3.0
3.28k stars 1.56k forks source link

PlayerInventory->setHeldItemIndex() may not work in PlayerInteractEvent #4558

Open dktapps opened 3 years ago

dktapps commented 3 years ago

Issue description

As per title. If the server changes the selected hotbar slot, other players will see it, but the player itself will still see themselves holding the original item.

Steps to reproduce the issue

  1. Use https://github.com/dktapps-pm-pl/BlockPickStick
  2. Get a block picking stick
  3. Use it
  4. Notice that the held item slot doesn't change to the newly picked item

OS and versions

Plugins

https://github.com/dktapps-pm-pl/BlockPickStick

dktapps commented 3 years ago

It looks like this is because of the old spam bug. Two transactions arrive: one that is handled by the plugin and updating the held itemslot, and then the second one sets it right back again by doing this: https://github.com/pmmp/PocketMine-MP/blob/f0661999717abc3ed5cefceb4c47b732915761f3/src/network/mcpe/handler/InGamePacketHandler.php#L359