Exemple #1
0
        public void Update()
        {
            if (!readNet || !connectionInfo.socketWrapper.IsConnected())
            {
                return;
            }

            try
            {
                while (connectionInfo.socketWrapper.HasDataAvailable())
                {
                    Packet packet = packetReadWriter.ReadNext();
                    HandlePacket(packet);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                readNet = false;
            }
        }
        /// <summary>
        /// Completes the Minecraft Forge handshake.
        /// </summary>
        /// <returns>Whether the handshake was successful.</returns>
        public bool CompleteForgeHandshake()
        {
            if (ForgeEnabled())
            {
                while (fmlHandshakeState != FMLHandshakeClientState.DONE)
                {
                    Packet packet = packetReadWriter.ReadNext();

                    if (packet.id == 0x40) // Disconnect
                    {
                        mcHandler.OnConnectionLost(DisconnectReason.LoginRejected, ChatParser.ParseText(dataTypes.ReadNextString(packet.data)));
                        return(false);
                    }
                    else
                    {
                        // Send back regular packet to the vanilla protocol handler
                        protocol18.HandlePacket(packet);
                    }
                }
            }
            return(true);
        }