u/IntroductionOld8554

Command block: how to make a command block execute once, when a condition is met

I have 2 command blocks, that replaces every light block in my big map with a air void and vice versa when a lever is turned, problem is the command blocks are set on repeat and it lags my server a lot because it executes it in a circa 3 million block area so i want to have these command blocks execute once when the lever is turned, not repeating when the lever is on, any help?

the commands:

  1. Turning lights on

execute if block -158 -2 24 lever[powered=true] run fill -198 36 67 17 -64 -41 minecraft:light replace minecraft:void_air

  1. Turning lights off

execute if block -158 -2 24 lever[powered=false] run fill -198 36 67 17 -64 -41 minecraft:void_air replace light

reddit.com
u/IntroductionOld8554 — 3 days ago