Interface in @minecraft/server
Extends CancellableEvent
The weather about to turn, by its cycle, a command or a plugin.
import type { WeatherChangeBeforeEvent } from '@minecraft/server';Subscribe to it with world.beforeEvents.weatherChange.
Example
Section titled “Example”import { world, type WeatherChangeBeforeEvent } from '@minecraft/server';
world.beforeEvents.weatherChange.subscribe((event: WeatherChangeBeforeEvent) => { console.log('weatherChange', event.previousWeather, event.newWeather, event.duration);
// Uncomment to stop it from happening. // event.cancel = true;});import { world } from '@minecraft/server';
world.beforeEvents.weatherChange.subscribe((event) => { console.log('weatherChange', event.previousWeather, event.newWeather, event.duration);
// Uncomment to stop it from happening. // event.cancel = true;});Properties
Section titled “Properties”previousWeather
Section titled “previousWeather”read-only
readonly previousWeather: WeatherType;Types
newWeather
Section titled “newWeather”newWeather: WeatherType;What it turns to, which handlers may change.
Types
duration
Section titled “duration”duration: number;Ticks the new weather lasts, which handlers may change.
Used by
Section titled “Used by”WorldBeforeEvents.weatherChange, WeatherChangeBeforeEventSignal.subscribe, WeatherChangeBeforeEventSignal.unsubscribe
Inherited
Section titled “Inherited”From CancellableEvent: cancel