Minecraft wiki entry for Chest, associated text: In Java Edition, a chest can be "locked" by setting its Lock tag using the /data command. If a chest's Lock tag is not blank, the chest cannot be opened unless the player is holding an item with the same name as the Lock tag's text. For example, to lock a chest at (0,64,0) so that the chest cannot be opened unless the player is holding an item named "Chest Key", use /data merge block 0 64 0 {Lock:"Chest Key"}.