Minecraft – way to keep repeating command blocks always running (even if the chunk it is in unloads)

minecraft-commandsminecraft-java-edition

This might just be asking how to keep chunks always loaded, but there's a bit more to this question.

I have a command block (repeating) that is always running a command that will detect if a specifically-renamed item (a feather that is renamed 'Feather of the Skies') is not in the offhand slot, and if it is not there, then it clears a specific potion effect (in this case, levitation)

Here is the command I am running currently (it runs fine):

/effect clear @a[nbt=!{SelectedItem:{id:"minecraft:feather",tag:{display:{Name:"\"Feather of the Skies\""}}}}] minecraft:levitation

However, whenever I leave my base, the chunk that the command block is in unloads, and renders the detector/command block useless. Is there any way to make this command block stay unloaded, or is there any alternative solution so that the command does not have to stay in a chunk to work? (maybe something like a scoreboard?)

In other words, is there a way to either keep this chunk always loaded OR is there a way to make the command run regardless of your location in the world?

I am playing on Minecraft Java Edition, on ver. 1.14.4, and the world is completely vanilla, if this information is needed.

Best Answer

The chunks surrounding the world spawn are always loaded, so this is the best place to put command blocks that you always want to run. You can change where the world span is using the /setworldspawn command.

However, the better option in this case is to put your commands in a function file and load it through a datapack. Google search offers a number of tutorials for how to do this.