QtCraft API C++ classes QML types Handbook

QcPortableContainers Namespace

The rules of portable containers (a backpack, decision E-832): a block whose container travels with it as the data of its item (QcItemData::contents). More...

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

Functions

bool isPortable(const QcContentRegistry &content, QcItemId item)
QList<QcItemStack> leftOver(const QcContentRegistry &content, const QcItemStack &stack, int slotCount)
bool mayHold(const QcContentRegistry &content, const QcItemStack &stack)
bool mayHoldAll(const QcContentRegistry &content, const QList<QcItemStack> &stacks)
QList<QcItemStack> slotsOf(const QcContentRegistry &content, const QcItemStack &stack, int slotCount)

Detailed Description

Nothing that carries contents goes into one, so neither a backpack nor a future shulker box nests, whatever moves the items (clicks, shift-clicks, hoppers, placing a filled item).

Function Documentation

bool QcPortableContainers::isPortable(const QcContentRegistry &content, QcItemId item)

Returns whether item of content places a portable container (QcItemDefinition::portableContainer).

QList<QcItemStack> QcPortableContainers::leftOver(const QcContentRegistry &content, const QcItemStack &stack, int slotCount)

Returns the stacks of stack's contents that slotsOf(content, stack, slotCount) leaves out, so the caller can drop them.

bool QcPortableContainers::mayHold(const QcContentRegistry &content, const QcItemStack &stack)

Returns whether stack (an item of content) may lie in a portable container: empty, or neither a portable container nor anything else with contents.

bool QcPortableContainers::mayHoldAll(const QcContentRegistry &content, const QList<QcItemStack> &stacks)

Returns whether every stack of stacks may (mayHold() with content).

QList<QcItemStack> QcPortableContainers::slotsOf(const QcContentRegistry &content, const QcItemStack &stack, int slotCount)

Returns the slots of a placed container for the contents of stack (items of content): its contents, empty slots after them up to slotCount; what does not fit the slots or must not lie in it is left out (see leftOver).