Command for detecting coordinates of a player then granting said player night vision
Solution 1:
@Bytes1024 had a good idea in his answer, but wrongly executed. The command you are looking for is this:
/execute positioned <coordinates> run effect give @a[distance=..<radius>] <effect> <time> <amplification>
Substitute <coordinates>
with the coordinates you want, and substitute <radius>
with the radius you want the command to detect players in, <effect>
with the effect you want to give, <time>
with how many seconds you want it to last, and <amplification>
with how many levels you want to add to the effect.
So, if you want to give a player at coordinates 32 68 338 in the radius of 1 the effect night vision 1 for 100 seconds, it would look like this:
/execute positioned 32 68 338 run effect give @a[distance=..1] minecraft:night_vision 100 0
Solution 2:
This should work:
/effect give @a[x={your x coordinate},y={your y coordinate},z={your z coordinate},r={the radius from the coordinates}] night_vision {length in seconds} true
(Don't put the {
and }
)
EDIT:
As user Quijibo pointed out, r
doesn't seem to work in 1.13 (I didn't know that), so does /effect give @a[x={your x coordinate},y={your y coordinate},z={your z coordinate},dx={final x coordinate},dy={final y coordinate},dz={final z coordinate}] true
work?
It checks for players within the x
,y
,z
to dx
,dy
,dz
box.