tutorial:command_argument_types
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
tutorial:command_argument_types [2024/04/15 06:58] – [Custom argument serializer] solidblock | tutorial:command_argument_types [2024/04/15 07:21] (current) – [Custom argument serializer] solidblock | ||
---|---|---|---|
Line 80: | Line 80: | ||
// Brigadier has support to show examples for what the argument should look like, | // Brigadier has support to show examples for what the argument should look like, | ||
// this should contain a Collection of only the argument this type will return. | // this should contain a Collection of only the argument this type will return. | ||
- | // This is mainly used to calculate ambiguous commands | + | // This is mainly used to detect ambiguity, |
return EXAMPLES; | return EXAMPLES; | ||
} | } | ||
Line 168: | Line 168: | ||
// Brigadier has support to show examples for what the argument should look like, | // Brigadier has support to show examples for what the argument should look like, | ||
// this should contain a Collection of only the argument this type will return. | // this should contain a Collection of only the argument this type will return. | ||
- | // This is mainly used to calculate ambiguous commands | + | // This is mainly used to detect ambiguity, |
return EXAMPLES; | return EXAMPLES; | ||
} | } | ||
Line 222: | Line 222: | ||
public void writePacket(Properties properties, PacketByteBuf buf) { | public void writePacket(Properties properties, PacketByteBuf buf) { | ||
// Writes the basic properties to a packet. You should ensure all properties | // Writes the basic properties to a packet. You should ensure all properties | ||
- | // can be in some ways stored in the packed. | + | // can be in some ways stored in the packet. |
buf.writeBoolean(properties.booleanValue).writeInt(properties.intValue); | buf.writeBoolean(properties.booleanValue).writeInt(properties.intValue); | ||
} | } | ||
Line 253: | Line 253: | ||
@Override | @Override | ||
- | public ArgumentSerializer< | + | public ArgumentSerializer< |
- | | + | |
+ | return Serializer.this; | ||
} | } | ||
} | } | ||
Line 260: | Line 261: | ||
} | } | ||
</ | </ | ||
+ | |||
+ | And now you can register it like this: | ||
+ | <code java> | ||
+ | ArgumentTypeRegistry.registerArgumentType(new Identifier(" | ||
+ | </ | ||
+ | |||
+ | ==== Another possible way to define serializer ==== | ||
If the argument does not require '' | If the argument does not require '' | ||
Line 307: | Line 315: | ||
} | } | ||
} | } | ||
+ | </ | ||
+ | |||
+ | And now you can register it like this: | ||
+ | <code java> | ||
+ | ArgumentTypeRegistry.registerArgumentType(new Identifier(" | ||
</ | </ |
tutorial/command_argument_types.1713164315.txt.gz · Last modified: 2024/04/15 06:58 by solidblock