QtCraft API C++ classes QML types Handbook

QcSpawnLight Namespace

The light test of monsters (decision E-836), as in the original game: a cell is dark enough when its sky light passes a random draw of 0..31, its block light (torches) is at most the rule's maxLight (0 for monsters) and its brightness, the larger of block light and the sky light less the darkening of the sky by time and weather, is at most a random threshold of 0..7. More...

Header: #include <server/spawning/QcSpawnLight.h>

Classes

struct Cell
struct Draws

Variables

const int maxThreshold
const int nightDarkening
const int skyChance
const int thunderDarkening
const float thunderStrength

Functions

bool darkEnough(QcSpawnLight::Cell cell, QcSpawnLight::Draws draws)
QcSpawnLight::Draws draw(QRandomGenerator &random)
int skyDarkening(double worldTime, float rain, float thunder)

Detailed Description

Day or night is no condition of its own: by day the open sky is far too bright, while caves, the shade of thick roofs and dense forests stay dark enough; at night the dimmed sky lets most open ground pass, the more often the darker it is. Spawn rules with "darkness": false (slime chunks) skip the test.

Classes

class Cell

The sky light, block light and darkening of a cell, and the brightest block light allowed. More...

class Draws

The random draws of one test: the sky's draw (0..skyChance - 1) and the threshold (0..maxThreshold). More...

Variable Documentation

const int QcSpawnLight::maxThreshold

The threshold the brightness is compared with lies in 0..maxThreshold.

const int QcSpawnLight::nightDarkening

Levels the sky light loses at night (midnight in clear weather).

const int QcSpawnLight::skyChance

The sky light must not exceed a draw of 0..skyChance - 1.

const int QcSpawnLight::thunderDarkening

Levels it loses during a thunderstorm, by day and by night.

const float QcSpawnLight::thunderStrength

A thunderstorm darkens the sky by thunderDarkening from this strength on.

Function Documentation

bool QcSpawnLight::darkEnough(QcSpawnLight::Cell cell, QcSpawnLight::Draws draws)

Returns whether cell is dark enough for a monster with draws.

QcSpawnLight::Draws QcSpawnLight::draw(QRandomGenerator &random)

Returns the draws of one test from random.

int QcSpawnLight::skyDarkening(double worldTime, float rain, float thunder)

Returns the levels the sky light loses at worldTime with rain and thunder of strengths 0..1: 0 at noon in clear weather, nightDarkening at midnight, rain dims the day a little, a storm as far as thunderDarkening.