Argument Types

Accessing Argument types

Contains the various built-in argument types Grenadier has.

Most argument types have a vanilla counterpart that the API types are mapped to. Grenadier does also feature several argument types that have no vanilla counterpart and have more general use cases.

General use argument types

Argument typeDescriptionExample
OptionsArgumentParse a list of pre-set options and flagskey=value -flag
MapArgumentTakes a string-object map and parses a map value via its string keya_value
EnumArgumentParses an enum constant from it’s Enum.name()red
ArrayArgumentParses a list of a specified type of argumentsminecraft:stone,minecraft:oak_log
LocalDateArgumentParses a LocalDate object from the ISO-8601 format12-12-2023
TimeArgumentParses a Duration3s, 3seconds, 5m, 5minutes, 3m+2s, 4h-23m

Minecraft argument types

Argument typeDescriptionExample
BlockArgumentParses a block state and optionally NBT data that can be applied to a blockminecraft:chest[facing=west]{dataKey:1b}
BlockFilterArgumentParses a block or block tag that can be used to as a predicate for blocks#minecraft:buttons[face=ceiling]
ComponentArgumentParses a text component from a JSON format{"text":"Some text","color":"red"}
EntityArgumentParses an entity selector that returns 1 or more entities/players@e[limit=1,distance=..2]
GameModeArgumentGame mode value from a non-vanilla set of labelscreative, survival, c, s
ItemArgumentParses an itemstack along with item NBT dataminecraft:stone{nbtKey:1b}
ItemFilterArgumentParses an item or itemtag along with NBT data that will be used as a predicate against other items#minecraft:flowers{nbtKey:1b}
KeyArgumentParses a namespaced keyminecraft:stone
NbtArgumentParses NBT data in the SNBT format{foo:'bar',abc:1b}
ObjectiveArgumentParses a scoreboard objective from its namedeaths, noClip
ParticleArgumentParses a particle by its keyminecraft:explosion_emitter
PositionArgumentParses a relative/local/absolute 2D or 3D position~ ~ ~
TagPathArgumentParses an NBT pathkey1.key2[]
TeamArgumentParses a scoreboard team from its nameteam1, Team2
UuidArgumentParses a UUID by its hexadecimal value21290ce5-679c-4917-b30e-168c0d450c72
WorldArgumentParses a world by its nameworld, world_the_end
DoubleRangeArgumentParses an inclusive range of double values1..2, 1.., ..3
IntRangeArgumentParses an inclusive range of integer values1..2, 1.., ..3

Using argument types

Argument types can be used very simply, for example:

command.then(argument("local date", ArgumentTypes.localDate())
  .executes(context -> {
    LocalDate date = context.getArgument("local date", LocalDate.class);

    context.getSource().sendMessage(date.toString());
    return 0;
  }
);