This NeoForge mod provides a socket-based API (CLI) for external agents (AI, scripts) to control the Minecraft player.
- State Observation: Get player health, position, hunger, etc.
- Inventory: Inspect inventory items and containers.
- Movement: Control movement (WASD, jump, sneak) or pathfind to coordinates.
- Interaction: Attack, use items, mine blocks, place blocks.
- Vision: Get screenshots of the current view and inspect nearby blocks/entities.
- Communication: Send/Receive chat messages and execute commands.
- Connectivity: Connect to servers programmatically.
- Events: Receive real-time JSON events (chat, death, join).
- Build the mod:
./gradlew build - Copy the jar from
build/libs/to your Minecraftmodsfolder. - Launch Minecraft with NeoForge 1.21.4.
The mod starts a TCP server on port 25566 (localhost) when the client loads.
Send a JSON string ending with a newline. The server responds with a JSON string ending with a newline. The server also sends asynchronous JSON events.
Check connectivity.
- Request:
{"command": "ping"} - Response:
{"status": "success", "message": "pong"}
Connect to a server.
- Request:
{"command": "connect", "address": "localhost:25565"}
Send chat message.
- Request:
{"command": "chat", "message": "Hello world"}
Execute slash command (without slash usually, or with).
- Request:
{"command": "execute", "cmd": "gamemode creative"}
Get player state.
- Request:
{"command": "state"} - Response:
{"status": "success", "data": { "x": 100, "y": 64, "z": 100, "health": 20, ... }}
Get player inventory.
- Request:
{"command": "inventory"} - Response:
{"status": "success", "data": { "main": [...], "armor": [...], "offhand": [...] }}
Select hotbar slot.
- Request:
{"command": "equip", "slot": 0}
Control movement keys.
- Request:
{"command": "move", "forward": true, "jump": false} - Flags:
forward,back,left,right,jump,sneak,sprint.
Set player rotation.
- Request:
{"command": "look", "yaw": 0.0, "pitch": 0.0}
Simple pathfinding to coordinates.
- Request:
{"command": "goto", "x": 100, "z": 100} - (Optional
yto target specific height). - Stops when within 0.5 blocks.
Perform actions.
- Request:
{"command": "interact", "action": "attack"} - Actions:
attack,use,stop_use,drop,drop_stack.
Mine block at coordinates.
- Request:
{"command": "mine", "x": 100, "y": 64, "z": 100}
Place block at coordinates.
- Request:
{"command": "place", "x": 100, "y": 64, "z": 100, "face": "UP"}
Inspect block at coordinates.
- Request:
{"command": "inspect", "x": 100, "y": 64, "z": 100} - Response:
{"status": "success", "data": { "id": "minecraft:stone", "properties": {...}, "nbt": "..." }}
Get nearby entities.
- Request:
{"command": "entities", "radius": 50, "type": "minecraft:zombie"} - Response:
{"status": "success", "data": [...]}
Get a screenshot.
- Request:
{"command": "view"} - Response:
{"status": "success", "image": "<base64_png>"}
Get current UI info.
- Request:
{"command": "ui"} - Response:
{"status": "success", "containerId": 1, "slots": [...]}
Click a slot in an open container.
- Request:
{"command": "click_slot", "containerId": 1, "slot": 0, "button": 0, "type": "PICKUP"}
The server sends JSON objects with an "event" field.
- Chat:
{"event": "chat", "message": "Player joined the game"} - Death:
{"event": "death", "message": "Player died"} - Join:
{"event": "join", "dimension": "minecraft:overworld"}