QcMachineRules Class
How machine blocks (furnaces) work (decisions E-037, E-038); their state lives in the block entities (QcBlockEntities::Machine: input, fuel and output slot, the fuel burning and the progress of the current item). More...
| Header: | #include <server/machines/QcMachineRules.h> |
Public Types
Public Functions
| double | burnFraction(const QcMachineRules::Machine &machine) const |
| double | fuelSeconds(QcItemId item) const |
| const QcMachineDefinition * | machineOf(QcBlockId block) const |
| double | progressFraction(const QcMachineRules::Machine &machine, QcBlockId block) const |
| const QcSmeltingRecipe * | recipeFor(const QcMachineDefinition &machine, QcItemId input) const |
| const QcSmeltingRecipe * | recipeFor(const QString &category, const QStringList &kinds, QcItemId input) const |
| bool | step(QcMachineRules::Machine &machine, const QcMachineDefinition &definition, double dt) const |
| QList<QcBlockPos> | tick(QcBlockEntities &entities, const QcBlockAccess &world, double dt) const |
Static Public Members
| const int | fuelSlot |
| const int | inputSlot |
| const int | outputSlot |
| const int | slotCount |
Detailed Description
A machine burns one fuel item whenever it can work (a recipe of its category for the input and room in the output) and nothing burns; burning time is the fuel's fuelSeconds. While fuel burns, the input item progresses at the machine's speed; without fuel the progress falls back twice as fast. Only machines in loaded chunks tick.
Member Type Documentation
[alias] QcMachineRules::Machine
The state of a machine (QcBlockEntities::Machine).
Member Function Documentation
double QcMachineRules::burnFraction(const QcMachineRules::Machine &machine) const
Returns the share of the current fuel of machine left, in [0, 1].
double QcMachineRules::fuelSeconds(QcItemId item) const
Returns the seconds item burns as fuel, 0 for no fuel.
const QcMachineDefinition *QcMachineRules::machineOf(QcBlockId block) const
Returns the machine definition of block, or null when it is no machine.
double QcMachineRules::progressFraction(const QcMachineRules::Machine &machine, QcBlockId block) const
Returns the share of the current item of machine (of the machine block block) done, in [0, 1].
const QcSmeltingRecipe *QcMachineRules::recipeFor(const QcMachineDefinition &machine, QcItemId input) const
Returns the recipe of the category and kinds of machine for input, or null when there is none.
const QcSmeltingRecipe *QcMachineRules::recipeFor(const QString &category, const QStringList &kinds, QcItemId input) const
Returns the recipe of category for input if its kind is among kinds (empty: any; a campfire).
bool QcMachineRules::step(QcMachineRules::Machine &machine, const QcMachineDefinition &definition, double dt) const
Runs machine of definition for dt seconds. Returns true when anything of it changed.
QList<QcBlockPos> QcMachineRules::tick(QcBlockEntities &entities, const QcBlockAccess &world, double dt) const
Advances all machines of entities in loaded chunks of world by dt seconds. Returns the positions whose slots changed (comparators and hoppers look again).