QcBlockRules Namespace
Rules that derive block states from the surroundings, shared by the server and the client's block prediction (decision E-853): the state a placed block takes from the player's view and the clicked face, connections of fences, walls and panes, and whether a block still has the support it needs. More...
| Header: | #include <common/blockrules/QcBlockRules.h> |
Classes
| struct | Aim |
Variables
| const float | verticalFacingPitch |
Functions
| QcBlockId | connectedState(const QcBlockAccess &world, QcBlockPos pos, QcBlockId id) |
| std::optional<QcBlockId> | covered(const QcBlockAccess &world, QcBlockPos pos, QcBlockId id) |
| std::optional<QcBlockFace> | faceFromName(const QString &name) |
| QString | faceName(QcBlockFace face) |
| std::optional<QcBlockId> | hardened(const QcBlockAccess &world, QcBlockPos pos, QcBlockId id) |
| bool | hasPartner(const QcBlockAccess &world, QcBlockPos pos, QcBlockId id) |
| bool | isSupported(const QcBlockAccess &world, QcBlockPos pos, QcBlockId id) |
| QString | lookDirection(float yaw) |
| QcBlockFace | opposite(QcBlockFace face) |
| QcBlockPos | otherHalf(const QcBlockAccess &world, QcBlockPos pos, QcBlockId id) |
| std::optional<QcPlacedBlock> | placement(const QcBlockAccess &world, QcBlockId block, const QcBlockRules::Aim &aim) |
| QcBlockFace | rightOf(QcBlockFace face) |
Detailed Description
Behaviour follows from data: the block's properties (facing, half, type, attach, hinge, open, north/east/south/west, up) and its definition flags.
Classes
class Aim
What the player aims at when placing a block: face of the block at clicked, hit (0..1 inside that block), while looking along yaw and pitch (degrees, positive is up). More...
Variable Documentation
const float QcBlockRules::verticalFacingPitch
Looking further up or down than this, a block whose facing allows up and down (pistons) faces vertically (decision E-334).
Function Documentation
QcBlockId QcBlockRules::connectedState(const QcBlockAccess &world, QcBlockPos pos, QcBlockId id)
Returns id at pos with its connection properties recomputed from the neighbours in world (unchanged for blocks that do not connect); rails take their track from the rails around them (QcRails::shapedState), stairs their corner from the stairs around them (QcStairShapes::shapedState). Sides towards unloaded chunks keep their current value.
std::optional<QcBlockId> QcBlockRules::covered(const QcBlockAccess &world, QcBlockPos pos, QcBlockId id)
Returns the block id at pos in world turns into while an opaque full block lies on it (its coveredInto: a dirt path becoming dirt, decision E-406), std::nullopt otherwise.
std::optional<QcBlockFace> QcBlockRules::faceFromName(const QString &name)
Returns the face the direction name name ("north" … "down", "floor", "ceiling") stands for.
QString QcBlockRules::faceName(QcBlockFace face)
Returns the direction name of face ("up" and "down" for the vertical ones).
std::optional<QcBlockId> QcBlockRules::hardened(const QcBlockAccess &world, QcBlockPos pos, QcBlockId id)
Returns the block id at pos in world turns into when it touches its hardensWith block on any side (concrete powder next to water), std::nullopt otherwise.
bool QcBlockRules::hasPartner(const QcBlockAccess &world, QcBlockPos pos, QcBlockId id)
Returns whether the other half of the door or bed id at pos is there in world (or not loaded).
bool QcBlockRules::isSupported(const QcBlockAccess &world, QcBlockPos pos, QcBlockId id)
Returns whether the block at pos (in state id) still has its support in world.
QString QcBlockRules::lookDirection(float yaw)
Returns the horizontal direction ("north", "east", "south", "west") a player with yaw (degrees) looks.
QcBlockFace QcBlockRules::opposite(QcBlockFace face)
Returns the face opposite face.
QcBlockPos QcBlockRules::otherHalf(const QcBlockAccess &world, QcBlockPos pos, QcBlockId id)
Returns the other half of a door (above or below) or a bed (the head lies in the foot's facing direction) in state id at pos in world.
std::optional<QcPlacedBlock> QcBlockRules::placement(const QcBlockAccess &world, QcBlockId block, const QcBlockRules::Aim &aim)
Returns where and in which state block (any state of it) is placed in world when the player clicks with aim. A slab clicked on its open half becomes a double slab in place; a clicked replaceable block (tall grass) is replaced as if the new block were placed on the ground below it. std::nullopt when the block cannot go there (a torch on a ceiling, a door without room).
QcBlockFace QcBlockRules::rightOf(QcBlockFace face)
Returns the direction to the right of someone looking towards face (clockwise seen from above).