Minecraft 命令行客户端Minecraft 命令行客户端
关于 & 特性
安装
使用方法
配置
Chat Bots
帮助我们翻译
  • 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
关于 & 特性
安装
使用方法
配置
Chat Bots
帮助我们翻译
  • 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
  • 关于 & 特性
  • 安装
  • 用法
  • 配置
  • 创建简单脚本
  • Chat Bots
  • 创建 Chat Bots
  • 贡献

WebSocket 事件

事件是推送到所有已认证的 WebSocket 客户端的JSON 消息。 事件有以下结构:

{
  "event": "事件名",
  "data": "{ ... 序列化载荷 ... }"
}

data字段是一个 JSON 字符串。 解析它来得到事件的有效载荷。

所有枚举值都被序列化为 字符串名称 (例如,"Zombie" 而不是 119)。

协议事件

OnWsCommandResponse

当命令执行后发送。

载荷:

{
  "success": true,
  "requestId": "请求-id",
  "message": "可选的结果或错误消息"
}

匹配 requestId 来跟踪哪个命令生成了这个响应。

OnMccCommandResponse

当纯文本MCC命令(以 / 开头)执行时发送。

载荷:

{
  "command": "move north",
  "status": "Done",
  "result": ""
}

OnGameJoined

在客户端加入服务器和游戏绘画开始后发送这个 有效载荷:N/A

OnWsRestarting

当WebSocket服务器重启的时候(比如重新连接服务器)发送这个 Payload: "N/A"

OnWsConnectionClose

当WebSocket服务器关闭时发送这个 Patload: "N/A"

聊天事件

OnChatRaw

发送所有收到的新消息,包含原始JSON

载荷:

{
  "text": "格式化后的文本内容",
  "json": "{ 从服务器发送的原始json }"
}

OnChatPublic

当检测到公开聊天信息时发送

载荷:

{
  "sender": "玩家名",
  "message": "Hello world",
  "rawText": "<PlayerName> Hello world"
}

OnChatPrivate

当检测到私信的时候发送

载荷:

{
  "sender": "玩家名",
  "message": "私信内容",
  "rawText": "PlayerName whispers to you: Secret message"
}

OnTeleportRequest

当检测到传送请求后发送

载荷:

{
  "sender": "PlayerName",
  "rawText": "PlayerName has requested to teleport to you"
}

连接事件

OnDisconnect

当 MCC 与服务器断连时发送。

载荷:

{
  "reason": "ConnectionLost",
  "message": "Connection has been lost."
}

原因值: ConnectionLost,UserLogout,InGameKick,LoginRejected。

实体事件

实体对象的 类型 表现为字符串(例如 "Zombie", "Player")。

OnEntitySpawn

当一个实体生成时发送。

有效载荷: 完整实体对象。

OnEntityDespawn

当一个实体被清除时发送。

有效载荷: 完整实体对象。

OnEntityMove

当实体移动时发送。

有效载荷: 具有更新位置的完整实体对象。

OnEntityAnimation

当实体播放动画时发送。

载荷:

{
  "entity": { ... },
  "animation": 0
}

OnEntityHealth

当实体生命值发生变化或更新时发送。

载荷:

{
  "entity": { ... },
  "health": 20.0
}

OnEntityMetadata

当实体元数据更新时发送。

载荷:

{
  "entity": { ... },
  "metadata": { "0": ..., "1": ... }
}

OnEntityEquipment

当实体的装备变化时发送。

载荷:

{
  "entity": { ... },
  "slot": 0,
  "item": { "type": "DiamondSword", "count": 1, ... }
}

物品类型表现为字符串名称(例如:"钻石剑")。

OnEntityEffect

当一个实体获得效果时发送。

载荷:

{
  "entity": { ... },
  "effect": "Speed",
  "amplifier": 1,
  "duration": 600,
  "flags": 0
}

OnBlockBreakAnimation

当一个方块的破坏动画播放时发送。

载荷:

{
  "entity": { ... },
  "location": { "x": 10, "y": 64, "z": -20 },
  "stage": 5
}

玩家事件

OnPlayerJoin

当玩家加入服务器时发送。

载荷:

{
  "uuid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "name": "玩家名"
}

OnPlayerLeave

当玩家离开服务器时发送。

载荷:

{
  "uuid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "name": "玩家名"
}

OnPlayerProperty

当玩家属性更新时发送(如:速度、攻击伤害)。

有效载荷: 属性名称到值的字典。

OnPlayerStatus

当玩家的状态发生变化时发送。

载荷:

{
  "statusId": 0
}

OnDeath

当玩家死亡时发送。 有效载荷:N/A

OnRespawn

当玩家重生时发送。 有效载荷:N/A

生命与经验值事件

OnHealthUpdate

当玩家的生命或饥饿值发生变化时发送。

载荷:

{
  "health": 20.0,
  "food": 20
}

OnSetExperience

当经验值更新时发送。

载荷:

{
  "experienceBar": 0.5,
  "level": 10,
  "totalExperience": 200
}

游戏事件

OnGamemodeUpdate

在玩家的游戏模式发生变化时发送。

载荷:

{
  "playerName": "Steve",
  "uuid": "...",
  "gamemode": 1
}

OnLatencyUpdate

当玩家的延迟发生变化时发送。

载荷:

{
  "playerName": "Steve",
  "uuid": "...",
  "latency": 42
}

OnHeldItemChange

当玩家选择的物品槽位变化时发送。

载荷:

{
  "slot": 0
}

OnExplosion

当爆炸发生时发送。

载荷:

{
  "location": { "x": 10, "y": 64, "z": -20 },
  "strength": 4.0,
  "recordcount": 12
}

OnTitle

当标题、副标题或动作栏文本显示时发送。

载荷:

{
  "action": 0,
  "titleText": "Welcome",
  "subtitleText": "",
  "actionBarText": "",
  "fadeIn": 10,
  "stay": 70,
  "fadeOut": 20,
  "json": "..."
}

服务器事件

OnServerTpsUpdate

当服务器 TPS 变化时发送。

载荷:

{
  "tps": 20.0
}

OnTimeUpdate

当世界时间发生变化时发送。

载荷:

{
  "worldAge": 1000000,
  "timeOfDay": 6000
}

OnInternalCommand

当一个 MCC 内部命令被执行时发送。

载荷:

{
  "commandName": "move",
  "commandParams": "north",
  "result": {
    "status": "Done",
    "result": ""
  }
}

物品栏事件

OnInventoryUpdate

当物品栏内容发生变化时发送。

载荷:

{
  "inventoryId": 0
}

OnInventoryOpen

当物品栏窗口打开时发送。

载荷:

{
  "inventoryId": 1
}

OnInventoryClose

当物品栏窗口关闭时发送。

载荷:

{
  "inventoryId": 1
}

记分板事件

OnScoreboardObjective

当计分板记分项更新时发送。

载荷:

{
  "objectiveName": "health",
  "mode": 0,
  "objectiveValue": "Health",
  "type": 0,
  "json": "...",
  "numberFormat": 0
}

OnUpdateScore

当计分板分数更新时发送。

载荷:

{
  "entityName": "Steve",
  "action": 0,
  "objectiveName": "health",
  "objectiveDisplayName": "Health",
  "value": 20,
  "numberFormat": 0
}

地图与交易事件

OnMapData

当地图数据更新时发送。

载荷:

{
  "mapId": 0,
  "scale": 1,
  "trackingPosition": true,
  "locked": false,
  "icons": [],
  "columnsUpdated": 128,
  "rowsUpdated": 128,
  "mapColumnX": 0,
  "mapRowZ": 0,
  "colors": "base64-文本"
}

注: colors 如果存在则是base64编码的字符串,否则为 null。

OnTradeList

当收到村民交易清单时发送。

载荷:

{
  "windowId": 1,
  "trades": [...],
  "villagerInfo": { ... }
}

网络事件

OnNetworkPacket

当网络数据包发生时发送(如果有订阅)。

载荷:

{
  "packetID": 42,
  "data": "base64-网络包-数据",
  "isLogin": false,
  "isInbound": true
}

注: data 为 base64 编码。 此事件会生成大量网络流量,主要用于调试。

在 GitHub 上编辑此页