Hello, I am working on a custom fishing script for minecraft for a server called hypixel. When you catch with your rod there is a chance to get a sea creature which is a mob pretty much and I was wondering if it was possible to make a script that tracks it and right clicks until its gone:
I have already coded the part that throws are releases the fishing rod but it might need small tweaks:
import pyautogui
import keyboard
import time
from PIL import ImageGrab
color_to_find = (252, 84, 84)
tolerance = 10
click_delay = 0.25
crosshair_size = 25
paused = False
def color_match(c1, c2, tol):
return all(abs(a - b) <= tol for a, b in zip(c1, c2))
def find_color_near_cursor():
x, y = pyautogui.position()
left = x - crosshair_size
top = y - crosshair_size
right = x + crosshair_size
bottom = y + crosshair_size
img = ImageGrab.grab(bbox=(left, top, right, bottom))
pixels = img.load()
for i in range(img.size[0]):
for j in range(img.size[1]):
if color_match(pixels[i, j], color_to_find, tolerance):
return True
return False
def main_loop():
global paused
print("Press F8 to pause/resume, 9 to exit.")
while True:
if keyboard.is_pressed('9'):
break
if keyboard.is_pressed('F8'):
paused = not paused
print("Paused" if paused else "Running")
time.sleep(0.5) # debounce
if not paused:
if find_color_near_cursor():
pyautogui.click(button='right')
time.sleep(click_delay)
pyautogui.click(button='right')
time.sleep(click_delay)
time.sleep(0.01)
if name == "main":
main_loop()
I am very new to python but have a little bit of experience in AHK