Minecraft Console Client (MCC) Documentation

repository·master·Indexed 24 days ago

https://github.com/mccteam/minecraft-console-client

A lightweight, cross-platform, open-source TUI client for Minecraft Java Edition. MCC allows users to connect to servers, send commands, and receive messages via a terminal. It features automation tools (Anti-AFK, Auto-Relog, Auto-Fishing), a C# API for custom bots, and support for Minecraft versions 1.4.6 through 26.1. Includes documentation for the WebSocket Bot for remote control and developer tools for adapting the client to new Minecraft versions.

Tokens
44.6K
Snippets
125
Records
244
Agent score
83%

What's inside Minecraft Console Client

  1. Overview of Minecraft Console Client (MCC)

    master

    Minecraft Console Client (MCC) is a lightweight, cross-platform, open-source TUI (Text User Interface) client for Minecraft Java Edition. It allows users to connect to servers, send commands, and receive messages without the overhead of the full Minecraft game client.

    Key Capabilities

    • Communication: Send/receive chat, log history, set keyword alerts, and auto-respond.
    • Automation: Includes features like Anti-AFK, Auto-Relog, Script Scheduler, Auto-Fishing, Auto-Eat, Auto-Craft, and more.
    • Extensibility: Provides a C# API for creating custom bots and runtime scripts.
    • Advanced Handling: Supports inventory, terrain traversing, and entity handling (subject to protocol version).
    • Deployment: Supports Docker for containerized usage.
  2. How MCC handles movement and path-finding

    master

    MCC utilizes an A* path-finding algorithm combined with a physics-based movement system.

    Supported Movement Capabilities

    • Navigation: Terrain navigation using A* and physics-driven movement.
    • Collision: Collision-aware movement using real block shapes.
    • Obstacles: Automatic jumping for vertical movement, step-up movement for slabs, and climbing (ladders, vines).
    • Physics: Movement in water/lava, gravity, friction, and block-specific modifiers (ice, soul sand, soul soil, honey blocks).
    • States: Sneaking and sprinting.

    Current Limitations

    • Complexity: Path-finding is block-based; extremely complex terrain may cause failures.
    • Water: Automatic route planning avoids underwater routes by default (not a full swimming path-finder).
    • External Forces: Knockback and other external velocity effects are not currently simulated.
  3. Operating Loop for MCC MCP Operators

    master

    When using the MCC MCP toolset, follow a structured operating loop to ensure accuracy and prevent hallucinating game states:

    1. Inspect: Always inspect the current situation using direct observation tools before acting.
    2. Plan: Create the shortest possible plan that can achieve the goal.
    3. Act: Use the smallest set of high-signal tools required to perform the action.
    4. Verify: After an action, use fresh tool calls to read the state again and confirm the outcome.
    5. Report: Report only what is verified. Clearly label anything that is inferred, conflicting, or unknown.

    Key Principles:

    • Use the MCC MCP toolset as the sole source of truth. Do not guess based on intent.
    • If tool results and fresh observations disagree, trust the freshest direct observation.
    • For conversational requests that don't require game state, answer directly without using tools.
  4. Understand the WebSocket Event structure

    master

    All events pushed to authenticated WebSocket clients follow a standard JSON envelope. The data field contains a serialized JSON string representing the event's specific payload, which you must parse to access the details.

    Event Envelope Format:

    {
      "event": "EventName",
      "data": "{ ... serialized payload ... }"
    }

    Important Note: Enum values (like entity types or item types) are serialized as their string names (e.g., "Zombie") rather than integer IDs.

    {
      "event": "EventName",
      "data": "{ ... serialized payload ... }"
    }
  5. Define recipes for Auto Craft

    master

    Recipes are defined in the [[ChatBot.AutoCraft.Recipes]] section. Each recipe requires a Name, Type (player or table), Result (item name), and Slots (an array of material names).

    Slot Mapping:

    • 2x2 (Player): 1 | 2 --+-- 3 | 4
    • 3x3 (Table): 1 | 2 | 3 --+---+-- 4 | 5 | 6 --+---+-- 7 | 8 | 9

    Important: Use the string "Null" to represent empty slots in the Slots array.

    # Stone Bricks using the player inventory
    [[ChatBot.AutoCraft.Recipes]]
    Name = "Recipe-Name-1"
    Type = "player"
    Result = "StoneBricks"
    Slots = [ "Stone", "Stone", "Stone", "Stone" ]
    
    # Stone Bricks using a crafting table
    [[ChatBot.AutoCraft.Recipes]]
    Name = "Recipe-Name-2"
    Type = "table"
    Result = "StoneBricks"
    Slots = [ "Stone", "Stone", "Null", "Stone", "Stone", "Null", "Null", "Null", "Null" ]
  6. Receiving WebSocket Bot Events

    master

    Events emitted by the bot arrive as JSON objects. The payload is contained within a stringified JSON field named data.

    Event Format:

    {
      "event": "EventName",
      "data": "{ ... serialized payload ... }"
    }

    To access the event details, you must parse the data field separately as a JSON string.

    {
      "event": "EventName",
      "data": "{ ... serialized payload ... }"
    }
  7. Understand the configuration file format

    master

    The configuration file uses the TOML format. Settings are organized into sections containing key-value pairs.

    Syntax Rules:

    • Sections: Defined by square brackets, e.g., [SectionName].
    • Key-Value Pairs: Written as key = value.
    • Comments: Lines starting with # are ignored by the program and used for descriptions.
    • Subsections: Defined using dot notation, e.g., [ParentSection.SubSection].
    • Data Types: Supports strings, integers, booleans, arrays (e.g., [ "a", "b" ]), and inline tables (e.g., { x = 1, y = 2 }).

    For complete syntax details, refer to the official TOML documentation.

    [SectionNameHere]
    Setting_Name = "this is some name"
    Setting_Something = 15
    
    [OtherSection]
    # This is a comment explaining what this setting/option does
    Other_Setting = true  # This also is a comment
    
    [ThirdSection]
    Section_Enabled = true
    colors = [ "red", "yellow", "green" ]
    
    [ThirdSection.Subsection]
    Coordinate = { x = 145, y = 64, z = 2045 }
  8. How the AI development harness works

    master

    The harness allows an AI agent to drive development without a human-interactive terminal. It uses the following components to create a feedback loop:

    • Local Minecraft Server: Runs in a tmux session.
    • mc-rcon: Used for server-side commands (e.g., /op, /give, /summon).
    • MCC Input Injection: MCC is started with MCC_FILE_INPUT=1.
    • FileInputBot: Watches the session input file located at ${TMPDIR:-/tmp}/mcc-debug/<session>/mcc_input.txt.
    • Log Inspection: The agent inspects logs from both MCC and the local server to validate changes.
  9. Handle Enums and Mappings in WebSocket Bot

    master

    The WebSocket Bot serializes all enums (e.g., ItemType, EntityType, Direction, Hand) as string names rather than numeric IDs.

    Sending Enum Parameters

    When sending commands that require enums, you can provide either the string name or the numeric ID:

    Using String Names:

    { "command": "InteractEntity", "requestId": "abc", "parameters": [42, "Interact", "MainHand"] }

    Using Numeric IDs:

    { "command": "InteractEntity", "requestId": "abc", "parameters": [42, 0, 0] }

    Querying Mappings

    To ensure your client uses the correct names or IDs for the current MCC version, use these dedicated commands to retrieve mapping tables:

    • GetItemTypeMappings: Returns a mapping of { "Name": ID, ... } for items.
    • GetEntityTypeMappings: Returns a mapping of { "Name": ID, ... } for entities.
    {
      "command": "InteractEntity",
      "requestId": "abc",
      "parameters": [42, "Interact", "MainHand"]
    }
  10. Manage isolated MCC sessions and shared servers

    master

    The harness separates shared server state from isolated MCC client state to allow multiple worktrees to interact with the same server simultaneously.

    • mc-* commands: Operate on the shared local Minecraft server.
    • mcc-* commands: Operate on a specific MCC client session.
    • Session Isolation: The default session is the current worktree name. The username is derived from the session name, preventing clients from kicking each other off the same server.
    • Session Files: Stored under ${TMPDIR:-/tmp}/mcc-debug/<session>/.

    Example: Running two worktrees against one server

    # worktree A
    cd ~/Minecraft/Minecraft-Console-Client
    source tools/mcc-env.sh
    mc-start 1.21.11
    mcc-debug -v 1.21.11 --file-input
    
    # worktree B
    cd ~/Minecraft/Minecraft-Console-Client-foo
    source tools/mcc-env.sh
    mcc-debug -v 1.21.11 --file-input
    
    # Both can run session-specific commands
    mcc-state

    To use a specific session name instead of the worktree default, pass the --session NAME flag to mcc-* commands.

    # worktree A
    cd ~/Minecraft/Minecraft-Console-Client
    source tools/mcc-env.sh
    mc-start 1.21.11
    mcc-debug -v 1.21.11 --file-input
    
    # worktree B
    cd ~/Minecraft/Minecraft-Console-Client-foo
    source tools/mcc-env.sh
    mcc-debug -v 1.21.11 --file-input
    
    # from each worktree, mcc-* targets that worktree's default session
    mcc-state