QcServerGameModes Class
The game modes of the players (decisions E-282 to E-285): the mode of new players, changing a player's mode with the inventory set that belongs to it, the items of the creative catalogue and picking blocks with the middle mouse button. More...
| Header: | #include <server/gameplay/QcServerGameModes.h> |
Public Functions
| void | creativeItem(QcServerClient &client, const QcMsg::CreativeItem &message) |
| QcGameMode | defaultMode() const |
| void | pickBlock(QcServerClient &client, QcBlockPos pos) |
| void | sendAdventureRules() const |
| bool | setMode(QcServerClient &client, QcGameMode mode) |
Static Public Members
| void | applyRules(QcServerClient &client) |
| std::optional<QcItemId> | itemForBlock(const QcContentRegistry &content, QcBlockId block) |
| void | send(QcServerClient &client, const QcAdventureRules &adventure) |
Detailed Description
Member Function Documentation
[static] void QcServerGameModes::applyRules(QcServerClient &client)
Applies to client what follows from its mode without changing it (frozen hunger); after joining.
void QcServerGameModes::creativeItem(QcServerClient &client, const QcMsg::CreativeItem &message)
Handles message (QcMsg::CreativeItem) of client: refused (the inventory is sent again) unless the player's mode has the item catalogue.
QcGameMode QcServerGameModes::defaultMode() const
Returns the mode of a player who joins the world for the first time: the server's setting (server.json, an unsaved world) or else the world's default.
[static] std::optional<QcItemId> QcServerGameModes::itemForBlock(const QcContentRegistry &content, QcBlockId block)
Returns the item of content that stands for block: the block's own item, else one that places it (seeds for a crop), else its first drop.
void QcServerGameModes::pickBlock(QcServerClient &client, QcBlockPos pos)
Handles QcMsg::PickBlock of client for the block at pos: selects the block's item in the hotbar or swaps it in from the storage rows; in creative mode it comes from the catalogue when the inventory has none.
[static] void QcServerGameModes::send(QcServerClient &client, const QcAdventureRules &adventure)
Sends client its mode; in adventure mode with the world's allow-lists adventure (decision E-735).
void QcServerGameModes::sendAdventureRules() const
The world's allow-lists changed (/adventure): every playing adventure player gets them.
bool QcServerGameModes::setMode(QcServerClient &client, QcGameMode mode)
Puts the player client into mode. A mode of the other inventory set swaps the inventory and armour with the kept ones (a backpack open in the hand is closed and the crafting grid goes back into the old inventory first; decision E-283); a mode without flight ends a flight; a mode without a body leaves the minecart; leaving spectator mode stops the flight's momentum and lifts a player inside blocks out of them (decision E-730). Tells the player, sends the inventory and the player list again. Returns true when the inventory set was swapped.