public boolean switchTools(ToolType tool) {
    MainPlayerEntity player = world.getBot().getPlayer();
    if (player == null) return false;
    PlayerInventory inventory = player.getInventory();

    ItemStack bestTool = null;
    int bestToolSlot = -1, bestToolValue = -1;
    for (int i = 0; i < 36; i++) {
      ItemStack item = inventory.getItemAt(i);
      if (tool == null) {
        if (i > 8) break;
        if (item == null || ToolType.getById(item.getId()) == null) {
          bestTool = item;
          bestToolSlot = i;
          break;
        }
        continue;
      }
      if (item == null) continue;
      ToolType toolType = ToolType.getById(item.getId());
      if (toolType == null || toolType != tool) continue;
      int toolValue = getToolPriority(item.getId());
      if (bestTool == null || toolValue > bestToolValue) {
        bestTool = item;
        bestToolSlot = i;
        bestToolValue = toolValue;
      }
    }
    if (bestToolSlot == -1) return false;
    return switchHeldItems(bestToolSlot);
  }
  public MainPlayerEntity(World world, MainPlayerEntity player) {
    this(world, player.getId(), player.getName(), player.getGameMode());

    inventory.setDelay(player.getInventory().getDelay());
  }