Are there any commands that checks the weather? (1.14.4)

I am working on a datapack and I want to check if the weather is rain, thunder , or clear. Is it possible to check the weather using only commands?


You can detect if it's raining or clear by using armorstands. However, there is no way to precisly check if a storm is happening. The closest i've seen is using redstone in which it won't detect in a certain time of the day.

Either way, the way you want to detect it is to ,firstly, create a scoreboard, in this case, called rain:

/scoreboard objectives add rain dummy

and then summon an armorstand, in this case, called rain with his fire nbt tag set to the max and invisible and with "NoGravity" set to true:

/summon minecraft:armor_stand ~ ~1 ~ {Invisible:1b,CustomName:"\"rain\"",Marker:0b,Fire:32766s,NoGravity:1v}

Here is the whole chain in action:

/execute as @e[limit=1,name=rain,nbt={Fire:-1s}] at @s run scoreboard players set @s rain 3
/execute as @e[limit=1,name=rain,nbt={Fire:-1s}] at @s run data modify entity @s Fire set value 30000
/execute as @e[name=rain,scores={rain=1..}] run scoreboard players remove @s rain 1

Basically, whenever it is raning, the armorstand's Fire: nbt tag will be set to -1, and so we will set his score to 3 if he matches the specification and we have a command block removing 1 from his scoreboard at all times. The reason I used score instead of tags were because I needed to have an constant output.

To use the raining output, simply refer to the entity as @e[name=rain,scores={rain=1..}].Also, a 0 output will be refered as clear. I will explain further if you need, but it seems you know enough.


I have found a way to detect thunderstorms. But it has to depend on a block, the daylight detector, and it only works if the power level of the daylight detector is above two.

It only works between sunrise to sunset

Start by creating a scoreboard called time and thunder:

/scoreboard objectives add time dummy
/scoreboard objectives add thunder dummy

Then, summon an armor stand with a tag time and thunder. Surely you can summon two different armor stands but then you have to change some commands as well.

/summon minecraft:armor_stand ~ ~ ~ {Tags:["time","thunder"]}

This armor stand will store the in-game time (and the score later on if thunder is true). In a repeating command block:

/execute as @e[tag=time] store result score @s time run time query daytime

Now place a daylight detector. This block would detect the thunderstorm.

Note: The daylight sensor should not be blocked from the sunlight.

Note: The daylight detector should not be inverted.

Placing it on y = 254 and surrounding it with barrier blocks should keep it inaccessible from players.

Here's the chain of command for thunder detection:

execute as @e[tag=thunder] run scoreboard players set @s thunder 0
execute as @e[tag=thunder] if entity @s[scores={time=23074..23297}] if block x y z minecraft:daylight_detector[power=2] run scoreboard players set @s thunder 1
execute as @e[tag=thunder] if entity @s[scores={time=23298..23532}] if block x y z minecraft:daylight_detector[power=2] run scoreboard players set @s thunder 1
execute as @e[tag=thunder] if entity @s[scores={time=23298..23532}] if block x y z minecraft:daylight_detector[power=3] run scoreboard players set @s thunder 1
execute as @e[tag=thunder] if entity @s[scores={time=23533..23768}] if block x y z minecraft:daylight_detector[power=3] run scoreboard players set @s thunder 1
execute as @e[tag=thunder] if entity @s[scores={time=23533..23768}] if block x y z minecraft:daylight_detector[power=4] run scoreboard players set @s thunder 1
execute as @e[tag=thunder] if entity @s[scores={time=23769..23963}] if block x y z minecraft:daylight_detector[power=4] run scoreboard players set @s thunder 1
execute as @e[tag=thunder] if entity @s[scores={time=23964..23999}] if block x y z minecraft:daylight_detector[power=4] run scoreboard players set @s thunder 1
execute as @e[tag=thunder] if entity @s[scores={time=23964..23999}] if block x y z minecraft:daylight_detector[power=5] run scoreboard players set @s thunder 1
execute as @e[tag=thunder] if entity @s[scores={time=0..170}] if block x y z minecraft:daylight_detector[power=4] run scoreboard players set @s thunder 1
execute as @e[tag=thunder] if entity @s[scores={time=0..170}] if block x y z minecraft:daylight_detector[power=5] run scoreboard players set @s thunder 1
execute as @e[tag=thunder] if entity @s[scores={time=171..537}] if block x y z minecraft:daylight_detector[power=5] run scoreboard players set @s thunder 1
execute as @e[tag=thunder] if entity @s[scores={time=171..537}] if block x y z minecraft:daylight_detector[power=6] run scoreboard players set @s thunder 1
execute as @e[tag=thunder] if entity @s[scores={time=538..940}] if block x y z minecraft:daylight_detector[power=6] run scoreboard players set @s thunder 1
execute as @e[tag=thunder] if entity @s[scores={time=941..1375}] if block x y z minecraft:daylight_detector[power=6] run scoreboard players set @s thunder 1
execute as @e[tag=thunder] if entity @s[scores={time=941..1375}] if block x y z minecraft:daylight_detector[power=7] run scoreboard players set @s thunder 1
execute as @e[tag=thunder] if entity @s[scores={time=1376..1867}] if block x y z minecraft:daylight_detector[power=7] run scoreboard players set @s thunder 1
execute as @e[tag=thunder] if entity @s[scores={time=1376..1867}] if block x y z minecraft:daylight_detector[power=8] run scoreboard players set @s thunder 1
execute as @e[tag=thunder] if entity @s[scores={time=1868..2450}] if block x y z minecraft:daylight_detector[power=8] run scoreboard players set @s thunder 1
execute as @e[tag=thunder] if entity @s[scores={time=2451..3175}] if block x y z minecraft:daylight_detector[power=8] run scoreboard players set @s thunder 1
execute as @e[tag=thunder] if entity @s[scores={time=2451..3175}] if block x y z minecraft:daylight_detector[power=9] run scoreboard players set @s thunder 1
execute as @e[tag=thunder] if entity @s[scores={time=3176..4301}] if block x y z minecraft:daylight_detector[power=9] run scoreboard players set @s thunder 1
execute as @e[tag=thunder] if entity @s[scores={time=3176..4301}] if block x y z minecraft:daylight_detector[power=10] run scoreboard players set @s thunder 1
execute as @e[tag=thunder] if entity @s[scores={time=4302..7707}] if block x y z minecraft:daylight_detector[power=10] run scoreboard players set @s thunder 1
execute as @e[tag=thunder] if entity @s[scores={time=7708..8833}] if block x y z minecraft:daylight_detector[power=10] run scoreboard players set @s thunder 1
execute as @e[tag=thunder] if entity @s[scores={time=7708..8833}] if block x y z minecraft:daylight_detector[power=9] run scoreboard players set @s thunder 1
execute as @e[tag=thunder] if entity @s[scores={time=8834..9957}] if block x y z minecraft:daylight_detector[power=9] run scoreboard players set @s thunder 1
execute as @e[tag=thunder] if entity @s[scores={time=8834..9957}] if block x y z minecraft:daylight_detector[power=8] run scoreboard players set @s thunder 1
execute as @e[tag=thunder] if entity @s[scores={time=9958..10139}] if block x y z minecraft:daylight_detector[power=8] run scoreboard players set @s thunder 1
execute as @e[tag=thunder] if entity @s[scores={time=10140..10632}] if block x y z minecraft:daylight_detector[power=8] run scoreboard players set @s thunder 1
execute as @e[tag=thunder] if entity @s[scores={time=10140..10632}] if block x y z minecraft:daylight_detector[power=7] run scoreboard players set @s thunder 1
execute as @e[tag=thunder] if entity @s[scores={time=10633..11067}] if block x y z minecraft:daylight_detector[power=7] run scoreboard players set @s thunder 1
execute as @e[tag=thunder] if entity @s[scores={time=10633..11067}] if block x y z minecraft:daylight_detector[power=6] run scoreboard players set @s thunder 1
execute as @e[tag=thunder] if entity @s[scores={time=11068..11469}] if block x y z minecraft:daylight_detector[power=6] run scoreboard players set @s thunder 1
execute as @e[tag=thunder] if entity @s[scores={time=11470..11836}] if block x y z minecraft:daylight_detector[power=6] run scoreboard players set @s thunder 1
execute as @e[tag=thunder] if entity @s[scores={time=11470..11836}] if block x y z minecraft:daylight_detector[power=5] run scoreboard players set @s thunder 1
execute as @e[tag=thunder] if entity @s[scores={time=11837..12041}] if block x y z minecraft:daylight_detector[power=5] run scoreboard players set @s thunder 1
execute as @e[tag=thunder] if entity @s[scores={time=11837..12041}] if block x y z minecraft:daylight_detector[power=4] run scoreboard players set @s thunder 1
execute as @e[tag=thunder] if entity @s[scores={time=12042..12238}] if block x y z minecraft:daylight_detector[power=4] run scoreboard players set @s thunder 1
execute as @e[tag=thunder] if entity @s[scores={time=12239..12474}] if block x y z minecraft:daylight_detector[power=4] run scoreboard players set @s thunder 1
execute as @e[tag=thunder] if entity @s[scores={time=12239..12474}] if block x y z minecraft:daylight_detector[power=3] run scoreboard players set @s thunder 1
execute as @e[tag=thunder] if entity @s[scores={time=12475..12708}] if block x y z minecraft:daylight_detector[power=3] run scoreboard players set @s thunder 1
execute as @e[tag=thunder] if entity @s[scores={time=12475..12708}] if block x y z minecraft:daylight_detector[power=2] run scoreboard players set @s thunder 1
execute as @e[tag=thunder] if entity @s[scores={time=12709..12933}] if block x y z minecraft:daylight_detector[power=2] run scoreboard players set @s thunder 1

Change x y z with the coordinates of your daylight detector.

The first line of command sets the score of thunder to 0 which is false but it is overcome by another command that detects the power level of the daylight detector during a certain time of the game. For example, the weather is clear and the time is between 4302 and 7707. The power of the daylight detector during that time is 15 but the change of weather also changes the power level of the daylight detector and is set to 10.

And to use the output:

execute if entity @e[tag=thunder,scores={thunder=1}] run <command>