QtCraft API C++ classes QML types Handbook

QcServerHanging Class

What players and the world do to item frames and paintings (decisions E-790 to E-792): hanging one from its item on a block face, putting an item into a frame and turning it, hitting (a frame's item drops first, then the frame) and dropping them when their wall or room goes. More...

Header: #include <server/hanging/QcServerHanging.h>

Public Functions

bool hit(QcServerClient &client, quint32 id)
bool place(QcServerClient &client, const QcMsg::UseItem &message)
void remove(quint32 id, bool drops)
void tick()
bool use(QcServerClient &client, quint32 id)

Static Public Members

QcHangingEntity *spawn(QcServerState &state, QcHangingEntity hanging)

Detailed Description

Holds no state of its own, so the server makes one where it needs it.

Member Function Documentation

bool QcServerHanging::hit(QcServerClient &client, quint32 id)

Handles a hit of client on the frame or painting id (none in adventure mode). Returns false when id is no frame or painting.

bool QcServerHanging::place(QcServerClient &client, const QcMsg::UseItem &message)

Hangs a frame or painting from the held item of client on the face message clicked. Returns false when the item hangs nothing. A refused placement (no room, too far, limit, adventure mode) still returns true.

void QcServerHanging::remove(quint32 id, bool drops)

Removes the frame or painting id; with drops its item and what it held fall where it hung.

[static] QcHangingEntity *QcServerHanging::spawn(QcServerState &state, QcHangingEntity hanging)

Adds hanging to state (placing, world setup, tests); its id and position are set here and comparators near it look again. Returns it, or null at the limit.

void QcServerHanging::tick()

Frames and paintings whose wall or room went fall off with their drops; checked after a block change next to them and once every QcHangingManager::supportCheckTicks ticks.

bool QcServerHanging::use(QcServerClient &client, quint32 id)

Handles a right click of client on the frame or painting id. Returns false when id is none.