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

# world/Weather

## Classes

- [WorldWeather](https://jsprismarine.dev/api/@jsprismarine/prismarine/world/Weather/classes/WorldWeather.md)

## Interfaces

### WeatherChange

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

A weather change about to happen, as the guards of the weather action read it.

#### Properties

##### duration

> `readonly` **duration**: `number`

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

How long the new weather lasts, in ticks.

##### next

> `readonly` **next**: `"thunder"` \| `"clear"` \| `"rain"`

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

##### previous

> `readonly` **previous**: `"thunder"` \| `"clear"` \| `"rain"`

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

***

### WeatherWorld

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

What [WorldWeather](https://jsprismarine.dev/api/@jsprismarine/prismarine/world/Weather/classes/WorldWeather.md) needs from the world it belongs to.

#### Methods

##### cycleAllowed()

> **cycleAllowed**(): `boolean`

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

Whether `doWeatherCycle` is on. Java stops the counters dead when it is not.

###### Returns

`boolean`

##### randomInt()

> **randomInt**(`bound`): `number`

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

A draw in `[0, bound)`, used only when a stretch has to be booked.

###### Parameters

###### bound

`number`

###### Returns

`number`

##### show()

> **show**(`from`, `to`): `void`

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

Shows everybody in the world a change of weather, which each client's edition draws its own way.

###### Parameters

###### from

`"thunder"` \| `"clear"` \| `"rain"`

###### to

`"thunder"` \| `"clear"` \| `"rain"`

###### Returns

`void`

## Type Aliases

### SavedWeather

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

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

The weather stored by the provider, which is Java's `WeatherData` field for field.

***

### WeatherGuard

> **WeatherGuard** = (`change`) => \{ `veto`: `true`; \} \| \{ `change`: [`WeatherChange`](#weatherchange); `veto`: `false`; \}

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

A guard of the weather action ([ADR 0013](https://jsprismarine.dev/adr/0013-vetoable-actions-are-staged.md)):
it reads the change and lets it through, with a weather and a duration it may replace, or
vetoes it. It writes nothing.

#### Parameters

##### change

[`WeatherChange`](#weatherchange)

#### Returns

\{ `veto`: `true`; \} \| \{ `change`: [`WeatherChange`](#weatherchange); `veto`: `false`; \}

***

### WeatherListener

> **WeatherListener** = (`change`) => `void`

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

Hears every weather change that took effect, whatever made it: a command, a script or the cycle.

#### Parameters

##### change

###### current

[`Weather`](https://jsprismarine.dev/api/@jsprismarine/prismarine/content/world/adapter/index.md#weather-1)

###### previous

[`Weather`](https://jsprismarine.dev/api/@jsprismarine/prismarine/content/world/adapter/index.md#weather-1)

#### Returns

`void`

## Functions

### savedWeatherOf()

> **savedWeatherOf**(`value`): [`WeatherState`](https://jsprismarine.dev/api/@jsprismarine/engine-systems/index.md#weatherstate) \| `undefined`

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

Whether a value read from world storage is a weather record this can use.

#### Parameters

##### value

`unknown`

#### Returns

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