QtCraft API C++ classes QML types Handbook

QcVillagePopulation Class

The villagers of the villages among the creatures (decisions E-411, E-415, E-422): one moves in beside each free bed when a chunk of its village is seen for the first time, the claims of a village are reconciled once per run when all its villagers' chunks are loaded, every villageLifeTicks ticks villagers move between villages (QcVillagerRelocation, decision E-490), get children (QcVillagerBreeding) and summon iron golems (QcVillageGolems, decision E-470), and a villager that leaves the world for good (QcMobManager::Departure: died, removed, despawned, void) frees its claims. More...

Header: #include <server/villages/QcVillagePopulation.h>

Public Types

NextId

Public Functions

QcVillagePopulation(QcMobManager &mobs, std::shared_ptr<const QcContentRegistry> content, quint64 seed)
bool claimsReconciled(qint64 village) const
const QcVillageGolems &golems() const
void noteChunk(QcServerWorld &world, QcChunkPos pos)
void setGolemLimit(qint64 golems)
void setVillagerLimits(QcVillagerHomes::Limits homes, QcVillagerBehaviour::Limits behaviour)
void setVillages(QcVillages *villages)
void settle(QcServerWorld &world, QcChunkPos pos, const QcVillagePopulation::NextId &nextEntityId, bool onlyAlwaysLivedIn)
void tick(QcServerWorld &world, double worldTime, const QcVillagePopulation::NextId &nextEntityId)

Static Public Members

const int villageLifeTicks

Detailed Description

Part of QcMobManager, which owns the creatures and tells it when one leaves.

Member Type Documentation

[alias] QcVillagePopulation::NextId

Gives the entity id of the next creature.

Member Function Documentation

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

mobs owns the villagers and outlives this; the population listens to its departures. Kinds from content, villagers' looks from the world seed.

bool QcVillagePopulation::claimsReconciled(qint64 village) const

Returns whether the claims of village were reconciled in this run (checkVillageClaims).

const QcVillageGolems &QcVillagePopulation::golems() const

Returns the iron golems the villagers summon.

void QcVillagePopulation::noteChunk(QcServerWorld &world, QcChunkPos pos)

The chunk at pos of world of a village arrived: the claims of the villages whose holders are all loaded now are reconciled (checkVillageClaims).

void QcVillagePopulation::setGolemLimit(qint64 golems)

At most golems iron golems in the world (QcServerLimits villageGolems; 0: villagers summon none).

void QcVillagePopulation::setVillagerLimits(QcVillagerHomes::Limits homes, QcVillagerBehaviour::Limits behaviour)

Sets how many villagers may live (homes) and their budgets per tick (behaviour).

void QcVillagePopulation::setVillages(QcVillages *villages)

Sets the village state villagers claim beds and workstations in (a villager that leaves frees its claims there) to villages.

void QcVillagePopulation::settle(QcServerWorld &world, QcChunkPos pos, const QcVillagePopulation::NextId &nextEntityId, bool onlyAlwaysLivedIn)

Spawns, with ids from nextEntityId, a villager for every free bed of a village of world whose head lies in the chunk at pos, within the limits, then the neighbours waiting for this chunk; with onlyAlwaysLivedIn only in a village that is always lived in (QcVillagePlan::alwaysLivedIn).

void QcVillagePopulation::tick(QcServerWorld &world, double worldTime, const QcVillagePopulation::NextId &nextEntityId)

Counts down to the next village life (children and golems) in world at worldTime, new creatures with ids from nextEntityId.

Member Variable Documentation

const int QcVillagePopulation::villageLifeTicks

Village life runs every this many ticks.