pmmp / PocketMine-MP

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

Projectile lag, also known as "Pot Lag" #4168

Closed HashimTheArab closed 3 years ago

HashimTheArab commented 3 years ago

This happens with many items, examples being ender pearls and splash potions. A video is attached below showing first the actual result, and second the expected result.

Steps to reproduce the issue

  1. Attempt to throw a potion, ender pearl, or other sort of projectile while scrolling really fast through your hotbar (wont happen 100% of the time)

OS and versions

Plugins

Core v3.1.0, MineReset v3.2.0, MultiWorld v1.5.2, PurePerms v2.0.0

Crashdump, backtrace or other files

https://user-images.githubusercontent.com/13991048/114323341-b5ee7980-9af2-11eb-8259-5137972c801b.mp4

HashimTheArab commented 3 years ago

After some testing, InventoryTransactionPacket is still sent (not sure if its 100% of the time) when theres pot lag, but PlayerInteractEvent is not at all

xDidntPot commented 3 years ago

Every person whos ever PvP'd on a Pocketmine server can confirm this

ethaniccc commented 3 years ago

This can be fixed super easily through plugins (haha plugin go brrt), but regardless

It's caused because of these few lines:

https://github.com/pmmp/PocketMine-MP/blob/547503e8f44d1475def28bda2c0ed068eb24e670/src/pocketmine/Player.php#L2555-L2556

https://github.com/pmmp/PocketMine-MP/blob/547503e8f44d1475def28bda2c0ed068eb24e670/src/pocketmine/Player.php#L2647-L2648

What could be done instead of checking if the item in hand equals the item in the slot, do a check if the hotbar slot in the packet is 0 >= and <= 9 and that the item given in the InventoryTransactionPacket equals the item in the player's inventory in the given hotbar slot (<- probably bad explanation but whatever)

dktapps commented 3 years ago

I don't see why those lines would cause a problem unless the server-side itemstacks were modified externally.

ethaniccc commented 3 years ago

https://streamable.com/ez9fg2

This was done on 3.19.1+dev with 0 plugins, if you'd like me to do it on the latest commit, I can re-do the video

ethaniccc commented 3 years ago

This behaviour also happens on vanilla (local world), which just shows how broken the game is: https://streamable.com/enfu3d

RageDevv commented 3 years ago

ethan has a point tbh

dktapps commented 3 years ago

The most obvious explanation for this that jumps to mind is that the server doesn't know about the change of held item slot by the time the transaction arrives, because the MobEquipmentPacket that updates the selected slot hasn't arrived yet. This can most likely be fixed by updating the server-side held-item index to whatever the transaction says it should be.