Minecraft Data Packs / Item

Key (Lock chests, other containers and doors)

  • check_circle Advancements
  • check_circle Functions
  • check_circle Recipes
  • 52,146 views, 30 today
  • 8,121 downloads, 10 today
  • 138
  • 142
  • 255
CMD-Golem's Avatar CMD-Golem
Level 64 : High Grandmaster Engineer
220
Lock your containers and doors to protect your items and buildings from other players and Creepers. Press shift and right-click on the block to lock or unlock it.


Crafting
Key (Lock chests, other containers and doors) Minecraft Data Pack

[​1.20.2 - 1.20.4] The Crafting Table will show a Knowledge Book as the result. This will be replaced by the Key after crafting.

The Key is damaged every time a block is locked. This functionality can be changed in the settings of the Data Pack. The damage can also occur when unlocking, every time the Key is used or be completely deactivated.
The Key can be repair by dropping a Gold Ingot with the Key onto an Anvil. To increase its durability, it can also be enchanted with Unbreaking.

Locking and settings
If a player locks a container or door, only that player can unlock it again. The Key itself doesn't matter in this process, as the lock only remembers the player.

In addition, you can allow the name of the Key to be used as password in the settings. This allows all players who use the right password to unlock the lock. To prevent forgotten passwords, the last player to lock the container or door owns it and can therefore also unlock it with any Key as described above.

If desired, the maximum number of locked blocks per player and the total in the world can be defined in the settings.

You can open the settings with the following command:
/function keylock:settings/menu
Use the follwing command to set the maximum numbers to unlimited:
/scoreboard players reset #max_player keylock/scoreboard players reset #max_world keylock


Locked containers
Once a container has been locked, the items inside can no longer be accessed, even by breaking it or placing a hopper underneath it.
This also means that locked furnaces and similar blocks cannot process the items inside and the fuel currently in use is not preserved. If items are placed in a locked container via a hopper, they will be dropped when the container is unlocked.

Settings Menu:
  • The automatic unlocking of containers can be activated. This causes all containers within a defined radius around the player to be unlocked, as long as the player is the owner of the container or has the correct Key with password selected in their hotbar. After the player has moved away, the container is automatically locked again.
  • The behaviour of locked containers can be changed. Locked containers can either be made unbreakable or replaced by holograms. Furthermore, the container can also remain as a block and only be replaced by a hologram once it has been destroyed. A hologram is a visualisation of the locked container. A player can walk through it without resistance and place and break blocks in it.

Locked doors and fence gates
All locked doors, trapdoors and fence gates are unbreakable and cannot be opened. However, the lock can be released by a piston if it moves the door, trapdoor or fence gate. Removing the support block from a normal door also causes the door to break.

If a double door is locked, both door leaves are locked.

Settings Menu:
  • The automatic opening of double doors can be activated. This setting applies to all doors, regardless of whether they are locked.
  • The automatic opening of doors can be activated. If this is activated, all doors that are three blocks in front of the player are opened. After the player has moved away, the door is automatically closed again.
  • The automatic unlocking of doors can be activated. This will unlock and open all doors that are three blocks in front of the player, provided the player is the owner of the door or has selected the correct key and password in their hotbar. After the player has moved away, the door is automatically closed and locked again.


Important technical stuff
Be aware that other Data Packs and mods that change the functionality of containers and doors can interrupt the operation of this pack. In the case of containers, this could result in the loss of items.

Never kill all entities in the world, as the lock status of the block is stored in special entities.

A server admin can use an Admin Key to unlock the locked blocks of another player:
/function keylock:admin_key
If a container or door can no longer be unlocked, an attempt should first be made to break it. If the locked block replaces itself, an Admin Key can be used to unlock it. If a locked container no longer replaces itself, the original container must be placed again first. The following command can then be used to restore the items in the container:
/function keylock:container/repair with block <container position>
This command cannot be used if a container has been locked again at the same position with new items in it. This will overwrite the data at this position.
The items themselves are not saved in the special entity, but in the command storage. The file is located in the data folder of your world and is called command_storage_keylock.dat.

Adjust lockable Blocks
The easiest way to select the lockable blocks is on the download page of the Data Pack. If these need to be changed after the first download, the Data Pack must first be unzipped. All lockable blocks are defined under the folder data/tags/blocks.

All lockable containers are stored in the containers.json file. The following blocks from Vanilla can be locked when defined in this file:
barrel, blast_furnace, brewing_stand, chest, dispenser, dropper, furnace, hopper, smoker, trapped_chest and all colour variants of the shulker_box

All lockable doors are stored in the doors.json file. All doors from Vanilla can be locked when defined in this file.

All lockable trapdoors and fence gates are stored in the trapgate.json file. All trapdoors and fence gates from Vanilla can be locked when defined in this file.

It is also possible to add blocks from mods. To do this, the block ID is stored in the most fitting block tag json file. In addition, it is always necessary to check whether the locking works correctly before using it.

Older versions
If you want to use the older version of this Data Pack, you can get it here.
In this version you can only lock normal chests, but this version can be used from Minecraft 1.15 onwards.

Download





If you have questions or you discovered a bug, please write a comment below.
CompatibilityMinecraft 1.15
toMinecraft 1.20
Tags

15 Update Logs

v6 : by CMD-Golem 04/28/2024 10:44:49 amApr 28th

Keys from 1.20.4 and older won't work in 1.20.5 an newer! Locked Chests can be unlocked as before.

Updated to 1.20.5
Improved storage of items of locked containers
Fixed duplication bug with pistons
Redstone cant open locked Doors, Trapdoors and Fence Gates anymore
Added more Key damage settings
Changed Admin Key Command
LOAD MORE LOGS

Create an account or sign in to comment.

1
05/07/2024 2:54 pm
Level 1 : New Miner
Piesel4YT
Piesel4YT's Avatar
Is there any way to make an admin key or could you program that?
1
05/08/2024 7:37 am
Level 64 : High Grandmaster Engineer
CMD-Golem
CMD-Golem's Avatar
Have a look at the important technical stuff spoiler
1
01/18/2024 9:58 am
Level 1 : New Miner
mandooooohgfj
mandooooohgfj's Avatar
that datapack its very OP! BUT.....
I have some problems that I am facing. I hope you can help me solve them :(

1-everything is working good
except trapdoors and fence gates i cant lock or open it!!


2-automattic unlokking ( what is that mean) i cant understand cuz eng is not my
My primary language.


3-
I have an iron machine, and at the end of the machine there is hopersdeliver iron to the chest ........The problem here is that when I lock the chest ... the hopers stop to deliver iron to the chest
i wana lock the chest and the hopers still working.

Thank you very much for this datapack <3
1
01/18/2024 4:58 pm
Level 64 : High Grandmaster Engineer
CMD-Golem
CMD-Golem's Avatar
1. In the settings you need to enable the locking of trapdoors

2. When the player is near to a locked block it automatically unlocks it for you, without the need to use the key. When the player moves away, the block also locks itself again.

3. This isn't possible with this data pack. Because then hoppers would also be able to suck out items of locked containers.
1
01/19/2024 6:22 amhistory
Level 1 : New Miner
mandooooohgfj
mandooooohgfj's Avatar
thx bro but i am sure that i enabled the loking of trapdoors and its still dont work



and the automattic unlokking also did not work



i ll send photo for my settings




files.fm/u/mzzsgvtn56





and also i am sure from that i slected trapdoors and fence gates photos.
1
01/20/2024 11:54 amhistory
Level 64 : High Grandmaster Engineer
CMD-Golem
CMD-Golem's Avatar
Execute the following command to check if the setting is truly enabled:
/function keylock:settings/menuIf not, you can change it in there.

If this doesn't work, please unzip the data pack and open the file under the following path and send the text in it to me (you can open it with any text editor like word, notepad or similar):
data/keylock/tags/blocks/trapgate.json
2
01/21/2024 5:48 am
Level 1 : New Miner
mandooooohgfj
mandooooohgfj's Avatar
thx bro everything is working good now
1
01/09/2024 12:07 pm
Level 1 : New Miner
Haeundae
Haeundae's Avatar
minecraft 1.20.1 datapack plz.....
1
01/09/2024 4:00 pm
Level 64 : High Grandmaster Engineer
CMD-Golem
CMD-Golem's Avatar
This isn't possible, because some features this data pack uses aren't available in this version.
But you can use the older version of this pack, which can only lock normal chests. You can find it here.
1
12/19/2023 2:56 pm
Level 1 : New Miner
Kawai
Kawai's Avatar
this datapack not work 12.0.4 ..
i can't make a key
Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome