最后活跃于 1723933506

auto load your minecraft map with tp command

minecraft_map_autoload.py 原始文件
1import os
2import time
3
4PLAYER_NAME = "Notch"
5TMUX_SESSION_NAME = "minecraft"
6SLEEP_DURATION = 6
7CHUNK_SIZE = 16
8VIEW_DISTANCE = 24
9WORLD_SIZE = 4096
10TP_STEP = CHUNK_SIZE * VIEW_DISTANCE
11START_COORDINATE = WORLD_SIZE // 2
12
13xz = [
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]
18total = len(xz)
19for 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)