runelite-client/src/main/java/net/runelite/client/plugins/fishingbot/FishingBotPlugin.java
// Checks if there is a fishing spot, and click it
Checks if there is a fishing spot, and click it
Checks if there is a fishing spot and click it
private void clickFishingSpot() {
        if (fishingSpots.size() == 0) {
            System.out.println("no fishing spot");
            return;
        }
        if(isMouseMoving) {
            return;
        }
        inverseSortSpotDistanceFromPlayer();
        NPC targetSpot = fishingSpots.get(fishingSpots.size() - 1);
        Shape shape = targetSpot.getConvexHull();
        if (shape == null) {
            return;
        }
        Random random = new Random();
        Rectangle rectangle = shape.getBounds();
        int xPoint = (int) rectangle.getX() + (int) (0.3 * rectangle.getWidth()) + (int) (0.4 * random.nextDouble() * rectangle.getWidth());
        int yPoint = (int) rectangle.getY() + (int) (0.3 * rectangle.getHeight()) + (int) (0.4 * random.nextDouble() * rectangle.getHeight());
        int x;
        int y;
        if (shape.contains(xPoint, yPoint)) {
            x = clientUI.frame.getX() + xPoint + clientUI.getCanvasOffset().getX();
            y = clientUI.frame.getY() + yPoint + clientUI.getCanvasOffset().getY();
        } else {
            System.out.println("Does not contain randomly generated point");
            return;
        }
        System.out.println("Attempting to fish at " + targetSpot.getId());
        FishingBotThread botThread = new FishingBotThread(x, y);
        botThread.start();
    }
private void clickFishingSpot ( ) { if ( fishingSpots . size ( ) == 0 ) { System . out . println ( "no fishing spot" ) ; return ; } if ( isMouseMoving ) { return ; } inverseSortSpotDistanceFromPlayer ( ) ; NPC targetSpot = fishingSpots . get ( fishingSpots . size ( ) - 1 ) ; Shape shape = targetSpot . getConvexHull ( ) ; if ( shape == null ) { return ; } Random random = new Random ( ) ; Rectangle rectangle = shape . getBounds ( ) ; int xPoint = ( int ) rectangle . getX ( ) + ( int ) ( 0.3 * rectangle . getWidth ( ) ) + ( int ) ( 0.4 * random . nextDouble ( ) * rectangle . getWidth ( ) ) ; int yPoint = ( int ) rectangle . getY ( ) + ( int ) ( 0.3 * rectangle . getHeight ( ) ) + ( int ) ( 0.4 * random . nextDouble ( ) * rectangle . getHeight ( ) ) ; int x ; int y ; if ( shape . contains ( xPoint , yPoint ) ) { x = clientUI . frame . getX ( ) + xPoint + clientUI . getCanvasOffset ( ) . getX ( ) ; y = clientUI . frame . getY ( ) + yPoint + clientUI . getCanvasOffset ( ) . getY ( ) ; } else { System . out . println ( "Does not contain randomly generated point" ) ; return ; } System . out . println ( "Attempting to fish at " + targetSpot . getId ( ) ) ; FishingBotThread botThread = new FishingBotThread ( x , y ) ; botThread . start ( ) ; }
Checks if there is a fishing spot, and click it
Checks if there is a fishing spot and click it
// Get shape of fishing spot // randomly picks a point within the boundary of the rectangle // check if this generated point is within the boundary