How do I use setblock with a coloured sign? [duplicate]

I tried the custom loot tables here:

(with his website: http://minecraft.tools/en/loots.php ). I successfully obtained my chest with the custom loot using:
/give @p minecraft:chest 1 0
{BlockEntityTag:{LootTable:"mctools:chests/loot_table"}}

The problem is that I want to summon the chest instead of giving it to the player. I tried the command:

/setblock ~1 ~ ~ chest 0 replace
{BlockEntityTag:{LootTable:"mctools:chests/loot_table"}}

The chest did place, but when I opened it, the chest was always empty. Why can't I retrieve my loot this way? And if possible, how can this be done?


Solution 1:

The BlockEntityTag is the data that will be given to the block when the item is placed. Since you're setting the block directly, you can just use

/setblock ~1 ~ ~ chest 0 replace {LootTable:"mctools:chests/loot_table"}