Class ClientLoginNetworking

java.lang.Object
net.fabricmc.fabric.api.client.networking.v1.ClientLoginNetworking

@Environment(CLIENT)
public final class ClientLoginNetworking
extends Object
Offers access to login stage client-side networking functionalities.

The Minecraft login protocol only allows the client to respond to a server's request, but not initiate one of its own.

See Also:
ClientPlayNetworking, ServerLoginNetworking
  • Method Details

    • registerGlobalReceiver

      public static boolean registerGlobalReceiver​(net.minecraft.util.Identifier channelName, ClientLoginNetworking.LoginQueryRequestHandler queryHandler)
      Registers a handler to a query request channel. A global receiver is registered to all connections, in the present and future.

      If a handler is already registered to the channel, this method will return false, and no change will be made. Use unregisterGlobalReceiver(Identifier) to unregister the existing handler.

      Parameters:
      channelName - the id of the channel
      queryHandler - the handler
      Returns:
      false if a handler is already registered to the channel
      See Also:
      unregisterGlobalReceiver(Identifier), registerReceiver(Identifier, LoginQueryRequestHandler)
    • unregisterGlobalReceiver

      @Nullable public static ClientLoginNetworking.LoginQueryRequestHandler unregisterGlobalReceiver​(net.minecraft.util.Identifier channelName)
      Removes the handler of a query request channel. A global receiver is registered to all connections, in the present and future.

      The channel is guaranteed not to have a handler after this call.

      Parameters:
      channelName - the id of the channel
      Returns:
      the previous handler, or null if no handler was bound to the channel
      See Also:
      registerGlobalReceiver(Identifier, LoginQueryRequestHandler), unregisterReceiver(Identifier)
    • getGlobalReceivers

      public static Set<net.minecraft.util.Identifier> getGlobalReceivers()
      Gets all query request channel names which global receivers are registered for. A global receiver is registered to all connections, in the present and future.
      Returns:
      all channel names which global receivers are registered for.
    • registerReceiver

      public static boolean registerReceiver​(net.minecraft.util.Identifier channelName, ClientLoginNetworking.LoginQueryRequestHandler queryHandler) throws IllegalStateException
      Registers a handler to a query request channel.

      If a handler is already registered to the channelName, this method will return false, and no change will be made. Use unregisterReceiver(Identifier) to unregister the existing handler.

      Parameters:
      channelName - the id of the channel
      queryHandler - the handler
      Returns:
      false if a handler is already registered to the channel name
      Throws:
      IllegalStateException - if the client is not logging in
    • unregisterReceiver

      @Nullable public static @Nullable ClientLoginNetworking.LoginQueryRequestHandler unregisterReceiver​(net.minecraft.util.Identifier channelName) throws IllegalStateException
      Removes the handler of a query request channel.

      The channelName is guaranteed not to have a handler after this call.

      Parameters:
      channelName - the id of the channel
      Returns:
      the previous handler, or null if no handler was bound to the channel name
      Throws:
      IllegalStateException - if the client is not logging in