I am looking for a command to store items in a chest that's in your inventory.
3 Answers
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.
-
-
[13:41:10] '{BlockEntityTag:{id:"Chest",Lock:"Days",Items:[{id:"minecraft:stone",Count:5,Slot:0,Damage:3},{id:"minecraft:sand",Count:3,Slot:1,Damage:1}]}}' is not a valid number Jul 22, 2016 at 18:43
-
What is the full command you're using? Make sure that you're substituting that into the
[dataTag]
and not the[data]
(which requires a number).– OliverJul 22, 2016 at 20:37 -
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
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.