Interface ClientLoginContext

All Superinterfaces:
ClientContext, ListenerContext

@Environment(CLIENT)
public interface ClientLoginContext
extends ClientContext
Represents the context for ClientNetworking.getLoginReceiver(), in which a login query request packest is received.

Compared to other type of packet reception context, the client login query packet reception is expected to respond after receiving a packet. Use respond methods to send a response; if none of the respond methods are called immediately within ChannelHandler.receive(io.github.fablabsmc.fablabs.api.networking.v1.ListenerContext, PacketByteBuf), a "not understood" response will be sent to the server. If a response cannot be calculated immediately, use respond(CompletableFuture) or respond(CompletableFuture, GenericFutureListener), which can send the response when the CompletableFuture is completed.

See Also:
ClientNetworking.getLoginReceiver()
  • Method Summary

    Modifier and Type Method Description
    net.minecraft.client.network.ClientLoginNetworkHandler getListener()
    Returns the packet listener that received this packet.
    void respond​(CompletableFuture<? extends net.minecraft.network.PacketByteBuf> future)
    Schedule to send a response to the server when the future is completed.
    void respond​(CompletableFuture<? extends net.minecraft.network.PacketByteBuf> future, GenericFutureListener<? extends Future<? super Void>> callback)
    Schedule to send a response to the server when the future is completed.
    void respond​(net.minecraft.network.PacketByteBuf buf)
    Sends a response to the server.
    void respond​(net.minecraft.network.PacketByteBuf buf, GenericFutureListener<? extends Future<? super Void>> callback)
    Sends a response to the server.

    Methods inherited from interface io.github.fablabsmc.fablabs.api.networking.v1.client.ClientContext

    getEngine
  • Method Details

    • getListener

      net.minecraft.client.network.ClientLoginNetworkHandler getListener()
      Returns the packet listener that received this packet.

      The packet listener offers access to the connection.

      In a client login context, the network handler is always a ClientLoginNetworkHandler.

      Specified by:
      getListener in interface ListenerContext
      Returns:
      the packet listener
    • respond

      void respond​(net.minecraft.network.PacketByteBuf buf)
      Sends a response to the server.

      The response may be null to indicate a "not understood" query response.

      Parameters:
      buf - the content of the response, may be null
    • respond

      void respond​(net.minecraft.network.PacketByteBuf buf, GenericFutureListener<? extends Future<? super Void>> callback)
      Sends a response to the server.

      The response may be null to indicate a "not understood" query response.

      Parameters:
      buf - the content of the response, may be null
      callback - a callback when the response is sent, may be null
    • respond

      void respond​(CompletableFuture<? extends net.minecraft.network.PacketByteBuf> future)
      Schedule to send a response to the server when the future is completed.

      If the future completed with null result, a "not understood" query response is sent to the server.

      If the future completed exceptionally, a "not understood" query response is sent to the server.

      Parameters:
      future - the future that calculates the response
    • respond

      void respond​(CompletableFuture<? extends net.minecraft.network.PacketByteBuf> future, GenericFutureListener<? extends Future<? super Void>> callback)
      Schedule to send a response to the server when the future is completed.

      If the future completed with null result, a "not understood" query response is sent to the server.

      If the future completed exceptionally, a "not understood" query response is sent to the server.

      Parameters:
      future - the future that calculates the response
      callback - a callback when the response is sent, may be null