/setblock
does not support replacing specific blocks. The /fill
command does:
/fill x1 y1 z1 x2 y2 z2 block1 0 replace block2 0
However, if "block1" is a tile entity, then you cannot replace a specific block and must instead supply NBT data. See this explanation by Searge:
Replacing blocks with tile entities is not supported, this is due to a limitation in the parsing of commands. It may be changed in the future, but not until after 1.8.
A chest is a tile entity, meaning you cannot use this to replace a specific block with a chest.
As a work-around, you could detect the existence of the particular block first using /testforblock
:
/testforblock x y z minecraft:stone 0
And then use /setblock
if that command succeeded:
/setblock x y z minecraft:chest