QtCraft API C++ classes QML types Handbook

QcServerCircuits Class

The Signal Dust circuits of the server: the tick phase "signal" (decision E-335). More...

Header: #include <server/signal/QcServerCircuits.h>

Public Functions

bool hitTarget(QcBlockPos pos, int power, bool stuck)
const QcServerHoppers &hoppers() const
qsizetype lastTickWork() const
void noteBlock(QcBlockPos pos)
void playNote(QcBlockPos pos)
void setEquipPlayer(QcDispenserActions::EquipPlayer equip)
void setIgnite(QcDispenserActions::Ignite ignite)
void setLight(QcDispenserActions::Ignite light)
const QcSignalTable &table() const
void tick()
bool use(QcBlockPos pos)

Static Public Members

const int openerRetryTicks
const int pruneIntervalTicks
int targetStrength(QcBlockPos pos, QcBlockFace face, const QcVec3 &point)

Detailed Description

Each tick it presses plates, then looks at the block changes near circuits since the last step and at the scheduled ticks that are due, in steps: a step decides everything on the world as it is (dust networks in one pass, components, pistons) and applies it together; the changes it makes are the next step. Steps run until the circuits are quiet or the tick's budget is used up; what is left waits for the next tick, so a runaway circuit never stalls the server.

Member Function Documentation

bool QcServerCircuits::hitTarget(QcBlockPos pos, int power, bool stuck)

A projectile hit the target block at pos with power (1..15, decision E-768); stuck for projectiles that stick (arrows), which hold it longer. A new hit replaces the strength and starts the time again. Returns false when it is no target.

const QcServerHoppers &QcServerCircuits::hoppers() const

Returns the Signal Hoppers.

qsizetype QcServerCircuits::lastTickWork() const

Returns the work done in the latest tick (debug display).

void QcServerCircuits::noteBlock(QcBlockPos pos)

Makes the circuits around pos look at it in the next step, as if it had just been placed (world setup, chunks generated again).

void QcServerCircuits::playNote(QcBlockPos pos)

Plays the note of the note block at pos (decision E-767): its instrument comes from the block below, its pitch from the state note; nothing sounds while a block lies on top or while the note budget (QcNoteBudget) holds the block back.

void QcServerCircuits::setEquipPlayer(QcDispenserActions::EquipPlayer equip)

Sets equip, how a dispenser puts armour on a player (the server's inventory part does it).

void QcServerCircuits::setIgnite(QcDispenserActions::Ignite ignite)

Sets ignite, how a dispenser lights fire with flint and steel.

void QcServerCircuits::setLight(QcDispenserActions::Ignite light)

Sets light, how a powered igniter lights its explosive (QcServerExplosions::light, decision E-601).

const QcSignalTable &QcServerCircuits::table() const

Returns the signal states of the content's blocks.

[static] int QcServerCircuits::targetStrength(QcBlockPos pos, QcBlockFace face, const QcVec3 &point)

Returns the strength of a hit at point (world space) on the face face of the block at pos: 15 in the middle, falling evenly to 1 at the edges (the larger distance along the face's two axes, as in the reference).

void QcServerCircuits::tick()

Runs the signal phase of one server tick.

bool QcServerCircuits::use(QcBlockPos pos)

A player uses the block at pos: a lever switches, a button is pressed, a repeater takes its next delay, a note block its next note (and plays it). Returns false when it is no such block.

Member Variable Documentation

const int QcServerCircuits::openerRetryTicks

The budget of work per tick (dust looked at, components evaluated, blocks pushed, bodies looked at), the share kept for due scheduled ticks, the work a change counts for and the least changes a step takes come from QcServerLimits (decision E-349). A step takes at most what is left (split in a fixed order of positions); a dust region or a piston's push in it can still cross it, nothing starts after that. A signal door that a body kept from moving tries again after this many ticks.

const int QcServerCircuits::pruneIntervalTicks

Memories of torches, burnouts and extensions that ran out are dropped this often.