Escapegoat
Escapegoat 是一个 Fabric 模组,它为 SNBT 字符串添加了各种转义序列。
本模组的制作原因是因为 快照 25w02a 中关于 tellraw 等命令中文本组件的更改,因为它们现在使用 SNBT 而不是 JSON。
由于这一更改,某些功能丢失了,例如转义大多数字符的能力。
本模组通过向 SNBT 添加转义功能来解决这个问题。
有关更多信息,请参阅错误报告 MC-279229 和 MC-279250。
转义序列在输入和输出两个方向上都有效,但请注意,将数据转换为字符串仅适用于 NBT。
这在未来非常有可能发生变化,以使其独立于 NBT,无论是通过 Mojang 还是通过这个模组中的我来实现,所以请留意这一点。
示例
/tellraw @a "Mi\necraft"
/tellraw @a {text: 'Abracadabra: \u{2728}', bold: true, color: "yellow"}
/item modify entity @s weapon {function: 'minecraft:set_writable_book_pages', pages: ['Line 1\nLine 2\nLine 3'], mode: 'replace_all'}
转义序列
所有转义序列都以 \ 字符开头。
简单转义序列
\\: 反斜杠
\': 单引号(取决于上下文,见下文)
\": 双引号(取决于上下文,见下文)
\n: 换行符
其他常见的简单转义序列目前不被允许因为 Minecraft 无法正确渲染它们。
用于包裹的转义序列仅在与其对应的包裹符一起使用时才允许。
这意味着 ' 和 " 是否被转义取决于用于包裹该字符串的字符。
换句话说:'\'' 是有效的,但 '\"' 不是,反之亦然,就像在 Minecraft 中已经这样工作一样。
复杂转义序列
这些复杂的转义序列可用于表示任何 Unicode 字符。
\uXXXX: 固定长度的四位十六进制 UTF-16 字符。
与 JSON 和 JavaScript 等语言中使用的相同。
示例:
\u004D (M)
\u2605 (★)
\uD83D\uDE0A (?)
\u{XXXXXX}: 可变长度的十六进制 UTF-32 字符。
与 JavaScript 中使用的相同。
示例:
\u{4D} (M)
\u{2605} (★)
\u{1F60A} (?)
Escapegoat
Escapegoat is a Fabric mod that adds various escape sequences to SNBT strings.
This mod was made because of the change made in snapshot 25w02a regarding text components in commands like tellraw, because they now use SNBT instead of JSON.
Because of this change, some functionality was lost, such as the ability to escape most characters.
This mod is there to fix that by adding the escape functionality to SNBT.
See the bug reports MC-279229 and MC-279250 for more information.
Escape sequences work both ways, for input and for output, though note that stringifying data only works with NBT.
This is something that is very likely to change in the future to make it independent of NBT, either by Mojang or by me in this mod, so please watch out for that.
Examples
/tellraw @a "Mi\necraft"
/tellraw @a {text: 'Abracadabra: \u{2728}', bold: true, color: "yellow"}
/item modify entity @s weapon {function: 'minecraft:set_writable_book_pages', pages: ['Line 1\nLine 2\nLine 3'], mode: 'replace_all'}
Escape Sequences
All escape sequences start with the \ character.
Simple escape sequences
\\: Backslash
\': Single quote (context-dependent, see below)
\": Double quote (context-dependent, see below)
\n: Line feed
Other common simple escape sequences are currently not allowed due to Minecraft not rendering them properly.
Escape sequences for surrounders are only allowed when used in a string with that surrounder.
This means that ' and " may be escaped depending on which one is used for a string that is surrounded by that character.
In other words: '\'' is valid, but '\"' is not, and vice versa, just like how it works in Minecraft already.
Complicated escape sequences
These complicated escape sequences can be used to represent any Unicode character.
\uXXXX: A fixed-length four-character hexadecimal UTF-16 character.
The same as the one used in languages like JSON and JavaScript.
Examples:
\u004D (M)
\u2605 (★)
\uD83D\uDE0A (?)
\u{XXXXXX}: A variable-length hexadecimal UTF-32 character.
The same as the one used in JavaScript.
Examples:
\u{4D} (M)
\u{2605} (★)
\u{1F60A} (?)
评论 0
登录后参与评分
还没有评论,来抢沙发吧