QtCraft API C++ classes QML types Handbook

QcMovingBlocks Class

Blocks a piston moves, as the clients see them (decision E-337): the world holds every moved block at its new cell at once (saves, chunk borders and other players see one consistent world), while the clients get the new cells only after the move and meanwhile see the block as an entity that slides there. More...

Header: #include <server/signal/QcMovingBlocks.h>

Public Functions

bool add(const QcMovingBlock &moving)
const QList<QcMovingBlock> &all() const
void cancelTo(QcBlockPos cell)
QList<QcMovingBlock> &editableAll()
bool isMovingTo(QcBlockPos cell) const
void setMaxMoving(qsizetype limit)
QList<QcBlockPos> tick(quint64 now)

Static Public Members

const qsizetype maxMoving
const int moveTicks
QcVec3 positionAt(const QcMovingBlock &moving, quint64 now)

Detailed Description

Only the look of the move lasts; nothing waits for it.

Member Function Documentation

bool QcMovingBlocks::add(const QcMovingBlock &moving)

Shows moving sliding. Returns false (and nothing shown) when too many move already. The entity's position follows the slide (positionAt), updated by tick().

const QList<QcMovingBlock> &QcMovingBlocks::all() const

Returns every move shown.

void QcMovingBlocks::cancelTo(QcBlockPos cell)

Forgets the slides into cell (a piston head that retracts before it arrived): the clients stop showing them and get no block from them.

QList<QcMovingBlock> &QcMovingBlocks::editableAll()

Returns the moves for the entity register (QcEntities); never add or remove through it.

bool QcMovingBlocks::isMovingTo(QcBlockPos cell) const

Returns whether the clients still wait for the block of cell.

[static] QcVec3 QcMovingBlocks::positionAt(const QcMovingBlock &moving, quint64 now)

Returns where the sliding block of moving is at now: its feet, as for falling blocks.

void QcMovingBlocks::setMaxMoving(qsizetype limit)

Sets the moves shown at once at most to limit.

QList<QcBlockPos> QcMovingBlocks::tick(quint64 now)

Returns the cells whose move ends at now (the clients get their block now); moves are forgotten one tick later, after the clients had the block, so nothing flickers.

Member Variable Documentation

const qsizetype QcMovingBlocks::maxMoving

Moves shown at once at most; beyond, blocks jump without the slide. Blocks shown sliding at once by default (QcServerLimits::movingBlocksShown).

const int QcMovingBlocks::moveTicks

Ticks a move lasts for the clients.