QtCraft API C++ classes QML types Handbook

QcServerBlocks Class

Block changes of the server with their consequences: clients are told, neighbours queued for an update, machines and chests spill their contents, placed saplings start to grow and broken blocks drop their items. More...

Header: #include <server/blocks/QcServerBlocks.h>

Public Functions

void breakBlock(QcBlockPos pos, bool drops)
void dropBlockItems(QcBlockId block, QcBlockPos pos, const QString &name = {})
void dropItemsWithoutExperience(QcBlockId block, QcBlockPos pos, const QString &name = {})
void dropSpills()
void dropStacks(const QList<QcItemStack> &stacks, QcBlockPos pos)
void sendBlock(QcBlockPos pos, QcBlockId block) const
void setAndBroadcast(QcBlockPos pos, QcBlockId block)
bool setQuietly(QcBlockPos pos, QcBlockId block)

Detailed Description

Member Function Documentation

void QcServerBlocks::breakBlock(QcBlockPos pos, bool drops)

Removes the block at pos as if broken: drops its items (when drops is set) and lets dependent blocks react (leaves decay, unsupported saplings break). The other half of a door breaks with it under the same drop decision.

void QcServerBlocks::dropBlockItems(QcBlockId block, QcBlockPos pos, const QString &name = {})

Drops the items of block state block as if it broke at pos (each drop by its chance, only from the states its when allows); ores add their experience (decision E-398). A container or machine with a custom name name (decision E-873) drops its item with that name.

void QcServerBlocks::dropItemsWithoutExperience(QcBlockId block, QcBlockPos pos, const QString &name = {})

Drops the items of block at pos like dropBlockItems() (with the custom name) but without experience: blocks an explosion breaks give none (decision E-602).

void QcServerBlocks::dropSpills()

Drops the contents that block entities spilled (QcBlockEntities::takeSpills) as items.

void QcServerBlocks::dropStacks(const QList<QcItemStack> &stacks, QcBlockPos pos)

Drops stacks as items at pos.

void QcServerBlocks::sendBlock(QcBlockPos pos, QcBlockId block) const

Tells the clients that have the chunk that pos shows block.

void QcServerBlocks::setAndBroadcast(QcBlockPos pos, QcBlockId block)

Sets block at pos, tells clients and queues its neighbours for an update.

bool QcServerBlocks::setQuietly(QcBlockPos pos, QcBlockId block)

Sets block at pos like setAndBroadcast() without telling the clients (a piston's block arrives later, decision E-337). Returns false when the block could not be set.