2

I'm making a battlefield and want to include an area for "admins" and the like to enter and leave a certain area without others being able to do the same thing. I don't want to use commands such as teleporting, as it will be too jarring to see, and I want it to be a legitimate door.

Is there a way to prevent someone from using a lever? For example, if someone had a certain tag or item on them, they are unable to right-click the lever. I'm on 1.17.1.

9
  • You can prevent the redstone circuit from executing with a command block attached to the lever. I can’t write up a full answer currently, but I think all you need is a command block, redstone dust and torch along with a comparator. Since the lever activates redstone you can use it to power the command block and have the command block complete the circuit if it detects the tag. Aug 11, 2021 at 2:34
  • That would work, provided that I wasn't attempting to put the lever right next to the door lol. I wouldn't be able to do that since it would power the door anyway.
    – 0xEARTH
    Aug 11, 2021 at 2:49
  • You could add a one block buffer between the lever and door to prevent it from opening; but, it doesn’t sound like you want to do that. I’m not sure if it can be accomplished with scoreboard or not, but who knows. 🤷🏻‍♀️ Aug 11, 2021 at 2:56
  • 1
    I might try to form an actual answer another day, but for anyone who may try or even the op, make a scoreboard with the criteria [use.lever] and and two command block under the door, one that will check if it is open + someone with a tag+score, if so, open and another that is reverse. Make sure the lever isn't conected to the door.
    – BunnyMerz
    Aug 11, 2021 at 12:21
  • So, i just found out that the used criteria is for placed blocks, not when you act on them (so not when you press the lever, but rather, when you place the block lever). Would it be enough to open the door if the corret player is close enough?
    – BunnyMerz
    Aug 11, 2021 at 22:48

1 Answer 1

1

So I made a slightly different solution for you using a sign.

Using this command to give a player a custom sign that places a Redstone torch underneath the door if the player clicking the sign has the admin tag:

/give @p oak_sign{BlockEntityTag:{Text1:'{"text":"Click to open"}',Text2:'{"text":"door","clickEvent":{"action":"run_command","value":"execute if entity @s[tag=admin] run setblock -63 54 -7 redstone_torch"}}'}} 1

At the end of the command, you can change the position, x y z values, to wherever your door is placed, to place a Redstone torch underneath the door.

This completely hides the opening mechanism underground. And using a few repeaters and a command block to replace the touch with air to close the door. setblock -63 54 -7 air

I also used an Observer to detect the torch so if someone with admin tag spam clicked the sign the door would not stay open. Like this: Door open


I also placed this command in a repeating command block to teleport any player without the admin tag away from the door:

execute as @a[x=-63,y=56,z=-7,distance=..1] at @s unless entity @s[tag=admin] run tp @s ~0.3 ~ ~

I found that 0.3 was a good amount, at 0.2 you can sprint thru it. And make sure the y position is at feet level, y=56 if it's at the head level it doesn't affect any player walking thru the door.

I also made a quick demonstration video:

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .