PT-BR EN ES
Channel Icon

Crazy Ozz

Official Channel Website

Command Block

How to Lock Chests in Minecraft with a Key (Lock Command)

Minecraft Java Edition 1.21+ and 26+ – Locked Chest System Using Commands

Want to protect your items and stop other players from opening your chests? In this tutorial you will learn how to lock chests in Minecraft using commands, creating a key system that only allows access if the player has the correct named item. This method works in Minecraft Java Edition 1.21+ and 26+ and uses the lock feature, making it perfect for adventure maps, RPG servers, puzzles, and custom protected areas without plugins.

Let's use the command below to get a locked chest and use it in our map

give @p minecraft:chest[minecraft:lock={components:{"minecraft:custom_name":"Chave123"}}]

The player needs an item with the name that is inside custom_name in order to unlock the chest

After using an item with that name, the chest will be unlocked

You can use an anvil to rename the item or do it through custom_name in the give command

Want cheap and lag-free Minecraft hosting?

I recommend Sparked Host: affordable plans, great performance, easy panel and fast support.

🚀 Start your Minecraft Server

Still have questions? Watch the video below