QtCraft API C++ classes QML types Handbook

QcServerAnvil Class

The anvil's screen in the server (decision E-866), as in the reference game: using an anvil opens it; the player puts a stack into the left slot (machineInputSlot) and optionally material, a second item of the kind or nothing into the right slot (machineFuelSlot), types a name and takes the output (QcAnvil::result) for its levels (nothing in creative mode). More...

Header: #include <server/machines/QcServerAnvil.h>

Public Functions

QcServerAnvil(const QcServerAnvil &)
~QcServerAnvil()
void close(QcServerClient &client, bool notify)
void forge(QcServerClient &client, const QcMsg::ForgeAnvil &request)
bool open(QcServerClient &client, QcBlockPos pos)
void rename(QcServerClient &client, const QcMsg::RenameAnvil &request)
void update()
QcServerAnvil &operator=(const QcServerAnvil &)

Static Public Members

QcAnvil::Result resultFor(const QcServerState &state, const QcServerClient &client)
QcMsg::AnvilState stateOf(const QcServerState &state, const QcServerClient &client)
void wear(QcServerState &state, QcServerBlocks &blocks, QcServerSounds &sounds, QcBlockPos pos)

Detailed Description

Taking it uses up the left stack and what the right one gave, and wears the anvil one step with QcAnvil::wearChance (QcBlockDefinition::wearsInto; the last step breaks it). The screen closes when the anvil is gone, out of reach, the player died or became a spectator; the slots then go back.

Member Function Documentation

[delete] QcServerAnvil::QcServerAnvil(const QcServerAnvil &)

The closer registered with QcBlockScreens refers to this object.

[constexpr noexcept default] QcServerAnvil::~QcServerAnvil()

Destroys the instance of QcServerAnvil.

void QcServerAnvil::close(QcServerClient &client, bool notify)

Gives the slots back to client and forgets the screen; notify tells the client (the server closed it).

void QcServerAnvil::forge(QcServerClient &client, const QcMsg::ForgeAnvil &request)

Takes the output for client when it is still the output and cost of request the client saw and the player can pay.

bool QcServerAnvil::open(QcServerClient &client, QcBlockPos pos)

Opens the screen of the anvil at pos for client. Returns false when it is no anvil. Any other screen closes; the same anvil again keeps its slots.

void QcServerAnvil::rename(QcServerClient &client, const QcMsg::RenameAnvil &request)

Sets the text of the name field of client to that of request; the client gets the new AnvilState (not the inventory).

[static] QcAnvil::Result QcServerAnvil::resultFor(const QcServerState &state, const QcServerClient &client)

Returns what the anvil client has open in state makes now; empty without an open anvil.

[static] QcMsg::AnvilState QcServerAnvil::stateOf(const QcServerState &state, const QcServerClient &client)

Returns the state message for the anvil client has open in state; QcServerInventory::send sends it with every inventory state while the anvil is open.

void QcServerAnvil::update()

Once per tick: closes the screens that may not stay open.

[static] void QcServerAnvil::wear(QcServerState &state, QcServerBlocks &blocks, QcServerSounds &sounds, QcBlockPos pos)

Wears the anvil at pos of state one step: into QcBlockDefinition::wearsInto (set with blocks), or it breaks with its sound from sounds.

[delete] QcServerAnvil &QcServerAnvil::operator=(const QcServerAnvil &)

Copy-assigns other to this QcServerAnvil instance. This function is deleted.