Minecraft Empty Chests Command Block

Minecraft Empty Chests Command Block - Assorted-color House Facade in Park

I am using the following Command to spawn a new chest at the given coordinates with stuff in it at each new round:

/setblock 264 4 997 minecraft:chest 0 replace {Items:[{id:274,Count:1,Slot:0},{id:275,Count:1,Slot:1}]}

The problem with that is that when replacing the old chest all the stuff in the old chest is thrown out. And that's pretty much not what I want. I need to find a way to replace a chest which might have stuff in it without throwing those things out.

Someone else said I should replace the given position for one tick with lava, which I tried. Works in 90% of the tries (in the other 10% the items from the chest are thrown to far away - out of the spawned lava block), but the problem with that is that I can't use it in wooden areas because it might burn everything down.

So what can I do to fix that problem, because otherwise my custom made Pv.P map is not gonna work?

Thanks very much!



Best Answer

As of the latest, latest snapshot (14w02b), this is most certainly possible. In fact, there's an easier way to do the whole thing now, which is awesome. With the /blockdata command added in the snapshot, you can modify and overwrite the contents of a tile entity (including a chest), and much, much more. The applications of /blockdata go beyond what I can fully comprehend at this point in time, but, for this specific case, it's not too hard.

Let's say for example your equipment chest is supposed to contain a notch apple, a gold sword, a bow, and a stack of arrows. The command for that would be /blockdata X Y Z {Items:[{id:322,Damage:1,Count:1,Slot:0},{id:283,Count:1,Slot:1},{id:261,Count:1,Slot:2},{id:262,Count:64,Slot:3}]}, replacing X Y and Z as appropriate. There's a lot of stuff going on in that command, but essentially, you are changing the data of the chest to contain the specified items. It's the same concept as using /setblock to spawn a new chest with these items, except instead of replacing the chest, you're overwriting its data.

In this more specific case, you want /blockdata 264 4 997 {Items:[{id:274,Count:1,Slot:0},{id:275,Count:1,Slot:1}]}.

And, of course, if you want an empty chest, all you need to do is use /blockdata X Y Z {Items:[]}




Pictures about "Minecraft Empty Chests Command Block"

Minecraft Empty Chests Command Block - Blank photo frame on blocks on gray background
Minecraft Empty Chests Command Block - Empty photo frame on round blocks in row
Minecraft Empty Chests Command Block - Black and white exterior of house located on street near asphalt road with brick and cement walls and shade in corner in daytime



How do you empty an entire 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.

What is the command to clear blocks in Minecraft?

How to Enter the Command
  • Open the Chat Window. The easiest way to run a command in Minecraft is within the chat window.
  • Type the Command. In this example, we will remove all items from your inventory with the following command: /clear. Once the cheat has been entered, your inventory will be cleared:




  • How to make Auto-Refilling Chests in Minecraft (Bedrock Edition) 1.16+ - Tutorial Series #015




    More answers regarding minecraft Empty Chests Command Block

    Answer 2

    You could have two chests set up and connected with a hopper from one to the other. Use the blockdata tag on the top chest to add the item. It will be sucked into the second chest, and added to whatever items are already there.

    Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.

    Images: Pixabay, Angela Roma, Angela Roma, Plato Terentev