How to Add a Lock to a Chest in Minecraft

by
How to Add a Lock to a Chest in Minecraft

This Minecraft tutorial shows how to apply a lock to a chest so that it can only be opened if the user has an item with a certain name in their inventory.

How to Add a LocHow to Add a Lock to a Chest in Minecraftk to a Chest in Minecraft – 

Requirements

In order to use game commands in Minecraft, you must enable cheats in your world.

Command to Add a Lock to a Chest

Java

Command in Minecraft Java Edition (PC/Mac)

In Minecraft Java Edition (PC/Mac) 1.13, 1.14, 1.15, 1.16, 1.17 and 1.18, the syntax to lock a chest using the /data command is:

/data merge block <pos> {Lock:”<value>”}

In Minecraft Java Edition (PC/Mac) 1.8, 1.9, 1.10, 1.11 and 1.12, the syntax to lock a chest using the /blockdata command is:

/blockdata <x> <y> <z> {Lock:”<value>”}

Definitions

pos or x y z is the x y z coordinate where the chest is located.

value is the secret passcode that unlocks the chest. A player must be holding an item with this name to be able to open the chest.

How to Execute the Command?

  1. Open the Chat Window first.

In Minecraft, the simplest way to run a command is via the chat window. The game control for opening the chat window varies depending on Minecraft version:

To launch the chat window in Java Edition (PC/Mac), hit the T key.

2. Fill in the Command

We’ll install a lock on a chest discovered at coordinates in this example (32, 73, -199). We want to make the secret passcode “DigMinecraft” so that only a player with a “DigMinecraft” item may access the chest.

In Minecraft Java Edition (PC/Mac) 1.13, we may put the lock to the chest using the following command:

/data merge block 32 73 -199 {Lock:”DigMinecraft”}

Type the command in the chat window. As you are typing, you will see the command appear in the lower left corner of the game window. Press the Enter key to run the command.

  • The message “Modified block data of 32, 73, -199” will show in the lower left corner of the game window once the cheat has been input, indicating that the chest has been successfully locked.
  • If you try to open the chest without having the item “DigMinecraft,” the message “Chest is locked!” will appear. show up in the game window
  • Congratulations for figuring out how to lock a chest in Minecraft using a secret passcode.

Leave a Comment