QtCraft API C++ classes QML types Handbook

QcServerGolems Class

Players and golems (decision E-471): building a golem from blocks and repairing one. More...

Header: #include <server/golems/QcServerGolems.h>

Public Types

struct Shape

Public Functions

std::optional<quint32> build(QcBlockPos pos)
bool repair(QcServerClient &client, quint32 entityId, const QcItemDefinition *held)

Static Public Members

std::optional<QcServerGolems::Shape> shapeAt(const QcBlockAccess &world, QcBlockPos head, const QcMobDefinition &definition)

Detailed Description

A golem kind with build (QcGolemDefinition) comes alive when a player places its head block on the middle of four body blocks standing upright in a T, the T along either horizontal axis, with air beside the head and beside the foot (an iron golem: four iron blocks and a carved pumpkin in any of the four directions); the blocks vanish and a golem that never attacks players stands in their place. A golem kind with a repairItem is healed by repairHealth when a player uses that item on it (one of the stack, except in creative mode).

Member Function Documentation

std::optional<quint32> QcServerGolems::build(QcBlockPos pos)

A player placed a block at pos: a golem whose head it is, standing on a complete body, comes alive. Returns the new golem's entity id, if one came.

bool QcServerGolems::repair(QcServerClient &client, quint32 entityId, const QcItemDefinition *held)

The player of client uses the item held on the creature entityId: a golem it repairs is healed. Returns false when it is no repair (other uses may follow).

[static] std::optional<QcServerGolems::Shape> QcServerGolems::shapeAt(const QcBlockAccess &world, QcBlockPos head, const QcMobDefinition &definition)

Returns the T of definition's body blocks in world under its head at head, if complete (the head itself is not checked).