操作模式
三種模式同時開啟,走同一條 WebSocket。ping 報告 defaultMode 和本版本里每種模式的操作(modes)。
| 模式 | 用於 | 操作 |
|---|---|---|
| bedboo(默認) | 玩法:移動、戰鬥、建造、背包、聊天、命令 | world look input slot action button settings send stack timescale join tap |
| UI 樹 | bedboo 覆蓋不到的菜單和界面 | ui;oreui(原始 Ore UI DOM,調試用) |
| 模擬輸入 | 其餘一切 | key text mouse raw release flush focus window screenshot |
用哪一種
先 bedboo,再 ui,最後模擬輸入。
- bedboo 操作用遊戲的語言(數字)回答:精確、小,不受窗口大小、界面縮放和鍵位綁定影響。
ui視圖每個界面幾百個字符;按ref點擊控件,不靠像素。- 一張截圖讓 agent 花約 500–1800 個圖像 token,還要再截一張來確認,而且像素位置會失效。
保持一條連接(或一個小助手函數)開著:每個操作一條 JSON 消息。用 world 或 ui 檢查結果,不用截圖。
bedboo
bedboo 是兼容 mineflayer 的基岩版機器人庫。用 transport: 'bedd' 時,它把
bot.dig、bot.lookAt、bot.setControlState、bot.chat、bot.clickWindow 等轉成這些操作,並從 tap 讀取數據包
(配置;覆蓋範圍:bedboo 的 BeDD 指南)。
不用 bedboo 時直接發操作(call;字段:bedboo 操作):
js
await call('look', { yaw: 90, pitch: 30 });
await call('input', { move: { x: 0, z: 1 }, sprint: true, ttlMs: 2000 });
await call('button', { button: 'attack', action: 'down', releaseOn: 'blockChange' });UI 樹
ui 把最前面的界面(JSON UI 或 Ore UI)返回成文本;對某行的 ref 執行動作。讀取方式、字段、角色和錯誤:
UI 樹。
text
screen start_screen
- button "Play" [e1]
- button "Settings" [e2]
- text "v26.60/LeviLamina-26.60.5"
under: toast_screen, debug_screen, cubemap_background_screenjs
await call('ui', { action: 'click', ref: 'e1' }); // reply: changed, target, screen; view when the screen changedref 在其界面留在棧上期間有效,跨連接通用。動作使用虛擬鼠標和鍵盤。遇到 stale_ref 時重新讀 ui。
模擬輸入
js
await call('key', { key: 'E' }); // open the inventory
await call('mouse', { action: 'click', rx: 0.5, ry: 0.474 }); // or { ref } from ui
await call('screenshot', { format: 'jpeg', region: { x: 0, y: 0, w: 480, h: 270 } }); // works while covered