[API reference](https://jsprismarine.dev/api/index.md) / [@jsprismarine/prismarine](https://jsprismarine.dev/api/@jsprismarine/prismarine/index.md) / [world/Weather](https://jsprismarine.dev/api/@jsprismarine/prismarine/world/Weather/index.md) / WorldWeather

# Class: WorldWeather

Defined in: [packages/prismarine/src/world/Weather.ts:89](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/Weather.ts#L89)

The weather of one world.

## Constructors

### Constructor

> **new WorldWeather**(`world`): `WorldWeather`

Defined in: [packages/prismarine/src/world/Weather.ts:98](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/Weather.ts#L98)

#### Parameters

##### world

[`WeatherWorld`](https://jsprismarine.dev/api/@jsprismarine/prismarine/world/Weather/index.md#weatherworld)

#### Returns

`WorldWeather`

## Methods

### addGuard()

> **addGuard**(`guard`): () => `void`

Defined in: [packages/prismarine/src/world/Weather.ts:105](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/Weather.ts#L105)

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

[`WeatherGuard`](https://jsprismarine.dev/api/@jsprismarine/prismarine/world/Weather/index.md#weatherguard)

#### Returns

A function that removes it.

() => `void`

***

### current()

> **current**(): `"thunder"` \| `"clear"` \| `"rain"`

Defined in: [packages/prismarine/src/world/Weather.ts:131](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/Weather.ts#L131)

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](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/Weather.ts#L117)

Hears each change of weather once it took effect.

#### Parameters

##### listener

[`WeatherListener`](https://jsprismarine.dev/api/@jsprismarine/prismarine/world/Weather/index.md#weatherlistener)

#### Returns

A function that removes the listener.

() => `void`

***

### raining()

> **raining**(): `boolean`

Defined in: [packages/prismarine/src/world/Weather.ts:136](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/Weather.ts#L136)

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](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/Weather.ts#L218)

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](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/Weather.ts#L146)

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`](https://jsprismarine.dev/api/@jsprismarine/engine-systems/index.md#weatherstate) \| `undefined`

#### Returns

`void`

***

### saved()

> **saved**(): [`WeatherState`](https://jsprismarine.dev/api/@jsprismarine/engine-systems/index.md#weatherstate)

Defined in: [packages/prismarine/src/world/Weather.ts:126](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/Weather.ts#L126)

The five numbers, for the save file.

#### Returns

[`WeatherState`](https://jsprismarine.dev/api/@jsprismarine/engine-systems/index.md#weatherstate)

***

### set()

> **set**(`kind`, `durationTicks?`): `void`

Defined in: [packages/prismarine/src/world/Weather.ts:189](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/Weather.ts#L189)

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](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/Weather.ts#L158)

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`
