I'm making a Minecraft 1.16 datapack and I need to check if a player is in a certain location. I want to check for that condition every tick and then run a function when it is met.

I'm currently using this command: execute as @a[x = 10, y = 56, z = 42, dx = 8, dy = 10, dz = 0] run say Passed
The problem is that when the condition is met, the run say Passed part also executes every tick, which is not what I want.

When the condition is met, I want that command to only run once, and not every tick, while still checking the condition every tick. But, I also want the command to be able to run again after a second or so.

Could I do this by checking the condition every tick, then running a function that has a timer that only executes a command if it was previously executed 1 or more seconds ago?

  • if im understanding correctly you want it to check every tick but not run every tick the condition is met?
    – Topcode
    Dec 30, 2020 at 14:43
  • So you want to continually check if the condition is met until the condition is met and then resume the check when the condition is no longer met? Dec 30, 2020 at 17:46
  • If you were making an adventure map or something of that nature, I would advise you to hook a command block to a monostable redstone circuit. But I don't think you can do that in a data pack. I suspect the answer you are looking for involves scoreboards in some fashion, but I don't know enough about how they work to provide a more specific answer.
    – Kevin
    Dec 30, 2020 at 21:01
  • @Topcode Yes, that's what I'm looking for Dec 31, 2020 at 20:48
  • @randomuser922 Pretty much yeah Dec 31, 2020 at 20:48

1 Answer 1


you could make a scoreboard that stores a timer, that counts down to 0 and once that 0 is hit, the command can be run again setup:

/scoreboard objectives add Timers dummy

so you'll run these functions each tick:

execute if score FunctionX Timers matches 1.. run scoreboard players remove FunctionX Timers 1
execute if score FunctionX Timers matches 0 run execute as @a[x = 10, y = 56, z = 42, dx = 8, dy = 10, dz = 0] run function <namespace>:passed

and in passed.mcfunction

scoreboard players add FunctionX Timers 20
say passed

this will make the command run only every 20 gameticks


You must log in to answer this question.

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