public void handleHandshake(Packet2Handshake par1Packet2Handshake)
    {
        boolean var2 = true;
        String var3 = par1Packet2Handshake.username;

        if (var3 != null && var3.trim().length() != 0)
        {
            if (!var3.equals("-"))
            {
                try
                {
                    Long.parseLong(var3, 16);
                }
                catch (NumberFormatException var8)
                {
                    var2 = false;
                }
            }
        }
        else
        {
            var2 = false;
        }

        if (!var2)
        {
            this.netManager.networkShutdown("disconnect.genericReason", new Object[] {"The server responded with an invalid server key"});
        }
        else if (par1Packet2Handshake.username.equals("-"))
        {
            /**
             * We use some of the unused fields in Packet 001 Login to identify the user as having Forge installed.
             * This allows modded clients to connect to Vanilla server without crashing.
             * It also allows unmodded clients to connect to Forge server without crashing. 
             * Its a bit of a dirty hack, but it doesnt interrupt the login flow, and its unused data.
             * The C->S serverMode is set to the hash code of the string "Forge", this should provide a fairly unique 
             * identifier so we are certain it is not random, and it is Forge installed.
             * The C->S dimension is set to the current Forge build number, in case we need to do any quick version checks.
             */
            Packet1Login pkt = new Packet1Login(mc.session.username, 29);
            pkt.serverMode    = ForgePacket.FORGE_ID;
            pkt.field_48170_e = ForgeHooks.buildVersion;
            addToSendQueue(pkt);
        }
        else
        {
            try
            {
                URL var4 = new URL("http://session.minecraft.net/game/joinserver.jsp?user=" + this.mc.session.username + "&sessionId=" + this.mc.session.sessionId + "&serverId=" + par1Packet2Handshake.username);
                BufferedReader var5 = new BufferedReader(new InputStreamReader(var4.openStream()));
                String var6 = var5.readLine();
                var5.close();

                if (var6.equalsIgnoreCase("ok"))
                {
                    /**
                     * We use some of the unused fields in Packet 001 Login to identify the user as having Forge installed.
                     * This allows modded clients to connect to Vanilla server without crashing.
                     * It also allows unmodded clients to connect to Forge server without crashing. 
                     * Its a bit of a dirty hack, but it doesnt interrupt the login flow, and its unused data.
                     * The C->S serverMode is set to the hash code of the string "Forge", this should provide a fairly unique 
                     * identifier so we are certain it is not random, and it is Forge installed.
                     * The C->S dimension is set to the current Forge build number, in case we need to do any quick version checks.
                     */
                    Packet1Login pkt = new Packet1Login(mc.session.username, 29);
                    pkt.serverMode    = ForgePacket.FORGE_ID;
                    pkt.field_48170_e = ForgeHooks.buildVersion;
                    addToSendQueue(pkt);
                }
                else
                {
                    this.netManager.networkShutdown("disconnect.loginFailedInfo", new Object[] {var6});
                }
            }
            catch (Exception var7)
            {
                var7.printStackTrace();
                this.netManager.networkShutdown("disconnect.genericReason", new Object[] {"Internal client error: " + var7.toString()});
            }
        }
    }