tutorial:command_redirects
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
tutorial:command_redirects [2023/02/20 05:58] – [Chainable Commands] solidblock | tutorial:command_redirects [2024/04/15 06:46] (current) – [Chainable Commands] solidblock | ||
---|---|---|---|
Line 15: | Line 15: | ||
final LiteralCommandNode< | final LiteralCommandNode< | ||
.executes(context -> { | .executes(context -> { | ||
- | | + | context.getSource().sendFeedback(() -> Text.literal(" |
- | | + | |
return 1; | return 1; | ||
Line 26: | Line 25: | ||
</ | </ | ||
- | The '' | + | The '' |
+ | |||
+ | The redirection target may not always be the root node. Commans can be redirected to sub-nodes, including arguments. | ||
===== Chainable Commands ====== | ===== Chainable Commands ====== | ||
Line 38: | Line 39: | ||
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. | + | // 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(" | ||
Line 46: | Line 49: | ||
.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 '' | + | The '' |
<code java [enable_line_numbers=" | <code java [enable_line_numbers=" | ||
- | .redirect(rootNode, | + | |
- | // When redirecting, | + | // When redirecting, |
- | return | + | return context.getSource().withLookingAt(Vec3ArgumentType.getVec3(context, |
- | }) | + | }) |
</ | </ | ||
+ | :!: In the redirect modifier, only arguments after the redirected nodes can be used. Meanwhile, arguments before the redirect modifier cannot be used in subsequent redirections (if any) or the final execution. |
tutorial/command_redirects.1676872729.txt.gz · Last modified: 2023/02/20 05:58 by solidblock