QcServerMinecarts Class
What players do with minecarts and how carts move in the server tick (decision E-382): placing a cart from its item on a rail, breaking it with a hit (it drops its item and what it carries), getting in with a use and out with sneak (a use of a container cart opens its screen instead), pushing it along with the forward key while riding, and the tick: carts move (QcMinecartManager), their riders go with them and hopper carts and hoppers under carts move items (QcMinecartHoppers). More...
| Header: | #include <server/minecarts/QcServerMinecarts.h> |
Public Functions
| bool | hit(QcServerClient &client, quint32 id) |
| const QcMinecartHoppers & | hoppers() const |
| void | leave(QcServerClient &client) |
| bool | place(QcServerClient &client, const QcMsg::UseItem &message) |
| std::optional<QcVec3> | restingPlace(QcBlockPos cell) const |
| QcMinecart * | spawn(QcMinecart cart) |
| bool | steer(QcServerClient &client, const QcPlayerInput &input) |
| QcMinecart * | summon(const QString &item, const QcVec3 &wanted, float yaw) |
| void | tick() |
| bool | use(QcServerClient &client, quint32 id) |
| quint32 | vehicleOf(const QcServerClient &client) const |
Static Public Members
| QcVec3 | exitSpot(const QcBlockAccess &world, const QcMinecart &cart) |
| const double | riderPushAcceleration |
| const double | riderPushTopSpeed |
| const double | seatTolerance |
Detailed Description
The server moves riders, never their input: a riding player's position is the cart's seat, so the client shows the player where it shows the cart and predicts nothing while riding.
Member Function Documentation
[static] QcVec3 QcServerMinecarts::exitSpot(const QcBlockAccess &world, const QcMinecart &cart)
Returns free ground in world for a player getting out of cart: its own cell, else beside it. Also where a rider is saved (QcServerPersistence), never the seat, which lies inside the block under the rail.
bool QcServerMinecarts::hit(QcServerClient &client, quint32 id)
Handles a hit of client on the cart id, which breaks it (dropping its item, except in creative mode); its rider gets out. Returns false when id is no cart.
const QcMinecartHoppers &QcServerMinecarts::hoppers() const
Returns the items moving between carts and blocks.
void QcServerMinecarts::leave(QcServerClient &client)
Gets the player client out of the cart and onto free ground beside it; nothing when not riding.
bool QcServerMinecarts::place(QcServerClient &client, const QcMsg::UseItem &message)
Places a cart from the held item of client on the rail message clicked. Returns false when the item places no cart. A refused placement (no rail, too far, another cart there, limit) still returns true.
std::optional<QcVec3> QcServerMinecarts::restingPlace(QcBlockPos cell) const
Returns where a cart stands on the rail at cell: the middle of its track; nothing for other blocks.
QcMinecart *QcServerMinecarts::spawn(QcMinecart cart)
Adds cart (commands, world setup, tests) with a new id. Returns it, or null when the limit is reached.
bool QcServerMinecarts::steer(QcServerClient &client, const QcPlayerInput &input)
Handles the input of client while riding: the view turns, sneak gets out, forward pushes the cart along. Returns false when the player rides no cart (the input moves the player as usual).
QcMinecart *QcServerMinecarts::summon(const QString &item, const QcVec3 &wanted, float yaw)
Returns a new cart of the cart item item with yaw near wanted (/summon): on the rail in the cell of wanted or the one below, standing along it, else at wanted itself, where it falls like a dropped cart. Null when the item places no cart or the limit is reached.
void QcServerMinecarts::tick()
Moves every cart one tick and takes the riders along, then the items of hopper carts.
bool QcServerMinecarts::use(QcServerClient &client, quint32 id)
Handles a use of the cart id by client: the player gets in, or looks into a container cart. Returns false when id is no cart.
quint32 QcServerMinecarts::vehicleOf(const QcServerClient &client) const
Returns the entity id of the cart the player client rides, 0 for none.
Member Variable Documentation
const double QcServerMinecarts::seatTolerance
A rider found further than this from the seat was moved by something else (a teleport, a respawn) and is no longer in the cart.