Is there a way that items can be stored in a chest that is in your inventory?
I am looking for a command to store items in a chest that's in your inventory.
Best Answer
This is entirely possible, just a little long-winded. You can use /give or even /replaceitem entity. There are pros and cons to both.
The syntax for /give is:
/give <player> <item_ID> [amount] [data] [dataTag]
The syntax for /replaceitem entity is:
/replaceitem entity <selector> <slot> <item_ID> [amount] [data] [dataTag]
The most important section needed for this question is the [dataTag] from both commands. The wiki for Chunk Format is helpful here.
So, to give a player a chest containing, say, 5 blocks of diorite and 3 blocks of red sand, the datatag for this would be:
{BlockEntityTag:{id:"Chest",Lock:"",Items:[{id:"minecraft:stone",Count:5,Slot:0,Damage:3},{id:"minecraft:sand",Count:3,Slot:1,Damage:1}]}}
If you wish to read what's in the chest, you can use scoreboards to add players whose inventory contains a chest which contains X item, then use the scoreboard to assist with a selector, like @a[score_haschest_min=1], if the scoreboard objective was "haschest" and was "1" when they had a chest and "0" otherwise.
Pictures about "Is there a way that items can be stored in a chest that is in your inventory?"



How do I put inventory in my chest?
Click and hold the shift key (on a PC) and then left-click on one item in the inventory. Next, drag and hover it on another similar item in the inventory, and click on it. All the items will be moved to the chest at the moment.How do you keep items in a chest in Minecraft?
By holding \u21e7 Shift and double-clicking while holding an item, all items of a type clicked on will be moved into or out of the chest.How to EFFICIENTLY MOVE ITEMS in Minecraft 1.16 [Inventory Tips]
More answers regarding is there a way that items can be stored in a chest that is in your inventory?
Answer 2
At least in 1.11.2 (the version I play in) all you have to do is press the control key at the same time as the "pick block" control (defaults to middle click, although it almost never worked for me so I set it to r instead). You can get chests with items, command blocks with commands and set to different modes (so you can have repeating/chain command block textures in your inventory) and it will add +nbt to the item lore
Answer 3
Im pretty sure in 1.8 if you middle click a chest in creative mode with items in it you can duplicate it. If it works it should say +NBT below it in purple.
Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.
Images: Ryutaro Tsukata, Julia Avamotive, cottonbro, Min An
