private void ClientForm_Load(object sender, EventArgs e)
 {
     Client = new MinecraftClient(Program.Session);
     Client.ChatMessage += Client_ChatMessage;
     Client.LoggedIn += Client_LoggedIn;
     Client.Connect(EndPoint);
 }
Example #2
0
        public static void Main(string[] args)
        {
            var endPoint = ParseEndPoint(args[0]);
            var ping = ServerPing.DoPing(endPoint);
            Console.WriteLine("{0}/{1} {2} ({3}): {4}", ping.CurrentPlayers, ping.MaxPlayers, ping.ServerVersion, ping.ProtocolVersion, ping.MotD);

            //var lastLogin = LastLogin.GetLastLogin();
            //var session = Session.DoLogin(lastLogin.Username, lastLogin.Password);
            var session = new Session("TestBot");

            // Connect to server
            var client = new MinecraftClient(session);
            client.Connect(endPoint);

            client.ChatMessage += (sender, e) => Console.WriteLine(e.RawMessage);
            string command;
            do
            {
                command = Console.ReadLine();
                if (command.StartsWith("say "))
                    client.SendChat(command.Substring(4));
            } while (command != "quit");

            client.Disconnect("Quitting");
        }
Example #3
0
        static void Main(string[] args)
        {
            // Set up log providers
            LogProvider.RegisterProvider(new FileLogWriter("packetLog.txt", LogImportance.Low));
            LogProvider.RegisterProvider(new ConsoleLogWriter(LogImportance.High));

            // Set up endpoint, ping server
            var endPoint = ParseEndPoint(args[0]);
            var ping = ServerPing.DoPing(endPoint);
            Console.WriteLine("{0}/{1} {2} ({3}): {4}", ping.CurrentPlayers, ping.MaxPlayers, ping.ServerVersion,
                ping.ProtocolVersion, ping.MotD);

            //var lastLogin = LastLogin.GetLastLogin();
            //var session = Session.DoLogin(lastLogin.Username, lastLogin.Password);
            var session = new Session("TestBot");

            // Connect to server
            var client = new MinecraftClient(session);
            client.Connect(endPoint);

            client.PlayerDied += (s, e) => Console.WriteLine("Player died! Type 'respawn' to respawn.");
            client.Disconnected += (s, e) => Console.WriteLine("Disconnected: " + e.Reason);

            string input = "";
            while (input != "quit")
            {
                input = Console.ReadLine();
                if (input.StartsWith("move "))
                {
                    var parts = input.Split(' ');
                    var amount = double.Parse(parts[2]);
                    var position = client.Position;
                    if (parts[1] == "x")
                        position.X += amount;
                    else if (parts[1] == "y")
                        position.Y += amount;
                    else
                        position.Z += amount;
                    client.Position = position;
                }
                else if (input.StartsWith("look "))
                {
                    var parts = input.Split(' ');
                    var amount = float.Parse(parts[2]);
                    if (parts[1] == "yaw")
                        client.Yaw = amount;
                    else
                        client.Pitch = amount;
                }
                else if (input.StartsWith("say "))
                    client.SendChat(input.Substring(4));
                else if (input == "respawn")
                    client.Respawn();
            }

            client.Disconnect("Quitting");
        }
Example #4
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            //var lastLogin = LastLogin.GetLastLogin();
            var session = new Session("Crafty");//Session.DoLogin(lastLogin.Username, lastLogin.Password);
            var client = new MinecraftClient(session);

            using (var window = new MainWindow(client))
            {
                window.Run(new IPEndPoint(IPAddress.Loopback, 25565));
            }
        }
Example #5
0
        public static void Main(string[] args)
        {
            var endPoint = ParseEndPoint(args[0]);
            var ping = ServerPing.DoPing(endPoint);
            Console.WriteLine("{0}/{1} {2} ({3}): {4} [{5}ms latency]",
                ping.Players.OnlinePlayers,
                ping.Players.MaxPlayers,
                ping.Version.Name,
                ping.Version.ProtocolVersion,
                ping.Description,
                (int)ping.Latency.TotalMilliseconds);
            Console.WriteLine("Player list sample:");
            if (ping.Players.Players != null)
                foreach (var player in ping.Players.Players)
                    Console.WriteLine("{0} ({1})", player.Name, player.Id);
            if (!string.IsNullOrEmpty(ping.Icon))
                Console.WriteLine("Server icon: {0}", ping.Icon);

            //var lastLogin = LastLogin.GetLastLogin();
            //var session = Session.DoLogin(lastLogin.Username, lastLogin.Password);
            var session = new Session("TestBot");

            // Connect to server
            var client = new MinecraftClient(session);
            client.Connect(endPoint);

            client.ChatMessage += (sender, e) => Console.WriteLine(e.RawMessage);
            string command;
            do
            {
                command = Console.ReadLine();
                if (command == null)
                    continue; // MonoDevelop debugger does this sometimes
                if (command.StartsWith("say "))
                    client.SendChat(command.Substring(4));
                if (command == "detect")
                {
                    var coordinates = new Coordinates3D((int)client.Position.X, (int)client.Position.Y - 1, (int)client.Position.Z);
                    Console.WriteLine("Looking up " + coordinates);
                    var id = client.World.GetBlockId(coordinates);
                    Console.WriteLine("Block ID: " + id);
                }
            } while (command != "quit");

            client.Disconnect("Quitting");
        }
Example #6
0
 public static ServerPing DoPing(string address)
 {
     return(DoPing(MinecraftClient.ParseEndPoint(address)));
 }
Example #7
0
 public MainWindow(MinecraftClient client)
 {
     Client = client;
 }
Example #8
0
        static void Main(string[] args)
        {
            // Set up log providers
            LogProvider.RegisterProvider(new FileLogWriter("packetLog.txt", LogImportance.Low));
            LogProvider.RegisterProvider(new ConsoleLogWriter(LogImportance.High));

            // Set up endpoint, ping server
            var ping = ServerPing.DoPing(args[0]);
            Console.WriteLine("{0}/{1} {2} ({3}): {4}", ping.CurrentPlayers, ping.MaxPlayers, ping.ServerVersion,
                ping.ProtocolVersion, ping.MotD);

            //var lastLogin = LastLogin.GetLastLogin();
            //var session = Session.DoLogin(lastLogin.Username, lastLogin.Password);
            var session = new Session("TestBot");

            // Connect to server
            var client = new MinecraftClient(session);
            client.Connect(args[0]);

            client.PlayerDied += (s, e) => Console.WriteLine("Player died! Type 'respawn' to respawn.");
            client.Disconnected += (s, e) => Console.WriteLine("Disconnected: " + e.Reason);

            string input = "";
            while (input != "quit")
            {
                input = Console.ReadLine();
                if (input == null) continue;

                if (input.StartsWith("move "))
                {
                    var parts = input.Split(' ');
                    var amountX = int.Parse(parts[1]);
                    var amountZ = int.Parse(parts[2]);

                    client.Move(amountX, amountZ);
                }
                else if (input.StartsWith("look "))
                {
                    var parts = input.Split(' ');
                    var amount = float.Parse(parts[2]);
                    if (parts[1] == "yaw")
                        client.Yaw = amount;
                    else
                        client.Pitch = amount;
                }
                else if (input.StartsWith("lookat "))
                {
                    var parts = input.Split(' ');
                    var pos = new Vector3
                    {
                        X = double.Parse(parts[1]),
                        Y = double.Parse(parts[2]),
                        Z = double.Parse(parts[3])
                    };

                    client.LookAt(pos);
                }
                else if (input.StartsWith("say "))
                    client.SendChat(input.Substring(4));
                else if (input == "respawn")
                    client.Respawn();
                else if (input == "save")
                    client.World.Save("testWorld", true);
                else if (input == "under")
                    Console.WriteLine(client.World.GetBlock(client.Position + Vector3.Down).GetType().Name);
            }

            client.Disconnect("Quitting");
        }