Stop a thief in Vanilla Minecraft: Detect if player is x distance from y,z coordinates
-
I'm trying to catch a thief in 1.19 Minecraft. I had one set of commands to see if items were taken out of a chest, but that was defeated -- I suspect they used X-ray hacked client to disable the command block:
/execute if block -109 63 208 chest{Items:[]} say @p is a thief
I want to duplicate the trap but also output to logs if they try to mine the command block again. I thought I could use this to see if they were too close:
/execute if entity @a[distance=..10] say @p is a vandal
but then realized if they have Xray, they can see the 2nd command block, suspect something was up, and avoid triggering the trap. I want to hide the 2nd block far away, so they only see the original command block
So I need a command to say
/execute if entity @a[distance_from_coords=..5| 102 59 210] say @p is a vandal
(an entity got within 5 blocks of the 1st command block)
Is there any way to do this, or otherwise clever way to catch the thief?
-
You can just use
x=
,y=
, andz=
to specify the location to calculate distance from:@a[x=102,y=59,z=210,distance=..5]
This checks that the distance between the player and the specified coordinates is less than five blocks.