I am posting this 'cause I have major problems with it, which I hope you guys could help me with. I think the problem is when it is scanning. It lags like hell, and doesnt find bobber.
I have never done Java except for this!
Code:
import java.awt.*;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.awt.image.BufferedImage;
import java.awt.image.PixelGrabber;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class myBot{
//USER VARIABLES
public static int MAX_CASTS= 100;
//KEY BINDINGS
public static int FISHSKILL = 49, FISHINGPOLE = 50, BAIT = 51;
//SYSTEM VARIABLE
public static Robot myRobot;
public static int PAUSE = 0, UNPAUSE = 1, RUNNING = 2;
public static int MODE = PAUSE;
public static int red = 0, green = 0, blue = 0;
public static Color cBobber;
public static Color cMouse;
public static int bobberX = 0;
public static int bobberY = 0;
public static void main(String[] args)throws AWTException, IOException{
myRobot = new Robot();
//MAIN
myRobot.delay(5000);
System.out.println("5seconds");
myRobot.delay(5000);
int mX = MouseInfo.getPointerInfo().getLocation().x; //Get location
int mY = MouseInfo.getPointerInfo().getLocation().y; //Get location
cMouse = myRobot.getPixelColor(mX, mY);
red = cMouse.getRed();
green = cMouse.getGreen();
blue = cMouse.getBlue();
//System.out.println(cMouse.getRGB());
Fish();
}
public static void Fish(){
//CAST FISHING POLE
Press(FISHSKILL);
myRobot.delay(5000);
Aim(red, green, blue);
}
public static void Say(String a){
//START CHAT WINDOW
Press(KeyEvent.VK_ENTER); //PRESS ENTER
for(int i=0; i<a.length(); i++){
Press(((int)a.charAt(i)), 100);
}
Press(KeyEvent.VK_ENTER);
}
public static void Whisper(String a){
//START WISPER BACK
Press(KeyEvent.VK_R);
for(int i=0; i<a.length(); i++){
Press(((int)a.charAt(i)), 100);
}
Press(KeyEvent.VK_R);
}
public static void Press(int a, int time){
myRobot.keyPress(a);
myRobot.delay(time);
myRobot.keyRelease(a);
}
public static void Press(int a){
myRobot.keyPress(a);
myRobot.delay(100);
myRobot.keyRelease(a);
}
public static void MouseWheel(){
myRobot.mouseWheel(-100);
}
public static String Input(String A) throws IOException{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
System.out.println(A);
String userInput = in.readLine();
return userInput;
}
public static void getInputs(){
}
public static void LogOut(){
Say("I have go now, dads yelling at me >_>. Bye.");
myRobot.delay(2500); //Wait 2,5seconds before logging out. More human-like.
Say("/logout");
myRobot.delay(25000); //Waits 25seconds before doing continuing. This is only needed if not in city.
}
public static void Aim(int red, int green, int blue){
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
int centerX = screenSize.width / 2;
int centerY = screenSize.height / 2;
for(int x = centerX - 50; x < centerX + 50; x++){
for(int y = centerY - 50; y < centerY + 50; y++){
cBobber = myRobot.getPixelColor(x, y);
/*System.out.println(x); //TESTING PURPOSE
System.out.println(y);*/ //TESTIONG PURPOSE
if (cBobber.getRGB() == -16777216){
bobberX = x;
bobberY = y;
break;
}
}
}
myRobot.mouseMove(bobberX, bobberY);
Scan(bobberX, bobberY);
System.out.println(bobberX);
System.out.println(bobberY);
}
public static void Scan(int x, int y){
boolean scanning = true;
while (scanning == true){
cBobber = myRobot.getPixelColor(x, y);
if (cBobber.getRGB() != -16777216){
myRobot.mouseMove(x, y);
myRobot.delay(100);
myRobot.mousePress(InputEvent.BUTTON2_MASK);
myRobot.mouseRelease(InputEvent.BUTTON2_MASK);
myRobot.delay(2000);
Fish();
break;
}
}
}
public static int CompareRGB(Color c1, Color c2){
if (c1.getRGB() > c2.getRGB()){
return c1.getRGB() - c2.getRGB();
} else {
if (c1.getRGB() < c2.getRGB()){
return c2.getRGB() - c1.getRGB();
} else {
return 0;
}
}
}
}