QtCraft API C++ classes QML types Handbook

QcBlockDefinition Struct

Definition of a block type as read from a content pack's JSON (QcBlockParser). More...

Header: #include <common/content/blocks/QcBlockDefinition.h>

Public Functions

bool hasRandomTicks() const
bool isWater() const
bool keepsSpawnsAway() const
const QcBlockProperty *property(const QString &propertyName) const
QString slotTexture(const QString &slot) const
const QString &texture(QcBlockFace face) const

Public Variables

std::optional<QcAnvilSwap> anvilSwap
bool bed
QcBitesDefinition bites
QcBlastDefinition blast
bool burnsItems
QcCampfireDefinition campfire
QString carveDrop
int carveDropCount
QString carvesInto
bool climbable
QString connectGroup
QStringList connectsTo
bool connectsToSolids
double contactDamage
QString containerCloseSound
int containerColumns
QString containerOpenSound
int containerSlots
QString coveredInto
QcCropDefinition crop
QString descriptionKey
bool door
QList<QcItemDrop> drops
QString dyeProperty
QcExperienceDrop experience
std::array<QString, qcBlockFaceCount> faceTextures
QcFacingRule facingRule
bool falls
QcFireDefinition fire
QString flattensInto
bool floats
QcLiquidDefinition flow
double fuelSeconds
QStringList groundBlocks
QString groundLiquid
bool growsVegetation
QcGrowthDefinition growth
QString hardensInto
QString hardensWith
double hardness
bool hasItem
QcHoldDisplay hold
QString infestsBlock
QString infestsMob
QStringList itemTags
QString itemTexture
double landingDamage
int lightLevel
int lightOpacity
bool liquid
QcMachineDefinition machine
QString name
bool opaque
bool opensAnvil
bool opensCrafting
bool opensEnchanting
bool opensStonecutter
QString partOf
bool portableContainer
QList<QcBlockProperty> properties
bool rail
QcRailAction railAction
QcRenderLayer renderLayer
bool replaceable
QcSaplingDefinition sapling
QcShapeDefinition shape
QString shapeName
QcSignDefinition sign
QcSignalDefinition signal
double slipperiness
double slowsInside
QcSoilDefinition soil
bool solid
std::array<QString, qcBlockSoundActionCount> soundKeys
QString soundMaterial
QcSpawnerDefinition spawner
bool stairs
QString strippedInto
QcBlockSupport support
bool supportsAbove
double surfaceJump
double surfaceSpeed
QList<std::pair<QString, QString>> textureSlots
QString tillsInto
bool toggles
QString tool
int toolLevel
QString translationKey
bool washable
QString wearsInto

Static Public Members

const double grippingSlipperiness
const double landingDamageLimit
const int maxContainerSlots
const int maxLightLevel
const double maxSlipperiness

Detailed Description

The parts that reach the client go through QcBlockSerializer; fields marked server side only stay on the server.

Member Function Documentation

bool QcBlockDefinition::hasRandomTicks() const

Returns whether the server gives the block random ticks (growing plants, crops, soil).

bool QcBlockDefinition::isWater() const

Returns whether the block is water: a liquid that sets nothing alight (lava does); the one test for spawn spots in water, drowned and fish, putting out burning bodies and QcPhysics::isWaterAt.

bool QcBlockDefinition::keepsSpawnsAway() const

Returns whether creatures keep from spawning on or in the block because it hurts or slows them (lava, cobweb; QcNaturalSpawner).

const QcBlockProperty *QcBlockDefinition::property(const QString &propertyName) const

Returns the state property named propertyName, or nullptr if the block has none.

QString QcBlockDefinition::slotTexture(const QString &slot) const

Returns the texture of the named slot, or an empty string.

const QString &QcBlockDefinition::texture(QcBlockFace face) const

Returns the texture name of the block's face.

Member Variable Documentation

std::optional<QcAnvilSwap> QcBlockDefinition::anvilSwap

The block the anvil turns this one into and back (decision E-870; QcAnvilSwaps puts it on both items), declared on one of the two blocks. Server side only.

bool QcBlockDefinition::bed

Two blocks long: placed and broken together, the head in the facing direction of the foot; part tells foot from head. Villages count them (QcVillages). Server side only (not synchronised).

QcBitesDefinition QcBlockDefinition::bites

Eaten bite by bite where it stands (cake, decision E-773); the food reaches the client.

QcBlastDefinition QcBlockDefinition::blast

Blast resistance and explosives (decision E-600). Server side only.

bool QcBlockDefinition::burnsItems

Whether items inside the block burn from its contactDamage ("burnsItems"). Server side only.

QcCampfireDefinition QcBlockDefinition::campfire

A campfire (decision E-772); the slots reach the client.

QString QcBlockDefinition::carveDrop

Item dropped when the block is carved ("carving", "drop"), empty for none. Server side only.

int QcBlockDefinition::carveDropCount

Number of carveDrop items dropped ("count"; 1 by default when there is a drop). Server side only.

QString QcBlockDefinition::carvesInto

Block it turns into when an item that carves (shears) is used on it, facing the clicked side, dropping carveDropCount of the item carveDrop (a pumpkin carved into a head, decision E-472); empty for none. Server side only.

bool QcBlockDefinition::climbable

Entities inside climb up and down (ladders).

bool QcBlockDefinition::connectsToSolids

Whether full solid blocks count as connections ("solids": false: only the groups, tripwire, decision E-782). Server side only.

double QcBlockDefinition::contactDamage

Damage per hit to bodies touching the block (lava); items inside burn unless burnsItems is false (a campfire hurts only creatures and players, decision E-772). Server side only.

int QcBlockDefinition::containerColumns

Slots per row of its screen (a dispenser's 3 x 3, a hopper's row of 5).

int QcBlockDefinition::containerSlots

Item slots of a storage block (chest); 0 for blocks without storage.

QString QcBlockDefinition::coveredInto

Block it turns into at its next block update while an opaque full block lies on it (a dirt path becoming dirt, decision E-406), empty for none. Server side only.

QString QcBlockDefinition::descriptionKey

Translation key of the handbook's text about it ("<translation>.description" unless set); a missing text leaves only the facts. Server side only.

bool QcBlockDefinition::door

Two blocks tall: placed, opened and broken together; half tells bottom from top.

QList<QcItemDrop> QcBlockDefinition::drops

Items dropped when broken ("drops", at most 64 entries).

QString QcBlockDefinition::dyeProperty

State property a dye sets to its colour when used on the block (QcItemDefinition::dye; the signal indicator light's color, decision E-765); empty for none. Server side only.

QcExperienceDrop QcBlockDefinition::experience

Experience points mining it gives as orbs, with a tool that gets its drops (ores; decision E-398). Server side only.

std::array<QString, qcBlockFaceCount> QcBlockDefinition::faceTextures

Texture names indexed by QcBlockFace.

QcFacingRule QcBlockDefinition::facingRule

How the placed block's facing follows the player's view ("facing").

bool QcBlockDefinition::falls

Without a block below it falls as an entity and lands again (sand, gravel). Server side only.

QcFireDefinition QcBlockDefinition::fire

Fire, flammability and eternal fire (decision E-392). Server side only.

QString QcBlockDefinition::flattensInto

Block it turns into when an item that flattens (a shovel) is used on its top, empty for none (decision E-406). Server side only.

bool QcBlockDefinition::floats

Placed on the surface of a liquid (a lily pad, decision E-774): the player aims at the liquid and the block goes into the cell above it. Reaches the client.

QcLiquidDefinition QcBlockDefinition::flow

Flow of a liquid block; distance and movement factor also reach the client.

double QcBlockDefinition::fuelSeconds

Seconds the block's item burns as fuel in a machine; 0 for blocks that are no fuel.

const double QcBlockDefinition::grippingSlipperiness

Slipperiness of a block that grips (the default and the least a block may have).

QStringList QcBlockDefinition::groundBlocks

Blocks it may stand on (plants); empty: any full solid top face. Server side only.

QString QcBlockDefinition::groundLiquid

A liquid that must touch the ground block from a side (sugar cane: water), unless the ground is this block itself. Server side only.

bool QcBlockDefinition::growsVegetation

Bone meal used on it grows grass and flowers of the biome around it (a grass block, decision E-814). Server side only.

QcGrowthDefinition QcBlockDefinition::growth

Growing upwards in a column ("growth", sugar cane); needs support below. Server side only.

double QcBlockDefinition::hardness

Seconds to break by hand; negative means unbreakable.

bool QcBlockDefinition::hasItem

Whether the block gets an item of its own name; internal variants (a lit lamp, a piston head) have none and drop the item of their main block. Server side only.

QcHoldDisplay QcBlockDefinition::hold

How a hand holds the item that places this block, for the fields that item leaves unset (decision E-831).

QStringList QcBlockDefinition::itemTags

Tags of the item that places this block (server side only).

QString QcBlockDefinition::itemTexture

Item icon drawn flat instead of the block model (torches, doors); empty for the block model.

double QcBlockDefinition::landingDamage

Damage a falling block deals to bodies in the cell it lands in, per block fallen beyond the first (an anvil: 2, at most landingDamageLimit); 0 for none. Server side only.

const double QcBlockDefinition::landingDamageLimit

Largest landing damage of a falling block in total and largest landingDamage.

int QcBlockDefinition::lightLevel

Block light emitted, 0..15.

int QcBlockDefinition::lightOpacity

Sky light reduction per block in [0, 15]; 15 blocks light completely.

bool QcBlockDefinition::liquid

Liquid block ("liquid"); its flow is in flow.

QcMachineDefinition QcBlockDefinition::machine

Using the block opens its machine screen (furnace).

const int QcBlockDefinition::maxContainerSlots

Most item slots a storage block may have (containerSlots).

const int QcBlockDefinition::maxLightLevel

Highest block light level (lightLevel).

const double QcBlockDefinition::maxSlipperiness

The most slippery a block may be.

QString QcBlockDefinition::name

Qualified block name ("name", e.g. "qtcraft:stone").

bool QcBlockDefinition::opaque

Opaque blocks are full cubes that hide adjacent faces and block sky light.

bool QcBlockDefinition::opensAnvil

Using the block opens the anvil's screen (decision E-866).

bool QcBlockDefinition::opensCrafting

Using the block opens the 3 x 3 crafting grid instead of placing against it.

bool QcBlockDefinition::opensEnchanting

Using the block opens the enchanting table's screen (decision E-864).

bool QcBlockDefinition::opensStonecutter

Using the block opens the stonecutter's screen (decision E-785).

QString QcBlockDefinition::partOf

"<material>/<family>" for building parts made by QcPartGenerator, empty otherwise; reaches the client (the creative tab Building parts sorts by it, decision E-874).

bool QcBlockDefinition::portableContainer

A portable container ("portable": true, a backpack, decision E-832): broken, it drops as one item that carries its contents; it holds no portable container. Its item gets QcItemDefinition::portableContainer. Server side only.

QList<QcBlockProperty> QcBlockDefinition::properties

Named state properties; every combination of values is a state with its own runtime id.

bool QcBlockDefinition::rail

A rail (decision E-382): minecarts roll along it; its states facing and shape follow from the rails around it (QcRails). Server side only.

QcRailAction QcBlockDefinition::railAction

What the rail does to carts ("railAction": boost, activate); such rails have a powered state.

QcRenderLayer QcBlockDefinition::renderLayer

Render pass of the block ("render").

bool QcBlockDefinition::replaceable

Replaceable blocks (air, water, tall grass) are overwritten when a block is placed into them.

QcSaplingDefinition QcBlockDefinition::sapling

A sapling that grows into a tree feature ("sapling"); its feature is empty for other blocks.

QcShapeDefinition QcBlockDefinition::shape

Inline shape ("shape" as an object); after the content sync, the resolved shape.

QString QcBlockDefinition::shapeName

Shape registered under this name ("shape" as a string; "cube" and "cross" name the base shapes, "cube" leaves it empty); empty uses shape (empty again: the full cube).

QcSignDefinition QcBlockDefinition::sign

A sign with text lines ("sign"); reaches the client.

QcSignalDefinition QcBlockDefinition::signal

Part in Signal Dust circuits (decision E-333); the kind reaches the client (usable blocks), the rest is server side only.

double QcBlockDefinition::slipperiness

How slippery the block is to bodies on it, in the units of the original game (decision E-430): the default 0.6 grips, ice 0.98; above 0.6 bodies keep their momentum (QcEntityMotion::step). Reaches the client.

double QcBlockDefinition::slowsInside

Factor on the movement of bodies inside the block (cobweb; 1 = no effect). Reaches the client.

bool QcBlockDefinition::solid

Solid blocks collide with entities.

QcSpawnerDefinition QcBlockDefinition::spawner

A monster spawner (decision E-520). Server side only.

bool QcBlockDefinition::stairs

Stairs with corners (decision E-754): the states facing, half and shape (straight, inner_left, inner_right, outer_left, outer_right); the server sets shape from the stairs around it (QcStairShapes). Derived from the states, server side only.

QString QcBlockDefinition::strippedInto

Block it turns into, keeping the state properties both have, when an item that strips (an axe) is used on it (a log losing its bark, decision E-753); empty for none. Server side only.

QcBlockSupport QcBlockDefinition::support

What the block needs next to it to stay ("support"; cross-shaped blocks default to below).

bool QcBlockDefinition::supportsAbove

Its top carries blocks that need support below although the top face is not full (rails on a Signal Hopper, decision E-386). Server side only.

QList<std::pair<QString, QString>> QcBlockDefinition::textureSlots

Further named textures that shape parts refer to (door halves), as slot -> texture.

QString QcBlockDefinition::tillsInto

Block it turns into when an item that tills (a hoe) is used on it, empty for none. Server side only.

bool QcBlockDefinition::toggles

Using the block flips its open property (doors, trapdoors, gates).

QString QcBlockDefinition::tool

Tool category that mines this block faster and may be required for drops, empty for none.

int QcBlockDefinition::toolLevel

Minimum tool tier for drops; 0 means hand works.

QString QcBlockDefinition::translationKey

Translation key of its display name ("translation"; derived from the name unless set, "block.<namespace>.<path>").

bool QcBlockDefinition::washable

A liquid flowing into the block breaks it with its drops (plants, torches). Server side only.

QString QcBlockDefinition::wearsInto

The anvil this one wears into when used or after a fall (chipped, damaged); empty: it breaks. Server side only.