QtCraft API C++ classes QML types Handbook

QcCreature Struct

A creature (decision E-364): a mob of the content's definitions (type indexes them) with its health, behaviour timers and breeding state. More...

Header: #include <server/entities/QcCreature.h>
Inherits: QcEntity

Public Functions

bool isTame() const
bool isVillager() const
bool isYoung() const
bool mayGrief(bool rule) const
bool sits() const

Public Variables

QcAirSupply air
double angerTimer
QcComponent<QcArcherState> archer
double attackCooldown
bool attackedThisTick
bool blockedLastTick
bool bred
double breedCooldown
bool calm
QcBlockId carried
QcItemId carriedItem
quint32 chasing
int climbTicks
bool confined
int dryTicks
QcComponent<QcStatusEffects> effects
double fleeTimer
QcComponent<QcGolemState> golem
double growUp
std::optional<QcGuardPost> guards
double health
QcHurtWindow hurt
bool hurtThisTick
bool hurtUnsent
int idleTicks
bool keptForBlock
double lastSpeed
double layTimer
double love
QString name
bool nightRule
bool noAi
quint32 parent
std::optional<QcChunkPos> parentChunk
quint64 parentUid
QcMobPath path
bool persistent
QcPose pose
quint32 provokedBy
double pulseClock
std::optional<QcBlockPos> spawner
int splits
quint32 struckBy
bool struckUnsent
bool summoned
QcComponent<QcTameState> tame
double targetMemory
int teleportCooldown
std::optional<QcVec3> teleportedFrom
float tilt
QcCreatureKindId type
quint64 uid
bool underground
quint32 vehicle
QcComponent<QcVillager> villager
QcVec3 wanderDirection
double wanderTimer
bool woundedThisTick

Static Public Members

const QcEntityKind entityKind

Detailed Description

QcMobManager moves and spawns them.

Member Function Documentation

bool QcCreature::isTame() const

Returns whether a player tamed it (it has an owner).

bool QcCreature::isVillager() const

Returns whether it is a villager: it has the villager component (QcMobManager::spawn and restore give it to every creature of a villager kind).

bool QcCreature::isYoung() const

Returns whether it is young (still growing up).

bool QcCreature::mayGrief(bool rule) const

Returns whether it may change the world under the game rule mobGriefing rule (decision E-510): the one check of every griefing path (a shadewalker taking and placing blocks, a silverfish hiding in a block and breaking blocks when it wakes its kind, a farmer harvesting, a villager picking up food). A confined creature and one without a mind change nothing.

bool QcCreature::sits() const

Returns whether it sits for its owner.

Member Variable Documentation

QcAirSupply QcCreature::air

Air under water (QcDrowning, decision E-955); not saved, a creature loaded again has a full breath.

QcComponent<QcArcherState> QcCreature::archer

The draw and aim of an archer (QcMobDefinition::Ai::Archer, decision E-426): a component only creatures with the archer AI have.

double QcCreature::attackCooldown

Seconds until it may attack again.

bool QcCreature::attackedThisTick

Struck at a player this tick (animation).

bool QcCreature::blockedLastTick

A wall stopped its steering in the last tick.

bool QcCreature::bred

Born from breeding (counted against QcMobBreeding::maxBredPerKind).

bool QcCreature::calm

A creature neutral by day (QcMobDefinition::neutralByDay, decision E-451) leaves players alone in this tick (set by QcMobBehaviour before it thinks; not while a player it was struck by makes it angry, provokedBy and angerTimer). Not saved.

int QcCreature::climbTicks

Game ticks a hovering creature (QcMobDefinition::hover) still rises after a wall stopped it (QcMobHover); not saved.

bool QcCreature::confined

Stays where a structure put it (QcStructureDefinition::Mob::confined, decision E-460): it neither teleports nor changes the world (mayGrief, decision E-510). Saved with it.

int QcCreature::dryTicks

Ticks a water creature (QcMobDefinition::aquatic, decision E-502) has been out of water; it suffocates after QcAquaticDefinition::airSeconds (QcBodyBurning). Not saved: a loaded fish on land has its full air again.

QcComponent<QcStatusEffects> QcCreature::effects

Status effects (decision E-450): a component only creatures that have any carry (QcServerEffects gives and drops it); saved with persistent creatures.

const QcEntityKind QcCreature::entityKind

The kind of every entity of this type (QcEntity::as).

double QcCreature::fleeTimer

Seconds it still flees.

QcComponent<QcGolemState> QcCreature::golem

Whether a player built it, its prey and its anger (QcMobDefinition::Ai::Golem, decision E-471): a component only creatures with the golem AI have.

std::optional<QcGuardPost> QcCreature::guards

The zone it guards (decision E-594; a sand golem in its temple's cellar): it came there by the zone's rule (QcGuardians, decision E-591), counts against the zone's max and QcServerLimits::guardians, not against the natural caps. Not saved (guardians are not persistent).

double QcCreature::health

Health points left.

QcHurtWindow QcCreature::hurt

The short invulnerability after a hurt (game rule mobInvulnerabilityTicks, decision E-429).

bool QcCreature::hurtThisTick

Hurt this tick by a fresh hit (QcHurtWindow::Take::Fresh; hurt animation).

bool QcCreature::hurtUnsent

Hurt by a fresh hit the clients were not told of yet (EntityMove::hurt); unlike hurtThisTick it lives until the next world sync (decision E-971).

int QcCreature::idleTicks

Ticks since a player was last within QcMobUpkeep::idleDistance or a blow struck it (decision E-836); beyond QcMobUpkeep::idleTicks a creature that is not kept may vanish by chance.

bool QcCreature::keptForBlock

Kept with the world only for the block it carries (QcCreatureTraits made it persistent when it took the block): it is let go again when it puts the block down. A creature that was kept before keeps that. Saved with it.

double QcCreature::lastSpeed

The speed it decided on when it last thought: a throttled creature in a crowd coasts along its path at it between its thoughts (decisions E-401, E-402).

double QcCreature::layTimer

Seconds until it lays next (QcMobDefinition::laying, decision E-452); below 0 until QcMobLaying first chooses a time. Saved with persistent creatures while it runs (QcEntityCodec::Component::Laying).

QString QcCreature::name

The name a name tag gave it (decision E-866); empty for none.

bool QcCreature::nightRule

Spawned by a rule for the night only: leaves by day like night creatures.

bool QcCreature::noAi

Without a mind, like the reference game's NoAI (decision E-510): it neither thinks nor steers, walks, jumps, swims, attacks, teleports nor changes the world, but it still falls, is pushed and knocked back and takes damage. Set by structure data ("noAi": true), /summon … noai and /mob … noai; saved with it (QcEntityCodec::Component::NoAi).

std::optional<QcChunkPos> QcCreature::parentChunk

The chunk the parent of a kept family was in when the child last saw it (QcMobFamilies keeps it in step; saved with the child): a child waiting for its parent is released once that chunk is loaded without the parent (it died while the child was unloaded). Unset when unknown.

QcMobPath QcCreature::path

Its goal and the path there (decision E-400); not saved, a loaded creature finds a new one.

bool QcCreature::persistent

Never despawns and is saved with the world (peaceful animals, named creatures).

QcPose QcCreature::pose

How it holds itself (decision E-423): a villager lies in its bed, where the physics leaves it (decision E-411). Its box (QcEntities::boxOf), its eyes and its animation follow from it; not saved, a loaded creature stands.

std::optional<QcBlockPos> QcCreature::spawner

The monster spawner it came from (decision E-520): counted against that spawner's maxNearby and QcServerLimits::spawnerCreatures, not against the natural caps. Not saved (spawned creatures are not persistent).

int QcCreature::splits

Children a parent of a family split off in its life (QcFamilyDefinition::maxSplits); not saved.

quint32 QcCreature::struckBy

The player whose blow or shot hurt it last (QcMobManager::damage; 0: none, or damage without a player such as lightning, fire or water): a neutral creature turns on that player when it next thinks, a creature neutral by day before it thinks (QcMobSteering::provoke); both clear it (other brains leave it). Not saved.

bool QcCreature::struckUnsent

Struck by a fresh blow (an attack, a projectile, an explosion, not burning or drowning) the clients were not told of yet (EntityMove::struck, decision E-974).

bool QcCreature::summoned

Came by /summon (counted against QcServerLimits::summonLimit); not saved.

QcComponent<QcTameState> QcCreature::tame

Owner, sitting and collar of a creature of a tameable kind (QcMobDefinition::tameable, decision E-480): a component only tamed creatures have. Saved with it.

int QcCreature::teleportCooldown

Game ticks until it may teleport again (QcTeleportDefinition::cooldownSeconds); not saved.

std::optional<QcVec3> QcCreature::teleportedFrom

Where it teleported from since the creatures' last tick: QcCreatureTraits plays the sounds and shows the clients the new place at once (not slid there); not saved.

QcCreatureKindId QcCreature::type

Index of its definition among the content's mobs.

quint64 QcCreature::uid

The persistent id of a creature that is saved (decision E-420; 0 for the others): unique in its world and kept across saving, loading and unloading, unlike the entity id (QcEntity::id), which only holds while the world is open. Villages claim beds and workstations under it; other saved data refers to a creature by it (QcMobManager::nextUid gives them out).

bool QcCreature::underground

Spawned on a cave floor: night creatures there stay in daylight.

quint32 QcCreature::vehicle

The boat it sits in (decision E-920; entity id, 0 for none): it neither thinks nor moves, the boat puts it on its seat every tick. Not saved: a creature saved on its seat gets in again.

QcComponent<QcVillager> QcCreature::villager

Home, work and routine of a villager (QcMobDefinition::villager, decision E-411): a component only creatures of a villager kind have (decision E-423).

QcVec3 QcCreature::wanderDirection

The direction it wanders or flees in; zero while it stands.

double QcCreature::wanderTimer

Seconds it goes on with its wandering (walking or standing) before it chooses anew.

bool QcCreature::woundedThisTick

Hurt this tick by a fresh hit that took health (a fresh hit without damage only sets hurtThisTick, a stronger hit during the invulnerability neither); families split on it (decision E-839).