- check_circle Advancements
- check_circle Functions
- check_circle Recipes
- 57,311 views, 23 today
- 8,810 downloads, 3 today
224
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.
[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. To increase its durability, it can also be enchanted with Unbreaking or Mending.
[1.21.2 +] The Key has a default durability of 400 and can be repaired with a Gold Ingot in the Anvil. The durability can be changed on the download page of the Data Pack.
[1.20.2 - 1.21.1] The Key has a durability of 100 and can be repaired by dropping it with a Gold Ingot onto an Anvil.
If you have questions or you discovered a bug, please write a comment below.
Crafting
[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. To increase its durability, it can also be enchanted with Unbreaking or Mending.
[1.21.2 +] The Key has a default durability of 400 and can be repaired with a Gold Ingot in the Anvil. The durability can be changed on the download page of the Data Pack.
[1.20.2 - 1.21.1] The Key has a durability of 100 and can be repaired by dropping it with a Gold Ingot onto an Anvil.
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:
Use the follwing command to set the maximum numbers to unlimited:
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:
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:
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:
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:
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.
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.
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 for 1.15 - 1.20.4
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
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.
Compatibility | Minecraft 1.15 |
to | Minecraft 1.21 |
Tags |
16 Update Logs
v6.1 : by CMD-Golem 05/22/2024 1:49:39 pmMay 22nd
Keys from 1.20.4 and older versions now work again with 1.20.5 and newer versions.
This means all Keys crafted in version 1.20.5 or 1.20.6 with the data pack version 6 wont work anymore.
This means all Keys crafted in version 1.20.5 or 1.20.6 with the data pack version 6 wont work anymore.
LOAD MORE LOGS
4543132
119
Create an account or sign in to comment.
But you can use the admin key to unlock them individually.
Something strange happens with enchanted books, the enchantment disappears.
Is there a solution or any command to unlock ALL the containers that exist before moving to 1.21?
This occurs because with 1.21 the nbt data (the format in which data is stored) for items has been changed. This destroys the items stored in the chest because they are not automatically updated with the new system like all other Minecraft items. Unfortunately, I didn't think of this when updating the pack.
But in the end it's not a problem at all, you can restore all items. There are two ways to do this. If you have made a backup of the world, you can unlock all chests in 1.20.4, update the world to 1.21 and lock them again. Unfortunately, it is not possible to unlock them all at once.
The other option would be to send me the file in which the items in the locked chests are stored. I will then update the data in it. This shouldn't take much time and if you have many it's much easier this way than unlocking them manually.
Before you send me the file, you must put all the items that were locked in a chest and are now broken back into the chest and lock it again. You can recognize all broken items by activating advanced tooltips (F3 + H). If the item displays the dark gray text "1 component(s)", it could be one.Then you need to open the world folder (go to the world selection screen, select your world and click on edit and there on open world folder). There you need to open the data folder and send me the command_storage_keylock.dat file. For example with swisstransfer.
I will send you back the revised file as soon as possible and you can replace the old file with the new one and enjoy 1.21.
Edit: When updating the file for OPtavius, I noticed that a lot has to be changed manually. Therefore, any other users with the same problem would have to use the first way. If not all locations of the locked chests are known, I can get them from the .dat file of option 2 and tell you about them.