Is there a way to detect rain in datapacks? [Minecraft 1.16] [duplicate]

The answer here technically works when utilizing command blocks, but isn't possible when working with datapacks. I do have the same limitations as the linked question, in that I can't use cauldrons, soil, and so on to detect it.

What I'm attempting to do is make it rain infinitely, but I don't want it to continuously run the command. Yes, I can set up commands so that load.json runs it on server (re)load, but the maximum time I can set that to is roughly 11 days. Since I'm making a datapack that is intended for survival world use, I need this to be continuous and run again if it's no longer raining.


You don't need to detect when it's raining to do that. Simply set the doWeatherCycle gamerule to false and run /weather rain in your function (the one that's registered in load.json). When the weather cycle gamerule is true, the weather can change naturally. When it's false, it can only be changed with commands.