QtCraft API C++ classes QML types Handbook

QcMining Namespace

Mining rules shared by server (validation) and client (progress display). More...

Header: #include <common/gameplay/QcMining.h>

Variables

const double minimumSeconds
const double secondsPerHardness
const double secondsPerHardnessWithoutTool

Functions

double breakSeconds(const QcBlockDefinition &block, const QcItemDefinition *held, double speedBonus = 0.0)
bool canHarvest(const QcBlockDefinition &block, const QcItemDefinition *held)
bool isBreakable(const QcBlockDefinition &block)

Detailed Description

Variable Documentation

const double QcMining::minimumSeconds

Blocks with hardness 0 still take one tick, so a click cannot break a whole row at once.

const double QcMining::secondsPerHardness

Seconds per hardness point with the right tool at speed 1 (and by hand for tool-free blocks).

const double QcMining::secondsPerHardnessWithoutTool

Seconds per hardness point when the block needs a tool the player does not use.

Function Documentation

double QcMining::breakSeconds(const QcBlockDefinition &block, const QcItemDefinition *held, double speedBonus = 0.0)

Returns the seconds needed to break block with the item held (nullptr = hand); negative for unbreakable blocks. speedBonus adds to a matching tool's speed (efficiency, QcEnchanting::speedBonus).

bool QcMining::canHarvest(const QcBlockDefinition &block, const QcItemDefinition *held)

Returns true when the item held (nullptr = hand) gets the drops of block.

bool QcMining::isBreakable(const QcBlockDefinition &block)

Returns whether block can be broken: a hardness that is not negative, no liquid, not invisible (air).