Skip to content

Enums

The entity anchor argument has two valid inputs: feet and eyes. The resulting LookAnchor is mainly used for methods like Entity#lookAt(Position, LookAnchor) or Player#lookAt(Entity, LookAnchor, LookAnchor).

Commands.argument("anchor", ArgumentTypes.entityAnchor())
.executes(context -> {
final LookAnchor anchor = context.getArgument("anchor", LookAnchor.class);
context.getSource().getSender().sendRichMessage("You chose <aqua><anchor></aqua>!",
Placeholder.unparsed("anchor", anchor.name())
);
return Command.SINGLE_SUCCESS;
})

The game mode argument works the same way as the first argument of the Vanilla /gamemode <gamemode> command. It accepts any of the 4 valid game modes, returning a GameMode enum to use in code.

Commands.argument("mode", ArgumentTypes.gameMode())
.executes(context -> {
final GameMode mode = context.getArgument("mode", GameMode.class);
final Player player = context.getSource().getPlayerOrThrow();
player.setGameMode(mode);
player.sendRichMessage("Your gamemode has been set to <red><mode></red>!",
Placeholder.component("mode", Component.translatable(mode))
);
return Command.SINGLE_SUCCESS;
})

The HeightMap argument consists of the following, valid inputs: motion_blocking, motion_blocking_no_leaves, ocean_floor, and world_surface. It is often used for declaring relative positioning for data packs or the /execute positioned over <height_map> command. E.g. world_surface would mean that the Y coordinate of the surface of the world on the set X/Z values should be used.

Commands.argument("height_map", ArgumentTypes.heightMap())
.executes(context -> {
final HeightMap heightMap = context.getArgument("height_map", HeightMap.class);
context.getSource().getSender().sendRichMessage("You selected <gold><selection></gold>",
Placeholder.unparsed("selection", heightMap.name())
);
return Command.SINGLE_SUCCESS;
})

This argument allows you to retrieve a DisplaySlot enum value from the user.

Commands.argument("slot", ArgumentTypes.scoreboardDisplaySlot())
.executes(context -> {
final DisplaySlot slot = context.getArgument("slot", DisplaySlot.class);
context.getSource().getSender().sendPlainMessage("You selected: " + slot.toString());
return Command.SINGLE_SUCCESS;
})

Here, the user has 3 valid input possibilities: front_back, left_right, and none. You can retrieve the result of the argument as a Mirror enum value.

Commands.argument("mirror", ArgumentTypes.templateMirror())
.executes(context -> {
final Mirror mirror = context.getArgument("mirror", Mirror.class);
context.getSource().getSender().sendPlainMessage("You selected: " + mirror.name());
return Command.SINGLE_SUCCESS;
})

For the template rotation argument, the user has 4 valid input possibilities: 180, clockwise_90, counterclockwise_90, and none. You can retrieve the result of the argument as a StructureRotation enum value.

Commands.argument("rotation", ArgumentTypes.templateRotation())
.executes(context -> {
final StructureRotation rotation = context.getArgument("rotation", StructureRotation.class);
context.getSource().getSender().sendPlainMessage("You selected: " + rotation.name());
return Command.SINGLE_SUCCESS;
})