-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathminer.py
More file actions
85 lines (64 loc) · 2.18 KB
/
miner.py
File metadata and controls
85 lines (64 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
from visibility_scanner.scanner import scan_targets, scan_target
from visibility_scanner.world_scanners import get_area, get_line
import aim.player_aim
import threading
import time
import minescript as m
# ------------------------------
# control handler
# ------------------------------
m.set_default_executor(m.script_loop)
active = False
def listen_keys():
global active
with m.EventQueue() as eq:
eq.register_key_listener()
while True:
event = eq.get()
if event.type == m.EventType.KEY:
if (event.key == 'o' or event.key == 79) and event.action == 1:
active = not active
m.echo(f"Script active: {active}")
event = None
threading.Thread(target=listen_keys, daemon=True).start()
m.echo("Press 'o' to activate/exit.")
# ------------------------------
# params
# ------------------------------
target_ids = [
"minecraft:diamond_ore",
"minecraft:deepslate_diamond_ore"
]
reach = 4.8
previous_target = m.player_position()
# ------------------------------
# main loop
# ------------------------------
while True:
if not active:
prev_block = None
while not active:
time.sleep(0.5)
px, py, pz = m.player_position()
occluders = get_area(position=(px, py + 1.62, pz))
aim_result = scan_targets(
position=(px, py + 1.62, pz), target_ids=target_ids, occluders=occluders, previous_target=previous_target
)
if aim_result is not None:
previous_target = aim_result.optimal_pos
x, y, z = aim_result.world_pos
aim.player_aim.smooth_rotate_to(aim_result.target_angle[0], aim_result.target_angle[1], duration=0.3)
prev_block = m.getblock(x, y, z)
m.player_press_attack(True)
while prev_block == m.getblock(x, y, z) and active:
time.sleep(0.05)
m.player_press_attack(False)
else:
time.sleep(0.5)
'''
# minimal usage example for scan_target()
start = (10, -58.5, 20) # use central position, or the ground will occlude
end = (10, -58.5, 10) # same here
occluders = get_line(position=start, target=end)
aim_result = scan_target(position=start, target=end, occluders=occluders)
'''