QtCraft API C++ classes QML types Handbook

QcEntityCodec Namespace

The entities of one chunk as a blob of its region file (entities/r.<x>.<z>.qen; decisions E-366, E-373, E-420): persistent creatures, dropped items and waiting drops, falling blocks and lit explosives, armour stands, minecarts (E-382), experience orbs (E-398), projectiles (E-425), and whether the chunk already got its animals, then item frames and paintings (E-793) and boats (E-920). More...

Header: #include <server/storage/QcEntityCodec.h>

Types

enum class Component { Creature, Villager, Item, FallingBlock, ArmourStand, …, Boat }

Variables

const quint16 kindVersion
const quint32 maxPerChunk
const qsizetype maxTypeName

Functions

QcResult<QcEntityRecord> decode(const QByteArray &blob, QcChunkPos chunk, const QcContentRegistry &content, QcLoadWarnings &warnings)
QByteArray encode(const QcEntityRecord &record, const QcContentRegistry &content)

Detailed Description

Items, blocks, creatures, armour and capes are stored by name.

Every entry is a header (type name, position, velocity, yaw, order, persistent id) and a list of components (QcComponentFrames): the fields of its kind and, for a villager, its record. A new field is a new version of its component or a new component, not a new world format.

Type Documentation

enum class QcEntityCodec::Component

The ids of the components of entity entries; a later version adds ids below QcComponentFrames::firstModId, a mod from it on; none is ever reused.

ConstantValueDescription
QcEntityCodec::Component::Creature1Health, breeding timers, bred (version 1).
QcEntityCodec::Component::Villager2QcVillagerRecord (QcVillagerCodec::version).
QcEntityCodec::Component::Item3Count, damage, age, pickup delay of a dropped stack (version 1).
QcEntityCodec::Component::FallingBlock4Age of a falling block (version 1).
QcEntityCodec::Component::ArmourStand5Pose, name, item, held item, armour, cape of an armour stand (version 1).
QcEntityCodec::Component::Minecart6Item, slots and whether a hopper cart pulls (version 1).
QcEntityCodec::Component::ExperienceOrb7Value, age, pickup delay of an experience orb (version 1).
QcEntityCodec::Component::Projectile8Pitch, age, pickup, damage factor and where it sticks of a projectile (version 1).
QcEntityCodec::Component::Effects9Status effects of a creature: count, then name, level and ticks left of each (version 1, decision E-450).
QcEntityCodec::Component::Carried10The block state a creature carries, by name, and whether it is kept with the world only for that block (version 1; decision E-460).
QcEntityCodec::Component::Confined11A creature that stays in its enclosure (version 1, no fields; decision E-460).
QcEntityCodec::Component::Golem12Whether a player built the golem (version 1, decision E-471).
QcEntityCodec::Component::Laying13Seconds until a laying creature lays next (version 1, decision E-452); only while its timer runs.
QcEntityCodec::Component::Tame14Owner identity, sitting and collar colour of a tame creature (version 1; decision E-480).
QcEntityCodec::Component::NoAi16A creature without a mind (version 1, no fields; decision E-510).
QcEntityCodec::Component::Fuse17The ticks left of a lit explosive, on a falling block entry (version 1, decision E-601): the entry is a lit explosive, which a version without it reads as a falling block.
QcEntityCodec::Component::Hanging18Type, face, cell, motif by name, rotation and held stack of an item frame or painting (version 1, decision E-793; QcHangingCodec).
QcEntityCodec::Component::ItemData19The data of a dropped stack: the components of its QcItemData (QcItemDataCodec; version 1, decision E-823); only for stacks with data.
QcEntityCodec::Component::Family20The persistent id of the parent of a child of a kept family and the chunk it was last in (version 1, decision E-839).
QcEntityCodec::Component::Name21The name a name tag gave a creature (version 1, decision E-866).
QcEntityCodec::Component::Boat22Feet, velocity and yaw of a boat (version 1, decision E-920; QcBoatCodec).

Variable Documentation

const quint16 QcEntityCodec::kindVersion

The current version of the components of each kind (QcVillagerCodec::version for villagers; the creature components beyond Creature have their own, QcCreatureComponents).

const quint32 QcEntityCodec::maxPerChunk

Entries of one kind in one chunk at most; a valid world never comes close.

const qsizetype QcEntityCodec::maxTypeName

Type names (creatures, items, block states) longer than this are damaged data.

Function Documentation

QcResult<QcEntityRecord> QcEntityCodec::decode(const QByteArray &blob, QcChunkPos chunk, const QcContentRegistry &content, QcLoadWarnings &warnings)

Returns the record of chunk read from blob, names looked up in content. Unknown items, blocks, creatures and capes and armour that no longer fits its slot are dropped with a warning in warnings (each unknown name once per world: QcLoadWarnings::addOnce); damaged or implausible data (an entity outside the chunk, values that cannot be) is an error.

QByteArray QcEntityCodec::encode(const QcEntityRecord &record, const QcContentRegistry &content)

Returns the blob of record, names after content.