Why don't these /execute parameters check for the entity in the specified position?
I have a system set up to trigger a command block if an entity walks to that spot. However, it is setting off the trigger without an entity being there. This is the command that I'm using:
execute if entity @e positioned -86 5 82 run fill -88 4 79 -88 4 79 minecraft:redstone_block
Why is my command running even when an entity is not in that location?
Best Answer
Your command is testing for an entity with the selector @e
, which is any entity. This will almost always be true while you are on the world / server.
The positioned
means that the command is ran from the location, so if you did /execute positioned x y z run setblock ^ ^ ^ stone
then the block at x y z would be set to stone.
The correct version of this command would be:
/execute positioned x y z if entity @e[distance=..1] run fill xyz1 xyz2 block
And obviously you would replace x y z, xyz1, xyz2 and block with your own data.
Pictures about "Why don't these /execute parameters check for the entity in the specified position?"
Why Don't We - Fallin' (Adrenaline) [Official Music Video]
Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.
Images: Anna Shvets, Alexander Suhorucov, Ono Kosuki, Ono Kosuki