tutorial:command_redirects
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revisionNext revisionBoth sides next revision | ||
tutorial:command_redirects [2022/08/08 02:19] – created (migrated from [[tutorial:commands]]) solidblock | tutorial:command_redirects [2023/02/20 05:59] – wrap the code solidblock | ||
---|---|---|---|
Line 1: | Line 1: | ||
======= Command Redirects ======= | ======= Command Redirects ======= | ||
- | Redirects are Brigadier' | + | Redirects are Brigadier' |
===== Aliases ===== | ===== Aliases ===== | ||
- | Below is how Minecraft | + | In vanilla |
+ | |||
+ | The example shows how ''/ | ||
<code java [enable_line_numbers=" | <code java [enable_line_numbers=" | ||
- | public | + | public |
- | LiteralCommandNode | + | @Override |
- | | + | public |
- | .then(argument("targets", EntityArgumentType.players()) | + | CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, |
- | | + | |
- | | + | .executes(context -> { |
- | | + | // For versions below 1.19, replace |
- | | + | context.getSource().sendMessage(Text.literal("Called /foo with no arguments")); |
- | | + | |
- | | + | return 1; |
- | | + | |
+ | dispatcher.register(literal(" | ||
+ | | ||
+ | } | ||
} | } | ||
</ | </ | ||
Line 24: | Line 29: | ||
===== Chainable Commands ====== | ===== Chainable Commands ====== | ||
- | Commands such as ''/ | + | 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. | + | // 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 42: | Line 53: | ||
</ | </ | ||
- | The '' | + | The '' |
<code java [enable_line_numbers=" | <code java [enable_line_numbers=" |
tutorial/command_redirects.txt · Last modified: 2024/04/15 06:46 by solidblock