Is it possible to only allow a person to open a chest if he has an item in his inventory in Minecraft?
In other words: If a person has, say, a gold ingot named "Bob" in his inventory, the chest will open and he may view its contents. If such an ingot is absent, he will be unable to view the contents of the chest.
What I'm trying to do is develop a safety deposit box system, where if a player has a "key" he may open the box, but otherwise the chest stays locked. I'm trying to avoid complicated redstone contraptions while trying to stay in vanilla MC. If my "key" idea doesn't work, any other suggestions?
Solution 1:
You can lock a chest but it will require a command.
This will set a locked chest:
/setblock x y z minecraft:chest 0 0 {Lock:Key}
x y z being coordinates. In this case you would have to have an item named 'Key' in your hand to open the chest. (otherwise it says chest is locked)
One thing to note, if you break the chest, it will drop it's contents onto the ground.
Also, just in case you haven't discovered it. An ender chest will keep your items safe from others. If you combine that with shulker boxes, you can store quite a lot of items.
Edit:
Other items besides chests can be locked. I used another command to test them:
/blockdata ~ ~-1 ~ {Lock:Key}
I set several items that contain an inventory. I jumped on top of each and used the above command.
All items in image successfully locked