How can I move items from one chest to another using commands?
I am trying to make a mailbox system and want to have the items in a chest teleported to another chest where I can pickup my 'mail'.
Best Answer
The /clone command can copy the chest and place it elsewhere:
/clone <x1> <y1> <z1> <x2> <y2> <z2> <x> <y> <z> [maskMode] [cloneMode] [TileName]
For example, if the chest you're inserting items to is at X0, Y64, Z0, and the mailbox chest is at X100, Y64, Z100:
/clone 0 64 0 0 64 0 100 64 100
Keep in mind that this requires both coordinate locations to be loaded. You can use the /spreadplayers command to forcibly load the chunks using a dummy entity such as an armor stand just before running the /clone command.
/spreadplayers <x> <z> <spreadDistance> <maxRange> <respectTeams> <player …>
/spreadplayers 0 0 0 1 false @e[type=ArmorStand,name=anchor]
/spreadplayers 100 100 0 1 false @e[type=ArmorStand,name=anchor]
/clone 0 64 0 0 64 0 100 64 100
And one other thing to note is that the contents of the mailbox will be completely replaced, so any items that were still in that chest will be deleted. A solution to that is to clone the initial chest above a hopper above the mailbox chest, such that the items will be transferred to the mailbox.
You could also use /setblock to destroy the cloned chest such that the items will be dropped instantly and do not have the risk of being deleted as well.
/setblock 100 64 100 minecraft:air 0 destroy
Pictures about "How can I move items from one chest to another using commands?"



How do you move items fast in chest?
You can also ctrl-click on an empty slot of a chest to transfer the whole content of the chest to your inventory. To transfer all stacks of the same item type at once, ctrl+left-click on one of the stacks of that item type.How do you move items between chests?
Type this command in when having the command block GUI open /teleport @p <x> <y> <z> . Then, activate the command block with redstone (including buttons, levers, and pressure plates), and they will be sent to their destination. The player can set up multiple different teleports.How to EFFICIENTLY MOVE ITEMS in Minecraft 1.16 [Inventory Tips]
More answers regarding how can I move items from one chest to another using commands?
Answer 2
You can't do this with commands, but there are several methods to transport items. Firstly, you can use minecarts and rails, secondly, you can use hoppers or droppers.
Answer 3
There isn't a way to do this with commands (yet) as chest data is store in NBT tags and there are no commands in the code that handle item transfer like that.
Ender Chests are an option if using a command isn't essential.
Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.
Images: Ketut Subiyanto, Ketut Subiyanto, Ketut Subiyanto, Ketut Subiyanto
