QcCropGrowth Class
Random-tick rules of farming (decisions E-289 to E-291), called by QcPlantGrowth for blocks with crop or soil. More...
| Header: | #include <server/plants/QcCropGrowth.h> |
Public Types
Public Functions
| QcCropGrowth(std::shared_ptr<const QcContentRegistry> content, double randomTickSeconds) | |
| QcBlockId | freshSoil(const QcBlockAccess &world, QcBlockPos pos, QcBlockId soil) const |
| double | fruitChance(QcBlockId crop, bool wet) const |
| bool | isOnWetSoil(const QcBlockAccess &world, QcBlockPos pos) const |
| bool | randomTick(const QcServerWorld &world, QcBlockPos pos, QcBlockId block, QRandomGenerator &random, const QcCropGrowth::SetBlock &setBlock) const |
| void | setRainCheck(QcCropGrowth::RainCheck check) |
| double | stageChance(QcBlockId crop, bool wet) const |
| QcCropGrowth::Water | waterNear(const QcBlockAccess &world, QcBlockPos pos, const QcSoilDefinition &soil) const |
Static Public Members
| int | plantLightAt(const QcServerWorld &world, QcBlockPos pos) |
Detailed Description
A crop advances one stage with a chance that gives its averageSeconds from the first to the ripe stage on wet soil (times dryFactor elsewhere) and only in enough light; a ripe crop with a fruit (stems) puts that fruit onto a free neighbouring cell. Soil turns wet near water or in the rain (the cell above it under the open rain, setRainCheck, decision E-396), dries step by step without either and reverts (to dirt) when dry and bare or covered by a full block.
Member Type Documentation
[alias] QcCropGrowth::RainCheck
Whether rain falls on a position (weather).
[alias] QcCropGrowth::SetBlock
Sets a block and tells the clients; returns false when it could not be set.
enum class QcCropGrowth::Water
Whether water lies near soil.
| Constant | Value | Description |
|---|---|---|
QcCropGrowth::Water::Near | 0 | Water lies near. |
QcCropGrowth::Water::None | 1 | No water lies near. |
QcCropGrowth::Water::Unknown | 2 | None was found, but part of the area is not loaded. |
Member Function Documentation
QcCropGrowth::QcCropGrowth(std::shared_ptr<const QcContentRegistry> content, double randomTickSeconds)
Reads the crops and soils of content; randomTickSeconds: average seconds between two random ticks of one block.
QcBlockId QcCropGrowth::freshSoil(const QcBlockAccess &world, QcBlockPos pos, QcBlockId soil) const
Returns the state of soil block soil freshly made at pos of world (a tilled block): wet when water is near.
double QcCropGrowth::fruitChance(QcBlockId crop, bool wet) const
Returns the chance that a random tick of the ripe stem crop puts its fruit down (wet: on wet soil).
bool QcCropGrowth::isOnWetSoil(const QcBlockAccess &world, QcBlockPos pos) const
Returns whether the block of world below pos is soil in its wettest state.
[static] int QcCropGrowth::plantLightAt(const QcServerWorld &world, QcBlockPos pos)
Returns the light at pos of world for plants: the brighter of block light and sky light of the world's light engine (decision E-389; sky light at full strength whatever the time of day).
bool QcCropGrowth::randomTick(const QcServerWorld &world, QcBlockPos pos, QcBlockId block, QRandomGenerator &random, const QcCropGrowth::SetBlock &setBlock) const
Runs one random tick of the crop or soil block at pos of world, drawn from random, setting blocks with setBlock. Returns true when it changed the world.
void QcCropGrowth::setRainCheck(QcCropGrowth::RainCheck check)
Sets the check of where rain falls (rain wets soil).
double QcCropGrowth::stageChance(QcBlockId crop, bool wet) const
Returns the chance that a random tick advances crop by one stage (wet: on wet soil).
QcCropGrowth::Water QcCropGrowth::waterNear(const QcBlockAccess &world, QcBlockPos pos, const QcSoilDefinition &soil) const
Returns whether a block of world named soil.water lies within soil.reach blocks of pos horizontally (soil), at the same level or one above (searched from the centre outwards). Unknown when none was found but part of the area is not loaded: soil at a chunk border then waits instead of drying.