QcPlantGrowth Class
Blocks with random ticks: plants that grow upwards by themselves (blocks with growth, e.g. sugar cane), crops and soil (QcCropGrowth). More...
| Header: | #include <server/plants/QcPlantGrowth.h> |
Public Types
Public Functions
| const QcCropGrowth & | crops() const |
| double | growthChance(QcBlockId block) const |
| std::optional<QcBlockPos> | growthTarget(const QcBlockAccess &world, QcBlockPos pos) const |
| bool | randomTick(const QcServerWorld &world, QcBlockPos pos, const QcPlantGrowth::SetBlock &setBlock) |
| void | setRainCheck(QcCropGrowth::RainCheck check) |
| void | setRandomTicksPerSection(int ticks) |
| void | tick(const QcServerWorld &world, const QcPlantGrowth::SetBlock &setBlock) |
Static Public Members
| const double | randomTickSeconds |
| const int | randomTicksPerSection |
Detailed Description
Every server tick picks QcServerLimits::randomTicksPerSection random blocks in each loaded section that may hold such a block (QcServerWorld::marks, QcBlockTrait::RandomTicks). A ticked top block of a plant column grows one block of its kind with the chance that gives its averageSeconds per step, while the column is below maxHeight, the block above is air and the column's base still has its ground (cane: water next to it). Random ticks run only in loaded chunks; time a chunk spent unloaded is not made up (decision E-289).
Member Type Documentation
[alias] QcPlantGrowth::SetBlock
Sets a block and tells the clients; returns false when it could not be set.
Member Function Documentation
const QcCropGrowth &QcPlantGrowth::crops() const
Returns the rules of crops and soil.
double QcPlantGrowth::growthChance(QcBlockId block) const
Returns the chance that a random tick of block grows it.
std::optional<QcBlockPos> QcPlantGrowth::growthTarget(const QcBlockAccess &world, QcBlockPos pos) const
Returns the air block of world a plant at pos would grow into, if its column may grow now.
bool QcPlantGrowth::randomTick(const QcServerWorld &world, QcBlockPos pos, const QcPlantGrowth::SetBlock &setBlock)
Runs one random tick of the block at pos of world, setting blocks with setBlock. Returns true when it changed the world.
void QcPlantGrowth::setRainCheck(QcCropGrowth::RainCheck check)
Sets the check of where rain falls: rain wets soil (QcCropGrowth::setRainCheck).
void QcPlantGrowth::setRandomTicksPerSection(int ticks)
Sets the random ticks per marked section and tick.
void QcPlantGrowth::tick(const QcServerWorld &world, const QcPlantGrowth::SetBlock &setBlock)
Runs the random ticks of one server tick in the marked sections of world, setting blocks with setBlock.
Member Variable Documentation
const double QcPlantGrowth::randomTickSeconds
Average seconds between two random ticks of one block at the default; the growth chances count with it, so more random ticks make plants grow faster.
const int QcPlantGrowth::randomTicksPerSection
Random ticks per marked section and tick by default (QcServerLimits::randomTicksPerSection).