QtCraft API C++ classes QML types Handbook

QcEntity Struct

What every entity of the server has (decision E-364): an id unique among all entities of the world, its kind, where it is and how it moves (feet in the middle of the bottom face), the direction it faces and whether it rests because its chunk (QcEntities::chunkOf) is not loaded. More...

Header: #include <server/entities/QcEntity.h>
Inherited By:

QcArmourStand, QcBoat, QcCreature, QcExperienceOrb, QcFallingBlock, QcHangingEntity, QcItemEntity, QcMinecart, QcMovingBlock, QcPrimedExplosive, QcProjectile, and QcServerClient

Public Functions

Type &as()
const Type &as() const

Public Variables

int burnTicks
bool dormant
quint32 id
QcEntityKept kept
QcEntityKind kind
QcEntityMotion motion
bool settled
QcChunkPos settledChunk
float yaw

Detailed Description

The kinds add their own state (QcCreature, QcItemEntity, QcFallingBlock, QcArmourStand, QcMovingBlock, QcServerClient for players); QcEntities keeps them all.

Member Function Documentation

template <typename Type> Type &QcEntity::as()

Returns the entity as its type (decision E-372): every type names its kind (entityKind), so a mismatch between the kind field and the type asked for is caught in debug builds instead of reading another type's fields.

template <typename Type> const Type &QcEntity::as() const

Returns the entity as its type, read-only (see the other overload).

Member Variable Documentation

int QcEntity::burnTicks

Ticks it still burns (players and creatures, QcBodyBurning, decision E-393); not saved.

bool QcEntity::dormant

Its chunk was not loaded at the start of the tick (QcEntities::settle): it is not simulated, not sent to clients and not counted. Players never rest.

quint32 QcEntity::id

Unique among all entities of the world while it is open.

QcEntityKept QcEntity::kept

What its saved entry holds that this version does not use (decision E-420), written back unchanged when it is saved again; empty for nearly every entity.

QcEntityKind QcEntity::kind

Which table it lives in and which type it is.

QcEntityMotion QcEntity::motion

Where its feet are and how it moves.

bool QcEntity::settled

Whether settle has seen it at all.

QcChunkPos QcEntity::settledChunk

The chunk the last QcEntities::settle saw it in; settle looks up whether a chunk is loaded only when this changed or the loaded chunks did.

float QcEntity::yaw

Degrees, as the protocol sends it.