Minecraft Máy Khách ĐơnMinecraft Máy Khách Đơn
Giới thiệu & Tính năng
Cài đặt
Sử dụng
Cấu hình
Chatbot
Hãy giúp chúng tôi dịch
  • Afrikaans
  • اللغة العربية
  • Català
  • Čeština
  • Dansk
  • Deutsch
  • Ελληνικά
  • English
  • Español
  • Suomi
  • Français
  • עברית
  • Magyar
  • Italiano
  • 日本語
  • 한국어
  • Latviešu
  • Nederlands
  • Norsk
  • Polski
  • Português (Brasil)
  • Português (Portugal)
  • Română
  • Русский
  • Српски (Cyrillic)
  • Svenska
  • Türkçe
  • Українська
  • Tiếng Việt
  • 简体中文
  • 繁體中文
GitHub
Giới thiệu & Tính năng
Cài đặt
Sử dụng
Cấu hình
Chatbot
Hãy giúp chúng tôi dịch
  • Afrikaans
  • اللغة العربية
  • Català
  • Čeština
  • Dansk
  • Deutsch
  • Ελληνικά
  • English
  • Español
  • Suomi
  • Français
  • עברית
  • Magyar
  • Italiano
  • 日本語
  • 한국어
  • Latviešu
  • Nederlands
  • Norsk
  • Polski
  • Português (Brasil)
  • Português (Portugal)
  • Română
  • Русский
  • Српски (Cyrillic)
  • Svenska
  • Türkçe
  • Українська
  • Tiếng Việt
  • 简体中文
  • 繁體中文
GitHub
  • Giới thiệu & Tính năng
  • Cài Đặt
  • Sử dụng
  • Cấu hình
  • Creating Simple Script
  • Chat Bots
  • Creating Chat Bots
  • Contributing

Lệnh WebSocket

Lệnh là những thực thể JSON gửi qua kết nối WebSocket Mỗi lệnh sinh ra phản hồi qua sự kiện OnWsCommandResponse.

{
  "command": " TênLệnh",  // nhớ không dấu, khoảng cách.
  "requestId": " id-duy-nhat",
  "parameters": []
}

Protocol Commands

Đây là những câu lệnh quản lý phiên WebSocket của chính nó.

Xác Thực

Xác thực với mật khẩu đã cài đặt. Nên được gọi trước bất kỳ lệnh nào khác (ngoại lệ: ChangeSessionId)

Các thông số.

Đầu vàoGõMô tả
0chuỗi ký tựMật khẩu

Ví dụ:

{
  "command": " XacThuc",
  "requestId": " auth-001",
  "parameters": ["mat-khau"]
}

ChangeSessionId

Đổi tên phiên làm việc hiện tại. Có thể được gọi mà không qua xác thực. ID mới nên là chuỗi 1-32 ký tự và chưa bị lấy trước.

Các thông số.

Đầu vàoGõMô tả
0chuỗi ký tựID phiên làm việc mới

Ví dụ:

{
  "command": "ChangeSessionId",
  "requestId": "rename-001",
  "parameters": ["my-bot"]
}

Logging Commands

LogToConsole

Log a message to the MCC console.

Các thông số.

IndexGõMô tả
0chuỗi ký tựMessage

LogDebugToConsole

Log a debug message to the MCC console (only visible in debug mode).

Các thông số.

IndexGõMô tả
0chuỗi ký tựMessage

LogToConsoleTranslated

Log a translated message using an MCC translation key.

Các thông số.

IndexGõMô tả
0chuỗi ký tựTranslation key

LogDebugToConsoleTranslated

Log a translated debug message.

Các thông số.

IndexGõMô tả
0chuỗi ký tựTranslation key

Session Commands

ReconnectToTheServer

Reconnect to the Minecraft server.

Các thông số.

IndexGõMô tả
0intExtra reconnect attempts (default 3)
1intDelay in seconds (default 0)

DisconnectAndExit

Disconnect from the server and shut down MCC. No parameters.

Chat Commands

SendPrivateMessage

Send a private message to a player.

Các thông số.

IndexGõMô tả
0chuỗi ký tựPlayer name
1chuỗi ký tựMessage

Script Commands

RunScript

Run an MCC script file.

Các thông số.

IndexGõMô tả
0chuỗi ký tựFile name

World and Terrain Commands

GetTerrainEnabled

Check if terrain handling is enabled. No parameters. Returns { "enabled": true/false }.

SetTerrainEnabled

Enable or disable terrain handling.

Các thông số.

IndexGõMô tả
0boolEnabled

GetWorld

Check if world data is available. No parameters. Returns { "available": true } if terrain is enabled.

DigBlock

Break a block at the given coordinates. Validates the block is within 6 blocks and is not air.

Các thông số.

IndexGõMô tả
0doubleX coordinate
1doubleY coordinate
2doubleZ coordinate
3chuỗi ký tựDirection (optional, e.g. "Down")

The Direction parameter accepts string names: Down, Up, North, South, West, East.

Entity Commands

GetEntityHandlingEnabled

Check if entity handling is enabled. No parameters. Returns { "enabled": true/false }.

GetEntities

Get all tracked entities. No parameters. Returns a dictionary of entity ID to entity object.

Entity types are serialized as string names (e.g., "Zombie", "Player").

InteractEntity

Interact with an entity.

Các thông số.

IndexGõMô tả
0intEntity ID
1chuỗi ký tựInteraction type (Interact, Attack, InteractAt)
2chuỗi ký tựHand (optional, MainHand or OffHand)

SendEntityAction

Send an entity action.

Các thông số.

IndexGõMô tả
0chuỗi ký tựAction type (e.g. StartSneaking, StopSneaking)

Sneak

Toggle sneaking.

Các thông số.

IndexGõMô tả
0booltrue to sneak, false to stop

Movement Commands

GetCurrentLocation

Get the player's current location. No parameters. Returns a location object with x, y, z.

MoveToLocation

Move the player to a location using pathfinding.

Các thông số.

IndexGõMô tả
0doubleX coordinate
1doubleY coordinate
2doubleZ coordinate
3boolAllow unsafe (optional, false)
4boolAllow direct teleport (optional)
5intMax offset (optional, 0)
6intMin offset (optional, 0)

ClientIsMoving

Check if the client is currently moving. No parameters. Returns { "moving": true/false }.

LookAtLocation

Make the player look at coordinates.

Các thông số.

IndexGõMô tả
0doubleX
1doubleY
2doubleZ

Player Info Commands

GetUsername

Get the player's username. No parameters. Returns { "username": "..." }.

GetUserUUID

Get the player's UUID. No parameters. Returns { "uuid": "..." }.

GetGamemode

Get the current gamemode. No parameters. Returns { "gamemode": 0 }.

GetYaw

Get the player's yaw rotation. No parameters. Returns { "yaw": 0.0 }.

GetPitch

Get the player's pitch rotation. No parameters. Returns { "pitch": 0.0 }.

GetOnlinePlayers

Get a list of online player names. No parameters. Returns a string array.

GetOnlinePlayersWithUUID

Get online players with their UUIDs. No parameters. Returns a dictionary of UUID to player name.

GetPlayersLatency

Get latency information for online players. No parameters.

Server Info Commands

GetServerHost

Get the server hostname. No parameters. Returns { "host": "..." }.

GetServerPort

Get the server port. No parameters. Returns { "port": 25565 }.

GetServerTPS

Get the server TPS (ticks per second). No parameters. Returns { "tps": 20.0 }.

GetTimestamp

Get the current timestamp. No parameters. Returns { "timestamp": "..." }.

GetProtocolVersion

Get the Minecraft protocol version. No parameters. Returns { "protocolVersion": 769 }.

GetMaxChatMessageLength

Get the maximum chat message length. No parameters. Returns { "length": 256 }.

Inventory Commands

GetInventoryEnabled

Check if inventory handling is enabled. No parameters. Returns { "enabled": true/false }.

GetPlayerInventory

Get the player's inventory. No parameters. Returns the full inventory container with items.

Item types are serialized as string names (e.g., "DiamondSword", "Stone").

GetInventories

Get all open inventories. No parameters.

WindowAction

Perform a window/inventory action.

Các thông số.

IndexGõMô tả
0intInventory ID
1intSlot ID
2chuỗi ký tựAction type (e.g. LeftClick, RightClick, DropItemStack)

ChangeSlot

Change the active hotbar slot.

Các thông số.

IndexGõMô tả
0shortSlot number (0-8)

GetCurrentSlot

Get the currently selected hotbar slot. No parameters. Returns { "slot": 0 }.

SetSlot

Set the active slot (legacy command).

Các thông số.

IndexGõMô tả
0intSlot number

ClearInventories

Clear tracked inventory state. No parameters.

CloseInventory

Close an inventory window.

Các thông số.

IndexGõMô tả
0intInventory ID

Creative Mode Commands

CreativeGive

Give an item in creative mode.

Các thông số.

IndexGõMô tả
0intSlot ID
1chuỗi ký tựItem type (e.g. "DiamondSword" or 798)
2intCount

CreativeDelete

Delete an item from a slot in creative mode.

Các thông số.

IndexGõMô tả
0intSlot ID

Block Interaction Commands

SendPlaceBlock

Place a block.

Các thông số.

IndexGõMô tả
0doubleX coordinate
1doubleY coordinate
2doubleZ coordinate
3chuỗi ký tựDirection (e.g. "Up")
4chuỗi ký tựHand (optional, "MainHand" or "OffHand")

SendAnimation

Play arm swing animation.

Các thông số.

IndexGõMô tả
0chuỗi ký tựHand (optional, default "MainHand")

UseItemInHand

Use the item currently held. No parameters.

UpdateSign

Update text on a sign.

Các thông số.

IndexGõMô tả
0doubleX coordinate
1doubleY coordinate
2doubleZ coordinate
3chuỗi ký tựLine 1
4chuỗi ký tựLine 2
5chuỗi ký tựLine 3
6chuỗi ký tựLine 4

UpdateCommandBlock

Update a command block.

Các thông số.

IndexGõMô tả
0doubleX coordinate
1doubleY coordinate
2doubleZ coordinate
3chuỗi ký tựCommand
4chuỗi ký tựMode (e.g. "Sequence", "Auto", "Redstone")
5chuỗi ký tựFlags

Trading Commands

SelectTrade

Select a villager trade.

Các thông số.

IndexGõMô tả
0intTrade index

Respawn

Respawn after death. No parameters.

Mapping Commands (New)

These commands let clients query enum mappings dynamically at runtime, so they do not need to maintain hardcoded numeric ID tables that break across MCC versions. For background, see issue #2805.

GetItemTypeMappings

Get a dictionary of all ItemType names to their numeric IDs. No parameters. Returns { "DiamondSword": 798, "Stone": 1, ... }.

GetEntityTypeMappings

Get a dictionary of all EntityType names to their numeric IDs. No parameters. Returns { "Player": 128, "Zombie": 119, ... }.

Chỉnh sửa trang này