QtCraft API C++ classes QML types Handbook

QcEquipment Struct

What a player or an armour stand wears in the four armour slots (QcEquipmentSlot, decisions E-232, E-234): one stack each. More...

Header: #include <common/gameplay/QcEquipment.h>

Public Functions

QcItemStack &at(QcEquipmentSlot slot)
const QcItemStack &at(QcEquipmentSlot slot) const
bool isEmpty() const
QcEquipment knownTo(const QcContentRegistry &content) const
QList<QcEquipmentSlot> wear(const QcContentRegistry &content, double damage, const std::function<bool (const QcItemStack &)> &keeps = {})

Public Variables

std::array<QcItemStack, slotCount> stacks

Static Public Members

const std::size_t slotCount

Detailed Description

The protocol carries it for the own player in InventoryState and for players and stands others see in EntitySpawn.

Member Function Documentation

QcItemStack &QcEquipment::at(QcEquipmentSlot slot)

Returns the stack in slot to change it.

const QcItemStack &QcEquipment::at(QcEquipmentSlot slot) const

Returns the stack in slot.

bool QcEquipment::isEmpty() const

Returns whether every slot is empty.

QcEquipment QcEquipment::knownTo(const QcContentRegistry &content) const

Returns only the stacks of items content knows; the others empty. The client checks what the server sends before anything is drawn from it.

QList<QcEquipmentSlot> QcEquipment::wear(const QcContentRegistry &content, double damage, const std::function<bool (const QcItemStack &)> &keeps = {})

Wears every worn piece with durability (as content defines it) by a hit of damage (QcArmour::wearOf); broken pieces are removed. Returns their slots. keeps tells for a piece whether it does not wear this time (unbreaking, decision E-864).

Member Variable Documentation

const std::size_t QcEquipment::slotCount

The number of armour slots.

std::array<QcItemStack, slotCount> QcEquipment::stacks

The stack of each slot, in the order of QcEquipmentSlot.