Fix early Fabric packet send during connection initialization - #65
Open
Miaoshroom wants to merge 1 commit into
Open
Miaoshroom wants to merge 1 commit into
Miaoshroom wants to merge 1 commit into
Conversation
Owner
|
Hmm, interesting |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Use
ServerPlayConnectionEvents.JOINinstead ofINITfor PatPat's Fabric player login callback.Problem
PatPat currently sends its initial hello packet from the Fabric
INITevent. This event is triggered while aServerGamePacketListenerImplis being initialized and does not necessarily represent a fully joined player.Mods such as ServerReplay create synthetic packet listeners for chunk recording. Sending PatPat's packet during their construction can call into the synthetic listener before its fields have been initialized, causing a
NullPointerExceptionand crashing the server.The same lifecycle issue was also observed with Flashback-related compatibility.
Solution
Move the Fabric login callback from
ServerPlayConnectionEvents.INITtoServerPlayConnectionEvents.JOIN.JOINis invoked when the play listener is ready to send packets. Real players still receive exactly one PatPat hello packet after joining, while synthetic listeners that are only initialized do not receive it.Testing
Automated builds and tests passed for both ends of PatPat's supported Fabric range:
bash gradlew :fabric-1.16.5:build --configure-on-demandbash gradlew :fabric-26.1:build --configure-on-demandManual verification confirmed: