Esempio n. 1
0
        /// <summary>
        /// Disconnects from the minecraft server (if connected) and resets the client's variables.
        /// </summary>
        public void Disconnect()
        {
            Nm.Disconnect();

            Location = new Vector3S();
            Position = new byte[2];

            Entities.Clear();
            ClientWorld = null;
        }
Esempio n. 2
0
        /// <summary>
        /// Connects to a minecraft server. 
        /// </summary>
        /// <param name="serverNameOrUrl">Can be the name of the server, the full server play url, or left blank.</param>
        /// <param name="isUrl">Set this to true if 'ServerNameorUrl' is a play url.</param>
        /// <param name="ip">Ip of the server to connect to. Use this if verify names is off.</param>
        /// <param name="port">Port of the server to connect to. Use this if verify names is off.</param>
        public void Connect(string serverNameOrUrl, bool isUrl, string ip="", int port=0)
        {
            if (VerifyNames) {
                var ls = new ClassicubeInteraction(Username, Password);

                if (!ls.Login()) {
                    RaiseErrorMessage("Failed to verify name.");
                    return;
                }

                var myServer = isUrl ? ls.GetServerByUrl(serverNameOrUrl) : ls.GetServerInfo(serverNameOrUrl);

                Ip = myServer.Ip;
                Port = myServer.Port;
                MpPass = myServer.Mppass;
            } else {
                Ip = ip;
                Port = port;
            }

            Entities = new Dictionary<sbyte, Entity>();
            ClientWorld = new WorldContainer();

            Nm = new NetworkManager(this);
            Nm.Connect();
        }