|
8 | 8 | pip install pyritone |
9 | 9 | ``` |
10 | 10 |
|
11 | | -## Beginner usage |
| 11 | +## Fastest Working Sync Example |
12 | 12 |
|
13 | 13 | ```python |
14 | 14 | from pyritone import PyritoneClient |
15 | 15 |
|
16 | 16 | with PyritoneClient() as client: |
| 17 | + print(client.ping()) |
17 | 18 | dispatch = client.goto(100, 70, 100) |
18 | | - task_id = dispatch.get("task_id") |
19 | | - if task_id: |
20 | | - terminal = client.wait_for_task(task_id) |
21 | | - print(terminal["event"]) |
| 19 | + print(dispatch) |
22 | 20 | ``` |
23 | 21 |
|
24 | | -## Command API |
25 | | - |
26 | | -All top-level Baritone v1.15.0 commands are exposed as Python methods on: |
27 | | - |
28 | | -- `PyritoneClient` (sync) |
29 | | -- `AsyncPyritoneClient` (async) |
30 | | - |
31 | | -Each command returns immediate dispatch info: |
32 | | - |
33 | | -- `command_text` |
34 | | -- `raw` bridge response |
35 | | -- optional `task_id` |
36 | | -- optional `accepted` |
37 | | - |
38 | | -Command aliases are exposed too (`qmark`, `stop`, `wp`, etc). Full generated reference: |
39 | | - |
40 | | -- `python/docs/baritone-commands.md` |
41 | | - |
42 | | -## Settings API |
43 | | - |
44 | | -You can control Baritone settings through a settings namespace. |
45 | | - |
46 | | -```python |
47 | | -from pyritone import PyritoneClient |
48 | | - |
49 | | -with PyritoneClient() as client: |
50 | | - client.settings.allowSprint = True |
51 | | - client.settings.allowBreak = False |
52 | | - |
53 | | - print(client.settings.allowSprint.get()) |
54 | | - print(client.settings.allowSprint.toggle()) |
55 | | - print(client.settings.allowSprint.reset()) |
56 | | -``` |
57 | | - |
58 | | -Async style: |
| 22 | +## Fastest Working Async Example |
59 | 23 |
|
60 | 24 | ```python |
| 25 | +import asyncio |
61 | 26 | from pyritone import AsyncPyritoneClient |
62 | 27 |
|
63 | | -client = AsyncPyritoneClient() |
64 | | -await client.connect() |
65 | | -try: |
66 | | - await client.settings.allowSprint.set(True) |
67 | | - await client.settings.allowSprint.get() |
68 | | -finally: |
69 | | - await client.close() |
70 | | -``` |
71 | 28 |
|
72 | | -## Low-level API still available |
| 29 | +async def main() -> None: |
| 30 | + client = AsyncPyritoneClient() |
| 31 | + await client.connect() |
| 32 | + try: |
| 33 | + print(await client.ping()) |
| 34 | + dispatch = await client.goto(100, 70, 100) |
| 35 | + print(dispatch) |
| 36 | + finally: |
| 37 | + await client.close() |
73 | 38 |
|
74 | | -- `execute("...")` |
75 | | -- `cancel()` |
76 | | -- `ping()` |
77 | | -- `status_get()` |
78 | | -- `next_event()` |
79 | | -- `wait_for_task(task_id)` |
80 | 39 |
|
81 | | -## Zero-setup discovery |
| 40 | +asyncio.run(main()) |
| 41 | +``` |
82 | 42 |
|
83 | | -By default, `pyritone` discovers bridge details from: |
| 43 | +## Docs |
| 44 | + |
| 45 | +- Full docs index: `python/docs/index.md` |
| 46 | +- Quickstart: `python/docs/quickstart.md` |
| 47 | +- Sync client guide: `python/docs/sync-client.md` |
| 48 | +- Async client guide: `python/docs/async-client.md` |
| 49 | +- Settings API: `python/docs/settings-api.md` |
| 50 | +- Tasks/events/waiting: `python/docs/tasks-events-and-waiting.md` |
| 51 | +- Errors/troubleshooting: `python/docs/errors-and-troubleshooting.md` |
| 52 | +- CLI usage: `python/docs/cli.md` |
| 53 | +- Command docs: |
| 54 | + - `python/docs/commands/navigation.md` |
| 55 | + - `python/docs/commands/world.md` |
| 56 | + - `python/docs/commands/build.md` |
| 57 | + - `python/docs/commands/control.md` |
| 58 | + - `python/docs/commands/info.md` |
| 59 | + - `python/docs/commands/waypoints.md` |
| 60 | + - `python/docs/commands/aliases.md` |
| 61 | +- Raw Baritone appendix: `python/docs/baritone-commands.md` |
| 62 | + |
| 63 | +## Public API Map |
| 64 | + |
| 65 | +- Clients: |
| 66 | + - `PyritoneClient` |
| 67 | + - `AsyncPyritoneClient` |
| 68 | +- Low-level methods: |
| 69 | + - `ping`, `status_get`, `execute`, `cancel`, `next_event`, `wait_for_task` |
| 70 | +- Command wrappers: |
| 71 | + - All top-level Baritone commands exposed as methods. |
| 72 | +- Settings namespace: |
| 73 | + - Sync: `client.settings.allowPlace = True` |
| 74 | + - Async: `await client.settings.allowPlace.set(True)` |
| 75 | + |
| 76 | +## Auto-Discovery (Zero-Setup) |
| 77 | + |
| 78 | +By default, `pyritone` discovers bridge metadata from: |
84 | 79 |
|
85 | 80 | - `<minecraft>/config/pyritone_bridge/bridge-info.json` |
86 | 81 |
|
87 | | -Override priority: |
| 82 | +Override precedence: |
88 | 83 |
|
89 | 84 | 1. Explicit constructor args |
90 | | -2. Environment variables (`PYRITONE_BRIDGE_INFO`, `PYRITONE_TOKEN`, `PYRITONE_HOST`, `PYRITONE_PORT`) |
91 | | -3. Default bridge info file |
92 | | - |
93 | | -## CLI |
94 | | - |
95 | | -```bash |
96 | | -pyritone ping |
97 | | -pyritone status |
98 | | -pyritone exec "goto 100 70 100" |
99 | | -pyritone cancel |
100 | | -pyritone events |
101 | | -``` |
102 | | - |
103 | | -## Regenerate command wrappers/docs |
104 | | - |
105 | | -```bash |
106 | | -python tools/generate_baritone_commands.py |
107 | | -``` |
108 | | - |
109 | | -## End-to-End Dev Test |
110 | | - |
111 | | -1. Start Minecraft dev client from the mod folder: |
| 85 | +2. Environment variables: `PYRITONE_BRIDGE_INFO`, `PYRITONE_TOKEN`, `PYRITONE_HOST`, `PYRITONE_PORT` |
| 86 | +3. Auto-discovered bridge info file |
112 | 87 |
|
113 | | -```powershell |
114 | | -cd ..\mod |
115 | | -.\gradlew.bat devClient |
116 | | -``` |
117 | | - |
118 | | -2. Join a world. |
119 | | -3. Run one of the example scripts: |
120 | | - |
121 | | -```powershell |
122 | | -cd ..\python |
123 | | -python example_sync.py |
124 | | -python example_async.py |
125 | | -``` |
0 commit comments