Minecraft – How to setblock whatever item is currently in hand in minecraft

minecraft-commandsminecraft-java-edition

I'm playing minecraft, doing some random stuff in my server.

I was creating an automatic builder, to avoid having to build blocks, so that I could just walk, and it would build.

What I did was create a pulse-clock connected to a commandblock having:

execute @p ~ ~ ~ setblock ~ ~ ~ dirt

I was wondering how I would make that "dirt" into whatever item I was holding in hand, or at a specific slot in my inventory as setblock ~ ~ ~ {slot:0b} doesn't seem to work.

On another note, how can I make the commandblock to work inside a range, and/or coordinates, as in execute @p[x=~10,y=~,z=~15,r=5] ~ ~ ~ setblock ~ ~-1 ~ dirt

Thanks in advance.

Best Answer

No, this is impossible unless you want to add command blocks for every block type.