fix: dispatch ServerJoinEvent once the play connection is established#694
Merged
Merged
Conversation
ServerJoinEvent was posted from the RETURN of the login-handshake handler on ClientHandshakePacketListenerImpl, which runs before the play phase begins. At that point Minecraft.getCurrentServer() is still null, so handlers reading mc.currentServer received null. Re-target the mixin to the play-phase listener ClientPacketListener and inject at the RETURN of handleLogin, where the play connection and world are established and currentServer is populated. handleLogin has a stable name across all supported versions (1.21.1-1.21.11), so the previous handleGameProfile/handleLoginFinished version conditional is no longer needed.
Member
|
thank you mr claude |
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.
Description
ServerJoinEventwas posted from theRETURNof the login-handshake handler onClientHandshakePacketListenerImpl(handleLoginFinishedon 1.21.4+,handleGameProfileon 1.21.1). That handler runs during the login handshake, before the play phase begins, so at that pointMinecraft.getCurrentServer()is still null. Any handler readingmc.currentServerfrom aServerJoinEventtherefore received null, as reported.This re-targets the mixin to the play-phase listener
ClientPacketListenerand injects at theRETURNofhandleLogin, which is where the play connection and world are established andcurrentServeris populated. The event still fires exactly once per join, just at a point where the current-server state is actually available.Because
handleLoginhas a stable name across every supported version (1.21.1 through 1.21.11), the previoushandleGameProfile/handleLoginFinishedversion conditional is no longer needed and has been removed, leaving a single injection target. The event object and theEventManager.INSTANCE.post(ServerJoinEvent.INSTANCE)wiring are unchanged.Related Issue(s)
Fixes #604
Checklist