This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
Hello!
So I am making an inn / hotel and I want the room doors to be locked, unless the player has a key (name tag) in his inventory. Since you can't lock doors, I figured I could place some barrier blocks in front, so the door can't be reached to right-click it.
Now I set up command blocks with [Repeat] and [Always Active] to check for this.The first line I put is
/execute if entity @p[nbt=!{SelectedItem:{id:"minecraft:name_tag",Count:1b,tag:{display:{Name:'{"text":"Room 3"}'}}}}]
So is there a way to add these to the same command, or how would I do this best?
/kill @e[type=minecraft:barrier,x=-31,y=68,z=712]
/kill @e[type=minecraft:barrier,x=-31,y=69,z=712]
Also, in case somebody had a key and lost it, how would I go about replacing the barrier blocks smartest?
* * * * * * * * * * * * * * * * * * * * * *
It took me a whiiile to test out things, but after removing and changing (based on input below) certain arguments from the code, I managed to find the
Solution!
Command Block #1: Repeat, Unconditional, Always Active
/execute if entity @p[nbt={SelectedItem:{tag:{display:{Name:'{"text":"Room 3"}'}}}}] run fill -31 68 712 -31 69 712 air
Command Block #2: Repeat, Unconditional, Always Active
/execute unless entity @p[nbt={SelectedItem:{tag:{display:{Name:'{"text":"Room 3"}'}}}}] run fill -31 68 712 -31 69 712 barrier
Thanks so much!
Subreddit
Post Details
- Posted
- 2 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/MinecraftCo...