QcCampfires Class
The items cooking on the lit campfires of the loaded chunks (decision E-772): one entry per campfire that holds an item, filed by chunk so that they are saved, unloaded and loaded with their chunk (QcBlockEntityRecord::Table::Campfires). More...
| Header: | #include <server/machines/QcCampfires.h> |
Public Types
Public Functions
| void | addCookingTime(QcBlockPos pos, double seconds) |
| const QcCampfires::Entry * | at(QcBlockPos pos) const |
| void | clear() |
| void | forgetChunk(QcChunkPos pos) |
| void | noteBlock(QcBlockPos pos, QcBlockId after) |
| QList<QcBlockPos> | positions() const |
| QList<QcBlockPos> | positionsIn(QcChunkPos pos) const |
| bool | put(QcBlockPos pos, int slotCount, QcItemId item) |
| void | restore(const QList<QcCampfires::Entry> &entries, const QcChunk &chunk) |
| QList<QcCampfires::Entry> | savedOf(QcChunkPos pos) const |
| void | set(const QcCampfires::Entry &entry) |
| qsizetype | size() const |
| int | slotsOf(QcBlockId block) const |
| QList<QcBlockPos> | takeChanges() |
| QList<QcCampfires::Entry> | takeChunk(QcChunkPos pos) |
| QList<QcCampfires::Spill> | takeSpills() |
Detailed Description
Kept in step with the blocks by QcServerWorld: a campfire whose block goes or stops cooking (put out, broken) loses its entry, and its items spill, to be dropped by QcServerBlocks::dropSpills. The rules that fill and cook them are QcServerKitchen.
Member Function Documentation
void QcCampfires::addCookingTime(QcBlockPos pos, double seconds)
Adds seconds to the cooking time of every item on the campfire at pos (no change for clients).
const QcCampfires::Entry *QcCampfires::at(QcBlockPos pos) const
Returns the entry at pos, or null when there is none.
void QcCampfires::clear()
Forgets every entry and spill.
void QcCampfires::forgetChunk(QcChunkPos pos)
Forgets the entries of the chunk at pos without spilling (it left the world or was generated again).
void QcCampfires::noteBlock(QcBlockPos pos, QcBlockId after)
The block at pos became after (QcServerWorld::setBlock): an entry it no longer fits goes and its items spill.
QList<QcBlockPos> QcCampfires::positions() const
Returns the positions of every entry in position order (the cooking steps go in this order).
QList<QcBlockPos> QcCampfires::positionsIn(QcChunkPos pos) const
Returns the positions of the entries in the chunk at pos.
bool QcCampfires::put(QcBlockPos pos, int slotCount, QcItemId item)
Puts one item into the first free slot of the campfire at pos (of slotCount slots). Returns false when they are taken.
void QcCampfires::restore(const QList<QcCampfires::Entry> &entries, const QcChunk &chunk)
Puts back the saved entries where chunk still has a campfire with that many slots.
QList<QcCampfires::Entry> QcCampfires::savedOf(QcChunkPos pos) const
Returns the entries of the chunk at pos in position order, to be saved.
void QcCampfires::set(const QcCampfires::Entry &entry)
Replaces the entry at the position of entry with it (an empty one goes).
qsizetype QcCampfires::size() const
Returns the number of entries.
int QcCampfires::slotsOf(QcBlockId block) const
Returns the item slots of block when it is a state that cooks (a lit campfire), 0 for others.
QList<QcBlockPos> QcCampfires::takeChanges()
Returns the campfires whose items changed since the last call (clients are told; cooking time is no change).
QList<QcCampfires::Entry> QcCampfires::takeChunk(QcChunkPos pos)
Returns the entries of the chunk at pos like savedOf() and forgets them.
QList<QcCampfires::Spill> QcCampfires::takeSpills()
Returns the items spilled since the last call.