Compatibility
Minecraft: Java Edition
Platforms
Links
Tags
Creators
Details

Lock & Key
A datapack that locks a door or a chest to one key.
Introduction
Lock chests and doors with unique and unguessable keys!
Craft a key, sneak + right-click a door or a chest, and it is now locked! No player can break, open, or activate (via redstone) the locked block without the key!
[!NOTE] Explosions are still able to break locked objects
How to Use it
Craft the key with 5 Iron Nuggets and 1 Iron Ingot.

Name it. A key is identified by its signature (who first used the key) and its name. Renaming a key is unique from any other key!
[!TIP] Name your key in an anvil before you lock anything with it, and make a spare! There is no master key. Lose the key and the lock stays shut.
[!NOTE] Due to the limitations of Minecraft string comparison, a lock cannot have a
"character in the name. If it does, you will not be able to lock anything.
Lock it. Sneak and right-click a door or a chest while holding the key. This will automatically sign the key to your user.
Share it. Give somebody a copy of the key and they can open everything it locked. Craft another, sign it, name it the same, and it opens the same locks.
Make spares. Lock something while holding multiple unsigned keys and the entire stack is signed at once!
Unlock it. Sneak and right-click a locked door or chest while holding the key that locked it.
Features
- Doors cannot be opened with redstone. The door stays in the same state as when it was locked.
- Both halves of a double chest lock, and unlock, together.
- If the block is destroyed some other way (e.g. an explosion), the key is also destroyed.
- Unguessable locks. Locks are keyed via their name AND who signed it. Another player cannot create a key that will open your chest, even if the name is the same!
Installation
- Download the release
.zip. - Drop it into
<world>/datapacks/. /reload, or load the world.
Commands
| Command | Description |
|---|---|
/function lk:give |
Gives an unsigned Lock Key without crafting one. |
/function lk:uninstall |
Takes every lock off and removes any storage, tags, etc from the datapack. Run this before deleting the pack. |
[!TIP] If you lose the key, a locked block cannot be opened (except via explosion, etc). If you uninstall while a lock is in unloaded chunks, it will not be removed. To remove a lock without a key or datapack, run the following command near the lock:
/kill @n[type=minecraft:interaction,tag=lock.lock,distance=..5]



