Minecraft – Summoning chest with specific items using name and lore

minecraft-commandsminecraft-java-edition

I want to summon a chest with one custom item inside that has a custom name and lore tag. I have not found any posts about this specific situation.

The item I want to have inside the chest is a tripwire hook named "Small Key" with the lore tag "This key may only be used at your current location." [As a give command]:

/give @a Minecraft:tripwire_hook{display:{Name:"\"Small Key\"",Lore:["\"This key may only be used at your current location.\""]}} 1

I have already tried using mcstacker.net but there is no available command for chests, only minecarts with chests. I tried to change chest_minecart to only chest, but this does not work in-game.
The command given from mcstacker.net is:

/summon chest_minecart ~ ~ ~ {Motion:[10.0,49.0,89.0],Items:[{Slot:1b,id:"minecraft:tripwire_hook",Count:1b,tag:{display:{Name:'{"text":"Small Key"}',Lore:['{"text":"This key may only be used at your current location."}']}}}]}

I have also looked in other threads and forums for answers but I have not found anything that helps.
Examples:

Here on there is also another question asked, why does the following command work:

/summon chest_minecart ~ ~ ~ {Motion:[10.0,49.0,89.0],Items:[{Slot:1b,id:"minecraft:tripwire_hook",Count:1b,tag:{display:{Name:'{"text":"Small Key"}',Lore:['{"text":"This key may only be used at your current location."}']}}}]}

while this command does not?

/summon chest ~ ~ ~ {Motion:[10.0,49.0,89.0],Items:[{Slot:1b,id:"minecraft:tripwire_hook",Count:1b,tag:{display:{Name:'{"text":"Small Key"}',Lore:['{"text":"This key may only be used at your current location."}']}}}]}

Note: chest_minecart can be replaced with all other blocks, even entities. But not chest.

Best Answer

This is the correct command:

/setblock ~ ~ ~1 chest{Items:[{Slot:1b,id:"minecraft:tripwire_hook",Count:1b,tag:{display:{Name:'{"text":"Small Key"}',Lore:['{"text":"This key may only be used at your current location."}']}}}]} replace

The reason as to why chest_minecart can't be replaced with chest is that /summon is specific for entities and /setblock for blocks.