Skip to content

Commit

Permalink
fix login network addon not properly initialized (#3531)
Browse files Browse the repository at this point in the history
  • Loading branch information
deirn authored Jan 17, 2024
1 parent e572f21 commit bf1eca5
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;

import io.netty.util.concurrent.Future;
Expand Down Expand Up @@ -67,11 +66,6 @@ private boolean handlePacket(int queryId, Identifier channelName, PacketByteBuf
this.logger.debug("Handling inbound login response with id {} and channel with name {}", queryId, channelName);

if (this.firstResponse) {
// Register global handlers
for (Map.Entry<Identifier, ClientLoginNetworking.LoginQueryRequestHandler> entry : ClientNetworkingImpl.LOGIN.getHandlers().entrySet()) {
ClientLoginNetworking.registerReceiver(entry.getKey(), entry.getValue());
}

ClientLoginConnectionEvents.QUERY_START.invoker().onLoginQueryStart(this.handler, this.client);
this.firstResponse = false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ abstract class ClientLoginNetworkHandlerMixin implements NetworkHandlerExtension
@Inject(method = "<init>", at = @At("RETURN"))
private void initAddon(CallbackInfo ci) {
this.addon = new ClientLoginNetworkAddon((ClientLoginNetworkHandler) (Object) this, this.client);
// A bit of a hack but it allows the field above to be set in case someone registers handlers during INIT event which refers to said field
this.addon.lateInit();
}

@Inject(method = "onQueryRequest", at = @At(value = "INVOKE", target = "Ljava/util/function/Consumer;accept(Ljava/lang/Object;)V", remap = false, shift = At.Shift.AFTER), cancellable = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,6 @@ public boolean queryTick() {
// Send the compression packet now so clients receive compressed login queries
this.sendCompressionPacket();

// Register global receivers.
for (Map.Entry<Identifier, ServerLoginNetworking.LoginQueryResponseHandler> entry : ServerNetworkingImpl.LOGIN.getHandlers().entrySet()) {
ServerLoginNetworking.registerReceiver(this.handler, entry.getKey(), entry.getValue());
}

ServerLoginConnectionEvents.QUERY_START.invoker().onLoginStart(this.handler, this.server, this, this.waits::add);
this.firstQueryTick = false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ abstract class ServerLoginNetworkHandlerMixin implements NetworkHandlerExtension
@Inject(method = "<init>", at = @At("RETURN"))
private void initAddon(CallbackInfo ci) {
this.addon = new ServerLoginNetworkAddon((ServerLoginNetworkHandler) (Object) this);
// A bit of a hack but it allows the field above to be set in case someone registers handlers during INIT event which refers to said field
this.addon.lateInit();
}

@Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/network/ServerLoginNetworkHandler;tickVerify(Lcom/mojang/authlib/GameProfile;)V"))
Expand Down

0 comments on commit bf1eca5

Please sign in to comment.