I am trying to make a container that unlocks for several keys, so far my testing says that only 1 key can be in place at a time. is there a way around this to have multiple keys?
I'm playing Minecraft Java Edition 1.12.2
minecraft-commandsminecraft-java-edition
I am trying to make a container that unlocks for several keys, so far my testing says that only 1 key can be in place at a time. is there a way around this to have multiple keys?
I'm playing Minecraft Java Edition 1.12.2
Best Answer
Not directly! The
Lock
tag only accepts one item name. You could have multiple items with the same name instead.But what you could do is repeatedly test if there is a player near the chest, and if they have an acceptable key, update the chest's
Lock
tag to match the name of the acceptable item.For example, let's have our keys named
AliceKey
andBobKey
, given to players Alice and Bob respectively. Summon an invisible armour stand on the chest with the tagchestKeys
, then create separate command chains for each possible key:1.13+
Command syntax was heavily changed in 1.13, and so the commands above won't work. Instead, use the new versions of
/execute
and/blockdata
: