zh_cn:tutorial:command_redirects
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| zh_cn:tutorial:command_redirects [2023/04/20 10:30] – created solidblock | zh_cn:tutorial:command_redirects [2024/04/15 06:46] (current) – [可串联的命令] solidblock | ||
|---|---|---|---|
| Line 28: | Line 28: | ||
| '' | '' | ||
| - | ===== Chainable Commands | + | ===== 可串联的命令 |
| - | Commands such as ''/ | + | 像 ''/ |
| - | Let's first consider the vanilla | + | 首先考虑原版的 |
| - | Below is an example of a chainable command: | + | 下面是一个可串联的命令的例子: |
| <code java [enable_line_numbers=" | <code java [enable_line_numbers=" | ||
| LiteralCommandNode< | LiteralCommandNode< | ||
| LiteralCommandNode< | LiteralCommandNode< | ||
| - | // You can register under the same literal more than once, it will just register new parts | + | // 你可以注册同一个纯文本节点,会注册分支的多个部分。 |
| - | // of the branch as shown below if you register a duplicate branch an error will popup in | + | // 就像可耐这样,注册重复的分支时,控制台会报错,提示命令冲突,但是仍能生效。 |
| - | // console warning of conflicting commands but one will still work. | + | |
| .then(literal(" | .then(literal(" | ||
| .then(literal(" | .then(literal(" | ||
| - | .redirect(rootNode, | + | .redirect(rootNode, |
| .then(literal(" | .then(literal(" | ||
| - | .redirect(rootNode, | + | .redirect(rootNode, |
| .then(literal(" | .then(literal(" | ||
| .executes(ctx -> { | .executes(ctx -> { | ||
| - | ctx.getSource().sendFeedback(Text.literal(" | + | ctx.getSource().sendFeedback(Text.literal(" |
| return Command.SINGLE_SUCCESS; | return Command.SINGLE_SUCCESS; | ||
| }))); | }))); | ||
| </ | </ | ||
| - | The '' | + | '' |
| <code java [enable_line_numbers=" | <code java [enable_line_numbers=" | ||
| .redirect(rootNode, | .redirect(rootNode, | ||
| - | // When redirecting, | + | // 重定向时,修改命令源的视线方向。 |
| return ((ServerCommandSource) context.getSource()).withLookingAt(Vec3ArgumentType.getVec3(context, | return ((ServerCommandSource) context.getSource()).withLookingAt(Vec3ArgumentType.getVec3(context, | ||
| }) | }) | ||
| </ | </ | ||
| + | :!: 在 redirect modifier 中,只有被重定向节点之后的参数会被使用。也就是说,重定向修饰之前的参数无法用于后续重定向(如有)或者最终执行。 | ||
zh_cn/tutorial/command_redirects.1681986614.txt.gz · Last modified: 2023/04/20 10:30 by solidblock