
命令参考
文本组件
文本组件是/tellraw、/title、告示牌、物品名称和实体名称所使用的格式化文本。组件可以是带引号的字符串、带有内容和样式字段的花括号对象,或组件列表。
| 纯文本 | 带引号的字符串:“Hello”或'Hello'。 |
| 对象 | {text:"Hello",color:"red"}。字段名可以带引号,也可以不带。 |
| 列表 | ["A",{text:"B"}].第一项是父项;其余各项跟随它,并沿用它的样式。 |
| 内容类型 | text, translatable, score, selector, keybind, nbt, object.类型根据字段识别;type字段是可选的。 |
| 颜色名称 | black, dark_blue, dark_green, dark_aqua, dark_red, dark_purple, gold, gray, dark_gray, blue, green, aqua, red, light_purple, yellow, white. |
| 十六进制颜色 | #后接六位十六进制数字,例如#FF8800。 |
| 继承的样式 | extra中的各部分使用其父级的样式,除非自行设置了样式。 |
| 点击操作 | open_url、run_command、suggest_command、show_dialog、change_page、copy_to_clipboard、custom。命令中会拒绝open_file。 |
| 悬停动作 | show_text, show_item, show_entity. |
| 换行 | 带引号文本中的 \n。 |
| text | 显示给定的文本 | /tellraw @a {text:"Hello",color:"red"} |
| translate | 按键名显示翻译后的文本 | /tellraw @a {translate:"block. |
| with | 填入翻译文本占位符的值 | /tellraw @a {translate:"chat. |
| fallback | 翻译键未知时使用的文本 | /tellraw @a {translate:"my. |
| score | 显示一个分数。需要 name(名称或选择器)和 objective | /tellraw @a ["Score: ",{score:{name:"@s",objective:"kills"},color:"gold"}] |
| selector | 显示所选实体的名称 | /tellraw @a {selector:"@a",separator:" and "} |
| separator | 放在多个名称或数值之间的文本 | /tellraw @a {selector:"@a",separator:{text:" | ",color:"gray"}} |
| keybind | 显示读者为某个操作设置的按键 | /tellraw @a {keybind:"key. |
| nbt | 通过数据路径显示从数据中读取的值 | /tellraw @a {nbt:"Health",entity:"@s"} |
| entity | 从所选实体中读取nbt值 | /tellraw @a {nbt:"Pos",entity:"@s",plain:true,separator:", "} |
| block | 从某个位置的方块中读取nbt值 | /tellraw @a {nbt:"Items[0]. |
| storage | 从命令存储中读取nbt值 | /tellraw @a {nbt:"message",storage:"my_ |
| interpret | 将nbt值视为文本组件。不能与plain同时使用 | /tellraw @a {nbt:"message",storage:"my_ |
| plain | 显示不带颜色的NBT值。不能与interpret同时使用 | /tellraw @a {nbt:"Pos",entity:"@s",plain:true,separator:", "} |
| sprite | 显示纹理图集中的图片 | /tellraw @a {sprite:"minecraft:block/ |
| atlas | 精灵图所属的图集。默认为minecraft:blocks | /tellraw @a {atlas:"minecraft:items",sprite:"minecraft:item/ |
| player | 显示玩家皮肤的头部 | /tellraw @a {player:{name:"Notch"},hat:false} |
| hat | 是否绘制头部的帽子层。默认为true | /tellraw @a {player:{name:"Notch"},hat:false} |
| type | 直接指明内容类型:text、translatable、score、selector、keybind、nbt 或 object | /tellraw @a {type:"text",text:"Typed"} |
| extra | 紧随此组件之后显示的更多组件 | /tellraw @a {text:"A",color:"red",extra:[{text:"B",bold:true},"C"]} |
| color | 文本颜色,颜色名称或#RRGGBB | /tellraw @a {text:"Hello",color:"#FF8800"} |
| shadow_color | 文字阴影的颜色,一个数或[red,green,blue,alpha],范围从0到1 | /tellraw @a {text:"Hello",shadow_ |
| bold | 粗体文本,true或false | /tellraw @a {text:"A",color:"red",extra:[{text:"B",bold:true},"C"]} |
| italic | 斜体文本,true或false | /title @a subtitle {text:"Good luck",italic:true} |
| underlined | 文本下划线,true 或 false | /tellraw @a {text:"Hello",color:"#FF8800",bold:true,italic:true,underlined:true,strikethrough:true,obfuscated:false} |
| strikethrough | 文本删除线,true 或 false | /tellraw @a {text:"Hello",color:"#FF8800",bold:true,italic:true,underlined:true,strikethrough:true,obfuscated:false} |
| obfuscated | 乱码般不断变化的字母,true或false | /tellraw @a {text:"Hello",color:"#FF8800",bold:true,italic:true,underlined:true,strikethrough:true,obfuscated:false} |
| font | 用于绘制的字体的ID | /tellraw @a {text:"Hello",font:"minecraft:alt"} |
| insertion | 按住Shift点击文本时放入聊天框的文本 | /tellraw @a {text:"Shift-click me",insertion:"inserted text"} |
| click_event | 点击文本时会发生什么 | /tellraw @a {text:"Click",click_ |
| hover_event | 指针停在文本上时显示的内容 | /tellraw @a {text:"Hover",hover_ |
| run_command | command | 以点击的玩家身份运行命令 | /tellraw @a {text:"Click",click_ |
| suggest_command | command | 将文本放入聊天框 | /tellraw @a {text:"Click",click_ |
| open_url | url | 打开网址 | /tellraw @a {text:"Click",click_ |
| copy_ | value | 将文本复制到剪贴板 | /tellraw @a {text:"Click",click_ |
| change_page | page | 翻到书中的某一页,为1或更大 | /tellraw @a {text:"Click",click_ |
| show_dialog | dialog | 打开对话框,可用ID或完整写出 | /tellraw @a {text:"Click",click_ |
| custom | id, payload(可选) | 向服务器发送自定义事件 | /tellraw @a {text:"Click",click_ |
| show_text | value | 作为提示框的文本组件 | /tellraw @a {text:"Hover",hover_ |
| show_item | id, count(可选), components(可选) | 物品的提示框 | /tellraw @a {text:"Hover",hover_ |
| show_entity | id, uuid, name(可选) | 实体的类型、名称和UUID | /tellraw @a {text:"Hover",hover_ |
| 聊天消息 | /tellraw @a "Hello" |
| 标题 | /title @a title {text:"Welcome",color:"gold",bold:true} |
| 动作栏 | /title @a actionbar {text:"Low health",color:"red"} |
| 告示牌文本 | /setblock ~ ~ ~ minecraft:oak_ |
| 实体名称 | /summon minecraft:zombie ~ ~ ~ {CustomName:{text:"Boss",color:"dark_ |
| 物品名称 | /give @s minecraft:stick[custom_ |
| Boss栏名称 | /bossbar add my_pack:boss {text:"Boss",color:"red"} |
| 计分项名称 | /scoreboard objectives add kills minecraft. |
/tellraw @a {text:"Hello",color:"red"}向所有玩家发送红色的Hello。
/tellraw @a ["",{text:"A",color:"red"},{text:"B",color:"blue"}]发送一个红色的A,后接一个蓝色的B。空的第一项用来将各颜色区分开。
/tellraw @a {text:"Click",click_event:{action:"suggest_command",command:"/tp @s 0 64 0"}}发送点击时会用传送命令填充聊天框的文本。
/tellraw @a ["Score: ",{score:{name:"@s",objective:"kills"},color:"gold"}]显示执行该命令者的kills分数。
/tellraw @a {text:"Hover",hover_event:{action:"show_item",id:"minecraft:diamond_sword",count:1,components:{"minecraft:damage":5}}}发送当指针停留其上时显示钻石剑提示框的文本。
/title @a title {text:"Welcome",color:"gold",bold:true}向每位玩家显示粗体金色标题。
/title @a subtitle {text:"Good luck",italic:true}设置显示在下一个标题下方的副标题。
/title @a actionbar {text:"Low health",color:"red"}在快捷栏上方显示红色文字。
/title @a times 0.5s 3s 1s将标题设为淡入半秒、停留3秒、淡出1秒。

