API Bridge 1.2.0 для Minecraft 1.21.11 (Fabric)
Файлы · 1
Что изменилось
Changelog
v1.2.0 — AI Endpoints + Observation Schema + Security Fixes
New Features
AI-Friendly Endpoints (OpenAI Gym style) — 6 new endpoints for Reinforcement Learning agents:
POST /session— Create/reuse AI sessionGET /observation— Full structured game observationPOST /action— Send actions (12 types)POST /step— Combined action + observation (likeenv.step())GET /stream— SSE streaming of observations per tickPOST /close— Close session and cancel tasks
Observation Schema — Fixed-size JSON for ML tensor compatibility:
viewport_blocks: 4608 block IDs (16×9×32 frustum)viewport_entities: Up to 16 entities with type, position, health, distanceinventory.slots: 41 fixed slots as[item_id, count]player.status:[health, food, saturation, armor, air]player.flags: 6 binary state indicatorstarget: Crosshair target withblock_id,distance,face
Screen Observation — Detect open UI screens with component extraction:
- 37 known screen class mappings (inventory, chest, crafting, furnace, etc.)
- Components: buttons, sliders, textboxes with type-specific properties
- Navigation path tracking
AI Agent Guide — Comprehensive documentation for AI agents:
docs/en/AI_AGENT_GUIDE.md— Complete JSON field guide + action strategiesdocs/vi/AI_AGENT_GUIDE.md— Vietnamese version- Workflows: survival, mining, combat, building, farming
- Error recovery and prioritization matrix
- 12 Action Types:
key,select_slot,place,break,interact,jump,swing,look,craft,chat,command,click_button
Bug Fixes
Server no longer stops on world exit — Removed
SERVER_STOPPING → ApiServer.stop(). API server now stays alive when leaving a world, allowing title-screen operations (click "Singleplayer", select world, etc.). Server only stops onCLIENT_STOPPING(Minecraft fully closes).ObservationHandler async response crash — Added
CountDownLatchto ObservationHandler so the HTTP response is sent synchronously after the MC client thread processes the command. Previously the handler returned before the response was written, causingcurl: (18) transfer closederrors.Frustum block scanning fixed —
viewport_blockswas returning all zeros because:rightvector had wrong sign ((-dirZ, 0, dirX)→(dirZ, 0, -dirX))upvector was not perpendicular to the look direction (computed with wrong formula)- Fixed with proper cross products:
right = cross(world_up, dir),up = cross(dir, right) - Added gimbal lock handling for straight up/down look
Screen ID no longer shows obfuscated names —
class_433→minecraft:pausevia 37 known screen class mappings + heuristic fallback- World name matching case-insensitive —
ClientUIHandlernow usestoLowerCase().contains()for matching button text
Security
- Constant-time token comparison — Using
MessageDigest.isEqual()instead of string comparison - Input validation — Block/item IDs validated against
RESOURCE_IDregex (namespace:pathformat) - Body size limit — 1 MB max request body
- Rate limiting — 60 requests/second per IP
- Thread pool increased — TaskManager scheduler pool 4→8 threads (DoS mitigation)
Improvements
- Slot bounds checking — Hotbar slots validated 0-8, inventory slots 0-35
- Client-side interactions — Block breaking/placing uses
client.gameModeinstead ofclient.player.gameMode(compatible with access widener) - Inventory API — Uses
inventory.getItem(i)/inventory.getContainerSize()instead of private field reflection - Documentation — Updated README.md, README_vi.md, docs/en/API.md, docs/vi/API.md with complete Section 8 (AI endpoints) + Section 9 (Observation Schema Details) + Section 10 (Registry Reference)
- Registry Reference — Added numeric ID reference for items, blocks, entities, effects, enchantments, biomes. Note: IDs are dynamic per session; use namespaced IDs (
minecraft:stone) for stability.