QtCraft API C++ classes QML types Handbook

QcServerEnchanting Class

The enchanting table's screen in the server (decision E-864), as in the reference game: using a table opens it; the player puts an item into the item slot (machineInputSlot) and lapis lazuli into the lapis slot (machineFuelSlot) and sees three offers, whose levels depend on the bookshelves around the table (QcEnchantingTable::shelvesAround) and whose enchantments follow from the player's enchantment seed. More...

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

Public Functions

QcServerEnchanting(const QcServerEnchanting &)
~QcServerEnchanting()
void choose(QcServerClient &client, QcMsg::ChooseEnchantment request)
void close(QcServerClient &client, bool notify)
bool open(QcServerClient &client, QcBlockPos pos)
void update()
QcServerEnchanting &operator=(const QcServerEnchanting &)

Static Public Members

QcEnchantingTable::Offers offersFor(QcServerState &state, QcServerClient &client)
QcMsg::EnchantingState stateOf(QcServerState &state, QcServerClient &client)

Detailed Description

Taking offer n (0–2) needs its level, costs n + 1 levels and n + 1 lapis (nothing in creative mode), enchants the item and draws a new seed. The screen closes when the table is gone, out of reach, the player died or became a spectator; the slots then go back.

Member Function Documentation

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

The closer registered with QcBlockScreens refers to this object.

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

Destroys the instance of QcServerEnchanting.

void QcServerEnchanting::choose(QcServerClient &client, QcMsg::ChooseEnchantment request)

Takes offer request.slot of request when the player client can pay for it; the client gets the slots either way.

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

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

[static] QcEnchantingTable::Offers QcServerEnchanting::offersFor(QcServerState &state, QcServerClient &client)

Returns the offers the player client of state sees at the open table now; none without an open table. Draws the player's seed on first use.

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

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

[static] QcMsg::EnchantingState QcServerEnchanting::stateOf(QcServerState &state, QcServerClient &client)

Returns the state message for the table client has open in state (slots, shelves, clues); QcServerInventory::send sends it with every inventory state while the table is open.

void QcServerEnchanting::update()

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

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

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