Class FMLHandshakeHandler
An instance is created during CHandshakePacket handling, and attached
 to the NetworkManager.channel via FMLNetworkConstants.FML_HANDSHAKE_HANDLER.
 
The FMLNetworkConstants.handshakeChannel is a SimpleChannel with standard messages flowing in both directions.
 
The loginWrapper transforms these messages into CCustomPayloadLoginPacket
 and SCustomPayloadLoginPacket compatible messages, by means of wrapping.
 
The handshake is ticked tickLogin(NetworkManager) from the ServerLoginNetHandler#update() method,
 utilizing the ServerLoginNetHandler.State#NEGOTIATING state, which is otherwise unused in vanilla code.
 
During client to server initiation, on the server, the NetworkEvent.GatherLoginPayloadsEvent is fired,
 which solicits all registered channels at the NetworkRegistry for any
 NetworkRegistry.LoginPayload they wish to supply.
 
The collected NetworkRegistry.LoginPayload are sent, one per tick, via
 the FMLLoginWrapper.wrapPacket(ResourceLocation, PacketBuffer) mechanism to the incoming client connection. Each
 packet is indexed via net.minecraft.network.login.client.CCustomPayloadLoginPacket#transaction, which is
 the only mechanism available for tracking request/response pairs.
 
Each packet sent from the server should be replied by the client, though not necessarily in sent order. The reply
 should contain the index of the server's packet it is replying to. The FMLLoginWrapper class handles indexing
 replies correctly automatically.
 
Once all packets have been dispatched, we wait for all replies to be received. Once all replies are received, the final login phase will commence.
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprivate final NetworkDirection(package private) static final org.apache.logging.log4j.Markerprivate static final org.apache.logging.log4j.Loggerprivate static final FMLLoginWrapperprivate final NetworkManagerprivate List<NetworkRegistry.LoginPayload>private intprivate Set<ResourceLocation>private Map<ResourceLocation,String> private Map<ResourceLocation,ForgeRegistry.Snapshot> 
- 
Constructor SummaryConstructorsModifierConstructorDescriptionprivateFMLHandshakeHandler(NetworkManager networkManager, NetworkDirection side) 
- 
Method SummaryModifier and TypeMethodDescriptionstatic <MSG extends IntSupplier>
 BiConsumer<MSG,Supplier<NetworkEvent.Context>> biConsumerFor(ThreeConsumer<FMLHandshakeHandler, ? super MSG, ? super Supplier<NetworkEvent.Context>> consumer) Transforms a two-argument instance method reference into aBiConsumerbased on thegetHandshake(Supplier)function.private static FMLHandshakeHandlergetHandshake(Supplier<NetworkEvent.Context> contextSupplier) Retrieve the handshake from theNetworkEvent.Context(package private) voidhandleClientAck(FMLHandshakeMessages.C2SAcknowledge msg, Supplier<NetworkEvent.Context> contextSupplier) (package private) voidhandleClientModListOnServer(FMLHandshakeMessages.C2SModListReply clientModList, Supplier<NetworkEvent.Context> c) (package private) voidhandleConfigSync(FMLHandshakeMessages.S2CConfigData msg, Supplier<NetworkEvent.Context> contextSupplier) (package private) <MSG extends IntSupplier>
 voidhandleIndexedMessage(MSG message, Supplier<NetworkEvent.Context> c) private booleanhandleRegistryLoading(Supplier<NetworkEvent.Context> contextSupplier) (package private) voidhandleRegistryMessage(FMLHandshakeMessages.S2CRegistry registryPacket, Supplier<NetworkEvent.Context> contextSupplier) (package private) voidhandleServerModListOnClient(FMLHandshakeMessages.S2CModList serverModList, Supplier<NetworkEvent.Context> c) static <MSG extends IntSupplier>
 BiConsumer<MSG,Supplier<NetworkEvent.Context>> Transforms a two-argument instance method reference into aBiConsumerbiConsumerFor(ThreeConsumer), first calling the#handleIndexedMessage(FMLHandshakeMessages.LoginIndexedMessage, Supplier)method to handle index tracking.(package private) static voidregisterHandshake(NetworkManager manager, NetworkDirection direction) Create a new handshake instance.(package private) static booleantickLogin(NetworkManager networkManager) booleanFML will send packets, from Server to Client, from the messages queue until the queue is drained.
- 
Field Details- 
FMLHSMARKERstatic final org.apache.logging.log4j.Marker FMLHSMARKER
- 
LOGGERprivate static final org.apache.logging.log4j.Logger LOGGER
- 
loginWrapper
- 
messageList
- 
sentMessages
- 
direction
- 
manager
- 
packetPositionprivate int packetPosition
- 
registrySnapshots
- 
registriesToReceive
- 
registryHashes
 
- 
- 
Constructor Details- 
FMLHandshakeHandler
 
- 
- 
Method Details- 
registerHandshakeCreate a new handshake instance. Called when connection is first created during theCHandshakePackethandling.- Parameters:
- manager- The network manager for this connection
- direction- The- NetworkDirectionfor this connection:- NetworkDirection.LOGIN_TO_SERVERor- NetworkDirection.LOGIN_TO_CLIENT
 
- 
tickLogin
- 
biConsumerForpublic static <MSG extends IntSupplier> BiConsumer<MSG,Supplier<NetworkEvent.Context>> biConsumerFor(ThreeConsumer<FMLHandshakeHandler, ? super MSG, ? super Supplier<NetworkEvent.Context>> consumer) Transforms a two-argument instance method reference into aBiConsumerbased on thegetHandshake(Supplier)function. This should only be used for login message types.- Type Parameters:
- MSG- message type
- Parameters:
- consumer- A two argument instance method reference
- Returns:
- A BiConsumerfor use in message handling
 
- 
indexFirstpublic static <MSG extends IntSupplier> BiConsumer<MSG,Supplier<NetworkEvent.Context>> indexFirst(ThreeConsumer<FMLHandshakeHandler, MSG, Supplier<NetworkEvent.Context>> next) Transforms a two-argument instance method reference into aBiConsumerbiConsumerFor(ThreeConsumer), first calling the#handleIndexedMessage(FMLHandshakeMessages.LoginIndexedMessage, Supplier)method to handle index tracking. Used for client to server replies. This should only be used for login messages.- Type Parameters:
- MSG- message type
- Parameters:
- next- The method reference to call after index handling
- Returns:
- A BiConsumerfor use in message handling
 
- 
getHandshakeRetrieve the handshake from theNetworkEvent.Context- Parameters:
- contextSupplier- the- NetworkEvent.Context
- Returns:
- The handshake handler for the connection
 
- 
handleServerModListOnClientvoid handleServerModListOnClient(FMLHandshakeMessages.S2CModList serverModList, Supplier<NetworkEvent.Context> c) 
- 
handleIndexedMessage
- 
handleClientModListOnServervoid handleClientModListOnServer(FMLHandshakeMessages.C2SModListReply clientModList, Supplier<NetworkEvent.Context> c) 
- 
handleRegistryMessagevoid handleRegistryMessage(FMLHandshakeMessages.S2CRegistry registryPacket, Supplier<NetworkEvent.Context> contextSupplier) 
- 
handleRegistryLoading
- 
handleClientAckvoid handleClientAck(FMLHandshakeMessages.C2SAcknowledge msg, Supplier<NetworkEvent.Context> contextSupplier) 
- 
handleConfigSyncvoid handleConfigSync(FMLHandshakeMessages.S2CConfigData msg, Supplier<NetworkEvent.Context> contextSupplier) 
- 
tickServerpublic boolean tickServer()FML will send packets, from Server to Client, from the messages queue until the queue is drained. Each message will be indexed, and placed into the "pending acknowledgement" queue. As indexed packets are received at the server, they will be removed from the "pending acknowledgement" queue. Once the pending queue is drained, this method returns true - indicating that login processing can proceed to the next step.- Returns:
- true if there is no more need to tick this login connection.
 
 
-