Class endstone::Location¶
ClassList > endstone > Location
Represents a 3-dimensional location in a dimension within a level.
#include <endstone/level/location.h>
Public Functions¶
| Type | Name |
|---|---|
| Location (Dimension & dimension, T x, T y, T z, const float pitch=0.0, const float yaw=0.0) |
|
| Result< float > | distance (const Location & other) const Get the distance between this location and another. |
| Result< float > | distanceSquared (const Location & other) const Get the squared distance between this location and another. |
| std::unique_ptr< Block > | getBlock () const Gets the block at the represented location. |
| int | getBlockX () const Gets the floored value of the X component, indicating the block that this location is contained with. |
| int | getBlockY () const Gets the floored value of the Y component, indicating the block that this location is contained with. |
| int | getBlockZ () const Gets the floored value of the Z component, indicating the block that this location is contained with. |
| Dimension & | getDimension () const Gets the dimension that this location resides in. |
| Vector | getDirection () const Gets a unit-vector pointing in the direction that this Location is facing. |
| float | getPitch () const Gets the pitch of this location, measured in degrees. |
| constexpr float | getX () const Gets the x-coordinate of this location. |
| constexpr float | getY () const Gets the y-coordinate of this location. |
| float | getYaw () const Gets the yaw of this location, measured in degrees. |
| constexpr float | getZ () const Gets the z-coordinate of this location. |
| float | length () const Gets the magnitude of the location, defined as sqrt(x2+y2+z^2). |
| constexpr float | lengthSquared () const Gets the magnitude of the location squared. |
| operator Vector () noexcept const |
|
| bool | operator!= (const Location & other) noexcept const |
| Location & | operator*= (T scalar) |
| Location & | operator+= (const Location & other) |
| Location & | operator+= (const Vector & other) |
| Location & | operator-= (const Location & other) |
| Location & | operator-= (const Vector & other) |
| bool | operator== (const Location & other) noexcept const |
| void | setDimension (Dimension & dimension) Sets the dimension that this position resides in. |
| Location & | setDirection (const Vector & vector) Sets the yaw and pitch to point in the direction of the vector. |
| void | setPitch (float pitch) Sets the pitch of this location, measured in degrees. |
| constexpr void | setX (T x) Sets the x-coordinate of this location. |
| constexpr void | setY (T y) Sets the y-coordinate of this location. |
| void | setYaw (float yaw) Sets the yaw of this location, measured in degrees. |
| constexpr void | setZ (T z) Sets the z-coordinate of this location. |
| constexpr Location & | zero () Zero this vector's components. Not world-aware. |
Public Static Functions¶
| Type | Name |
|---|---|
| float | normalizePitch (float pitch) Normalizes the given pitch angle to a value between +/-90 degrees. |
| float | normalizeYaw (float yaw) Normalizes the given yaw angle to a value between +/-180 degrees. |
Public Functions Documentation¶
function Location¶
template<std::convertible_to< float > T>
inline endstone::Location::Location (
Dimension & dimension,
T x,
T y,
T z,
const float pitch=0.0,
const float yaw=0.0
)
function distance¶
Get the distance between this location and another.
Parameters:
otherThe other location
Returns:
the distance
function distanceSquared¶
Get the squared distance between this location and another.
Parameters:
otherThe other location
Returns:
the distance
function getBlock¶
Gets the block at the represented location.
Returns:
Block at the represented location
function getBlockX¶
Gets the floored value of the X component, indicating the block that this location is contained with.
Returns:
block X
function getBlockY¶
Gets the floored value of the Y component, indicating the block that this location is contained with.
Returns:
block Y
function getBlockZ¶
Gets the floored value of the Z component, indicating the block that this location is contained with.
Returns:
block Z
function getDimension¶
Gets the dimension that this location resides in.
Returns:
Dimension that contains this location
function getDirection¶
Gets a unit-vector pointing in the direction that this Location is facing.
Returns:
a vector pointing the direction of this location's pitch and yaw
function getPitch¶
Gets the pitch of this location, measured in degrees.
Returns:
the incline's pitch
function getX¶
Gets the x-coordinate of this location.
Returns:
x-coordinate
function getY¶
Gets the y-coordinate of this location.
Returns:
y-coordinate
function getYaw¶
Gets the yaw of this location, measured in degrees.
Returns:
the rotation's yaw
function getZ¶
Gets the z-coordinate of this location.
Returns:
z-coordinate
function length¶
Gets the magnitude of the location, defined as sqrt(x2+y2+z^2).
Not world-aware and orientation independent.
Returns:
the magnitude
function lengthSquared¶
Gets the magnitude of the location squared.
Not world-aware and orientation independent.
Returns:
the magnitude
function operator Vector¶
function operator!=¶
function operator*=¶
template<std::convertible_to< float > T>
inline Location & endstone::Location::operator*= (
T scalar
)
function operator+=¶
function operator+=¶
function operator-=¶
function operator-=¶
function operator==¶
function setDimension¶
Sets the dimension that this position resides in.
Parameters:
dimensionNew dimension that this position resides in
function setDirection¶
Sets the yaw and pitch to point in the direction of the vector.
Parameters:
vectorthe direction vector
Returns:
the same location
function setPitch¶
Sets the pitch of this location, measured in degrees.
- A pitch of 0 represents level forward facing.
- A pitch of 90 represents downward facing, or negative y direction.
- A pitch of -90 represents upward facing, or positive y direction.
Increasing pitch values the equivalent of looking down.
Parameters:
pitchnew incline's pitch
function setX¶
Sets the x-coordinate of this location.
Parameters:
xX-coordinate
function setY¶
Sets the y-coordinate of this location.
Parameters:
yy-coordinate
function setYaw¶
Sets the yaw of this location, measured in degrees.
- A yaw of 0 or 360 represents the positive z direction.
- A yaw of 180 represents the negative z direction.
- A yaw of 90 represents the negative x direction.
- A yaw of 270 represents the positive x direction.
Increasing yaw values are the equivalent of turning to your right-facing, increasing the scale of the next respective axis, and decreasing the scale of the previous axis.
Parameters:
yawnew rotation's yaw
function setZ¶
Sets the z-coordinate of this location.
Parameters:
zz-coordinate
function zero¶
Zero this vector's components. Not world-aware.
Returns:
the same location
Public Static Functions Documentation¶
function normalizePitch¶
Normalizes the given pitch angle to a value between +/-90 degrees.
Parameters:
pitchthe pitch in degrees
Returns:
the normalized pitch in degrees
function normalizeYaw¶
Normalizes the given yaw angle to a value between +/-180 degrees.
Parameters:
yawthe yaw in degrees
Returns:
the normalized yaw in degrees
The documentation for this class was generated from the following file include/endstone/level/location.h