Skip to content

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.

inline Result< float > endstone::Location::distance (
    const Location & other
) const

Parameters:

  • other The other location

Returns:

the distance


function distanceSquared

Get the squared distance between this location and another.

inline Result< float > endstone::Location::distanceSquared (
    const Location & other
) const

Parameters:

  • other The other location

Returns:

the distance


function getBlock

Gets the block at the represented location.

inline std::unique_ptr< Block > endstone::Location::getBlock () const

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.

inline int endstone::Location::getBlockX () const

Returns:

block X


function getBlockY

Gets the floored value of the Y component, indicating the block that this location is contained with.

inline int endstone::Location::getBlockY () const

Returns:

block Y


function getBlockZ

Gets the floored value of the Z component, indicating the block that this location is contained with.

inline int endstone::Location::getBlockZ () const

Returns:

block Z


function getDimension

Gets the dimension that this location resides in.

inline Dimension & endstone::Location::getDimension () const

Returns:

Dimension that contains this location


function getDirection

Gets a unit-vector pointing in the direction that this Location is facing.

inline Vector endstone::Location::getDirection () const

Returns:

a vector pointing the direction of this location's pitch and yaw


function getPitch

Gets the pitch of this location, measured in degrees.

inline float endstone::Location::getPitch () const

Returns:

the incline's pitch


function getX

Gets the x-coordinate of this location.

inline constexpr float endstone::Location::getX () const

Returns:

x-coordinate


function getY

Gets the y-coordinate of this location.

inline constexpr float endstone::Location::getY () const

Returns:

y-coordinate


function getYaw

Gets the yaw of this location, measured in degrees.

inline float endstone::Location::getYaw () const

Returns:

the rotation's yaw


function getZ

Gets the z-coordinate of this location.

inline constexpr float endstone::Location::getZ () const

Returns:

z-coordinate


function length

Gets the magnitude of the location, defined as sqrt(x2+y2+z^2).

inline float endstone::Location::length () const

Not world-aware and orientation independent.

Returns:

the magnitude


function lengthSquared

Gets the magnitude of the location squared.

inline constexpr float endstone::Location::lengthSquared () const

Not world-aware and orientation independent.

Returns:

the magnitude


function operator Vector

inline endstone::Location::operator Vector () noexcept const

function operator!=

inline bool endstone::Location::operator!= (
    const Location & other
) noexcept const

function operator*=

template<std::convertible_to< float > T>
inline Location & endstone::Location::operator*= (
    T scalar
) 

function operator+=

inline Location & endstone::Location::operator+= (
    const Location & other
) 

function operator+=

inline Location & endstone::Location::operator+= (
    const Vector & other
) 

function operator-=

inline Location & endstone::Location::operator-= (
    const Location & other
) 

function operator-=

inline Location & endstone::Location::operator-= (
    const Vector & other
) 

function operator==

inline bool endstone::Location::operator== (
    const Location & other
) noexcept const

function setDimension

Sets the dimension that this position resides in.

inline void endstone::Location::setDimension (
    Dimension & dimension
) 

Parameters:

  • dimension New dimension that this position resides in

function setDirection

Sets the yaw and pitch to point in the direction of the vector.

inline Location & endstone::Location::setDirection (
    const Vector & vector
) 

Parameters:

  • vector the direction vector

Returns:

the same location


function setPitch

Sets the pitch of this location, measured in degrees.

inline void endstone::Location::setPitch (
    float pitch
) 

  • 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:

  • pitch new incline's pitch

function setX

Sets the x-coordinate of this location.

template<std::convertible_to< float > T>
inline constexpr void endstone::Location::setX (
    T x
) 

Parameters:

  • x X-coordinate

function setY

Sets the y-coordinate of this location.

template<std::convertible_to< float > T>
inline constexpr void endstone::Location::setY (
    T y
) 

Parameters:

  • y y-coordinate

function setYaw

Sets the yaw of this location, measured in degrees.

inline void endstone::Location::setYaw (
    float yaw
) 

  • 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:

  • yaw new rotation's yaw

function setZ

Sets the z-coordinate of this location.

template<std::convertible_to< float > T>
inline constexpr void endstone::Location::setZ (
    T z
) 

Parameters:

  • z z-coordinate

function zero

Zero this vector's components. Not world-aware.

inline constexpr Location & endstone::Location::zero () 

Returns:

the same location


Public Static Functions Documentation

function normalizePitch

Normalizes the given pitch angle to a value between +/-90 degrees.

static inline float endstone::Location::normalizePitch (
    float pitch
) 

Parameters:

  • pitch the pitch in degrees

Returns:

the normalized pitch in degrees


function normalizeYaw

Normalizes the given yaw angle to a value between +/-180 degrees.

static inline float endstone::Location::normalizeYaw (
    float yaw
) 

Parameters:

  • yaw the 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