Package codechicken.lib.internal.network
Class LoginPacketHandler
java.lang.Object
codechicken.lib.internal.network.LoginPacketHandler
- All Implemented Interfaces:
ICustomPacketHandler,ICustomPacketHandler.ILoginPacketHandler
Created by covers1624 on 5/3/20.
-
Nested Class Summary
Nested classes/interfaces inherited from interface codechicken.lib.packet.ICustomPacketHandler
ICustomPacketHandler.IClientPacketHandler, ICustomPacketHandler.ILoginPacketHandler, ICustomPacketHandler.IServerPacketHandler -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidgatherLoginPackets(BiConsumer<String, Supplier<PacketCustom>> consumer) Called on the server to gather all login packets to be sent to the client.voidhandleLoginPacket(PacketCustom packet, net.minecraft.client.Minecraft mc, net.minecraft.network.protocol.login.ClientLoginPacketListener handler, net.minecraftforge.network.NetworkEvent.Context context) Called on the client to handle a login packet provided throughICustomPacketHandler.ILoginPacketHandler.gatherLoginPackets(java.util.function.BiConsumer<java.lang.String, java.util.function.Supplier<codechicken.lib.packet.PacketCustom>>).
-
Constructor Details
-
LoginPacketHandler
public LoginPacketHandler()
-
-
Method Details
-
gatherLoginPackets
Description copied from interface:ICustomPacketHandler.ILoginPacketHandlerCalled on the server to gather all login packets to be sent to the client. Unlike usual PacketCustom operation, Login packets are handled differently in FML, and require an acknowledgement response to be sent. Login packets must be sent using, this.- Specified by:
gatherLoginPacketsin interfaceICustomPacketHandler.ILoginPacketHandler- Parameters:
consumer- The consumer to accept any packets to be sent, The first generic parameter being a descriptive name for the packet used in FML logging, the second generic being a supplier used to generate the packet. Supplier is used for cleaner scope variable name hiding.
-
handleLoginPacket
public void handleLoginPacket(PacketCustom packet, net.minecraft.client.Minecraft mc, net.minecraft.network.protocol.login.ClientLoginPacketListener handler, net.minecraftforge.network.NetworkEvent.Context context) Description copied from interface:ICustomPacketHandler.ILoginPacketHandlerCalled on the client to handle a login packet provided throughICustomPacketHandler.ILoginPacketHandler.gatherLoginPackets(java.util.function.BiConsumer<java.lang.String, java.util.function.Supplier<codechicken.lib.packet.PacketCustom>>). This method unlike the other handlers, does not sync to the main thread for processing, instead it is fired on the network thread, this is to allow mods to choose if the packet is important in the handshake cycle and must be handled before anything else can continue. If the data isn't critical to the handshake process, feel free to useNetworkEvent.Context.enqueueWork(Runnable)to throw things on the main thread.- Specified by:
handleLoginPacketin interfaceICustomPacketHandler.ILoginPacketHandler- Parameters:
packet- The packet to handle.mc- The Minecraft instance.handler- Vanilla's NetHandler.context- The network context.
-