New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Player: Experimental new movement processing system #2646
Conversation
This should make use of real time instead of ticks to reduce lag problems. |
This can be enhanced by ignoring movements which only involve rotation compared to the previous movement, since rotation has no effect on movement distance. |
I've been testing this and the only bug I've noticed was when falling from a very large height (32,000 to less than 20,000) you lose hunger rapidly, which isn't like that in vanilla. |
This pull is overcomplicated. This change could be better implemented by removing buffering entirely and implementing a simple network-layer rate-limit, which would also cooperate better with things like block placement. I'm closing this due to being stale and having conflicts. |
#3167) Introduction This PR is a second attempt at improving movement processing to fix #1215 , #2730 and more. This is significantly less complex than the previous attempt #2646 -- it gets rid of the movement buffering system entirely and instead relies on a simple rate limit counter to restrict on-the-fly movement processing. Movement is rate limited to a max average of 2 per tick. It allows up to 5 seconds' backlog to accommodate network lag. The rate limit counter is increased by 2 per tick and decreased once for every movement processed. This prevents movement processing being abused for denial of service attacks. Changes API changes This PR, while obviously highly beneficial for most current users, poses some BC-breaking issues because of changes to the internal Player API. Player->processMovement() (protected) has been removed. This is a BC concern for custom player classes which overrode it and called it as a parent. In addition, child implementations won't be called every tick any more, which could break some custom movement processing systems. Player->newPosition (protected) has been removed. This internal field may have been accessed by custom movement implementations. Player->isTeleporting (protected) has been removed. BC concern is same as previous point. Player->getNextPosition() (public) has been @deprecated. Added the following protected Player class members: int $moveRateLimit ?Vector3 $forceMoveSync handleMovement() processMostRecentMovements() revertMovement() Behavioural changes Player movement is now subject to less rubberbanding and has more reliable behaviour.
Introduction
The existing movement system is problematic because it only processes the last movement received on a tick. This can be a problem on laggy connections. Even when not on a laggy connection, this can cause problems like anti-cheat triggering falsely (anti fly not seeing players touch ground), the infamous "moved too fast", and more.
This PR changes movement processing to use a pending movement queue instead of only processing the last movement. This allows much more effective recovery from network lag spikes without rubberbanding. With this in place, appearances of
moved too fast
will be significantly reduced.This has been carefully designed to avoid exposing the server to attack vectors, but it is not complete on the security front yet.
Relevant issues
moved too fast
is also significantly reduced.