import bot.*;
 
public class boner extends Methods {
   
   String stage;
   String myName;
   
   public boner(Client mc) {
        super(mc);
    }
    public void main(String args[]) {
      try {
         int curX;
         int curY;
         int count = 0;
         int startX = myPos()[0];
         int startY = myPos()[1];
         int last = inventoryCount();
      
         printMessage("@gr2@Boner: @whi@by Fate");
         printMessage("@gr2@Boner: @whi@Start Point: " + startX + "," + startY);
         
         while(running()) {
            if (itemCount(20) > 0) {
               stage = "BURY";
            } else if (itemCount(20) < 1) {
               stage = "PICK";
            }
            if (stage == "BURY" && !sleeping()) {
               useItem(getItemSlot(20));
               wait(random(500,700));
               modProtection();
               
            } else if (stage == "PICK" && !sleeping()) {
                  int bones = getGroundItemById(20);
                  while (bones != -1 && !sleeping() && inventoryCount() < 30) {
                     curX = myPos()[0];
                     curY = myPos()[1];
                     pickupItemById(20);
                     wait(random(1000,1200));
                     modProtection();
                     if (curX == myPos()[0] && curY == myPos()[1] && inventoryCount() == last) {
                        printMessage("@gr2@Boner @whi@We got stuck x" + count);
                        count++;
                        if (count >= 10) {
                           printMessage("@gr2@Boner @whi@Walking back..");
                           walk(curX + random(-3,3), curY + random(-3,3));
                           count = 0;
                        }
                     }
                     last = inventoryCount();
                     bones = getGroundItemById(20);
                  }
            }
            if (sleeping()) {
               wait(1000);
            }
            wait(random(800,1000));
         }

      } catch (Exception e) {
         printMessage("@red@Error: @whi@ Wrong arguments.");
      }
      }
     public void modProtection() {
      if (fatigue() == 100) {
         printMessage("@red@ Mod detected!");
         stop();
      }
     }
      public void walk(int x, int y) {
      while(!imAt(x, y)) {
         walkTo(x, y);
         wait(random(2000, 3000));
      }
   }
   
   public void onStop() {
      printMessage("@or2@Bot: @yel@Script stopped");
   }
}
