Class ClientNetworking
java.lang.Object
io.github.fablabsmc.fablabs.api.networking.v1.client.ClientNetworking
@Environment(CLIENT) public final class ClientNetworking extends Object
Offers access to client-side networking functionalities.
Client-side networking functionalities include receiving clientbound packets, sending serverbound packets, and events related to client-side network handlers.
This class should be only used on the physical client and for the logical client.
- See Also:
ServerNetworking
-
Field Summary
Fields Modifier and Type Field Description static Event<PacketChannelCallback<net.minecraft.client.network.ClientPlayNetworkHandler>>
CHANNEL_REGISTERED
An event for the client play network handler receiving an update indicating the connected server's ability to receive packets in certain channels.static Event<PacketChannelCallback<net.minecraft.client.network.ClientPlayNetworkHandler>>
CHANNEL_UNREGISTERED
An event for the client play network handler receiving an update indicating the connected server's lack of ability to receive packets in certain channels.static Event<PacketListenerCallback<net.minecraft.client.network.ClientPlayNetworkHandler>>
PLAY_DISCONNECTED
An event for the disconnection of the client play network handler.static Event<PacketListenerCallback<net.minecraft.client.network.ClientPlayNetworkHandler>>
PLAY_INITIALIZED
An event for the initialization of the client play network handler. -
Constructor Summary
Constructors Constructor Description ClientNetworking()
-
Method Summary
Modifier and Type Method Description static PacketReceiver<ClientLoginContext>
getLoginReceiver()
Returns the packet receiver for channel handler registration on client login network handlers, receivinglogin query request packets
.static PacketReceiver<ClientPlayContext>
getPlayReceiver()
Returns the packet receiver for channel handler registration on client play network handlers, receivingserver to client custom payload packets
.static PlayPacketSender
getPlaySender()
Returns the packet sender for the current client player.static PlayPacketSender
getPlaySender(net.minecraft.client.network.ClientPlayNetworkHandler handler)
Returns the packet sender for a client play network handler.
-
Field Details
-
PLAY_INITIALIZED
public static final Event<PacketListenerCallback<net.minecraft.client.network.ClientPlayNetworkHandler>> PLAY_INITIALIZEDAn event for the initialization of the client play network handler.At this stage, the network handler is ready to send packets to the server. Use
getPlaySender(ClientPlayNetworkHandler)
to obtain the packet sender in the callback. -
PLAY_DISCONNECTED
public static final Event<PacketListenerCallback<net.minecraft.client.network.ClientPlayNetworkHandler>> PLAY_DISCONNECTEDAn event for the disconnection of the client play network handler.No packets should be sent when this event is invoked.
-
CHANNEL_REGISTERED
public static final Event<PacketChannelCallback<net.minecraft.client.network.ClientPlayNetworkHandler>> CHANNEL_REGISTEREDAn event for the client play network handler receiving an update indicating the connected server's ability to receive packets in certain channels.- See Also:
PlayPacketSender.hasChannel(Identifier)
-
CHANNEL_UNREGISTERED
public static final Event<PacketChannelCallback<net.minecraft.client.network.ClientPlayNetworkHandler>> CHANNEL_UNREGISTEREDAn event for the client play network handler receiving an update indicating the connected server's lack of ability to receive packets in certain channels.- See Also:
PlayPacketSender.hasChannel(Identifier)
-
-
Constructor Details
-
ClientNetworking
public ClientNetworking()
-
-
Method Details
-
getPlaySender
Returns the packet sender for the current client player.This is a shortcut method for getting a sender. When a client play network handler is available,
getPlaySender(ClientPlayNetworkHandler)
is preferred.- Returns:
- the packet sender for the current client player
- Throws:
IllegalStateException
- if the client's player isnull
-
getPlaySender
public static PlayPacketSender getPlaySender(net.minecraft.client.network.ClientPlayNetworkHandler handler)Returns the packet sender for a client play network handler.- Parameters:
handler
- a client play network handler- Returns:
- the associated packet sender
-
getPlayReceiver
Returns the packet receiver for channel handler registration on client play network handlers, receivingserver to client custom payload packets
. -
getLoginReceiver
Returns the packet receiver for channel handler registration on client login network handlers, receivinglogin query request packets
.
-