Hello guys, What I'm trying to achieve is an Automatic Door opener for a certain player when they're at a certain location, I know a comparator infront of a command block will activate when the block performs a successful command. I need a command to detect when a certain player is in front of the door. I'm new to the Java edition and I know this command is something that can be done on the bedrock edition. I also need help with changing a certain persons gamemode from adventure to survival when they walk past a certain block. Can anyone help me with these commands ? I try /execute but its kind of confusing.
execute as @p at @s if block ~ ~-1 ~ <block> run <command>
execute as @p[gamemode=adventure] at @s if block ~ ~-1 ~ <block> run gamemode survival @s
Unfortunately, with this setup, the door will open every time the player is over any block that is the type of block used by the door. You can use specific coordinates, instead, to make it work easier, as well as make it so you can change the type of blocks around the door without it messing up the command.
If you have an always active, unconditional, repeating command block with the command
/execute as @a[x=insertxcoordinate,y=insertycoordinate,z=insertzcoordinate,distance=..1]
then have a comparator running from the command block, it will activate every time a player crosses over the designated coordinates! It's that simple! Furthermore, if you want the door to work for only one player or team, you can add a name=username or a team=teamname after the distance=..1
For the gamemode change command, do this command in a repeating, unconditional, always active command block:
/execute as @a[x=insertxcoordinate,y=insertycoordinate,z=insertzcoordinate,distance=..1,gamemode=adventure] run gamemode survival @s
You don't need any comparator attached to the gamemode change command block, it'll do everything for you!
Unfortunately, with this setup, the door will open every time the player is over any [/i]block that is the type of block used by the door. You can use specific coordinates, instead, to make it work easier, as well as make it so you can change the type of blocks around the door without it messing up the command.
If you don't have 1 but several blocks, your solution is much more complicated. You also can hide the blocks by changing the command to
execute as @p at @s if block ~ ~-2 ~ <block> run <command>
and set the block(s) 1 block deeper.
If you don't want that every block in the world triggers the door you can add a "distance=..<radius>" filter.
If you don't have 1 but several blocks, your solution is much more complicated. You also can hide the blocks by changing the command to
execute as @p at @s if block ~ ~-2 ~ <block> run <command>
and set the block(s) 1 block deeper.
If you don't want that every block in the world triggers the door you can add a "distance=..<radius>" filter.
It's much less complicated, because all you have to do for multiple blocks is add a distance=..radius or dx=, dy=, and dz=. I just thought that it made more sense to tell the OP how to use coordinates in /execute, because it seemed to fit the description more of what they were looking for
Hello guys, What I'm trying to achieve is an Automatic Door opener for a certain player when they're at a certain location, I know a comparator infront of a command block will activate when the block performs a successful command. I need a command to detect when a certain player is in front of the door. I'm new to the Java edition and I know this command is something that can be done on the bedrock edition. I also need help with changing a certain persons gamemode from adventure to survival when they walk past a certain block. Can anyone help me with these commands ? I try /execute but its kind of confusing.
Unfortunately, with this setup, the door will open every time the player is over any block that is the type of block used by the door. You can use specific coordinates, instead, to make it work easier, as well as make it so you can change the type of blocks around the door without it messing up the command.
If you have an always active, unconditional, repeating command block with the command
/execute as @a[x=insertxcoordinate,y=insertycoordinate,z=insertzcoordinate,distance=..1]
then have a comparator running from the command block, it will activate every time a player crosses over the designated coordinates! It's that simple! Furthermore, if you want the door to work for only one player or team, you can add a name=username or a team=teamname after the distance=..1
For the gamemode change command, do this command in a repeating, unconditional, always active command block:
/execute as @a[x=insertxcoordinate,y=insertycoordinate,z=insertzcoordinate,distance=..1,gamemode=adventure] run gamemode survival @s
You don't need any comparator attached to the gamemode change command block, it'll do everything for you!
Hope this helps!
Memelord and general minecraft enthusiast
If you don't have 1 but several blocks, your solution is much more complicated. You also can hide the blocks by changing the command to
and set the block(s) 1 block deeper.
If you don't want that every block in the world triggers the door you can add a "distance=..<radius>" filter.
It's much less complicated, because all you have to do for multiple blocks is add a distance=..radius or dx=, dy=, and dz=. I just thought that it made more sense to tell the OP how to use coordinates in /execute, because it seemed to fit the description more of what they were looking for
Memelord and general minecraft enthusiast