tutorial:command_suggestions
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
tutorial:command_suggestions [2021/09/17 04:49] – external edit 127.0.0.1 | tutorial:command_suggestions [2023/02/20 05:44] – solidblock | ||
---|---|---|---|
Line 8: | Line 8: | ||
A '' | A '' | ||
- | |||
Suggestions can be contextual since a suggestion provider gives you access to the current command context. | Suggestions can be contextual since a suggestion provider gives you access to the current command context. | ||
Line 14: | Line 13: | ||
===== An example suggestion provider ===== | ===== An example suggestion provider ===== | ||
- | For example | + | For example |
<code java [enable_line_numbers=" | <code java [enable_line_numbers=" | ||
Line 33: | Line 32: | ||
public CompletableFuture< | public CompletableFuture< | ||
Identifier entityTypeId = context.getArgument(" | Identifier entityTypeId = context.getArgument(" | ||
- | EntityType<?> | + | EntityType<?> |
+ | // For versions before 1.19.3, use '' | ||
| | ||
if (!DefaultAttributeContainer.hasDefinitionFor(entityType)) { | if (!DefaultAttributeContainer.hasDefinitionFor(entityType)) { | ||
Line 42: | Line 42: | ||
// You will need mixin to get the ' | // You will need mixin to get the ' | ||
for (EntityAttribute attribute : attributeContainer.instances().keySet()) { | for (EntityAttribute attribute : attributeContainer.instances().keySet()) { | ||
- | Identifier attributeId = Registry.ATTRIBUTE.getId(attribute); | + | Identifier attributeId = Registries.ATTRIBUTE.getId(attribute); |
if (attributeId != null) { | if (attributeId != null) { | ||
... | ... | ||
Line 51: | Line 51: | ||
<code java [enable_line_numbers=" | <code java [enable_line_numbers=" | ||
for (EntityAttribute attribute : attributeContainer.instances().keySet()) { | for (EntityAttribute attribute : attributeContainer.instances().keySet()) { | ||
- | Identifier attributeId = Registry.ATTRIBUTE.getId(attribute); | + | Identifier attributeId = Registries.ATTRIBUTE.getId(attribute); |
if (attributeId != null) { | if (attributeId != null) { | ||
| | ||
Line 73: | Line 73: | ||
public CompletableFuture< | public CompletableFuture< | ||
Identifier entityTypeId = context.getArgument(" | Identifier entityTypeId = context.getArgument(" | ||
- | EntityType<?> | + | EntityType<?> |
| | ||
if (!DefaultAttributeContainer.hasDefinitionFor(entityType)) { | if (!DefaultAttributeContainer.hasDefinitionFor(entityType)) { | ||
Line 82: | Line 82: | ||
// You will need mixin to get the ' | // You will need mixin to get the ' | ||
for (EntityAttribute attribute : attributeContainer.instances().keySet()) { | for (EntityAttribute attribute : attributeContainer.instances().keySet()) { | ||
- | Identifier attributeId = Registry.ATTRIBUTE.getId(attribute); | + | Identifier attributeId = Registries.ATTRIBUTE.getId(attribute); |
if (attributeId != null) { | if (attributeId != null) { | ||
builder.suggest(attributeId.toString()); | builder.suggest(attributeId.toString()); | ||
Line 109: | Line 109: | ||
^ Type ^ Field/ | ^ Type ^ Field/ | ||
- | | Summonable entities | SuggestionProviders.SUMMONABLE_ENTITIES | | + | | Summonable entities | '' |
- | | Available sounds | + | | Available sounds |
- | | Loot Tables | + | | Loot Tables |
- | | Biomes | + | | Biomes |
===== Utilities in CommandSource ===== | ===== Utilities in CommandSource ===== |
tutorial/command_suggestions.txt · Last modified: 2023/11/18 12:06 by solidblock