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:59] – wrap the code 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 48: | 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.1676872778.txt.gz · Last modified: 2023/02/20 05:59 by solidblock