QtCraft API C++ classes QML types Handbook

QcServerWeather Class

The weather in the server tick (decision E-395). More...

Header: #include <server/weather/QcServerWeather.h>

Public Types

StrikeHook

Public Functions

QcWeather::Climate climateAt(int x, int z) const
int columnTop(int x, int z) const
bool isRainingAt(QcBlockPos pos) const
bool isSnowingAt(QcBlockPos pos) const
int meanStrikeTicks() const
bool openToSky(QcBlockPos pos) const
QcPrecipitation precipitationAt(QcBlockPos pos) const
void sendTo(QcServerClient &client)
void set(QcWeatherKind kind, std::optional<qint64> ticks)
void setStrikeHook(QcServerWeather::StrikeHook hook)
const QcWeatherState &state() const
void strike(QcBlockPos pos)
quint64 strikes() const
void tick()

Static Public Members

const float rainThreshold
const float sendStep
const double strikeHearing
const int strikeReach
const float thunderThreshold

Detailed Description

The world's spell runs its course by the seed (QcWeatherCycle, game rule weatherCycle), its strengths fade in and out, and every player gets the weather where it stands (QcMsg::Weather) when it joins and whenever that changes. Where rain or snow falls follows from the column's biome (QcWeather::climateOf) and whether the sky is open above the position (nothing above it that stops precipitation, QcPrecipitationTable).

During a thunderstorm lightning strikes near the players now and then (the top of a column in the rain); every player within hearing range gets a QcMsg::Lightning, and the strike hook does what a strike does to the world.

Member Type Documentation

[alias] QcServerWeather::StrikeHook

What a strike does to the world at pos (the cell above the column's top); unset, nothing.

Member Function Documentation

QcWeather::Climate QcServerWeather::climateAt(int x, int z) const

Returns the climate of the column (x, z) from its biome.

int QcServerWeather::columnTop(int x, int z) const

Returns the highest cell of the column (x, z) that keeps rain and snow out; QcWorld::worldHeight for a column that is not loaded.

bool QcServerWeather::isRainingAt(QcBlockPos pos) const

Returns whether rain falls on pos now (precipitationAt()).

bool QcServerWeather::isSnowingAt(QcBlockPos pos) const

Returns whether snow falls on pos now (precipitationAt()).

int QcServerWeather::meanStrikeTicks() const

Returns the mean time between strikes: on average one strike per player every this many ticks of a thunderstorm (lightning meanSeconds of the content's weather, decision E-396).

bool QcServerWeather::openToSky(QcBlockPos pos) const

Returns whether nothing stops rain coming straight down above pos (a loaded column whose top lies below it).

QcPrecipitation QcServerWeather::precipitationAt(QcBlockPos pos) const

Returns what falls on pos now: nothing while it does not rain (strength below rainThreshold), in a dry biome or under a roof; otherwise rain or snow by the climate and the height.

void QcServerWeather::sendTo(QcServerClient &client)

Sends client the weather where its player stands, now (joining).

void QcServerWeather::set(QcWeatherKind kind, std::optional<qint64> ticks)

Begins a spell of kind lasting ticks or as long as the seed says (/weather).

void QcServerWeather::setStrikeHook(QcServerWeather::StrikeHook hook)

Sets hook as what a strike does to the world.

const QcWeatherState &QcServerWeather::state() const

Returns the world's weather (spell, ticks left, strengths).

void QcServerWeather::strike(QcBlockPos pos)

Lightning strikes the column top pos: the players within strikeHearing are told, then the strike hook runs.

quint64 QcServerWeather::strikes() const

Returns the strikes since the server started (tests, measurements).

void QcServerWeather::tick()

One tick of a simulated world: the course, strikes and what the players are sent.

Member Variable Documentation

const float QcServerWeather::rainThreshold

Rain counts from this strength on (precipitationAt); below it the first drops only darken the sky.

const float QcServerWeather::sendStep

A sent strength is sent again when it changed by this much (or reached 0 or 1).

const double QcServerWeather::strikeHearing

Players within this many blocks (horizontally) of a strike see and hear it.

const int QcServerWeather::strikeReach

Strikes fall within this many blocks of the player (each axis).

const float QcServerWeather::thunderThreshold

Lightning strikes while the thunder's strength is at least this.