//下层时的转向 private void ChangeDIRdown(McTcpClient handler, bool DIR, Location location) { if (DIR) { MoveTo(handler, location + new Location(8, 0, -1)); Thread.Sleep(200); BreakBlock(handler, location + new Location(8, 0, -2)); BreakBlock(handler, location + new Location(8, 0, -3)); BreakBlock(handler, location + new Location(8, 0, -4)); FindBucketAndUse(handler, 8, location + new Location(8, -1, -2)); FindBucketAndUse(handler, 8, location + new Location(8, -1, -3)); FindBucketAndUse(handler, 8, location + new Location(8, -1, -4)); Thread.Sleep(200); MoveTo(handler, location + new Location(8, 0, -2)); Thread.Sleep(200); MoveTo(handler, location + new Location(8, 0, -3)); } else { MoveTo(handler, location + new Location(-8, 0, -1)); Thread.Sleep(200); BreakBlock(handler, location + new Location(-8, 0, -2)); BreakBlock(handler, location + new Location(-8, 0, -3)); BreakBlock(handler, location + new Location(-8, 0, -4)); FindBucketAndUse(handler, 8, location + new Location(-8, -1, -2)); FindBucketAndUse(handler, 8, location + new Location(-8, -1, -3)); FindBucketAndUse(handler, 8, location + new Location(-8, -1, -4)); Thread.Sleep(200); MoveTo(handler, location + new Location(-8, 0, -2)); Thread.Sleep(200); MoveTo(handler, location + new Location(-8, 0, -3)); } }
public override string Run(McTcpClient handler, string command, Dictionary <string, object> localVars) { if (hasArg(command)) { string[] args = getArgs(command); if (args.Length > 0) { if (args[0] == "mainhand" || args[0] == "0") { handler.DoAnimation(0); return("Done"); } else if (args[0] == "offhand" || args[0] == "1") { handler.DoAnimation(1); return("Done"); } else { return(CMDDesc); } } else { return(CMDDesc); } } else { return(CMDDesc); } }
public override string Run(McTcpClient handler, string command, Dictionary <string, object> localVars) { if (hasArg(command)) { string[] temp = getArg(command).Split('='); if (temp.Length > 1) { if (Settings.SetVar(temp[0], getArg(command).Substring(temp[0].Length + 1))) { return(""); //Success } else { return("variable name must be A-Za-z0-9."); } } else { return(CMDDesc); } } else { return(CMDDesc); } }
public override string Run(McTcpClient handler, string command, Dictionary <string, object> localVars) { if (!handler.GetInventoryEnabled()) { return("Please enable InventoryHandling in the config file first."); } if (hasArg(command)) { short slot; try { slot = Convert.ToInt16(getArg(command)); } catch (FormatException) { return("Could not change slot: Not a Number"); } if (slot >= 1 && slot <= 9) { if (handler.ChangeSlot(slot -= 1)) { return("Changed to slot " + (slot += 1)); } else { return("Could not change slot"); } } } return(CMDDesc); }
public override string Run(McTcpClient handler, string command) { if (hasArg(command)) { string[] args = getArgs(command); if (args.Length > 1) { if (!Settings.SetAccount(args[1])) { return("Unknown account '" + args[1] + "'."); } } if (Settings.SetServerIP(args[0])) { Program.Restart(); return(""); } else { return("Invalid server IP '" + args[0] + "'."); } } else { return(CMDDesc); } }
public override string Run(McTcpClient handler, string command) { if (hasArg(command)) { ChatBot.LogToConsole(getArg(command)); return ""; } else return CMDDesc; }
private bool BreakBlock(McTcpClient handler, Location goal) { if (!handler.GetWorld().GetBlock(goal).Type.IsSolid()) { return(false); } handler.DiggingBlock(0, goal); return(true); }
public override string Run(McTcpClient handler, string command) { if (hasArg(command)) { ConsoleIO.WriteLogLine(getArg(command)); return ""; } else return CMDDesc; }
public override string Run(McTcpClient handler, string command) { if (hasArg(command)) { handler.BotLoad(new ChatBots.Script(getArg(command))); return ""; } else return CMDDesc; }
public override string Run(McTcpClient handler, string command) { if (hasArg(command)) { handler.SendText(getArg(command)); return ""; } else return CMDDesc; }
public override string Run(McTcpClient handler, string command, Dictionary <string, object> localVars) { Dictionary <int, Item> items = handler.GetPlayerInventory().Items; foreach (KeyValuePair <int, Item> a in items) { ConsoleIO.WriteLine("Slot: " + a.Key + " ItemID: " + a.Value.ID + ", Count: " + a.Value.Count); } return(""); }
public override string Run(McTcpClient handler, string command) { if (hasArg(command)) { ChatBot.LogToConsole(getArg(command)); return(""); } else { return(CMDDesc); } }
public override string Run(McTcpClient handler, string command, Dictionary <string, object> localVars) { if (hasArg(command)) { handler.BotLoad(new ChatBots.Script(getArg(command), null, localVars)); return(""); } else { return(CMDDesc); } }
public override string Run(McTcpClient handler, string command, Dictionary <string, object> localVars) { if (hasArg(command)) { handler.SendText(getArg(command)); return(""); } else { return(CMDDesc); } }
public override string Run(McTcpClient handler, string command) { if (hasArg(command)) { handler.SendText(getArg(command)); return(""); } else { return(CMDDesc); } }
public override string Run(McTcpClient handler, string command, Dictionary <string, object> localVars) { if (hasArg(command)) { ConsoleIO.WriteLogLine(getArg(command)); return(""); } else { return(CMDDesc); } }
public override string Run(McTcpClient handler, string command, Dictionary <string, object> localVars) { if (hasArg(command)) { Settings.DebugMessages = (getArg(command).ToLower() == "on"); } else { Settings.DebugMessages = !Settings.DebugMessages; } return("Debug messages are now " + (Settings.DebugMessages ? "ON" : "OFF")); }
public override string Run(McTcpClient handler, string command, Dictionary <string, object> localVars) { if (handler.GetInventoryEnabled()) { handler.UseItemOnHand(); return("Used an item"); } else { return("Please enable inventoryhandling in config to use this command."); } }
public override string Run(McTcpClient handler, string command) { if (hasArg(command)) { handler.BotLoad(new ChatBots.Script(getArg(command))); return(""); } else { return(CMDDesc); } }
public override string Run(McTcpClient handler, string command) { if (hasArg(command)) { ConsoleIO.WriteLogLine(getArg(command)); return(""); } else { return(CMDDesc); } }
public override string Run(McTcpClient handler, string command) { string[] args = getArgs(command); if (args.Length > 0) { if (!Settings.setAccount(args[0])) { return "Unknown account '" + args[0] + "'."; } } Program.Restart(); return ""; }
public override string Run(McTcpClient handler, string command) { DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(Status)); WebClient wc = new WebClient(); List<string> status = Regex.Replace(wc.DownloadString("http://status.mojang.com/check"), "[{}\"]", "").Replace("[", "").Replace("]", "").Split(',').ToList<string>(); foreach (string s in status) { handler.SendText(s); System.Threading.Thread.Sleep(1000); } return ""; }
public override string Run(McTcpClient handler, string command, Dictionary <string, object> localVars) { string[] args = getArgs(command); if (args.Length > 0) { if (!Settings.SetAccount(args[0])) { return("Unknown account '" + args[0] + "'."); } } Program.Restart(); return(""); }
public bool FindBucketAndUse(McTcpClient handler, int hotbar, Location block) { Container container = handler.GetPlayerInventory(); Container inventory = new Container(container.ID, container.Type, container.Title, container.Items); bool found = false; byte CurrentSlot = handler.GetCurrentSlot(); if (inventory.Items.ContainsKey(CurrentSlot + 36) && inventory.Items[CurrentSlot + 36].Type == ItemType.Bucket) { found = true; } else { for (int i = 36; i <= 44; i++) { if (!inventory.Items.ContainsKey(i)) { continue; } if (inventory.Items[i].Type == ItemType.Bucket) { int slot = i - 36; handler.ChangeSlot((short)slot); found = true; break; } } for (int i = 9; i <= 35; i++) { if (!inventory.Items.ContainsKey(i)) { continue; } if (inventory.Items[i].Type == ItemType.Bucket) { handler.ClickWindowSlot(0, i, hotbar, 2); handler.ChangeSlot((short)hotbar); found = true; break; } } } if (found) { handler.UpdateLocation(handler.GetCurrentLocation(), block); handler.UseItemOnHand(); Thread.Sleep(100); handler.ChangeSlot((short)CurrentSlot); } return(found); }
public override string Run(McTcpClient handler, string command) { if (toggle == true) { Console.BackgroundColor = ConsoleColor.White; toggle = false; } else { Console.BackgroundColor = ConsoleColor.Black; toggle = true; } return CMDDesc; }
public override string Run(string command, string[] args, string argStr) { McTcpClient handler = tcpClientRetriever.GetTcpClient(); if (args.Length == 1) { string dirStr = args[0].Trim().ToLower(); Direction direction = DirectionMethods.FromString(dirStr); if (direction == Direction.None) { return("Invalid direction: " + dirStr); } player.UpdateLocation(player.GetCurrentLocation(), direction); return("Looking " + dirStr); } else if (args.Length == 2) { try { float yaw = Single.Parse(args[0]); float pitch = Single.Parse(args[1]); player.UpdateLocation(player.GetCurrentLocation(), yaw, pitch); return(String.Format("Looking at YAW: {0} PITCH: {1}", yaw.ToString("0.00"), pitch.ToString("0.00"))); } catch (FormatException) { return(CMDDesc); } } else if (args.Length == 3) { try { int x = int.Parse(args[0]); int y = int.Parse(args[1]); int z = int.Parse(args[2]); Location block = new Location(x, y, z); player.UpdateLocation(player.GetCurrentLocation(), block); return("Looking at " + block); } catch (FormatException) { return(CMDDesc); } } else { return(CMDDesc); } }
private void MoveTo(McTcpClient handler, Location goal) { if (!handler.GetWorld().GetBlock(goal + new Location(0, -1, 0)).Type.IsSolid()) { handler.PlaceBlock(1, goal + new Location(0, -1, 0)); Thread.Sleep(100); } if (handler.GetWorld().GetBlock(goal + new Location(0, 1, 0)).Type.IsSolid()) { BreakBlock(handler, goal + new Location(0, 1, 0)); Thread.Sleep(100); } goal += new Location(0.5, 0, 0.5); handler.UpdateLocation(goal, goal + new Location(0, 1, 0)); handler.handler.SendLocationUpdate(goal, true, handler.yaw, handler.pitch); }
public override string Run(McTcpClient handler, string command, Dictionary <string, object> localVars) { Console.WriteLine(command); if (sneaking) { var result = handler.sendEntityAction(Protocol.EntityActionType.StopSneaking); sneaking = false; return(result ? "Success" : "Fail"); } else { var result = handler.sendEntityAction(Protocol.EntityActionType.StartSneaking); sneaking = true; return(result ? "Success" : "Fail"); } }
public override string Run(McTcpClient handler, string command) { if (hasArg(command)) { string[] temp = getArg(command).Split('='); if (temp.Length > 1) { if (Settings.SetVar(temp[0], getArg(command).Substring(temp[0].Length + 1))) { return ""; //Success } else return "variable name must be A-Za-z0-9."; } else return CMDDesc; } else return CMDDesc; }
public override string Run(McTcpClient handler, string command) { if (Settings.TerrainAndMovements) { string[] args = getArgs(command); if (args.Length == 1) { string dirStr = getArg(command).Trim().ToLower(); Direction direction; switch (dirStr) { case "up": direction = Direction.Up; break; case "down": direction = Direction.Down; break; case "east": direction = Direction.East; break; case "west": direction = Direction.West; break; case "north": direction = Direction.North; break; case "south": direction = Direction.South; break; case "get": return handler.GetCurrentLocation().ToString(); default: return "Unknown direction '" + dirStr + "'."; } if (Movement.CanMove(handler.GetWorld(), handler.GetCurrentLocation(), direction)) { handler.MoveTo(Movement.Move(handler.GetCurrentLocation(), direction)); return "Moving " + dirStr + '.'; } else return "Cannot move in that direction."; } else if (args.Length == 3) { try { int x = int.Parse(args[0]); int y = int.Parse(args[1]); int z = int.Parse(args[2]); Location goal = new Location(x, y, z); if (handler.MoveTo(goal)) return "Walking to " + goal; return "Failed to compute path to " + goal; } catch (FormatException) { return CMDDesc; } } else return CMDDesc; } else return "Please enable terrainandmovements in config to use this command."; }
public override string Run(McTcpClient handler, string command, Dictionary <string, object> localVars) { if (hasArg(command)) { Protocol18Handler protocol = handler.GetMinecraftCom() as Protocol18Handler; if (protocol == null) { return("Error: Only Protocol18 is supported right now..."); } int response; command = getArg(command); switch (command) { case "loaded": response = 0; break; case "declined": response = 1; break; case "failed": response = 2; break; case "accepted": response = 3; break; default: return($"Error: Unknown return code: '{command}'"); } protocol.SendPacket(PacketOutgoingType.ResourcePackStatus, protocol.dataTypes.GetVarInt(response)); return("Packet sent!"); } else { return(CMDDesc); } }
public override string Run(McTcpClient handler, string command) { if (hasArg(command)) { char[] delimiterChars = { '|' }; string[] newalert = command.Split(delimiterChars); newalert.Skip(1); foreach (string s in newalert.Skip(1)) { ConsoleIO.WriteLineFormatted("§8MCC: A new alert word/phrase: '" + s + "' has been added"); System.IO.File.AppendAllText(Settings.Alerts_MatchesFile, Environment.NewLine + s); System.IO.File.Open(Settings.Alerts_MatchesFile, System.IO.FileMode.Open); //Alerts c = new Alerts(); //c.Initialize(); } return ""; } else return CMDDesc; }
public override string Run(McTcpClient handler, string command, Dictionary <string, object> localVars) { string[] args = getArgs(command); if (args.Length == 3 || args.Length == 4) { try { //hotbar 0-8 int hotbar; int x, y, z; if (args.Length == 4) { hotbar = int.Parse(args[0]); x = int.Parse(args[1]); y = int.Parse(args[2]); z = int.Parse(args[3]); } else { hotbar = 8; x = int.Parse(args[0]); y = int.Parse(args[1]); z = int.Parse(args[2]); } Location goal = new Location(x, y, z); if (!handler.GetWorld().GetBlock(goal).Type.IsLiquid()) { return("Can't bucket solid block or air"); } if (FindBucketAndUse(handler, hotbar, goal)) { return("Use bucket at " + goal); } return("Failed to use bucket at " + goal); } catch (FormatException) { return(CMDDesc); } } else { return(CMDDesc); } }
public override string Run(string command, string[] args, string argStr) { McTcpClient handler = tcpClientRetriever.GetTcpClient(); if (args.Length == 1) { if (argStr == "get") { return(handler.player.GetCurrentLocation().ToString()); } Direction direction = DirectionMethods.FromString(argStr); if (Movement.CanMove(handler.GetWorld(), handler.player.GetCurrentLocation(), direction)) { //handler.player.MoveTo(Movement.Move(handler.player.GetCurrentLocation(), direction)); return("Moving " + argStr + '.'); } else { return("Cannot move in that direction."); } } else if (args.Length == 3) { try { int x = int.Parse(args[0]); int y = int.Parse(args[1]); int z = int.Parse(args[2]); Location goal = new Location(x, y, z); //if (handler.player.MoveTo(goal)) //return "Walking to " + goal; return("Failed to compute path to " + goal); } catch (FormatException) { return(CMDDesc); } } else { return(CMDDesc); } }
public override string Run(McTcpClient handler, string command) { PortsName = new SerialPort(); PortsName.PortName = "COM3"; if (!PortsName.IsOpen) { try { PortsName.Open(); PortsName.WriteLine("b"); PortsName.Close(); return("YES WORK"); } catch { return("NO WORK"); } } return(""); }
public override string Run(McTcpClient handler, string command, Dictionary <string, object> localVars) { if (sneaking) { var result = handler.sendEntityAction(Protocol.EntityActionType.StopSneaking); if (result) { sneaking = false; } return(result ? "You aren't sneaking anymore" : "Fail"); } else { var result = handler.sendEntityAction(Protocol.EntityActionType.StartSneaking); if (result) { sneaking = true; } return(result ? "You are sneaking now" : "Fail"); } }
public override string Run(McTcpClient handler, string command) { if (hasArg(command)) { string[] args = getArgs(command); if (args.Length > 1) { if (!Settings.SetAccount(args[1])) { return "Unknown account '" + args[1] + "'."; } } if (Settings.SetServerIP(args[0])) { Program.Restart(); return ""; } else return "Invalid server IP '" + args[0] + "'."; } else return CMDDesc; }
private void DigSide(McTcpClient handler, bool DIR, Location location, int i) { if (DIR) { BreakBlock(handler, location + new Location(i, 0, 0)); BreakBlock(handler, location + new Location(i, 0, -1)); BreakBlock(handler, location + new Location(i, 0, 1)); FindBucketAndUse(handler, 8, location + new Location(i, -1, 0)); FindBucketAndUse(handler, 8, location + new Location(i, -1, -1)); FindBucketAndUse(handler, 8, location + new Location(i, -1, 1)); } else { BreakBlock(handler, location + new Location(-i, 0, 0)); BreakBlock(handler, location + new Location(-i, 0, -1)); BreakBlock(handler, location + new Location(-i, 0, 1)); FindBucketAndUse(handler, 8, location + new Location(-i, -1, 0)); FindBucketAndUse(handler, 8, location + new Location(-i, -1, -1)); FindBucketAndUse(handler, 8, location + new Location(-i, -1, 1)); } }
public override string Run(McTcpClient handler, string command, Dictionary <string, object> localVars) { string[] args = getArgs(command); if (args.Length == 3 || args.Length == 4) { try { int status; int x, y, z; if (args.Length == 4) { status = int.Parse(args[0]); x = int.Parse(args[1]); y = int.Parse(args[2]); z = int.Parse(args[3]); } else { status = 0; x = int.Parse(args[0]); y = int.Parse(args[1]); z = int.Parse(args[2]); } Location goal = new Location(x, y, z); if (handler.DiggingBlock(status, goal)) { return("Dig block at " + goal); } return("Failed to dig block at " + goal); } catch (FormatException) { return(CMDDesc); } } else { return(CMDDesc); } }
public override string Run(McTcpClient handler, string command, Dictionary <string, object> localVars) { string[] args = getArgs(command); if (args.Length == 3 || args.Length == 4) { int hand, x, y, z; if (args.Length == 3) { hand = 0; x = int.Parse(args[0]); y = int.Parse(args[1]); z = int.Parse(args[2]); } else { hand = int.Parse(args[0]); x = int.Parse(args[1]); y = int.Parse(args[2]); z = int.Parse(args[3]); } try { Location goal = new Location(x, y, z); if (handler.PlaceBlock(hand, goal)) { return("Place block at " + goal); } return("Failed to place block at " + goal); } catch (FormatException) { return(CMDDesc); } } else { return(CMDDesc); } }
public override string Run(McTcpClient handler, string command) { Program.Exit(); return ""; }
private bool FindBucketAndUse(McTcpClient handler, int hotbar, Location block) { if (!handler.GetWorld().GetBlock(block).Type.IsLiquid()) { return(false); } ConsoleIO.WriteLine("use bucket at " + block.ToString()); Container container = handler.GetPlayerInventory(); Container inventory = new Container(container.ID, container.Type, container.Title, container.Items); bool found = false; byte CurrentSlot = handler.GetCurrentSlot(); if (inventory.Items.ContainsKey(CurrentSlot + 36) && inventory.Items[CurrentSlot + 36].Type == ItemType.Bucket) { found = true; } else { Thread.Sleep(100); for (int i = 36; i <= 44; i++) { if (!inventory.Items.ContainsKey(i)) { continue; } if (inventory.Items[i].Type == ItemType.Bucket) { int slot = i - 36; handler.ChangeSlot((short)slot); found = true; break; } } if (!found) { for (int i = 9; i <= 35; i++) { if (!inventory.Items.ContainsKey(i)) { continue; } if (inventory.Items[i].Type == ItemType.Bucket) { handler.ClickWindowSlot(0, i, hotbar, 2); handler.ChangeSlot((short)hotbar); found = true; break; } } } } if (found) { handler.UpdateLocation(handler.GetCurrentLocation(), block); Thread.Sleep(200); handler.UseItemOnHand(); Thread.Sleep(500); if (handler.GetWorld().GetBlock(block).Type.IsLiquid()) { for (int i = 36; i <= 44; i++) { if (!inventory.Items.ContainsKey(i)) { continue; } if (inventory.Items[i].Type == ItemType.Bucket) { int slot = i - 36; handler.ChangeSlot((short)slot); found = true; break; } } if (found) { Thread.Sleep(200); handler.UseItemOnHand(); Thread.Sleep(200); } if (handler.GetWorld().GetBlock(block).Type.IsLiquid()) { handler.PlaceBlock(1, block); ConsoleIO.WriteLine("fail to use bucket, place block instead"); Thread.Sleep(100); } } handler.ChangeSlot(CurrentSlot); } return(found); }
public override string Run(McTcpClient handler, string command) { handler.SendRespawnPacket(); return "You have respawned."; }
public override string Run(McTcpClient handler, string command) { return "PlayerList: " + String.Join(", ", handler.GetOnlinePlayers()); }