Search in sources :

Example 1 with RegistryManager

use of net.minecraftforge.registries.RegistryManager in project MinecraftForge by MinecraftForge.

the class NetworkInitialization method getHandshakeChannel.

public static SimpleChannel getHandshakeChannel() {
    SimpleChannel handshakeChannel = NetworkRegistry.ChannelBuilder.named(NetworkConstants.FML_HANDSHAKE_RESOURCE).clientAcceptedVersions(a -> true).serverAcceptedVersions(a -> true).networkProtocolVersion(() -> NetworkConstants.NETVERSION).simpleChannel();
    handshakeChannel.messageBuilder(HandshakeMessages.C2SAcknowledge.class, 99, NetworkDirection.LOGIN_TO_SERVER).loginIndex(HandshakeMessages.LoginIndexedMessage::getLoginIndex, HandshakeMessages.LoginIndexedMessage::setLoginIndex).decoder(HandshakeMessages.C2SAcknowledge::decode).encoder(HandshakeMessages.C2SAcknowledge::encode).consumer(HandshakeHandler.indexFirst(HandshakeHandler::handleClientAck)).add();
    handshakeChannel.messageBuilder(HandshakeMessages.S2CModList.class, 1, NetworkDirection.LOGIN_TO_CLIENT).loginIndex(HandshakeMessages.LoginIndexedMessage::getLoginIndex, HandshakeMessages.LoginIndexedMessage::setLoginIndex).decoder(HandshakeMessages.S2CModList::decode).encoder(HandshakeMessages.S2CModList::encode).markAsLoginPacket().consumer(HandshakeHandler.biConsumerFor(HandshakeHandler::handleServerModListOnClient)).add();
    handshakeChannel.messageBuilder(HandshakeMessages.C2SModListReply.class, 2, NetworkDirection.LOGIN_TO_SERVER).loginIndex(HandshakeMessages.LoginIndexedMessage::getLoginIndex, HandshakeMessages.LoginIndexedMessage::setLoginIndex).decoder(HandshakeMessages.C2SModListReply::decode).encoder(HandshakeMessages.C2SModListReply::encode).consumer(HandshakeHandler.indexFirst(HandshakeHandler::handleClientModListOnServer)).add();
    handshakeChannel.messageBuilder(HandshakeMessages.S2CRegistry.class, 3, NetworkDirection.LOGIN_TO_CLIENT).loginIndex(HandshakeMessages.LoginIndexedMessage::getLoginIndex, HandshakeMessages.LoginIndexedMessage::setLoginIndex).decoder(HandshakeMessages.S2CRegistry::decode).encoder(HandshakeMessages.S2CRegistry::encode).buildLoginPacketList(// TODO: Make this non-static, and store a cache on the client.
    RegistryManager::generateRegistryPackets).consumer(HandshakeHandler.biConsumerFor(HandshakeHandler::handleRegistryMessage)).add();
    handshakeChannel.messageBuilder(HandshakeMessages.S2CConfigData.class, 4, NetworkDirection.LOGIN_TO_CLIENT).loginIndex(HandshakeMessages.LoginIndexedMessage::getLoginIndex, HandshakeMessages.LoginIndexedMessage::setLoginIndex).decoder(HandshakeMessages.S2CConfigData::decode).encoder(HandshakeMessages.S2CConfigData::encode).buildLoginPacketList(ConfigSync.INSTANCE::syncConfigs).consumer(HandshakeHandler.biConsumerFor(HandshakeHandler::handleConfigSync)).add();
    return handshakeChannel;
}
Also used : Arrays(java.util.Arrays) List(java.util.List) SimpleChannel(net.minecraftforge.network.simple.SimpleChannel) EventNetworkChannel(net.minecraftforge.network.event.EventNetworkChannel) RegistryManager(net.minecraftforge.registries.RegistryManager) SimpleChannel(net.minecraftforge.network.simple.SimpleChannel) RegistryManager(net.minecraftforge.registries.RegistryManager)

Aggregations

Arrays (java.util.Arrays)1 List (java.util.List)1 EventNetworkChannel (net.minecraftforge.network.event.EventNetworkChannel)1 SimpleChannel (net.minecraftforge.network.simple.SimpleChannel)1 RegistryManager (net.minecraftforge.registries.RegistryManager)1