Compare commits

66 Commits

Author SHA1 Message Date
alexpolo1
185d865db9 security: replace hardcoded Discord webhook URLs with environment variable
- Remove leaked Discord webhook URL from autologin_no_attack.py
- Replace all hardcoded webhook URLs with os.environ.get('DISCORD_WEBHOOK_URL')
- Add .env.example file with webhook configuration template
- Add .gitignore to prevent .env files from being committed
- Affected files: autologin.py, autologin_no_attack.py, autocraft9x9.py, raidfarm2.py, trader.py, trader2.py, trader_laptop.py, trader_laptopv2.py, trader_wayland.py, trader_win.py, traderv2.py
- Improves security by separating configuration from code
2026-03-01 09:20:29 +01:00
alexpolo1
bfc6100320 Update traderv2.py
remove
2024-11-08 08:15:03 +01:00
alexpolo1
6a09d90fd7 Update trader_win.py
remove
2024-11-08 08:14:29 +01:00
alexpolo1
b81ca75a32 Update trader_laptopv2.py
remove
2024-11-08 08:13:44 +01:00
alexpolo1
059a8d2551 Update trader_laptop.py
remove
2024-11-08 08:13:22 +01:00
alexpolo1
9da39f8fac Update trader2.py
remove
2024-11-08 08:13:00 +01:00
alexpolo1
966f3e5632 Update trader.py
remove
2024-11-08 08:11:46 +01:00
alexpolo1
c22c2aa4fa Update raidfarm2.py 2024-11-08 08:11:22 +01:00
alexpolo1
d456cefb5b Delete debug_color_search.png
remove
2024-11-08 08:09:23 +01:00
alexpolo1
c94413a396 Update autocraft9x9.py
nodisc
2024-11-08 08:08:15 +01:00
a76e0ca8da ver1 2024-04-24 08:15:59 +02:00
72d7c5d520 not wokring good 2024-04-19 10:13:48 +02:00
4ec7fc9346 more fix 2024-04-10 15:20:49 +02:00
bb199a9bf2 moretrader 2024-04-09 19:59:19 +02:00
78e1e7e2f5 cleanup1 2024-04-06 14:32:21 +02:00
8aa78b72e5 wokring verison on pc 2024-04-06 12:10:11 +02:00
15585685e7 moreconifg 2024-04-04 20:48:10 +02:00
156939b252 a 2024-04-04 20:38:25 +02:00
alex
5c032b443c .051 2024-04-03 08:23:32 +02:00
alex
8b1fb06a32 log1 2024-04-01 11:55:28 +02:00
5436a29c58 a 2024-02-20 00:19:47 +01:00
2bdc40dc7c slagfag 2024-02-13 23:17:20 +01:00
79f739f8bc auto1, 2 2024-02-09 10:53:10 +01:00
44b795a4cc Merge branch 'main' of github.com:alexpolo1/minecraft 2024-01-11 19:40:19 +01:00
43c4aa320a display 2024-01-11 19:39:11 +01:00
alex
f590f0bb1c newest version 2024-01-08 00:33:38 +01:00
alex
2d8e170047 new version 2024-01-07 14:54:45 +01:00
alex
acf3c69c90 webhook 2024-01-07 13:08:39 +01:00
alex
0dd70e4a08 wokring version 2024-01-07 12:34:17 +01:00
alex
e421103f8b v1 being v2 2024-01-06 11:12:45 +01:00
alex
0802c10fd4 log1 2024-01-06 11:12:20 +01:00
alex
1d3f35c2e1 s1 2024-01-06 00:18:19 +01:00
alex
9a9fc05ab5 hook_and_sum 2024-01-05 22:54:18 +01:00
alex
190f2bf864 new versions 2024-01-05 20:25:31 +01:00
alex
86da40fbfe test 2024-01-01 22:02:10 +01:00
alex
6b660b0716 no_attack 2023-12-30 22:35:11 +01:00
4ca45b5332 new1 2023-12-20 10:21:17 +01:00
b98f4d51a3 v7 2023-12-15 13:39:16 +01:00
df901c9c29 v6 2023-12-15 13:11:47 +01:00
55a17886d2 ver4 2023-12-15 13:04:09 +01:00
87602935e2 fff 2023-12-15 12:54:29 +01:00
f59d077800 failsafe-no 2023-12-15 12:39:29 +01:00
c2e9a9f5e2 version3 2023-12-15 12:38:28 +01:00
5279d4f517 v2 2023-12-15 12:31:49 +01:00
5606d21b48 Merge branch 'main' of github.com:alexpolo1/minecraft 2023-12-15 12:25:09 +01:00
d4611ca467 win_vers1 2023-12-15 12:23:45 +01:00
alex
04f93cc14a check1 2023-12-05 22:01:45 +01:00
alex
22b40566c4 farm3update 2023-11-28 17:10:29 +01:00
62c977f170 now with real cliky 2023-11-27 20:28:53 +01:00
406ff1eb7e imagestuff 2023-11-27 20:16:34 +01:00
92c343e18e imageteststuff 2023-11-24 20:42:24 +01:00
alex
53715ade95 new2 2023-11-24 12:34:52 +01:00
alex
d9ccff2192 new 2023-11-24 12:23:57 +01:00
alex
ce554e45a3 new-verison 2023-11-24 12:21:29 +01:00
alex
f9f5a5e63e discord send fix 2023-11-24 08:39:08 +01:00
alex
0c210b4fbe tmp 2023-11-24 07:29:13 +01:00
alexpolo1
7f1761e0c1 Update raidfarm2.py
now with disc link
2023-11-24 07:23:36 +01:00
alexpolo1
effac7cf68 Update raidfarm2.py
new full version
2023-11-24 07:19:35 +01:00
alex
84a06c6c01 now with backup cords 2023-11-23 12:05:57 +01:00
alex
4a3459ce17 dottest 2023-11-23 11:50:43 +01:00
125e5c5ee7 name 2023-11-23 11:27:43 +01:00
d3c80b0ab5 raidfarmwithautoconenct 2023-11-23 11:26:28 +01:00
02d2d67833 logstuff 2023-11-22 08:54:53 +01:00
5207849330 old version better 2023-11-20 19:57:24 +01:00
104622402e better 2023-11-20 19:41:36 +01:00
7694fdaed5 get a countdown 2023-11-20 19:33:33 +01:00
26 changed files with 1637 additions and 2990 deletions

44
#autoclick 2.0 Normal file
View File

@@ -0,0 +1,44 @@
import subprocess
import sys
# Function to execute a command using ydotool
def execute_ydotool_command(command):
try:
subprocess.run(command, check=True)
except subprocess.CalledProcessError as e:
print(f"Error executing {' '.join(command)}: {e}", file=sys.stderr)
# Function to simulate mouse click
def ydotool_click(x, y, button='left', repeat=1):
# Move the mouse to the specified coordinates
execute_ydotool_command(['ydotool', 'mousemove', str(x), str(y)])
button_arg = '1' if button == 'left' else '2'
for _ in range(repeat):
execute_ydotool_command(['ydotool', 'click', button_arg])
def main():
coordinates = []
click_type = 'left'
repeat = 1
num_coordinates = int(input("Enter the number of coordinates to record: "))
for i in range(num_coordinates):
while True:
coords = input(f"Enter coordinates {i+1} (format x,y): ")
try:
x, y = map(int, coords.split(','))
coordinates.append((x, y))
break # Exit the loop if coordinates are valid
except ValueError:
print("Invalid format. Please enter coordinates in the format x,y.")
click_type = input("Enter click type (left or right, default left): ") or click_type
repeat = int(input("How many times to repeat each click (default 1): ") or repeat)
for x, y in coordinates:
ydotool_click(x, y, button=click_type, repeat=repeat)
print(f"Clicked at {x},{y} with {click_type} button, repeated {repeat} times.")
if __name__ == "__main__":
main()

37
#autoclick.py Normal file
View File

@@ -0,0 +1,37 @@
#autoclick
import os
os.environ['DISPLAY'] = ':0'
import pyautogui
import tkinter as tk
from threading import Thread
from Xlib import display
def automate_clicking():
while True:
pyautogui.click(x1, y1)
pyautogui.click(x2, y2)
def start_clicking():
global x1, y1, x2, y2
x1, y1 = map(int, point1_entry.get().split(','))
x2, y2 = map(int, point2_entry.get().split(','))
t = Thread(target=automate_clicking)
t.daemon = True
t.start()
app = tk.Tk()
app.title("Simple Mouse Clicker")
tk.Label(app, text="Point 1 (x,y):").pack()
point1_entry = tk.Entry(app)
point1_entry.pack()
tk.Label(app, text="Point 2 (x,y):").pack()
point2_entry = tk.Entry(app)
point2_entry.pack()
start_button = tk.Button(app, text="Start Clicking", command=start_clicking)
start_button.pack()
app.mainloop()

4
.env.example Normal file
View File

@@ -0,0 +1,4 @@
# Discord Webhook Configuration
# Set your Discord webhook URL here for Discord notifications
# Get a webhook URL from your Discord server settings
DISCORD_WEBHOOK_URL=https://discord.com/api/webhooks/your-webhook-id-here/your-webhook-token-here

43
.gitignore vendored Normal file
View File

@@ -0,0 +1,43 @@
# Environment variables
.env
.env.local
.env.*.local
# Logs and temporary files
*.log
*.txt
# Python
__pycache__/
*.py[cod]
*$py.class
*.so
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# IDE
.vscode/
.idea/
*.swp
*.swo
*~
# Screenshot directories
/tmp/mcscreens/

View File

@@ -2,13 +2,14 @@ import subprocess
import time
import pyautogui
import requests
import os
def log_and_print(message):
print(message)
# Add logging here if needed
def post_to_discord(message):
webhook_url = 'https://discord.com/api/webhooks/1171735460729606145/Fyls4_uD7it29TNo7LktQFynb3k1K-BHLx9Y4WqzDK806o1_bVTNz94JNc996kDi-jE6'
webhook_url = os.environ.get('DISCORD_WEBHOOK_URL', '')
data = {"content": message}
response = requests.post(webhook_url, json=data)
log_and_print(f"Posted to Discord: {message}")
@@ -58,4 +59,4 @@ focus_minecraft_window()
shift_click_inventory_slots()
final_message = f"Crafted 256 {crafted_item}(s)."
log_and_print(final_message)
post_to_discord(final_message)
post_to_discord(final_message)

View File

@@ -7,6 +7,7 @@ from PIL import ImageGrab
from datetime import datetime, timedelta
import time
import random
import os
# Define the paths to your screenshots
back_to_server_image_path = '/home/alex/minecraft/screenshots/back_to_server.png'
@@ -14,7 +15,7 @@ join_button_image_path = '/home/alex/minecraft/screenshots/join_button.png'
log_file_path = '/home/alex/minecraft/autologin.log'
# Set up the Discord webhook URL
webhook_url = 'https://discord.com/api/webhooks/your_webhook_url_here'
webhook_url = os.environ.get('DISCORD_WEBHOOK_URL', '')
def log(message, discord_notify=True):
timestamp = datetime.now().strftime('%Y-%m-%d %H:%M:%S')

140
autologin_no_attack.py Normal file

File diff suppressed because one or more lines are too long

141
craft1.py Normal file
View File

@@ -0,0 +1,141 @@
import pyautogui
import keyboard
centerX = 0
centerY = 0
deluje = False
gledam = 0
premik = 150
delay = 100
class Point:
def __init__(self, x, y):
self.X = x
self.Y = y
guiPoss = {}
guiBarva = {}
def obrniSeNa(pozicija):
global gledam, centerX, centerY, premik
if pozicija != gledam:
posX = centerX + (pozicija - gledam) * premik
posY = centerY
pyautogui.moveTo(posX, posY, duration=0.05)
gledam = pozicija
def cakajNaGui(kateri, mode):
global guiPoss, guiBarva
while True:
pixel = pyautogui.pixel(guiPoss[kateri - 1].X, guiPoss[kateri - 1].Y)
if (mode == 1 and pixel == guiBarva[kateri - 1]) or (mode == 2 and pixel != guiBarva[kateri - 1]):
return
def cakajNaItem(mode, posX, posY, auto=True):
global guiBarvaOzadjaItema, guiBarvaOzadjaItemaHighlight
isOk = False
while not isOk:
y = -2
while y < 3:
x = -2
while x < 3:
if auto:
preveriAliKonca()
pixel = pyautogui.pixel(posX + x, posY + y)
if mode == 1: # cakaj da pride na slot
if pixel != guiBarvaOzadjaItema and pixel != guiBarvaOzadjaItemaHighlight:
return
elif mode == 2: # cakaj da gre stran
if pixel == guiBarvaOzadjaItema or pixel == guiBarvaOzadjaItemaHighlight:
isOk = True
if isOk >= 9:
return
x += 2
y += 2
isOk = False
def preveriAliKonca():
if not keyboard.is_pressed('Minecraft'):
prekini()
if not deluje:
keyboard.release('Shift')
exit()
def craft(pozicija):
global guiPoss, guiBarva, centerX, centerY
if not pozicija:
pozicija = 10
C_recepti = {}
I_recepti = {}
if pozicija < 6:
y = 0
x = 0
while y < 3:
while x < 5:
C_recepti[(y, x)] = Point(guiPoss[0].X + x * C_korakX, guiPoss[0].Y + y * C_korakY)
I_recepti[(y, x)] = Point(guiPoss[4].X + x * I_korakX, guiPoss[4].Y + y * I_korakY)
x += 1
y += 1
pixelCraftingTable = pyautogui.pixel(guiPoss[0].X, guiPoss[0].Y)
pixelReceptiCraftingT = pyautogui.pixel(guiPoss[2].X, guiPoss[2].Y)
pixelReceptiInventory = pyautogui.pixel(guiPoss[3].X, guiPoss[3].Y)
pixelInventory = pyautogui.pixel(guiPoss[4].X, guiPoss[4].Y)
if pixelCraftingTable == guiBarva[0] and pixelReceptiCraftingT == guiBarva[2]: # odprt crafting tabla in recepti
y = 0
x = 0
while y < 3:
while x < 5:
# Perform the desired crafting action...
x += 1
y += 1
def prekini():
global deluje
deluje = False
def hotkey_start():
global deluje, gledam, centerX, centerY
deluje = True
gledam = 0
centerX, centerY = pyautogui.position()
while deluje:
preveriAliKonca()
zanka()
def hotkey_stop():
global deluje
deluje = False
keyboard.add_hotkey('windows+j', hotkey_start, suppress=False)
keyboard.add_hotkey('windows-j', hotkey_stop, suppress=False)
keyboard.add_hotkey('e', prekini)
keyboard.add_hotkey('esc', prekini)
# Register hotkeys for crafting
for i in range(10):
keyboard.add_hotkey('shift+'+str(i), lambda x=i: craft(x))
# Define GUI positions and colors
guiPoss[0] = Point(956, 403)
guiPoss[1] = Point(802, 402)
guiPoss[2] = Point(658, 402)
guiPoss[3] = Point(657, 403)
guiPoss[4] = Point(954, 403)
guiBarva[0] = 0xC3C3C3
guiBarva[1] = 0xC4C4C4
guiBarva[2] = 0xC5C5C5
guiBarva[3] = 0xC5C5C5
guiBarva[4] = 0xC2C2C2
# Other variables for crafting logic
C_korakX = (1094 - 1023) / 4
C_korakY = (516 - 443) / 3
I_korakX = (897 - 692) / 4
I_korakY = (631 - 478) / 3
guiBarvaOzadjaItema = 0x8B8B8B
guiBarvaOzadjaItemaHighlight = 0xC5C5C5
# Start the keyboard listener
keyboard.wait()

53
craft_gold_bar.py Normal file
View File

@@ -0,0 +1,53 @@
import pyautogui
import time
from PIL import ImageGrab
import logging
# Setup logging
logging.basicConfig(filename='gold_bar_crafting_log.txt', level=logging.INFO, format='%(asctime)s: %(message)s')
def log_and_print(message):
print(message)
logging.info(message)
def click(x, y):
pyautogui.moveTo(x, y, duration=0.2)
log_and_print(f"Performing left click at ({x}, {y}).")
pyautogui.click()
def find_color_in_image(target_color, search_area):
screenshot = ImageGrab.grab(search_area)
width, height = screenshot.size
for x in range(width):
for y in range(height):
if screenshot.getpixel((x, y))[:3] == target_color:
# Adjusting coordinates relative to the whole screen
return x + search_area[0], y + search_area[1]
return None, None
def craft_gold_bars():
log_and_print("Looking for yellow gold bars to craft...")
gold_bar_color = (255, 204, 0) # This color might need adjustment
crafting_area = (100, 100, 800, 600) # Define your game's crafting area
gold_bar_x, gold_bar_y = find_color_in_image(gold_bar_color, crafting_area)
if gold_bar_x is not None and gold_bar_y is not None:
log_and_print(f"Gold bar found at ({gold_bar_x}, {gold_bar_y}). Initiating crafting sequence.")
click(gold_bar_x, gold_bar_y) # Click on the gold bar
# Add more actions here to perform the crafting, such as clicking on a crafting tool or station
else:
log_and_print("Gold bar not found within the specified area.")
def countdown(seconds):
for i in range(seconds, 0, -1):
print(f"Starting in {i} seconds...", end="\r")
time.sleep(1)
print("Starting now!")
# 5-second countdown before the script starts
countdown(5)
# Define the number of attempts or use a condition to keep crafting
for _ in range(10): # Adjust based on how many times you want to attempt crafting
craft_gold_bars()
time.sleep(5) # Wait time between crafting attempts

BIN
debug_trade_window.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

View File

@@ -0,0 +1,5 @@
# Just before this line:
# if screenshot.getpixel((x_area - 896, y_area - 139))[:3] == red_x_color:
print(f"Calculated coordinates: ({x_area - 896}, {y_area - 139})")
print(f"Screenshot dimensions: ({screenshot.width}, {screenshot.height})")

20
gold_bar_crafting_log.txt Normal file
View File

@@ -0,0 +1,20 @@
2024-02-13 23:19:40,711: Looking for yellow gold bars to craft...
2024-02-13 23:19:41,129: Gold bar not found within the specified area.
2024-02-13 23:19:46,130: Looking for yellow gold bars to craft...
2024-02-13 23:19:46,533: Gold bar not found within the specified area.
2024-02-13 23:19:51,533: Looking for yellow gold bars to craft...
2024-02-13 23:19:52,241: Gold bar not found within the specified area.
2024-02-13 23:19:57,242: Looking for yellow gold bars to craft...
2024-02-13 23:19:57,700: Gold bar not found within the specified area.
2024-02-13 23:20:02,702: Looking for yellow gold bars to craft...
2024-02-13 23:20:03,143: Gold bar not found within the specified area.
2024-02-13 23:20:08,143: Looking for yellow gold bars to craft...
2024-02-13 23:20:08,619: Gold bar not found within the specified area.
2024-02-13 23:20:13,621: Looking for yellow gold bars to craft...
2024-02-13 23:20:14,147: Gold bar not found within the specified area.
2024-02-21 19:42:52,296: Looking for yellow gold bars to craft...
2024-02-21 19:42:52,572: Gold bar not found within the specified area.
2024-02-21 19:42:57,572: Looking for yellow gold bars to craft...
2024-02-21 19:42:57,943: Gold bar not found within the specified area.
2024-02-21 19:43:02,943: Looking for yellow gold bars to craft...
2024-02-21 19:43:03,352: Gold bar not found within the specified area.

52
imagestuff.py Normal file

File diff suppressed because one or more lines are too long

27
import pyautogui.py Normal file
View File

@@ -0,0 +1,27 @@
import pyautogui
import keyboard
import time
print("Hover over a position and press 'x' to capture the mouse coordinates. Press 'Esc' to exit.")
captured_positions = []
while True:
try:
if keyboard.is_pressed('x'):
x, y = pyautogui.position()
if (x, y) not in captured_positions: # Prevent capturing the same position if the key is held down
captured_positions.append((x, y))
print(f"Position captured: {x}, {y}")
time.sleep(0.2) # Add a slight delay to prevent multiple captures for a single press
if keyboard.is_pressed('esc'):
print("Exiting.")
break
except RuntimeError as e:
print(e)
continue
print("\nAll captured positions:")
for position in captured_positions:
print(position)

File diff suppressed because it is too large Load Diff

44
move1.py Normal file
View File

@@ -0,0 +1,44 @@
import pyautogui
import time
import threading
from Xlib import display
def is_minecraft_focused():
current_display = display.Display()
window_id = current_display.get_input_focus().focus.get_full_property(current_display.intern_atom('_NET_WM_NAME'), 0)
if window_id:
window_name = window_id.value
if "Minecraft" in window_name:
return True
return False
def hold_key():
time.sleep(5) # Wait for 5 seconds before starting
print("Starting to hold 'W' key. Press 'E' to stop.")
while not stop_thread:
if is_minecraft_focused():
pyautogui.keyDown('w')
else:
pyautogui.keyUp('w')
time.sleep(0.1)
pyautogui.keyUp('w')
# This flag will control the thread execution
stop_thread = False
# Starting the thread that holds down the 'W' key
thread = threading.Thread(target=hold_key)
thread.start()
# Waiting for the user to press 'E' to stop
try:
while True:
time.sleep(0.1) # Small delay to reduce CPU usage
if is_minecraft_focused() and pyautogui.press('x'):
stop_thread = True
break
except KeyboardInterrupt:
stop_thread = True
thread.join()
print("Stopped.")

25
moveing1.py Normal file
View File

@@ -0,0 +1,25 @@
import requests
import subprocess
import time
from PIL import Image, ImageGrab
import logging
def log_and_print(message):
print(message)
# Assuming you want to log to the same file as your main script
with open('minecraft_automation_log.txt', 'a') as log_file:
log_file.write(f'{time.strftime("%Y-%m-%d %H:%M:%S")}: {message}\n')
def hold_key_for_duration(key, duration):
log_and_print(f"Waiting 5 seconds before holding '{key}' key for {duration} seconds.")
time.sleep(5) # Delay for 5 seconds
log_and_print(f"Holding '{key}' key.")
subprocess.run(['xdotool', 'keydown', key])
time.sleep(duration)
subprocess.run(['xdotool', 'keyup', key])
log_and_print(f"Released '{key}' key.")
# Example usage
hold_key_for_duration('a', 11) # This will hold the 'a' key for 11 seconds

View File

@@ -11,5 +11,5 @@ time.sleep(10)
# Continuously perform left clicks every 0.645 seconds
while True:
click()
time.sleep(0.645) # Wait for 0.645 seconds before the next click
time.sleep(0.651) # Wait for 0.645 seconds before the next click

94
raidfarm2.py Normal file
View File

@@ -0,0 +1,94 @@
import cv2
import numpy as np
from PIL import ImageGrab
import subprocess
import time
import datetime
import os
import requests
# Configuration
temp_screenshot_directory = '/tmp/mcscreens'
discord_webhook_url = os.environ.get('DISCORD_WEBHOOK_URL', '')
screenshot_interval = 3600 # seconds (1 hour)
disconnect_check_interval = 10800 # seconds (3 hours)
# Ensure the temp screenshot directory exists
os.makedirs(temp_screenshot_directory, exist_ok=True)
def send_discord_message(message, image_path=None):
data = {
"content": message,
"username": "Minecraft Bot"
}
files = None
if image_path:
image_data = open(image_path, 'rb').read()
files = {'file': (os.path.basename(image_path), image_data, 'image/png')}
result = requests.post(discord_webhook_url, data=data, files=files if files is not None else None)
try:
result.raise_for_status()
except requests.exceptions.HTTPError as err:
print(err)
else:
print("Payload delivered successfully, code {}.".format(result.status_code))
def capture_hourly_screenshot():
current_time = datetime.datetime.now()
file_name = f"{current_time.strftime('%Y%m%d%H%M')}.png"
file_path = os.path.join(temp_screenshot_directory, file_name)
screenshot = ImageGrab.grab()
screenshot.save(file_path, 'PNG')
send_discord_message("Hourly status screenshot:", file_path)
def click_at_position(x, y):
subprocess.run(['xdotool', 'mousemove', str(x), str(y), 'click', '1'])
def raid_farm_clicking():
print("Performing left click.")
subprocess.run(['xdotool', 'click', '1']) # Left-click
def handle_disconnect():
print("Handling disconnect...")
# Backup coordinates
back_to_server_button_pos = (1170, 364)
join_server_button_pos = (955, 457)
# Click the "Back to Server List" button
click_at_position(*back_to_server_button_pos)
print("Clicked 'Back to Server List'.")
time.sleep(2) # Wait for the UI to respond
# Click the "Join Server" button
click_at_position(*join_server_button_pos)
print("Clicked 'Join Server'.")
time.sleep(10) # Wait for the server to respond
# Take a screenshot and send it to Discord
capture_hourly_screenshot()
print("Screenshot captured and sent to Discord.")
if __name__ == "__main__":
print('Raid farm clicker started.')
last_hourly_screenshot_time = None
last_disconnect_check_time = None
while True:
current_time = datetime.datetime.now()
# Perform the raid farm clicking
raid_farm_clicking()
# Take a screenshot based on the defined interval
if last_hourly_screenshot_time is None or (current_time - last_hourly_screenshot_time).total_seconds() >= screenshot_interval:
capture_hourly_screenshot()
last_hourly_screenshot_time = current_time
# Check for disconnects based on the defined interval
if last_disconnect_check_time is None or (current_time - last_disconnect_check_time).total_seconds() >= disconnect_check_interval:
handle_disconnect()
last_disconnect_check_time = current_time
time.sleep(0.651) # Time interval between clicks

View File

@@ -3,6 +3,8 @@ import subprocess
import time
from PIL import Image, ImageGrab
import logging
from Xlib import display
import os
# Setup logging
logging.basicConfig(filename='minecraft_automation_log.txt', level=logging.INFO, format='%(asctime)s: %(message)s')
@@ -12,7 +14,7 @@ def log_and_print(message):
logging.info(message)
def post_to_discord(message):
webhook_url = 'https://discord.com/api/webhooks/1171735460729606145/Fyls4_uD7it29TNo7LktQFynb3k1K-BHLx9Y4WqzDK806o1_bVTNz94JNc996kDi-jE6'
webhook_url = os.environ.get('DISCORD_WEBHOOK_URL', '')
data = {"content": message}
response = requests.post(webhook_url, json=data)
log_and_print(f"Posted to Discord: {message}")
@@ -52,7 +54,7 @@ def find_color_in_image(target_color, image):
def focus_minecraft_window():
log_and_print("Focusing Minecraft window...")
subprocess.run(['xdotool', 'search', '--name', 'Minecraft*1.20.2 - Multiplayer (3rd-party-Server)', 'windowactivate', '--sync'])
subprocess.run(['xdotool', 'search', '--name', 'Minecraft*3.20.2 - Multiplayer (3rd-party-Server)', 'windowactivate', '--sync'])
time.sleep(2)
log_and_print("Pressing Esc...")
subprocess.run(['xdotool', 'key', 'Escape'])

View File

@@ -1,8 +1,9 @@
import requests
import subprocess
import pyautogui
import time
from PIL import Image, ImageGrab
from PIL import ImageGrab
import logging
import os
# Setup logging
logging.basicConfig(filename='minecraft_automation_log.txt', level=logging.INFO, format='%(asctime)s: %(message)s')
@@ -12,35 +13,32 @@ def log_and_print(message):
logging.info(message)
def post_to_discord(message):
webhook_url = 'https://discord.com/api/webhooks/1171735460729606145/Fyls4_uD7it29TNo7LktQFynb3k1K-BHLx9Y4WqzDK806o1_bVTNz94JNc996kDi-jE6'
webhook_url = os.environ.get('DISCORD_WEBHOOK_URL', '')
data = {"content": message}
response = requests.post(webhook_url, json=data)
log_and_print(f"Posted to Discord: {message}")
def right_click(x, y):
move_mouse(x, y)
log_and_print("Performing right click.")
subprocess.run(['xdotool', 'click', '3']) # Right-click
pyautogui.moveTo(x, y)
log_and_print(f"Performing right click at ({x}, {y}).")
pyautogui.rightClick()
def drag_slider(start_x, start_y, end_x, end_y):
log_and_print("Dragging slider.")
move_mouse(start_x, start_y)
subprocess.run(['xdotool', 'mousedown', '1']) # Left mouse button down
move_mouse(end_x, end_y)
subprocess.run(['xdotool', 'mouseup', '1']) # Left mouse button up
log_and_print(f"Dragging slider from ({start_x}, {start_y}) to ({end_x}, {end_y}).")
pyautogui.mouseDown(start_x, start_y, button='left')
pyautogui.moveTo(end_x, end_y, duration=2)
pyautogui.mouseUp(button='left')
def click(x, y):
move_mouse(x, y)
log_and_print("Performing left click.")
subprocess.run(['xdotool', 'click', '1']) # Left-click
pyautogui.moveTo(x, y)
log_and_print(f"Performing left click at ({x}, {y}).")
pyautogui.click()
def shift_click(x, y):
log_and_print("Performing shift click.")
move_mouse(x, y)
subprocess.run(['xdotool', 'keydown', 'shift', 'click', '1', 'keyup', 'shift']) # Shift-click
def move_mouse(x, y):
subprocess.run(['xdotool', 'mousemove', str(x), str(y)])
log_and_print(f"Performing shift click at ({x}, {y}).")
pyautogui.keyDown('shift')
click(x, y)
pyautogui.keyUp('shift')
def find_color_in_image(target_color, image):
width, height = image.size
@@ -50,51 +48,32 @@ def find_color_in_image(target_color, image):
return x, y
return None, None
def focus_minecraft_window():
log_and_print("Focusing Minecraft window...")
subprocess.run(['xdotool', 'search', '--name', 'Minecraft*1.20.2 - Multiplayer (3rd-party-Server)', 'windowactivate', '--sync'])
time.sleep(2)
log_and_print("Pressing Esc...")
subprocess.run(['xdotool', 'key', 'Escape'])
time.sleep(2)
def check_trade_window():
log_and_print("Checking for trade window...")
trade_window_area = (2314, 974, 3124, 1455)
screenshot = ImageGrab.grab(trade_window_area)
screenshot.save("debug_trade_window.png") # Save screenshot for debugging
r, g, b = screenshot.getpixel((51, 69))[:3]
log_and_print(f"Color at check position: {r}, {g}, {b}")
if (r, g, b) == (137, 51, 24):
log_and_print("Trade window detected.")
return True
else:
log_and_print("Trade window not detected. Adjusting position.")
adjustment_combinations = [('a', 0.1), ('d', 0.1), ('a', 0.2), ('d', 0.2)]
for _ in range(5): # Try up to three times
for key, duration in adjustment_combinations:
subprocess.run(['xdotool', 'keydown', key])
time.sleep(duration)
subprocess.run(['xdotool', 'keyup', key])
time.sleep(0.1)
subprocess.run(['xdotool', 'click', '3']) # Right-click without moving the mouse
time.sleep(3)
screenshot = ImageGrab.grab(trade_window_area)
r, g, b = screenshot.getpixel((51, 69))[:3]
if (r, g, b) == (137, 51, 24):
log_and_print("Trade window detected after adjustment.")
return True
log_and_print("Trade window not found after adjustments.")
post_to_discord("Trade window not found.")
log_and_print("Trade window not detected.")
return False
def countdown(seconds):
for i in range(seconds, 0, -1):
print(f"Starting in {i} seconds...", end="\r")
time.sleep(1)
print("Starting now!")
def trade_actions():
right_click(2725, 1203)
time.sleep(1)
if not check_trade_window():
log_and_print("Trade window not detected after adjustments. Stopping script.")
log_and_print("Trade window not detected. Stopping script.")
return False
drag_slider(2600, 1399, 2600, 1408)
@@ -102,6 +81,7 @@ def trade_actions():
log_and_print("Taking a screenshot for color search...")
screenshot = ImageGrab.grab()
screenshot.save("debug_color_search.png") # Save screenshot for debugging
target_color = (222, 227, 114) # The color to search for
found_x, found_y = find_color_in_image(target_color, screenshot)
@@ -121,19 +101,19 @@ def trade_actions():
post_to_discord("Potion clicked.")
log_and_print("Pressing 'Esc' key.")
subprocess.run(['xdotool', 'key', 'Escape'])
pyautogui.press('esc')
time.sleep(1)
log_and_print("Holding 'D' key for a step.")
subprocess.run(['xdotool', 'keydown', 'd'])
pyautogui.keyDown('d')
time.sleep(0.45) # Hold 'D' for 0.45 seconds
subprocess.run(['xdotool', 'keyup', 'd'])
pyautogui.keyUp('d')
time.sleep(1)
return True # Indicate that the trade action was successful
focus_minecraft_window()
# 5-second countdown before the script starts
countdown(5)
for _ in range(40): # Number of trades to perform
result = trade_actions()

200
trader_laptop.py Normal file
View File

@@ -0,0 +1,200 @@
import requests
import subprocess
import time
from PIL import Image, ImageGrab
import logging
import os
# Setup logging
logging.basicConfig(filename='minecraft_automation_log.txt', level=logging.INFO, format='%(asctime)s: %(message)s')
def log_and_print(message):
print(message)
logging.info(message)
def post_to_discord(message):
webhook_url = os.environ.get('DISCORD_WEBHOOK_URL', '')
data = {"content": message}
response = requests.post(webhook_url, json=data)
log_and_print(f"Posted to Discord: {message}")
def right_click(x, y):
move_mouse(x, y)
log_and_print("Performing right click.")
subprocess.run(['xdotool', 'click', '3']) # Right-click
def drag_slider(start_x, start_y, end_x, end_y):
log_and_print("Dragging slider.")
move_mouse(start_x, start_y)
subprocess.run(['xdotool', 'mousedown', '1']) # Left mouse button down
move_mouse(end_x, end_y)
subprocess.run(['xdotool', 'mouseup', '1']) # Left mouse button up
def click(x, y):
move_mouse(x, y)
log_and_print("Performing left click.")
subprocess.run(['xdotool', 'click', '1']) # Left-click
def shift_click(x, y):
subprocess.run(['xdotool', 'keyup', 'Super_L', 'Super_R'])
log_and_print("Performing shift click.")
move_mouse(x, y)
time.sleep(0.5) # Added delay before pressing shift
subprocess.run(['xdotool', 'keydown', 'shift'])
time.sleep(0.5) # Added delay to ensure shift is held down
subprocess.run(['xdotool', 'click', '1']) # Left-click
time.sleep(0.5) # Added delay before releasing shift
subprocess.run(['xdotool', 'keyup', 'shift'])
def move_mouse(x, y):
subprocess.run(['xdotool', 'mousemove', str(x), str(y)])
first_run = True # Flag to check if it's the first run
def focus_minecraft_window():
global first_run
log_and_print("Focusing Minecraft window...")
subprocess.run(['xdotool', 'search', '--name', 'Minecraft*3.20.2 - Multiplayer (3rd-party-Server)', 'windowactivate', '--sync'])
time.sleep(2)
if first_run:
log_and_print("Pressing Esc (first run only)...")
subprocess.run(['xdotool', 'key', 'Escape'])
time.sleep(2)
first_run = False # Set the flag to False after the first run
def check_trade_window():
log_and_print("Checking for trade window...")
trade_window_area = (896, 145, 11434, 460) # Defined area
screenshot = ImageGrab.grab(trade_window_area)
target_color = (195, 100, 64) # Target color for trade window
for x in range(screenshot.width):
for y in range(screenshot.height):
if screenshot.getpixel((x, y))[:3] == target_color:
log_and_print("Trade window detected.")
return True
log_and_print("Trade window not detected. Adjusting position.")
adjustment_combinations = [('a', 0.1), ('d', 0.1), ('a', 0.2), ('d', 0.2)]
for _ in range(5):
for key, duration in adjustment_combinations:
subprocess.run(['xdotool', 'keydown', key])
time.sleep(duration)
subprocess.run(['xdotool', 'keyup', key])
time.sleep(0.1)
subprocess.run(['xdotool', 'click', '3'])
time.sleep(3)
screenshot = ImageGrab.grab(trade_window_area)
for x in range(screenshot.width):
for y in range(screenshot.height):
if screenshot.getpixel((x, y))[:3] == target_color:
log_and_print("Trade window detected after adjustment.")
return True
log_and_print("Trade window not found after adjustments.")
post_to_discord("Trade window not found.")
return False
successful_trades = 0
def trade_actions():
global successful_trades
right_click(1168, 306)
time.sleep(1)
if not check_trade_window():
log_and_print("Trade window not detected after adjustments. Stopping script.")
return False
drag_slider(1084, 199, 1084, 423)
time.sleep(3)
log_and_print("Looking for XP potion color and red 'X' on trader side...")
left_side_trade_window_area = (896, 139, 1094, 445) # Defined area for trader's side
screenshot = ImageGrab.grab(left_side_trade_window_area)
xp_potion_color = (103, 177, 125) # XP potion color
red_x_color = (150, 35, 0) # Red 'X' color
red_x_areas = [(1022, 424), (1022, 383)] # Coordinates where the red 'X' can appear
found_x, found_y = None, None
trader_blocked = False
# Check for red 'X'
for x_area, y_area in red_x_areas:
if screenshot.getpixel((x_area - 896, y_area - 139))[:3] == red_x_color:
log_and_print(f"Trader is blocked at ({x_area}, {y_area}). Moving to the next trader.")
trader_blocked = True
break
# If trader is not blocked, look for XP potion
if not trader_blocked:
for x in range(screenshot.width):
for y in range(screenshot.height):
if screenshot.getpixel((x, y))[:3] == xp_potion_color:
found_x, found_y = x, y
break
if found_x is not None:
break
if found_x is not None and found_y is not None:
log_and_print(f"XP potion found at ({found_x}, {found_y}). Initiating purchase.")
click(found_x + 896, found_y + 139)
shift_click(1345, 219)
else:
log_and_print("XP potion not found. Using fallback coordinates.")
click(1053, 427)
shift_click(1345, 219)
click(1053, 390)
shift_click(1346, 220)
# Exiting trade window and moving to next trade
log_and_print("Exiting trade window.")
subprocess.run(['xdotool', 'key', 'Escape'])
time.sleep(1)
if trader_blocked:
log_and_print("Moving to the next trade due to blocked trader.")
else:
log_and_print("Moving to the next trade.")
subprocess.run(['xdotool', 'keydown', 'd'])
time.sleep(0.45)
subprocess.run(['xdotool', 'keyup', 'd'])
time.sleep(1)
if not trader_blocked:
successful_trades += 1
return True
def hold_key_for_duration(key, duration):
log_and_print(f"Waiting 5 seconds before holding '{key}' key for {duration} seconds.")
time.sleep(5) # Delay for 5 seconds
log_and_print(f"Holding '{key}' key.")
subprocess.run(['xdotool', 'keydown', key])
time.sleep(duration)
subprocess.run(['xdotool', 'keyup', key])
log_and_print(f"Released '{key}' key.")
# Function to perform a cycle of trading actions
def perform_trading_cycle():
global successful_trades
successful_trades = 0
focus_minecraft_window()
for _ in range(25): # Number of trades to perform
if not trade_actions():
break # Stop the script if trade window is not detected
trade_summary = f"Trading session completed. Trades performed: {successful_trades}"
post_to_discord(trade_summary)
# Main loop to run trading cycles and reset position
def main_loop():
while True:
perform_trading_cycle()
hold_key_for_duration('a', 11) # Adjust the key and duration as needed
time.sleep(5) # Delay before next cycle starts
# Run the main loop
main_loop()

200
trader_laptopv2.py Normal file
View File

@@ -0,0 +1,200 @@
import requests
import subprocess
import time
from PIL import Image, ImageGrab
import logging
import os
# Setup logging
logging.basicConfig(filename='minecraft_automation_log.txt', level=logging.INFO, format='%(asctime)s: %(message)s')
def log_and_print(message):
print(message)
logging.info(message)
def post_to_discord(message):
webhook_url = os.environ.get('DISCORD_WEBHOOK_URL', '')
data = {"content": message}
response = requests.post(webhook_url, json=data)
log_and_print(f"Posted to Discord: {message}")
def right_click(x, y):
move_mouse(x, y)
log_and_print("Performing right click.")
subprocess.run(['xdotool', 'click', '3']) # Right-click
def drag_slider(start_x, start_y, end_x, end_y):
log_and_print("Dragging slider.")
move_mouse(start_x, start_y)
subprocess.run(['xdotool', 'mousedown', '1']) # Left mouse button down
move_mouse(end_x, end_y)
subprocess.run(['xdotool', 'mouseup', '1']) # Left mouse button up
def click(x, y):
move_mouse(x, y)
log_and_print("Performing left click.")
subprocess.run(['xdotool', 'click', '1']) # Left-click
def shift_click(x, y):
subprocess.run(['xdotool', 'keyup', 'Super_L', 'Super_R'])
log_and_print("Performing shift click.")
move_mouse(x, y)
time.sleep(0.5) # Added delay before pressing shift
subprocess.run(['xdotool', 'keydown', 'shift'])
time.sleep(0.5) # Added delay to ensure shift is held down
subprocess.run(['xdotool', 'click', '1']) # Left-click
time.sleep(0.5) # Added delay before releasing shift
subprocess.run(['xdotool', 'keyup', 'shift'])
def move_mouse(x, y):
subprocess.run(['xdotool', 'mousemove', str(x), str(y)])
first_run = True # Flag to check if it's the first run
def focus_minecraft_window():
global first_run
log_and_print("Focusing Minecraft window...")
subprocess.run(['xdotool', 'search', '--name', 'Minecraft*3.20.2 - Multiplayer (3rd-party-Server)', 'windowactivate', '--sync'])
time.sleep(2)
if first_run:
log_and_print("Pressing Esc (first run only)...")
subprocess.run(['xdotool', 'key', 'Escape'])
time.sleep(2)
first_run = False # Set the flag to False after the first run
def check_trade_window():
log_and_print("Checking for trade window...")
trade_window_area = (896, 145, 11434, 460) # Defined area
screenshot = ImageGrab.grab(trade_window_area)
target_color = (195, 100, 64) # Target color for trade window
for x in range(screenshot.width):
for y in range(screenshot.height):
if screenshot.getpixel((x, y))[:3] == target_color:
log_and_print("Trade window detected.")
return True
log_and_print("Trade window not detected. Adjusting position.")
adjustment_combinations = [('a', 0.1), ('d', 0.1), ('a', 0.2), ('d', 0.2)]
for _ in range(5):
for key, duration in adjustment_combinations:
subprocess.run(['xdotool', 'keydown', key])
time.sleep(duration)
subprocess.run(['xdotool', 'keyup', key])
time.sleep(0.1)
subprocess.run(['xdotool', 'click', '3'])
time.sleep(3)
screenshot = ImageGrab.grab(trade_window_area)
for x in range(screenshot.width):
for y in range(screenshot.height):
if screenshot.getpixel((x, y))[:3] == target_color:
log_and_print("Trade window detected after adjustment.")
return True
log_and_print("Trade window not found after adjustments.")
post_to_discord("Trade window not found.")
return False
successful_trades = 0
def trade_actions():
global successful_trades
right_click(1168, 306)
time.sleep(1)
if not check_trade_window():
log_and_print("Trade window not detected after adjustments. Stopping script.")
return False
drag_slider(1084, 199, 1084, 423)
time.sleep(3)
log_and_print("Looking for XP potion color and red 'X' on trader side...")
left_side_trade_window_area = (896, 139, 1094, 445) # Defined area for trader's side
screenshot = ImageGrab.grab(left_side_trade_window_area)
xp_potion_color = (103, 177, 125) # XP potion color
red_x_color = (150, 35, 0) # Red 'X' color
red_x_areas = [(1022, 424), (1022, 383)] # Coordinates where the red 'X' can appear
found_x, found_y = None, None
trader_blocked = False
# Check for red 'X'
for x_area, y_area in red_x_areas:
if screenshot.getpixel((x_area - 896, y_area - 139))[:3] == red_x_color:
log_and_print(f"Trader is blocked at ({x_area}, {y_area}). Moving to the next trader.")
trader_blocked = True
break
# If trader is not blocked, look for XP potion
if not trader_blocked:
for x in range(screenshot.width):
for y in range(screenshot.height):
if screenshot.getpixel((x, y))[:3] == xp_potion_color:
found_x, found_y = x, y
break
if found_x is not None:
break
if found_x is not None and found_y is not None:
log_and_print(f"XP potion found at ({found_x}, {found_y}). Initiating purchase.")
click(found_x + 896, found_y + 139)
shift_click(1345, 219)
else:
log_and_print("XP potion not found. Using fallback coordinates.")
click(1053, 427)
shift_click(1345, 219)
click(1053, 390)
shift_click(1346, 220)
# Exiting trade window and moving to next trade
log_and_print("Exiting trade window.")
subprocess.run(['xdotool', 'key', 'Escape'])
time.sleep(1)
if trader_blocked:
log_and_print("Moving to the next trade due to blocked trader.")
else:
log_and_print("Moving to the next trade.")
subprocess.run(['xdotool', 'keydown', 'd'])
time.sleep(0.45)
subprocess.run(['xdotool', 'keyup', 'd'])
time.sleep(1)
if not trader_blocked:
successful_trades += 1
return True
def hold_key_for_duration(key, duration):
log_and_print(f"Waiting 5 seconds before holding '{key}' key for {duration} seconds.")
time.sleep(5) # Delay for 5 seconds
log_and_print(f"Holding '{key}' key.")
subprocess.run(['xdotool', 'keydown', key])
time.sleep(duration)
subprocess.run(['xdotool', 'keyup', key])
log_and_print(f"Released '{key}' key.")
# Function to perform a cycle of trading actions
def perform_trading_cycle():
global successful_trades
successful_trades = 0
focus_minecraft_window()
for _ in range(25): # Number of trades to perform
if not trade_actions():
break # Stop the script if trade window is not detected
trade_summary = f"Trading session completed. Trades performed: {successful_trades}"
post_to_discord(trade_summary)
# Main loop to run trading cycles and reset position
def main_loop():
while True:
perform_trading_cycle()
hold_key_for_duration('a', 11) # Adjust the key and duration as needed
time.sleep(5) # Delay before next cycle starts
# Run the main loop
main_loop()

125
trader_wayland.py Normal file
View File

@@ -0,0 +1,125 @@
import requests
import subprocess
import time
from PIL import Image
import logging
import os
from wayland_screenshot import take_screenshot # This will be a custom function you need to implement
# Setup logging
logging.basicConfig(filename='minecraft_automation_log.txt', level=logging.INFO, format='%(asctime)s: %(message)s')
def log_and_print(message):
print(message)
logging.info(message)
def post_to_discord(message):
webhook_url = os.environ.get('DISCORD_WEBHOOK_URL', '')
data = {"content": message}
response = requests.post(webhook_url, json=data)
log_and_print(f"Posted to Discord: {message}")
def right_click(x, y):
move_mouse(x, y)
log_and_print("Performing right click.")
subprocess.run(['ydotool', 'click', '3']) # Right-click
def drag_slider(start_x, start_y, end_x, end_y):
log_and_print("Dragging slider.")
move_mouse(start_x, start_y)
subprocess.run(['ydotool', 'mousedown', '1']) # Left mouse button down
move_mouse(end_x, end_y)
subprocess.run(['ydotool', 'mouseup', '1']) # Left mouse button up
def click(x, y):
move_mouse(x, y)
log_and_print("Performing left click.")
subprocess.run(['ydotool', 'click', '1']) # Left-click
def shift_click(x, y):
log_and_print("Performing shift click.")
move_mouse(x, y)
subprocess.run(['ydotool', 'keydown', 'Shift', 'click', '1', 'keyup', 'Shift']) # Shift-click
def move_mouse(x, y):
subprocess.run(['ydotool', 'mousemove', str(x), str(y)])
def find_color_in_image(target_color, image):
width, height = image.size
for x in range(width):
for y in range(height):
if image.getpixel((x, y))[:3] == target_color:
return x, y
return None, None
def focus_minecraft_window():
log_and_print("Focusing Minecraft window...")
# Note: Focusing a specific window might not work in Wayland as it does in X11
subprocess.run(['ydotool', 'search', '--name', 'Minecraft*3.20.2 - Multiplayer (3rd-party-Server)', 'windowactivate', '--sync'])
time.sleep(2)
log_and_print("Pressing Esc...")
subprocess.run(['ydotool', 'key', 'Escape'])
time.sleep(2)
def check_trade_window():
log_and_print("Checking for trade window...")
trade_window_area = (2314, 974, 3124, 1455)
screenshot = take_screenshot(trade_window_area) # This needs a custom implementation for Wayland
r, g, b = screenshot.getpixel((51, 69))[:3]
if (r, g, b) == (137, 51, 24):
log_and_print("Trade window detected.")
return True
else:
log_and_print("Trade window not detected. Adjusting position.")
# Adjusting position might not work as expected in Wayland
# This part needs to be tested and potentially adjusted
# ...
def trade_actions():
right_click(2725, 1203)
time.sleep(1)
if not check_trade_window():
log_and_print("Trade window not detected after right click. Stopping script.")
return False
drag_slider(2600, 1399, 2600, 1408)
time.sleep(3)
log_and_print("Taking a screenshot for color search...")
screenshot = take_screenshot() # This needs a custom implementation for Wayland
target_color = (222, 227, 114) # The color to search for
found_x, found_y = find_color_in_image(target_color, screenshot)
if found_x is not None and found_y is not None:
log_and_print(f"Color found at ({found_x}, {found_y}). Clicking at this position.")
click(found_x, found_y)
else:
log_and_print("Color not found on the screen. Using fallback coordinates.")
click(2535, 1421)
time.sleep(1)
for _ in range(2):
shift_click(2994, 1105)
time.sleep(1)
post_to_discord("Potion clicked.")
log_and_print("Pressing 'Esc' key.")
subprocess.run(['ydotool', 'key', 'Escape'])
time.sleep(1)
log_and_print("Holding 'D' key for a step.")
subprocess.run(['ydotool', 'keydown', 'd'])
time.sleep(0.45) # Hold 'D' for 0.45 seconds
subprocess.run(['ydotool', 'keyup', 'd'])
time.sleep(1)
return True # Indicate that the trade action was successful
focus_minecraft_window()
for _ in range(40): # Number of trades to perform
result = trade_actions()
if not result:
break # Stop the script if trade window is not detected

View File

@@ -3,6 +3,7 @@ import pyautogui
import time
from PIL import ImageGrab
import logging
import os
# Setup logging
logging.basicConfig(filename='minecraft_automation_log.txt', level=logging.INFO, format='%(asctime)s: %(message)s')
@@ -12,29 +13,29 @@ def log_and_print(message):
logging.info(message)
def post_to_discord(message):
webhook_url = 'https://discord.com/api/webhooks/1171735460729606145/Fyls4_uD7it29TNo7LktQFynb3k1K-BHLx9Y4WqzDK806o1_bVTNz94JNc996kDi-jE6'
webhook_url = os.environ.get('DISCORD_WEBHOOK_URL', '')
data = {"content": message}
response = requests.post(webhook_url, json=data)
log_and_print(f"Posted to Discord: {message}")
def right_click(x, y):
pyautogui.moveTo(x, y)
log_and_print("Performing right click.")
log_and_print(f"Performing right click at ({x}, {y}).")
pyautogui.rightClick()
def drag_slider(start_x, start_y, end_x, end_y):
log_and_print("Dragging slider.")
log_and_print(f"Dragging slider from ({start_x}, {start_y}) to ({end_x}, {end_y}).")
pyautogui.mouseDown(start_x, start_y, button='left')
pyautogui.moveTo(end_x, end_y, duration=2)
pyautogui.mouseUp(button='left')
def click(x, y):
pyautogui.moveTo(x, y)
log_and_print("Performing left click.")
log_and_print(f"Performing left click at ({x}, {y}).")
pyautogui.click()
def shift_click(x, y):
log_and_print("Performing shift click.")
log_and_print(f"Performing shift click at ({x}, {y}).")
pyautogui.keyDown('shift')
click(x, y)
pyautogui.keyUp('shift')
@@ -49,58 +50,45 @@ def find_color_in_image(target_color, image):
def check_trade_window():
log_and_print("Checking for trade window...")
trade_window_area = (2314, 974, 3124, 1455)
screenshot = ImageGrab.grab(trade_window_area)
r, g, b = screenshot.getpixel((51, 69))[:3]
if (r, g, b) == (137, 51, 24):
log_and_print("Trade window detected.")
return True
else:
log_and_print("Trade window not detected. Adjusting position.")
adjustment_combinations = [('a', 0.1), ('d', 0.1), ('a', 0.2), ('d', 0.2)]
for _ in range(5): # Try up to three times
for key, duration in adjustment_combinations:
pyautogui.keyDown(key)
time.sleep(duration)
pyautogui.keyUp(key)
time.sleep(0.1)
right_click(2725, 1203) # Right-click without moving the mouse
time.sleep(3)
screenshot = ImageGrab.grab(trade_window_area)
r, g, b = screenshot.getpixel((51, 69))[:3]
if (r, g, b) == (137, 51, 24):
log_and_print("Trade window detected after adjustment.")
return True
trade_window_area = (835, 372, 836, 712)
screenshot = ImageGrab.grab(bbox=trade_window_area)
log_and_print("Trade window not found after adjustments.")
post_to_discord("Trade window not found.")
relative_x, relative_y = (0, 10) # Adjust these values as needed
try:
r, g, b = screenshot.getpixel((relative_x, relative_y))[:3]
if (r, g, b) == (137, 51, 24):
log_and_print("Trade window detected.")
return True
else:
log_and_print("Trade window not detected.")
return False
except IndexError as e:
log_and_print(f"Error in getting pixel data: {e}")
return False
def trade_actions():
right_click(2725, 1203)
middle_x, middle_y = 960, 531
slider_top_x, slider_top_y = 835, 372
slider_bottom_x, slider_bottom_y = 836, 712
xp_x, xp_y = 787, 721
right_click(middle_x, middle_y)
time.sleep(1)
if not check_trade_window():
log_and_print("Trade window not detected after adjustments. Stopping script.")
log_and_print("Trade window not detected. Stopping script.")
return False
drag_slider(2600, 1399, 2600, 1408)
drag_slider(slider_top_x, slider_top_y, slider_bottom_x, slider_bottom_y)
time.sleep(3)
log_and_print("Taking a screenshot for color search...")
screenshot = ImageGrab.grab()
target_color = (222, 227, 114) # The color to search for
found_x, found_y = find_color_in_image(target_color, screenshot)
# Add any additional actions needed here
for _ in range(2):
if found_x is not None and found_y is not None:
log_and_print(f"Color found at ({found_x}, {found_y}). Clicking at this position.")
click(found_x, found_y)
else:
log_and_print("Color not found on the screen. Using fallback coordinates.")
click(2535, 1421)
time.sleep(1)
return True # Indicate that the trade action was successful
for _ in range(2):
click(found_x, found_y)
shift_click(2994
print("Running this on Windows. Ensure Minecraft window is focused before continuing.")
for _ in range(40): # Number of trades to perform
result = trade_actions()
if not result:
break # Stop the script if trade window is not detected

276
traderv2.py Normal file
View File

@@ -0,0 +1,276 @@
import requests
import subprocess
import time
from PIL import Image, ImageGrab
import logging
import os
print("")
# Setup logging
logging.basicConfig(filename='minecraft_automation_log.txt', level=logging.INFO, format='%(asctime)s: %(message)s')
left_side_trade_window_area = (2314, 992, 2616, 1465) # Defined area for trader's side
screenshot = ImageGrab.grab(left_side_trade_window_area)
xp_potion_color = (238, 231, 153) # XP potion color
red_x_color = (186, 55, 15) # Red 'X' color
red_x_areas = [(2505, 1424), (2898, 1122)] # Coordinates where the red 'X' can appear
# Number of attempts to retry starting a new trade if a trader is blocked
max_retry_attempts = 5
successful_trades = 0
def log_and_print(message):
print(message)
logging.info(message)
def post_to_discord(message):
webhook_url = os.environ.get('DISCORD_WEBHOOK_URL', '')
data = {"content": message}
response = requests.post(webhook_url, json=data)
log_and_print(f"Posted to Discord: {message}")
def right_click(x, y):
move_mouse(x, y)
log_and_print("Performing right click.")
subprocess.run(['xdotool', 'click', '3']) # Right-click
def drag_slider(start_x, start_y, end_x, end_y):
log_and_print("Dragging slider.")
move_mouse(start_x, start_y)
subprocess.run(['xdotool', 'mousedown', '1']) # Left mouse button down
move_mouse(end_x, end_y)
subprocess.run(['xdotool', 'mouseup', '1']) # Left mouse button up
def click(x, y):
move_mouse(x, y)
log_and_print("Performing left click.")
subprocess.run(['xdotool', 'click', '1']) # Left-click
def shift_click():
x, y = 2990, 1121 # Hardcoded coordinates for the shift-click action
subprocess.run(['xdotool', 'keyup', 'Super_L', 'Super_R'])
log_and_print("Performing shift click.")
move_mouse(x, y) # Ensure the mouse moves to the right coordinates before clicking
time.sleep(1) # Added delay before pressing shift
subprocess.run(['xdotool', 'keydown', 'shift'])
time.sleep(1) # Added delay to ensure shift is held down
log_and_print("Clicking at ({}, {})".format(x, y))
subprocess.run(['xdotool', 'click', '1']) # Perform the click
time.sleep(1) # Added delay before releasing shift
subprocess.run(['xdotool', 'keyup', 'shift'])
def trade_fallback():
log_and_print("Initiating fallback trading sequence.")
# First fallback potion
log_and_print("Buying fallback potion at first preset coordinates.")
click(2552, 1433) # Click on the fallback potion position
time.sleep(2) # Allow time for the GUI to respond
shift_click() # Confirm the purchase
log_and_print("First fallback potion transaction attempted.")
# Second fallback potion (if needed)
log_and_print("Buying fallback potion at second preset coordinates.")
click(2551, 1365) # Click on the second fallback potion position
time.sleep(2) # Allow time for the GUI to respond
shift_click() # Confirm the purchase
log_and_print("Second fallback potion transaction attempted.")
log_and_print("Fallback trading actions completed.")
def finish_trading():
# Exiting the trade window by sending the 'Escape' key
log_and_print("Exiting trade window.")
subprocess.run(['xdotool', 'key', 'Escape'])
time.sleep(1) # Brief delay to ensure the action has been processed
# Logging and updating trade success count
log_and_print("Trade completed. Moving to the next trader, good trade +1.")
global successful_trades
successful_trades += 1 # Increment success count
# Move slightly to prepare for interaction with the next trader
log_and_print("Adjusting position to face the next trader.")
subprocess.run(['xdotool', 'keydown', 'a']) # Simulate pressing 'a' to move left
time.sleep(0.35) # Hold the key briefly to simulate a slight move
subprocess.run(['xdotool', 'keyup', 'a']) # Release the key
time.sleep(1) # Wait a moment before the next action
def hold_key_for_duration(key, duration):
log_and_print(f"Waiting 5 seconds before holding '{key}' key for {duration} seconds.")
time.sleep(5) # Delay for 5 seconds
log_and_print(f"Holding '{key}' key.")
subprocess.run(['xdotool', 'keydown', key])
time.sleep(duration)
subprocess.run(['xdotool', 'keyup', key])
log_and_print(f"Released '{key}' key.")
def move_mouse(x, y):
subprocess.run(['xdotool', 'mousemove', str(x), str(y)])
def shift_double_click(x, y):
move_mouse(x, y)
subprocess.run(['xdotool', 'keydown', 'shift'])
subprocess.run(['xdotool', 'click', '--repeat', '2', '--delay', '100', '1'])
subprocess.run(['xdotool', 'keyup', 'shift'])
def fill_inventory_with_emeralds():
log_and_print("Opening emerald chest...")
right_click(1168, 306)
time.sleep(2) # Wait a moment for the chest to open
cord1 = (2507, 977)
cord2 = (2561, 975)
log_and_print("Selecting emeralds...")
click(cord1[0], cord1[1]) # Move to cord1 and left-click to select emeralds
log_and_print("Transferring emeralds to inventory...")
shift_double_click(cord2[0], cord2[1]) # Move to cord2 and shift-left-click to transfer emeralds
time.sleep(1)
log_and_print("Closing emmerald chest...")
subprocess.run(['xdotool', 'key', 'Escape']) # Press Esc to exit the chest
time.sleep(1)
def move_first_trade():
log_and_print("Moveing to first trade")
# Prepare for the first trade
subprocess.run(['xdotool', 'keydown', 'a'])
time.sleep(0.25)
subprocess.run(['xdotool', 'keyup', 'a'])
time.sleep(1)
# TRADE ACTIONS !! main function doing the trades and looking for red x as blocked trades
def trade_actions():
global successful_trades
trader_blocked = False # Initialize as False
attempts = 0
found_x, found_y = None, None # Initialize coordinates for XP potion
time.sleep(1)
if not check_trade_window():
log_and_print("Trade window not detected after adjustments. Stopping script.")
return False
drag_slider(2599, 1071, 2598, 1419)
time.sleep(3)
log_and_print("Looking for XP potion")
potion_bought = False # Flag to check if potion is bought
for x in range(screenshot.width):
for y in range(screenshot.height):
if screenshot.getpixel((x, y))[:3] == xp_potion_color:
found_x, found_y = x, y
log_and_print(f"XP potion found at ({found_x}, {found_y}). Initiating purchase.")
global_x = found_x + 2317 # Adjust for global positioning
global_y = found_y + 994
click(global_x, global_y)
time.sleep(2)
shift_click()
log_and_print("XP potion bought.")
potion_bought = True
successful_trades += 1 # Increment the successful trades count
finish_trading()
break
if potion_bought:
break
# Use fallback if XP potion is not found
if not potion_bought:
trade_fallback()
finish_trading()
return False
return True # Indicates the trade actions completed successfully
def check_trade_window():
log_and_print("Checking for trade window...")
trade_window_area = (2317, 994, 3126, 1472) # Defined area
screenshot = ImageGrab.grab(trade_window_area)
target_color = (178, 67, 32) # Target color for trade window
#use right click to check for trade window
log_and_print("useing right click to check for trade window")
right_click(1168, 306)
for x in range(screenshot.width):
for y in range(screenshot.height):
if screenshot.getpixel((x, y))[:3] == target_color:
log_and_print("Trade window detected.")
return True
log_and_print("Trade window not detected. Adjusting position.")
adjustment_combinations = [('a', 0.1), ('d', 0.1), ('a', 0.2), ('d', 0.2)]
for _ in range(5):
for key, duration in adjustment_combinations:
subprocess.run(['xdotool', 'keydown', key])
time.sleep(duration)
subprocess.run(['xdotool', 'keyup', key])
time.sleep(0.1)
subprocess.run(['xdotool', 'click', '3'])
time.sleep(3)
screenshot = ImageGrab.grab(trade_window_area)
for x in range(screenshot.width):
for y in range(screenshot.height):
if screenshot.getpixel((x, y))[:3] == target_color:
log_and_print("Trade window detected after adjustment.")
return True
log_and_print("Trade window not found after adjustments.")
post_to_discord("Trade window not found.")
return False
def dump_xp_potions():
log_and_print("Dumping XP potions into dump chest...")
right_click(1168, 306)
time.sleep(2) # Wait a moment for the chest to open
cord1 = (2508, 1342)
cord2 = (2558, 1342)
log_and_print("Selecting xp potions...")
click(cord1[0], cord1[1]) # Move to cord1 and left-click to select emeralds
log_and_print("Transferring xp potions to dump chest...")
shift_double_click(cord2[0], cord2[1]) # Move to cord2 and shift-left-click to transfer emeralds
log_and_print("Closing chest...")
subprocess.run(['xdotool', 'key', 'Escape']) # Press Esc to exit the chest
time.sleep(1)
first_run = True # Flag to check if it's the first run
def focus_minecraft_window():
global first_run
log_and_print("Focusing Minecraft window...")
subprocess.run(['xdotool', 'search', '--name', 'Minecraft*3.20.2 - Multiplayer (3rd-party-Server)', 'windowactivate', '--sync'])
time.sleep(2)
if first_run:
log_and_print("Pressing Esc (first run only)...")
subprocess.run(['xdotool', 'key', 'Escape'])
time.sleep(2)
first_run = False # Set the flag to False after the first run
def perform_trading_cycle():
global successful_trades
successful_trades = 0 # Reset count at the start of each cycle
focus_minecraft_window()
fill_inventory_with_emeralds() # Fill up on emeralds before starting trades
move_first_trade()
# Define the number of trade attempts
trade_attempts = 50
for _ in range(trade_attempts): # Loop for defined number of trades
trade_successful = trade_actions()
if not trade_successful:
log_and_print(f"Trade attempt failed or blocked, continuing to next. Attempt {_ + 1} of {trade_attempts}")
else:
log_and_print(f"Trade attempt successful. Attempt {_ + 1} of {trade_attempts}")
# Check if the number of successful trades reached the desired trades before moving to dump chest
if successful_trades >= trade_attempts:
break
log_and_print("Moving to dump chest after trade attempts.")
hold_key_for_duration('a', 25) # Adjust the key and duration as needed
dump_xp_potions() # Dump XP potions after completing trades
trade_summary = f"Trading session completed. Trades performed: {successful_trades}"
post_to_discord(trade_summary)
log_and_print("Cycle done, moving back to start.")
hold_key_for_duration('d', 25) # Adjust the key and duration as needed
# Main loop to run trading cycles and reset position
def main_loop():
while True:
log_and_print("starting trade cycle")
perform_trading_cycle()
log_and_print("cycle done waiting 5")
time.sleep(5) # Delay before next cycle starts
# Run the main loop
main_loop()