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) { 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); } }
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); }