minecraft_map_autoload.py
· 735 B · Python
原始文件
import os
import time
PLAYER_NAME = "Notch"
TMUX_SESSION_NAME = "minecraft"
SLEEP_DURATION = 6
CHUNK_SIZE = 16
VIEW_DISTANCE = 24
WORLD_SIZE = 4096
TP_STEP = CHUNK_SIZE * VIEW_DISTANCE
START_COORDINATE = WORLD_SIZE // 2
xz = [
(x, z)
for x in range(-START_COORDINATE, START_COORDINATE, TP_STEP)
for z in range(-START_COORDINATE, START_COORDINATE, TP_STEP)
]
total = len(xz)
for i, v in enumerate(xz):
x, z = v
mc_commands = f"/tp {PLAYER_NAME} {x} ~100 {z}"
tmux_commands = f'tmux send-keys -t {TMUX_SESSION_NAME} "{mc_commands}" Enter'
print(tmux_commands)
os.system(tmux_commands)
print(f"{i}/{total} {x}/{z} done. {SLEEP_DURATION*(total-i)//60} minute remaining")
time.sleep(SLEEP_DURATION)
1 | import os |
2 | import time |
3 | |
4 | PLAYER_NAME = "Notch" |
5 | TMUX_SESSION_NAME = "minecraft" |
6 | SLEEP_DURATION = 6 |
7 | CHUNK_SIZE = 16 |
8 | VIEW_DISTANCE = 24 |
9 | WORLD_SIZE = 4096 |
10 | TP_STEP = CHUNK_SIZE * VIEW_DISTANCE |
11 | START_COORDINATE = WORLD_SIZE // 2 |
12 | |
13 | xz = [ |
14 | (x, z) |
15 | for x in range(-START_COORDINATE, START_COORDINATE, TP_STEP) |
16 | for z in range(-START_COORDINATE, START_COORDINATE, TP_STEP) |
17 | ] |
18 | total = len(xz) |
19 | for i, v in enumerate(xz): |
20 | x, z = v |
21 | mc_commands = f"/tp {PLAYER_NAME} {x} ~100 {z}" |
22 | tmux_commands = f'tmux send-keys -t {TMUX_SESSION_NAME} "{mc_commands}" Enter' |
23 | print(tmux_commands) |
24 | os.system(tmux_commands) |
25 | print(f"{i}/{total} {x}/{z} done. {SLEEP_DURATION*(total-i)//60} minute remaining") |
26 | time.sleep(SLEEP_DURATION) |