QtCraft API C++ classes QML types Handbook

QcServerPlants Class

Plants in the server tick: growing saplings and decaying leaves (QcPlantManager), random ticks of plants that grow upwards like sugar cane, of crops and soil (QcPlantGrowth), items that plant themselves (despawning saplings, seeds lying on free soil; decision E-294), and players tilling soil with a hoe (decision E-290), making paths with a shovel (decision E-406), bone meal on crops and saplings (decision E-426) and carving pumpkins with shears (decision E-472). More...

Header: #include <server/plants/QcServerPlants.h>

Public Functions

bool carve(QcServerClient &client, QcBlockPos target, QcBlockFace face, const QcItemDefinition *held)
bool fertilize(QcServerClient &client, QcBlockPos target, const QcItemDefinition *held)
bool flatten(QcServerClient &client, QcBlockPos target, QcBlockFace face, const QcItemDefinition *held)
bool growCrop(QcBlockPos pos, int stages)
void plantItems(const QList<QcItemEntity> &despawned)
bool strip(QcServerClient &client, QcBlockPos target, const QcItemDefinition *held)
void tick()
bool till(QcServerClient &client, QcBlockPos target, QcBlockFace face, const QcItemDefinition *held)

Static Public Members

const int fertilizeStagesMax
const int fertilizeStagesMin
const int seedCheckTicks

Detailed Description

Member Function Documentation

bool QcServerPlants::carve(QcServerClient &client, QcBlockPos target, QcBlockFace face, const QcItemDefinition *held)

Carves the block target that client clicked on face when the held item carves (shears) and the block has carvesInto (a pumpkin, decision E-472): the carved block faces the clicked side (on the top or bottom: the player), its carveDrop falls out of the clicked face and the shears wear by one. Returns false when the click is no carving.

bool QcServerPlants::fertilize(QcServerClient &client, QcBlockPos target, const QcItemDefinition *held)

Uses the held bone meal (an item that fertilizes, decision E-426) of client on the clicked block target within reach: a crop that is not ripe grows fertilizeStagesMin..Max stages at once, a sapling grows into its tree on the next tick with QcItemDefinition::fertilizeSaplingChance, a block that growsVegetation with air above grows the biome's grass and flowers around it (QcVegetationSpread, decision E-814); each takes one item (not in creative mode). Returns false for other blocks (then other uses of the item may follow).

bool QcServerPlants::flatten(QcServerClient &client, QcBlockPos target, QcBlockFace face, const QcItemDefinition *held)

Flattens the block target that client clicked on face into a path when the held item flattens and the block has flattensInto (decision E-406): only on its top face, with air above, within reach. Returns false when the click is no flattening.

bool QcServerPlants::growCrop(QcBlockPos pos, int stages)

Grows the crop at pos by up to stages stages (not beyond ripe). Returns false when it is no crop or ripe already.

void QcServerPlants::plantItems(const QList<QcItemEntity> &despawned)

Items in the item phase of a tick: despawned saplings and, every seedCheckTicks, resting seeds plant themselves.

bool QcServerPlants::strip(QcServerClient &client, QcBlockPos target, const QcItemDefinition *held)

Strips the block target that client clicked when the held item strips (an axe) and the block has strippedInto (a log, decision E-753): the new block keeps the state properties both have (the axis), drops nothing, and the axe wears by one. Returns false when the click is no stripping.

void QcServerPlants::tick()

Growing saplings, decaying leaves and random ticks (unless the game rule randomTicks is off).

bool QcServerPlants::till(QcServerClient &client, QcBlockPos target, QcBlockFace face, const QcItemDefinition *held)

Tills the block target that client clicked on face when the held item tills and the block has tillsInto, on any face but the bottom, with air above, within reach. Returns false when the click is no tilling (then other uses of the item may follow).

Member Variable Documentation

const int QcServerPlants::seedCheckTicks

Seeds (items placing a crop with plantChance) plant themselves once every this many ticks with that chance when they lie on soil with air above (decision E-294).