1

I'm doing a project in Minecraft 1.10 where I want to detect a named chest and put an item in it. The player puts down a chest that's named Mailbox, and the command blocks are supposed to detect it. I tried using the execute command to detect the chest, and then blockdata to put an item in that chest, but never got to work correctly.

Does anyone know how to do this?

  • I have fixed my answer. It should solve the issue. – Dusan Dakic Feb 25 '17 at 2:18
-1

Blocks don't keep names once placed. So finding a placed block with a name is not possible. Only items keep the name, once you shift their state all properties are restored to default.

Names are not stored in blockdata!!

But, a chest has a block entity associated with it that holds additional data about the block. The block's block entity ID is chest. As stated on the Minecraft Wiki:

CustomName: Optional. The name of this container, which will display in its GUI where the default name ordinarily is.

Lock: Optional. When not blank, prevents the container from being opened unless the opener is holding an item whose name matches this string.

Items: List of items in the container.

LootTable: Optional. Loot table to be used to fill the chest when it is next opened, or the items are otherwise interacted with.

LootTableSeed: Optional. Seed for generating the loot table. 0 or omitted will use a random seed. Both loot table tags will be removed once the items have been generated.

The name of a chest is stored in the CustomName tag. So, to test for it, run this on a superfast clock:

/testforblock x y z chest -1 {CustomName:"The Name"}
  • 1
    Some tile entities (chests included) will keep their names when placed. – SirBenet Feb 24 '17 at 10:34
  • Please read the answer in whole before you comment or downvote. – Dusan Dakic May 31 '17 at 21:50
  • "Please read the answer in whole before you comment or downvote" - you only edited the correct info in after my comment and the downvote. You can see the history of the answer by clicking on the "edited Feb 25 at 2:19" hyperlink. This is what it looked at the time of my comment. You should able to submit another answer if you want to get rid of the downvotes/comments from your previously incorrect answer. – SirBenet Jun 1 '17 at 11:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.