Skip to content

Weather Station

The Weather Station block
Weather Station. Asset render of the block model, not an in-game screenshot.

The Weather Station knows the weather and the time of day where it stands. Use it to switch lights on at night, close roofs in the rain or show the weather on a screen.

Weather Station

Shaped crafting table recipe. Progression: early automation. Ingredients: 4 × Iron Ingot, 1 × Lightning Rod, 2 × Glass Pane, 1 × Clock, 1 × Copper Ingot. It appears in the recipe book once you pick up one of its ingredients.

Place it anywhere in the dimension you care about and link it to a Network Repeater. Weather is the same for a whole dimension; only wet, whether rain falls on the station itself, depends on where it stands.

Its form shows its name, network status and the current readings. It has no other settings.

read() gives a dictionary:

Field Meaning
dimension such as minecraft:overworld
hasWeather false in dimensions without weather, such as the Nether and the End
raining, thundering, clear the dimension’s weather
rainLevel, thunderLevel 0 to 1
precipitation none, rain or snow for the station’s biome
wet rain or snow is falling on the station right now
dayTime 0 to 23,999; 0 is sunrise and 6,000 is noon
day, gameTime days and ticks since the world began
isDay, isNight, fixedTime time of day, and whether the time is frozen

There are no forecasts: the values are Minecraft’s current state.

Yes. A drive program uses device.read(), device.weather() and the other methods, and handles device.rainStart, device.nightStart and the other events.

weather.named(alias)

Refer to a Weather Station by its name. Use it in a constant, then handle its events with on NAME.event(...).

Parameters: alias: string. Gives: WeatherStation. Cost: 4 operations.

const sky = weather.named("sky")

weather.from(alias)

Resolve a weather station by name.

Parameters: alias: string. Gives: WeatherStation, or an error. Errors: device.type, device.unavailable, device.unknown, host.denied. Capability: weather.read. Cost: 16 operations.

station, err = weather.from("roof")

Properties: sky.connected, sky.id, sky.kind, sky.name. They are read-only.

sky.clear()

True when it is not raining in this dimension.

Gives: bool, or an error. Errors: device.type, device.unavailable, device.unknown, host.denied. Capability: weather.read. Cost: 8 operations.

sunny, err = station.clear()

sky.raining()

True while it rains or snows in this dimension.

Gives: bool, or an error. Errors: device.type, device.unavailable, device.unknown, host.denied. Capability: weather.read. Cost: 8 operations.

wet, err = station.raining()

sky.read()

Read global weather (raining, thundering, clear, rain and thunder levels), local precipitation and wet at the station, and time of day.

Gives: dict, or an error. Errors: device.type, device.unavailable, device.unknown, host.denied. Capability: weather.read. Cost: 32 operations.

now, err = station.read()

sky.thundering()

True during a thunderstorm in this dimension.

Gives: bool, or an error. Errors: device.type, device.unavailable, device.unknown, host.denied. Capability: weather.read. Cost: 8 operations.

storm, err = station.thundering()

sky.time()

Read dayTime (0–23999, 0 is sunrise), day, gameTime, isDay, isNight and fixedTime.

Gives: dict, or an error. Errors: device.type, device.unavailable, device.unknown, host.denied. Capability: weather.read. Cost: 16 operations.

clock, err = station.time()

sky.weather()

Read the weather in this dimension: Weather.CLEAR, Weather.RAIN or Weather.THUNDER. Use read() for rain at the station itself.

Gives: enum, or an error. Errors: device.type, device.unavailable, device.unknown, host.denied. Capability: weather.read. Cost: 8 operations.

if station.weather() is Weather.RAIN { print("Rain!") }
EventWhen it runs
rainStartRuns when it starts raining or snowing.
rainStopRuns when rain or snow stops.
thunderStartRuns when a thunderstorm starts.
thunderStopRuns when a thunderstorm ends.
dayStartRuns at sunrise.
nightStartRuns at nightfall.
weatherChanged(weather, previous)Runs when the weather changes between Weather.CLEAR, Weather.RAIN and Weather.THUNDER.
connectedRuns when the device becomes reachable, for example after its area loads.
disconnectedRuns when the device stops being reachable: unloaded, unlinked or removed.
programStartedRuns when the device's own program starts.
programStoppedRuns when the device's own program stops.
programFailed(message)Runs when the device's own program stops on an error.

Weather is sampled every 20 ticks, once per dimension for every listening station.

const sky = weather.named("sky")
on sky.nightStart {
print("Night falls. Day " + str(sky.time().day))
}
on sky.thunderStart {
print("Thunderstorm! Stay indoors.")
}