-
-
Notifications
You must be signed in to change notification settings - Fork 257
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
fix invalid packet types due to state mismatch when calling packet events #2568
Conversation
When will this be merged? Should I directly build and use this PR? |
I'm getting this error when using the version with this PR, is it InteractiveChat's fault?
|
@SrBedrock yes, it's not related with this PR (maybe indirectly, but still not the PRs fault) |
When using the master version the error does not occur, I will wait for the PR to be accepted to report it to the plugin dev. |
@LOOHP you mind taking a look? |
@SrBedrock Mind if I know which version of Minecraft you produced that error? |
|
@derklaro Here's the code that registered the packet listener and here's is the line of code that threw the error. As far as I'm aware, |
In 1.20.2 Mojang decided to share some packet classes between the play and configuration state. This leads to an issue that resolving the packet type by class is no longer possible, as it either returns only the play or the configuration state packet type. Therefore we need to register packets based on 2 keys: protocol and class.
I also rewrote how we retreive the protocol state, as in 1.20.2 the client and server direction can be in different protocol states. The resolve process works by using the protocol specific AttributeKey(s):
When sending or receiving a packet the protocol state is resolved from the wrapped channel and then the correct packet type is selected when calling the packet event. This fix was confirmed to work by the reporter in #2552 (comment) .
For the future Mojang might decide to not even make two classes for the same packet anymore (for example KeepAlive could be shared between states and directions). In that case we need to extend the packet registry to also handle that, but for now this fix does the job good enough imo.
Closes #2561, Closes #2552