NetworkSession: add support for discarding repeated packets before th…
…ey're decoded
this dramatically reduces the server workload dealing with spammy packets like right-click interactions trigger. It also solves the problem of players getting kicked for right-clicking for too long.
Related issues & PRs
Fixes #5728 in local testing
Changes
API changes
No public API changes.
The network system has some new functions supporting this feature, but these are not part of the versioned API (as with all pocketmine\network\mcpe stuff).
Behavioural changes
The server will now discard InventoryTransactionPacket when repeated.
This may result in a performance improvement in some servers.
Follow-up
Maybe filter out more spammy c2s packets, like AnimatePacket?
Tests
Locally tested with the "Improved input response" toggle in the client set to ON.
Caveats
I'm not sure if doing this might have unintended side effects. So far as I know, there is no obvious reason to send the same transaction multiple times, but I may have overlooked something. Please test thoroughly and feedback.
https://github.com/user-attachments/assets/694eab42-c1f9-47d9-9b01-65f28eaa71e6
Not too sure how to resolve that issue. I could have it expire the filter after 1 tick, but it might still result in legit actions disappearing in certain conditions.
The latest commit of the PR should work better for your case @kostamax27, it's now more conservative than before