So I know how to do /replaceitem but is it possible to do the command but instead of only doing one slot but multiple or even slot.container.x, x being that slot and continuing to the next slot?
-
Couldn't you just use multiple command blocks?– James WestmanApr 7, 2015 at 10:49
-
I tried using that method but this would mean I would have to place 27 or up to 54 command block. In reality for what I'm doing I would have to actually use 162 and I think that might cause lag, I could be wrong.– Jordan RamirezApr 7, 2015 at 19:31
2 Answers
/replaceitem
can only replace one slot at a time. You could use multiple command blocks, although as you said it'd get messy when you want to use a lot of items.
What you can use instead is either /setblock
or /blockdata
, which allow editing the entirety of the chest's data.
To add 5 stone to slot 0 (the first slot) and 10 sponge to slot 7, you could do:
/blockdata X Y Z {Items:[{id:stone,Slot:0,Count:5},{id:sponge,Slot:7,Count:10}]}
To add more items, you just add a comma and another compound tag to the Items
list:
/blockdata X Y Z {Items:[{id:stone,Slot:0,Count:5},{id:sponge,Slot:7,Count:10},{id:arrow,Slot:15,Count:64}]}
NOTE: I know that It may be late, and an answer is shown, but I figured i'd give an updated version with 1.8 just in case some people don't know it yet.
You can use the /clone command to clone a chest with the items you want to include to another location.
You'd set up your chest template but placing a chest somewhere (Preferably hidden) and place all the items you want in it. Make sure the chest is facing the same direction as the chest you want filled up.
Then you'd use this command, or put it in a command block:
/clone <x1> <y1> <z1> <x2> <y2> <z2> <x> <y> <z>
In your case the x1 and x2 would be the same, y1 and y2 would be the same, and z1 and z2 would be the same.
The x1 y1 z1 would be the coordinates of your chest, and the x y z would be the coordinates of the chest you want filled up.
There! Now whenever somebody activates the command block, the template chest should clone to the real chest, filling it up! You may put as many items in the template chest as you please, and is, in my opinion, a much easier way to do it!