QtCraft API C++ classes QML types Handbook

QcChunkSpawns Class

The creatures of a chunk seen for the first time: its group of persistent animals (decision E-086) and the creatures of the village pieces in it (decision E-404); and the seed's sets of chunks of the kinds that spawn only in some (slime chunks). More...

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

Public Types

NextId

Public Functions

QcChunkSpawns(QcMobManager &mobs, std::shared_ptr<const QcContentRegistry> content, quint64 seed)
void spawnChunkAnimals(const QcServerWorld &world, QcChunkPos pos, const QcChunk &chunk, const QcChunkSpawns::NextId &nextEntityId)
void spawnVillageMobs(const QcServerWorld &world, QcChunkPos pos, const QcChunkSpawns::NextId &nextEntityId)
bool spawnsInChunk(QcCreatureKindId type, QcChunkPos pos, double chance, int rule) const

Static Public Members

const double chunkAnimalChance
const std::array<std::pair<int, int>, 4> groupOffsets
bool isAnimal(const QcMobDefinition &definition)

Detailed Description

Part of QcNaturalSpawner; everything it draws comes from the seed and the chunk's position, so a chunk gets the same animals in every start of the world.

Member Type Documentation

[alias] QcChunkSpawns::NextId

Gives the entity id of the next creature.

Member Function Documentation

QcChunkSpawns::QcChunkSpawns(QcMobManager &mobs, std::shared_ptr<const QcContentRegistry> content, quint64 seed)

mobs owns the creatures this adds and outlives it; kinds from content, chances decided by the world seed.

[static] bool QcChunkSpawns::isAnimal(const QcMobDefinition &definition)

Returns whether creatures of definition are animals: peaceful walkers that are kept with the world, not flying, ambient or water creatures, not villagers or golems (they belong to villages, decisions E-411, E-470).

void QcChunkSpawns::spawnChunkAnimals(const QcServerWorld &world, QcChunkPos pos, const QcChunk &chunk, const QcChunkSpawns::NextId &nextEntityId)

Spawns the group of animals of chunk at pos in world (chunkAnimalChance, decided by the seed) on the highest fitting ground of a random column, with ids from nextEntityId.

void QcChunkSpawns::spawnVillageMobs(const QcServerWorld &world, QcChunkPos pos, const QcChunkSpawns::NextId &nextEntityId)

Spawns the persistent creatures of the village plan of world whose spot lies in the chunk at pos, with ids from nextEntityId.

bool QcChunkSpawns::spawnsInChunk(QcCreatureKindId type, QcChunkPos pos, double chance, int rule) const

Returns whether the seed lets the kind type with the chunk chance chance below 1 spawn in the chunk at pos; rule is the index of its spawn rule (0: main rule), each rule has its own set of chunks.

Member Variable Documentation

const double QcChunkSpawns::chunkAnimalChance

Share of newly generated chunks that get a group of animals.

const std::array<std::pair<int, int>, 4> QcChunkSpawns::groupOffsets

A group stands on these neighbouring columns.