跳转到内容
WikilyWIKILY
全部游戏23 个 Wiki · 选择你的游戏
命令与作弊所有命令

切换游戏

23 个 Wiki · 选择你的游戏
文本组件

命令参考

文本组件

文本组件是/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.minecraft.stone"}
with填入翻译文本占位符的值/tellraw @a {translate:"chat.type.announcement",with:["Server","Hello"]}
fallback翻译键未知时使用的文本/tellraw @a {translate:"my.custom.key",fallback:"Hi %s",with:[{selector:"@s"}]}
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.jump"}
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].id",block:"~ ~-1 ~"}
storage从命令存储中读取nbt值/tellraw @a {nbt:"message",storage:"my_pack:data",interpret:true}
interpret将nbt值视为文本组件。不能与plain同时使用/tellraw @a {nbt:"message",storage:"my_pack:data",interpret:true}
plain显示不带颜色的NBT值。不能与interpret同时使用/tellraw @a {nbt:"Pos",entity:"@s",plain:true,separator:", "}
sprite显示纹理图集中的图片/tellraw @a {sprite:"minecraft:block/diamond_block"}
atlas精灵图所属的图集。默认为minecraft:blocks/tellraw @a {atlas:"minecraft:items",sprite:"minecraft:item/diamond"}
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_color:[1.0f,0.0f,0.0f,1.0f]}
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_event:{action:"run_command",command:"/say hi"}}
hover_event指针停在文本上时显示的内容/tellraw @a {text:"Hover",hover_event:{action:"show_text",value:"Tooltip"}}

点击操作

run_commandcommand以点击的玩家身份运行命令/tellraw @a {text:"Click",click_event:{action:"run_command",command:"/say hi"}}
suggest_commandcommand将文本放入聊天框/tellraw @a {text:"Click",click_event:{action:"suggest_command",command:"/tp @s 0 64 0"}}
open_urlurl打开网址/tellraw @a {text:"Click",click_event:{action:"open_url",url:"https://www.minecraft.net"}}
copy_to_clipboardvalue将文本复制到剪贴板/tellraw @a {text:"Click",click_event:{action:"copy_to_clipboard",value:"copied text"}}
change_pagepage翻到书中的某一页,为1或更大/tellraw @a {text:"Click",click_event:{action:"change_page",page:2}}
show_dialogdialog打开对话框,可用ID或完整写出/tellraw @a {text:"Click",click_event:{action:"show_dialog",dialog:"minecraft:server_links"}}
customid, payload(可选)向服务器发送自定义事件/tellraw @a {text:"Click",click_event:{action:"custom",id:"my_pack:event",payload:{a:1}}}

悬停动作

show_textvalue作为提示框的文本组件/tellraw @a {text:"Hover",hover_event:{action:"show_text",value:{text:"Tooltip",color:"yellow"}}}
show_itemid, count(可选), components(可选)物品的提示框/tellraw @a {text:"Hover",hover_event:{action:"show_item",id:"minecraft:diamond_sword",count:1,components:{"minecraft:damage":5}}}
show_entityid, uuid, name(可选)实体的类型、名称和UUID/tellraw @a {text:"Hover",hover_event:{action:"show_entity",id:"minecraft:pig",uuid:"dd12be42-52a9-4a91-a8a1-11c01849e498",name:"Porky"}}

文本组件的使用位置

聊天消息/tellraw @a "Hello"
标题/title @a title {text:"Welcome",color:"gold",bold:true}
动作栏/title @a actionbar {text:"Low health",color:"red"}
告示牌文本/setblock ~ ~ ~ minecraft:oak_sign{front_text:{messages:["Line 1",{text:"Line 2",color:"red"},"",""]}}
实体名称/summon minecraft:zombie ~ ~ ~ {CustomName:{text:"Boss",color:"dark_red"},CustomNameVisible:1b}
物品名称/give @s minecraft:stick[custom_name={text:"Magic Wand",color:"gold",italic:false}]
Boss栏名称/bossbar add my_pack:boss {text:"Boss",color:"red"}
计分项名称/scoreboard objectives add kills minecraft.killed:minecraft.zombie {text:"Zombie Kills",color:"green"}

示例

/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秒。

加入创作者社区建设 Minecraft Java Edition Wiki 的伙伴们都在我们的 Discord。欢迎提问或推荐页面。加入 Discord (在新标签页打开 Discord)