QtCraft API C++ classes QML types Handbook

QcMobDefinition Struct

Data definition of a creature: stats, behaviour, spawning, model and drops. More...

Header: #include <common/content/mobs/QcMobDefinition.h>

Public Types

struct SpawnRule
enum class Ai { Passive, Hostile, Villager, Archer, Neutral, …, Guardian }
enum class SpawnTime { Any, Day, Night }

Public Functions

bool isMonster() const
QList<QcMobDefinition::SpawnRule> spawnRules() const
bool spawnsNaturally() const

Public Variables

QcMobAbilities abilities
QcMobDefinition::Ai ai
bool ambient
QString ambientSound
std::optional<QcAquaticDefinition> aquatic
QcArcherDefinition archer
bool armsForward
double attackCooldown
double attackDamage
double attackRange
QList<QcStatusEffect> blowEffects
bool breathesUnderWater
QcBreedingDefinition breeding
bool burnsInDaylight
QString cape
std::optional<QcCarryDefinition> carries
QString catchItem
QString catchSound
QString catchWith
double chaseSpeed
std::optional<QcCrumbleDefinition> crumbles
QString deathSound
QString descriptionKey
std::optional<QcDrinkHealDefinition> drinks
QList<QcItemDrop> drops
QcExperienceDrop experience
QList<QcMobDefinition::SpawnRule> extraSpawns
std::optional<QcFamilyDefinition> family
bool flying
bool frightens
std::optional<QcGazeDefinition> gaze
int glow
QcGolemDefinition golem
double guardLeash
double height
QString heldItem
QcItemId heldItemId
bool hidesInBlocks
bool hostile
std::optional<QcHoverDefinition> hover
QString hurtSound
QStringList immuneTo
QString ink
QcLayingDefinition laying
double leapSpeed
int maxCount
double maxFallSpeed
int maxGroup
double maxHealth
int maxSpawnLight
QString milkItem
QString milkSound
QString milkWith
QString name
bool neutralByDay
QString outfit
double packRange
QList<QcMobPart> parts
std::optional<QcPulseDefinition> pulse
bool scaredOfCats
std::optional<QcShyDefinition> shy
double sightRange
QString skeleton
QStringList spawnBiomes
QList<QString> spawnBlocks
double spawnChunkChance
bool spawnInDarkness
bool spawnInWater
int spawnMaxY
QcMobDefinition::SpawnTime spawnTime
bool spawnUnderSky
double spawnWeight
bool spawnsInCaves
std::optional<QcTameDefinition> tameable
std::optional<QcTeleportDefinition> teleport
QString translationKey
bool villager
QString villagerSettings
int villagerSettingsIndex
double walkSpeed
double waterDamage
double width

Static Public Members

const int maxExtraSpawns
const int maxGlow

Detailed Description

Member Type Documentation

enum class QcMobDefinition::Ai

What decides what it does (decision E-423): QcMobBehaviour keeps one brain of each kind.

Hostile ones chase players (only with hostile), passive ones wander and flee, villagers live by their villager settings (only with villager), archers keep their distance and shoot (only with hostile and archer, decision E-426), neutral ones wander like passive ones until a player provokes them (hurts them, or looks at their head with gaze) and then chase that player (decision E-460), golems guard villagers against hostile creatures (only without hostile, with golem, decision E-471), guardians keep to the zone they guard and chase only players who come within guardLeash of it (only with hostile, decision E-594). Server side only.

ConstantValueDescription
QcMobDefinition::Ai::Passive0wanders and flees
QcMobDefinition::Ai::Hostile1chases players
QcMobDefinition::Ai::Villager2lives by its villager settings
QcMobDefinition::Ai::Archer3keeps its distance and shoots
QcMobDefinition::Ai::Neutral4passive until a player provokes it
QcMobDefinition::Ai::Golem5guards villagers
QcMobDefinition::Ai::Guardian6guards a zone

enum class QcMobDefinition::SpawnTime

Time of day a spawn rule allows ("time": any, day or night).

ConstantValueDescription
QcMobDefinition::SpawnTime::Any0day and night
QcMobDefinition::SpawnTime::Day1only by day
QcMobDefinition::SpawnTime::Night2only at night

Member Function Documentation

bool QcMobDefinition::isMonster() const

Returns whether creatures of the kind spawn as monsters (decision E-836): hostile ones that walk, hover or fly, not water or ambient creatures.

QList<QcMobDefinition::SpawnRule> QcMobDefinition::spawnRules() const

Returns the main rule followed by the extra ones.

bool QcMobDefinition::spawnsNaturally() const

Returns whether any rule lets it spawn by itself; with all weights 0 it only comes from /summon and world setups (the showcase's mannequin).

Member Variable Documentation

QcMobAbilities QcMobDefinition::abilities

How it finds its way ("abilities"); the villager AI starts from opening doors and climbing ladders.

QcMobDefinition::Ai QcMobDefinition::ai

Its AI ("ai"); without the key: Villager for villagers, Hostile for hostile creatures, else Passive.

bool QcMobDefinition::ambient

Ambient creatures (fireflies) have their own spawn cap and never count as passive or hostile.

std::optional<QcAquaticDefinition> QcMobDefinition::aquatic

Lives in water and schools (fish, decision E-502).

QcArcherDefinition QcMobDefinition::archer

How an archer shoots (Ai::Archer).

bool QcMobDefinition::armsForward

Skeleton mobs that walk with their arms stretched forward (zombies).

double QcMobDefinition::attackCooldown

Seconds between two of its blows ("attackCooldown", 0.1..60).

double QcMobDefinition::attackDamage

Damage of one of its blows ("attackDamage", 0..100).

double QcMobDefinition::attackRange

Horizontal distance in metres from which it strikes its target ("attackRange", 0.5..8).

QList<QcStatusEffect> QcMobDefinition::blowEffects

Effects its blows give the player struck (a cave spider's poison), with their ticks. Server side only.

bool QcMobDefinition::breathesUnderWater

Needs no air under water and never drowns ("breathesUnderWater", decision E-955; by default the creatures that swim, dive or live in water). Server side only.

QcBreedingDefinition QcMobDefinition::breeding

Feeding and young ones (decision E-293); only breeding.food reaches the client.

bool QcMobDefinition::burnsInDaylight

Catches fire in direct sunlight (decision E-426): by day, with the open sky above its head, neither in water nor in the rain. Server side only.

QString QcMobDefinition::cape

Skeleton mobs only: a cape on the back (an appearance of kind cape); empty for none.

std::optional<QcCarryDefinition> QcMobDefinition::carries

Takes and places single blocks (decision E-460).

double QcMobDefinition::chaseSpeed

Movement speed in m/s while chasing ("chaseSpeed", twice walkSpeed unless set).

std::optional<QcCrumbleDefinition> QcMobDefinition::crumbles

Crumbles into blocks at a liquid's source (decision E-593).

QString QcMobDefinition::descriptionKey

Translation key of the handbook's text about it ("<translation>.description" unless set); a missing text leaves only the facts. Server side only.

std::optional<QcDrinkHealDefinition> QcMobDefinition::drinks

Drinks to heal itself (the witch, decision E-623).

QList<QcItemDrop> QcMobDefinition::drops

Items it drops when killed ("drops": item, count 1..64, chance 0..1).

QcExperienceDrop QcMobDefinition::experience

Experience points a creature killed by a player gives as orbs (decision E-398). Server side only.

QList<QcMobDefinition::SpawnRule> QcMobDefinition::extraSpawns

Extra spawn rules ("spawn": {"also": [...]}), at most maxExtraSpawns.

std::optional<QcFamilyDefinition> QcMobDefinition::family

Splits off children when hurt and takes them with it when it dies (the Kjut, decision E-839).

bool QcMobDefinition::flying

Flies (no gravity) and drifts a little above the ground.

std::optional<QcGazeDefinition> QcMobDefinition::gaze

Provoked by a player's look at its head (Ai::Neutral, decision E-460).

int QcMobDefinition::glow

Drawn at least this bright (0..15): glowing creatures. It lights nothing around them.

QcGolemDefinition QcMobDefinition::golem

How a golem fights, is repaired and built (Ai::Golem).

double QcMobDefinition::guardLeash

A guardian (Ai::Guardian) chases players up to this many blocks outside the zone it guards ("guardian": {"leash": 6}, decision E-594). Server side only.

double QcMobDefinition::height

Height of its body box in metres ("height", 0.2..4).

QString QcMobDefinition::heldItem

Item it holds in its right hand (an archer's bow), shown on the client with the entity's held item; empty for none. Server side only.

QcItemId QcMobDefinition::heldItemId

The id of heldItem, resolved when the content is finished (QcContentRegistry::finish).

bool QcMobDefinition::hidesInBlocks

Hides in blocks (silverfish, decision E-453): an idle one turns a block next to it into the infested block of its kind and is gone; one that is hurt wakes its kind in the infested blocks around it (QcInfestation). Server side only.

bool QcMobDefinition::hostile

Hostile to players ("hostile"): the default AI is then Ai::Hostile, and the hostile, archer and guardian AIs require it.

std::optional<QcHoverDefinition> QcMobDefinition::hover

Hovers above the ground instead of walking (the Kjut, decision E-839).

QStringList QcMobDefinition::immuneTo

Kinds of status effects that do nothing to it (spiders and the undead: poison; decision E-450). Server side only.

QString QcMobDefinition::ink

Texture of the cloud of ink it leaves where a blow strikes it ("aquatic": {"ink": ...}, decision E-974); empty for none. Reaches the client.

QcLayingDefinition QcMobDefinition::laying

Laying eggs (decision E-452). Server side only.

double QcMobDefinition::leapSpeed

Leaps at its target from QcMobSteering::leapMin to leapMax metres with this horizontal speed in m/s (spiders); 0 for never. Server side only.

int QcMobDefinition::maxCount

Most creatures of this kind near one player; 0 for no limit beyond the category's cap.

const int QcMobDefinition::maxExtraSpawns

Most extra spawn rules a creature may have.

double QcMobDefinition::maxFallSpeed

Falls no faster than this, in m/s, at least one tick of gravity (a chicken flapping its wings); 0 for no limit. Server side only.

const int QcMobDefinition::maxGlow

Highest value of glow.

double QcMobDefinition::maxHealth

Full health ("health", 1..1000).

int QcMobDefinition::maxSpawnLight

Brightest block light (torches) at the feet that still allows spawning, 0..15 (hostile creatures: 0 unless the data says otherwise).

QString QcMobDefinition::name

Content name of the creature ("name", qualified with the pack's namespace).

bool QcMobDefinition::neutralByDay

A hostile creature that leaves players alone by day unless one hurt it (spiders, decision E-451). Server side only.

double QcMobDefinition::packRange

A neutral creature struck by a player angers the creatures of its kind within this many metres at that player (a wolf pack, decision E-480); 0 for none. Server side only.

std::optional<QcPulseDefinition> QcMobDefinition::pulse

Swims in pulses (the squid, decision E-974; "aquatic": {"pulse": ...}); none for a steady swimmer. Reaches the client.

std::optional<QcShyDefinition> QcMobDefinition::shy

It flees from players who come close (decision E-480).

double QcMobDefinition::sightRange

Distance in metres within which it notices players ("sightRange", 1..64).

QStringList QcMobDefinition::spawnBiomes

Biomes it spawns in; empty for all.

double QcMobDefinition::spawnChunkChance

Share of chunks (chosen by the world seed, separately for each kind) where it spawns at all, like slime chunks; 1 for every chunk. Server side only.

bool QcMobDefinition::spawnInDarkness

The monsters' light test of the original game (QcSpawnLight, decision E-836): a random draw against the sky light and the darkened sky; on by default for hostile creatures.

bool QcMobDefinition::spawnInWater

In water instead of on dry ground: its feet in water above a solid block (drowned; decision E-838). Server side only.

int QcMobDefinition::spawnMaxY

Highest block its feet may stand in when spawning. Server side only.

bool QcMobDefinition::spawnUnderSky

Only where its feet see the open sky (sky light 15: husks, strays; decision E-838).

bool QcMobDefinition::spawnsInCaves

Hostile mobs that need darkness also spawn underground at any time of day.

std::optional<QcTameDefinition> QcMobDefinition::tameable

Players tame it (decision E-480).

std::optional<QcTeleportDefinition> QcMobDefinition::teleport

Teleports away (decision E-460).

QString QcMobDefinition::translationKey

Translation key of its name ("translation", else derived from the name).

bool QcMobDefinition::villager

A villager (decision E-411): lives in a village with a bed and a workstation, follows the routine of its villager settings and opens doors; it is drawn in the look the server sends with it (QcMsg::EntitySpawn::appearance) rather than in outfit.

QString QcMobDefinition::villagerSettings

The villager settings it lives by (villagers/<name>.json, decision E-421); set exactly when villager is. Server side only.

int QcMobDefinition::villagerSettingsIndex

The index of those settings in QcVillageCatalog::villagerSpecies (QcContentRegistry::finish), -1 before.

double QcMobDefinition::walkSpeed

Movement speed in m/s while wandering; chasing uses chaseSpeed.

double QcMobDefinition::waterDamage

Damage it takes every QcBodyBurning::wetIntervalTicks in water or rain (decision E-460); 0 for none. Server side only.

double QcMobDefinition::width

Width of its body box in metres ("width", 0.2..4).