Apologies if this is a stupid question; I'm new to mod dev. I'm writing a simple mod to register a client-side command that takes two block positions as arguments: /testcommand <pos1> <pos2>. This is my code currently:
import net.minecraft.command.argument.BlockPosArgumentType;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback;
import net.minecraft.client.MinecraftClient;
import net.minecraft.text.Text;
import net.minecraft.util.math.BlockPos;
public class TestClient implements ClientModInitializer {
@Override
public void onInitializeClient() {
ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> {
MinecraftClient client = MinecraftClient.getInstance();
dispatcher.register(
ClientCommandManager.literal("testcommand").then(
ClientCommandManager.argument("pos1", new BlockPosArgumentType()
).then(
ClientCommandManager.argument("pos2", new BlockPosArgumentType()).executes(
context -> {
BlockPos pos1 = context.getArgument("pos1", BlockPos.class);
BlockPos pos2 = context.getArgument("pos2", BlockPos.class);
context.getSource().sendFeedback(Text.literal("test"));
return 1;
}
)
)
)
);
});
}
}
The mod compiles and runs without errors, but when I try to run the command in-game (/testcommand 10 10 10 20 20 20) I get the error:
Argument 'pos1' is defined as DefaultPosArgument, not class net.minecraft.util.math.BlockPos
What am I doing wrong, and how can I correctly read the BlockPos arguments?