QcInventoryAccess Class
The slots of containers (chests, barrels, hoppers, dispensers) and machines (furnaces) as Signal Hoppers, droppers and dispensers reach them (decision E-344). More...
| Header: | #include <server/machines/QcInventoryAccess.h> |
Public Types
| struct | Insertion |
Public Functions
| bool | ensure(QcBlockPos pos) |
| void | finish() |
| QList<std::pair<int, int>> | fit(QcBlockPos pos, QList<QcItemStack> stacks, const QList<int> &cells, const QcItemStack &stack) const |
| bool | hasInventory(QcBlockPos pos) const |
| bool | mayTakeOut(QcBlockPos pos, int slot, const QcItemStack &stack) const |
| bool | put(QcBlockPos pos, int slot, const QcItemStack &stack) |
| QList<QcInventoryAccess::Insertion> | resolve(QList<QcInventoryAccess::Insertion> insertions) const |
| int | slotFor(QcBlockPos pos, const QList<QcItemStack> &stacks, const QList<int> &cells, const QcItemStack &stack) const |
| QList<QcItemStack> | slotsAt(QcBlockPos pos) const |
| QList<int> | slotsIn(QcBlockPos pos, QcBlockFace face) const |
| QList<int> | slotsOut(QcBlockPos pos, QcBlockFace face) const |
| bool | take(QcBlockPos pos, int slot, int count) |
| bool | wasEmptyBefore(QcBlockPos pos) const |
Detailed Description
A furnace takes items from above into its input and from the other sides into its fuel slot (fuel only) and gives its output downwards. Items go into the first slot in index order that is empty or holds the same item with room, as in the reference.
Changes are units added to and taken from slots; QcServerState::noteContents tells comparators and hoppers around once finish() runs.
Member Function Documentation
bool QcInventoryAccess::ensure(QcBlockPos pos)
Makes sure the container or machine at pos has its entry (it has none when the table was full as the block was placed), so items can go into it. Returns false when it has no inventory or the table of entries is full. Called while deciding, so a step never moves an item into nowhere.
void QcInventoryAccess::finish()
Empties slots left at count 0 and tells the neighbours about every changed inventory.
QList<std::pair<int, int>> QcInventoryAccess::fit(QcBlockPos pos, QList<QcItemStack> stacks, const QList<int> &cells, const QcItemStack &stack) const
Returns where as much of stack as fits into stacks of the inventory at pos through cells goes: slot and count each.
bool QcInventoryAccess::hasInventory(QcBlockPos pos) const
Returns whether the block at pos is a container or machine.
bool QcInventoryAccess::mayTakeOut(QcBlockPos pos, int slot, const QcItemStack &stack) const
Returns whether stack may leave slot of the inventory at pos (a machine's fuel slot gives only an empty bucket back).
bool QcInventoryAccess::put(QcBlockPos pos, int slot, const QcItemStack &stack)
Puts stack into slot of the inventory at pos (chosen by this class). Returns false when the slot does not exist.
QList<QcInventoryAccess::Insertion> QcInventoryAccess::resolve(QList<QcInventoryAccess::Insertion> insertions) const
Decides which insertions into the same targets happen together (one unit each): per target the one from above first, then the others grouped by item in a fixed item order, each group whole or not at all, so no direction or coordinate decides (decision E-344). Returns the kept ones with their slots.
int QcInventoryAccess::slotFor(QcBlockPos pos, const QList<QcItemStack> &stacks, const QList<int> &cells, const QcItemStack &stack) const
Returns the first slot of cells in stacks of the inventory at pos that takes one more of stack's item, or -1.
QList<QcItemStack> QcInventoryAccess::slotsAt(QcBlockPos pos) const
Returns a copy of the slots at pos (an unopened container is empty); empty without an inventory.
QList<int> QcInventoryAccess::slotsIn(QcBlockPos pos, QcBlockFace face) const
Returns the slots of the inventory at pos an item may enter through face.
QList<int> QcInventoryAccess::slotsOut(QcBlockPos pos, QcBlockFace face) const
Returns the slots of the inventory at pos an item may leave through face.
bool QcInventoryAccess::take(QcBlockPos pos, int slot, int count)
Takes count from slot of the inventory at pos (the slot was chosen by this class). Returns false when the slot does not exist. Callers put first and take only after a successful put.
bool QcInventoryAccess::wasEmptyBefore(QcBlockPos pos) const
Returns whether the hopper at pos received something while it was empty since the last finish().