How do you lock and give chest a name?

How do you lock and give chest a name? - Brown Wooden Storage Box on White Box

I'm making an adventure map and I need to have a command block next to a clock set the block near it to a chest with a custom name with a lock this I what I have so far:

/setblock ~-1 ~-1 ~ Minecraft:trapped_chest 1 {display:{Name:"Locked Chest",Lock:"Chest Key 47"}}

And then it says:

[16:26:39] Data tag parsing failed: Invalid tag encountered, expected '{' as first char.

I'm in 1.8.



Best Answer

The syntax of /setblock is:

/setblock <x> <y> <z> <TimeName> [dataValue] [oldBlockHandling] [dataTag]

Which means that you need to specify an [oldBlockHandling] mode (E.G: replace) before you can specify the [dataTag].

The name tag of an entity or tile entity is CustomName, rather than just Name as it is on items. Also, neither it nor Lock are stored in a Display compound tag.

This should be your fixed command:

/setblock ~-1 ~-1 ~ trapped_chest 1 replace {CustomName:"Locked Chest",Lock:"Chest Key 47"}



Pictures about "How do you lock and give chest a name?"

How do you lock and give chest a name? - Person Holding Brown Wooden Chest
How do you lock and give chest a name? - Brand Name Printed on a Wooden Chest Box
How do you lock and give chest a name? - Top view of opened carton present box with small postcard with Thank You inscription and paper stuffing on wooden table



Can you lock a chest in Minecraft?

Locking a chest in Minecraft is a feature that was first added to the game as part of the April Fool's celebrations by the developers. The feature has since been implemented in the game and lets players use commands to lock a chest.



Chest Lock | Minecraft




More answers regarding how do you lock and give chest a name?

Answer 2

Go on top of the thing you want to lock (examples include chest, dispenser, dropper, trapped chest) and type this command. Make sure you are the owner of the world or have Operator rights.

/blockdata ~ ~-1 ~ {Lock:"Key"}

I'll break this up so it is easier to understand.

(/blockdata) You are editing the data of the block

(~ ~-1 ~) You are telling minecraft what you are locking in co ordinates. XYZ

{Lock:"Key"} And you are telling to only open this thing when you have "Key" in your hand.

You may change the word "Key" to whatever you like, just act like it is a password so it's not like 123 or ABC. Someone could rename a block as 123 and open your thing.

Happy locking!

Answer 3

For version 1.16.5:

/setblock ~ ~1 ~ chest{CustomName:'[{"text":"name","italic":false,"color":"yellow"}]',Lock:"password"}

Answer 4

You might need to use block data such as

/blockdata ~ ~ ~ {Lock:"Chest Key 47"}

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

Images: Pixabay, david martins, Kevin Bidwell, Monstera