Command arguments dont seem to work
Blayyke opened this issue ยท 1 comments
I am using the following code trying to register a command with a block argument. Typing /test will give me an exception because there is no block argument (to be expected, i provided none. however, minecraft handles these on their own commands somehow.), yet if i provide a block argument (the block suggestions work fine), I get Unknown Command: https://i.imgur.com/dyFBpLy.jpg.
LiteralArgumentBuilder<ServerCommandSource> testCmd = literal("test").then(ServerCommandManager.argument("block", BlockArgumentType.create())).executes(context -> catchExecute(new CommandExecutor(context) {
@Override
int execute() throws CommandSyntaxException {
ServerPlayerEntity player = context.getSource().getPlayer();
message(player, "Test!");
BlockArgument block = BlockArgumentType.method_9655(context, "block");
message(player, block.getBlockState().getBlock().getClass().getSimpleName());
return 0;
}
}));
CommandRegistry.INSTANCE.register(false, (serverCommandSourceCommandDispatcher -> serverCommandSourceCommandDispatcher.register(testCmd)));