Minecraft – How to fix the locked door

minecraft-commandsminecraft-java-edition

I've made these commands to lock a door and make it only able to open if a user is holding an item called "Hotel Master Key".

This summons an armor stand, and I have placed it in front of the door to stop rightclicking to open it. I've done this 2 more times for the corners of the door.

/summon minecraft:armor_stand ~ ~ ~ {CustomNameVisible:0b,NoGravity:1b,Invulnerable:1b,Invisible:1b,NoBasePlate:1b,PersistenceRequired:1b,DisabledSlots:4144959,CustomName:"{\"text\":\"Main Door\"}"}

I've made a execute command to check if the player trying to enter is holding the correct item.

/execute if entity @a[nbt={SelectedItem:{id:"minecraft:tripwire_hook",Count:1b,tag:{display:{Name:"{\"text\":\"Hotel Master Key\",\"color\":\"white\",\"bold\":true,\"italic\":false}"},HideFlags:63}}}]

I've also made a command that kills the armor stands if the first command was true using a chain and conditional commandblock.

/kill @e[distance=..3,type=armor_stand,name=Main Door]

How would I make it so that the door would become re-locked (armor stands would come back) after 3 seconds?

Please don't suggest that I should use a iron door.

Best Answer

You could remove the armour stand's hitbox temporarily instead of killing it:

/data merge entity @e[type=armor_stand,name="Main Door",distance=..3] {Marker:1}

Then just undo that three seconds later:

/data merge entity @e[type=armor_stand,name="Main Door",distance=..3] {Marker:0}
Related Topic