#๐Ÿ”’ Need help with mob detection for minecraft

8 messages ยท Page 1 of 1 (latest)

candid wing
#

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

shy hemlockBOT
#

@candid wing

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

candid wing
#

If you can give me a small example of tracking or a sample of code I would be very greatful

inner kelp
#

!codeblock

shy hemlockBOT
#
Formatting code on Discord

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

For long code samples, you can use our pastebin.

inner kelp
#

Format it accordingly

shy hemlockBOT
#
Python help channel closed for inactivity

This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.