fix login network addon not properly initialized ()

This commit is contained in:
deirn 2024-01-18 00:55:42 +07:00 committed by GitHub
parent e572f21602
commit bf1eca5483
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 4 additions and 11 deletions
fabric-networking-api-v1/src
client/java/net/fabricmc/fabric
impl/networking/client
mixin/networking/client
main/java/net/fabricmc/fabric

View file

@ -18,7 +18,6 @@ package net.fabricmc.fabric.impl.networking.client;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import io.netty.util.concurrent.Future;
@ -67,11 +66,6 @@ public final class ClientLoginNetworkAddon extends AbstractNetworkAddon<ClientLo
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;
}

View file

@ -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)

View file

@ -80,11 +80,6 @@ public final class ServerLoginNetworkAddon extends AbstractNetworkAddon<ServerLo
// 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;
}

View file

@ -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"))