QcMinecartMotion Namespace
How a minecart moves in one tick (decision E-382), for one cart on its own: on a rail it follows the track from end to end and on into the next rail whose end meets it (also up or down a slope), keeps its momentum, speeds up downhill and slows uphill and loses speed to drag. More...
| Header: | #include <server/minecarts/QcMinecartMotion.h> |
Classes
Variables
| const double | endInset |
| const double | maxSpeed |
| const double | restSpeed |
| const double | slopeAcceleration |
| const double | snapDistance |
Functions
| std::optional<QcMinecartMotion::Segment> | segmentAt(const QcVec3 &feet, const QcRails::Table &rails, const QcBlockAccess &world, bool fromAbove = false) |
| QcMinecartMotion::Result | step(QcMinecart &cart, const QcRails::Table &rails, const QcBlockAccess &world, double dt) |
| float | yawAlong(const QcVec3 &direction) |
Detailed Description
At the end of a track it stops before a block level with the end (a buffer stop), waits with its speed while the chunk beyond is not loaded, and else leaves the track with its velocity and flies on (decision E-430); off the rails it falls and slides like any body, coasting far on ice, and gets on a rail again that it comes close to. Deterministic: the same world and cart give the same result at every place and in every rotation.
Classes
class Result
What a step did to a cart. More...
class Segment
The track a cart is on: the cell, its ends in the world and the direction from the first to the second end, and its length. More...
Variable Documentation
const double QcMinecartMotion::endInset
A cart that stops at the end of a track (before a block) stays this far inside the rail's cell.
const double QcMinecartMotion::maxSpeed
Fastest speed along a track, metres per second (0.4 blocks per tick).
const double QcMinecartMotion::restSpeed
Slower than this on a level track or on the ground off the rails, a cart stands still.
const double QcMinecartMotion::slopeAcceleration
Pull of gravity along a slope, metres per second squared (0.0078125 blocks per tick squared).
const double QcMinecartMotion::snapDistance
A cart this close to a track (or closer) is on it.
Function Documentation
std::optional<QcMinecartMotion::Segment> QcMinecartMotion::segmentAt(const QcVec3 &feet, const QcRails::Table &rails, const QcBlockAccess &world, bool fromAbove = false)
Returns the track of rails in world the feet are on (the rail in their cell, below or above it), if one is close enough; fromAbove (a cart in the air) leaves out tracks whose nearest point lies higher than the feet.
QcMinecartMotion::Result QcMinecartMotion::step(QcMinecart &cart, const QcRails::Table &rails, const QcBlockAccess &world, double dt)
Advances cart on the tracks of rails in world by dt seconds. Returns what the step did.
float QcMinecartMotion::yawAlong(const QcVec3 &direction)
Returns the yaw (degrees, 0 looks north) of a cart moving along direction.