API reference / @jsprismarine/prismarine / world/Weather / WorldWeather
Class: WorldWeather
Defined in: packages/prismarine/src/world/Weather.ts:89
The weather of one world.
Constructors
Constructor
new WorldWeather(
world):WorldWeather
Defined in: packages/prismarine/src/world/Weather.ts:98
Parameters
world
Returns
WorldWeather
Methods
addGuard()
addGuard(
guard): () =>void
Defined in: packages/prismarine/src/world/Weather.ts:105
Adds a guard to the weather action, after the ones already there. A change that keeps the weather as it is goes past no guard.
Parameters
guard
Returns
A function that removes it.
() => void
current()
current():
"thunder"|"clear"|"rain"
Defined in: packages/prismarine/src/world/Weather.ts:131
What the rules branch on: clear, rain or thunder.
Returns
"thunder" | "clear" | "rain"
onChange()
onChange(
listener): () =>void
Defined in: packages/prismarine/src/world/Weather.ts:117
Hears each change of weather once it took effect.
Parameters
listener
Returns
A function that removes the listener.
() => void
raining()
raining():
boolean
Defined in: packages/prismarine/src/world/Weather.ts:136
Whether rain is falling from the sky right now, before anything about one position.
Returns
boolean
resetCycle()
resetCycle():
void
Defined in: packages/prismarine/src/world/Weather.ts:218
What a night slept through does to the weather: the rain and the storm stop, and the next tick books the dry spell that follows. Announced at once, as the players wake to it.
Returns
void
See
resetWeatherCycle
restore()
restore(
saved):void
Defined in: packages/prismarine/src/world/Weather.ts:146
Puts back what a save held.
Nothing is announced: a world being loaded has nobody in it, and the first tick after it does sends the state anyway.
Parameters
saved
WeatherState | undefined
Returns
void
saved()
saved():
WeatherState
Defined in: packages/prismarine/src/world/Weather.ts:126
The five numbers, for the save file.
Returns
set()
set(
kind,durationTicks?):void
Defined in: packages/prismarine/src/world/Weather.ts:189
What /weather <kind> [duration] sets, announced at once rather than on the next tick.
The seam the command needs, and the whole of it: a host wires world.setWeather(kind, durationTicks) to its /weather and nothing else.
A change of weather goes through the guards first, in the order they were added, and the first veto leaves the weather as it was; a guard may also replace the weather and the duration. Setting the weather it already is changes only how long it lasts.
Parameters
kind
"thunder" | "clear" | "rain"
clear, rain or thunder.
durationTicks?
number
How long, in ticks. Left out, each kind gets Java's own randomized default: 10 to 150 minutes clear, 10 to 20 raining, 3 to 13 storming.
Returns
void
tick()
tick(
tick):void
Defined in: packages/prismarine/src/world/Weather.ts:158
One game tick: advances the cycle and keeps the clients in step.
Parameters
tick
number
The world's tick counter, which paces the resend.
Returns
void