Posted October 8, 20204 yr Hello there, my goal is to get the Direction enum as an argument into a command. I tried this: Commands.argument("isFacing", EnumArgument.enumArgument(Direction.class)) .executes(source -> { return createShip(source.getSource(), StringArgumentType.getString(source, "shipName"), StringArgumentType.getString(source, "portName"), BlockPosArgument.getBlockPos(source, "pos1"), BlockPosArgument.getBlockPos(source, "pos2"), source.getArgument("isFacing", Direction.class)); } But that suggests me all the Direction Names which when use autocomplete can't be referred to an enum. Is there a way to get the suggestions in upper case letters? Also I only want to display the horizontal Directions. Bumpay
October 8, 20204 yr builder.then(Commands.literal(direction)) where ArgumentBuilder is an instance of ArgumentBuilder, and direction is the argument you want to add to the command, which can be achieved using for loops
October 8, 20204 yr Author 2 minutes ago, poopoodice said: builder.then(Commands.literal(direction)) where ArgumentBuilder is an instance of ArgumentBuilder, and direction is the argument you want to add to the command, which can be achieved using for loops I don't get your way of implementing the argument. You mean i should create a for loop to get all directions out of the Direction class? But the how do I add those as an argument?
October 8, 20204 yr For example LiteralArgumentBuilder<CommandSource> command = Commands.literal("test"); for(int i=2;i<5;i++) command.then(Commands.literal(Direction.byIndex(i).getString()));
October 8, 20204 yr Author Ah I see the problem with that is I do not use a literal Argument builder in the way you do. I have my main Command class (TraSimCommands) and they register a new command in this case the CreateDock class and in there the fourth argument is the enum.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.