pub struct Vec3 {
pub x: f64,
pub y: f64,
pub z: f64,
}
Expand description
Used to represent an exact position in the world where an entity could be.
For blocks, BlockPos
is used instead.
Fields§
§x: f64
§y: f64
§z: f64
Implementations§
Source§impl Vec3
impl Vec3
pub const fn new(x: f64, y: f64, z: f64) -> Vec3
Sourcepub fn length_squared(&self) -> f64
pub fn length_squared(&self) -> f64
Get the distance of this vector to the origin by doing x^2 + y^2 + z^2
.
Sourcepub fn distance_squared_to(&self, other: &Vec3) -> f64
pub fn distance_squared_to(&self, other: &Vec3) -> f64
Get the squared distance from this position to another position.
Equivalent to (self - other).length_squared()
.
pub fn horizontal_distance_squared(&self) -> f64
pub fn horizontal_distance_squared_to(&self, other: &Vec3) -> f64
Sourcepub fn down(&self, y: f64) -> Vec3
pub fn down(&self, y: f64) -> Vec3
Return a new instance of this position with the y coordinate decreased by the given number.
Sourcepub fn up(&self, y: f64) -> Vec3
pub fn up(&self, y: f64) -> Vec3
Return a new instance of this position with the y coordinate increased by the given number.
Sourcepub fn north(&self, z: f64) -> Vec3
pub fn north(&self, z: f64) -> Vec3
Return a new instance of this position with the z coordinate subtracted by the given number.
Sourcepub fn east(&self, x: f64) -> Vec3
pub fn east(&self, x: f64) -> Vec3
Return a new instance of this position with the x coordinate increased by the given number.
Sourcepub fn south(&self, z: f64) -> Vec3
pub fn south(&self, z: f64) -> Vec3
Return a new instance of this position with the z coordinate increased by the given number.
Sourcepub fn west(&self, x: f64) -> Vec3
pub fn west(&self, x: f64) -> Vec3
Return a new instance of this position with the x coordinate subtracted by the given number.
pub fn dot(&self, other: Vec3) -> f64
Source§impl Vec3
impl Vec3
pub const ZERO: Vec3
Sourcepub fn length(&self) -> f64
pub fn length(&self) -> f64
Get the distance of this vector to the origin by doing
sqrt(x^2 + y^2 + z^2)
.
Sourcepub fn distance_to(&self, other: &Vec3) -> f64
pub fn distance_to(&self, other: &Vec3) -> f64
Get the distance from this position to another position.
Equivalent to (self - other).length()
.
pub fn x_rot(self, radians: f32) -> Vec3
pub fn y_rot(self, radians: f32) -> Vec3
Trait Implementations§
Source§impl AddAssign for Vec3
impl AddAssign for Vec3
Source§fn add_assign(&mut self, rhs: Vec3)
fn add_assign(&mut self, rhs: Vec3)
+=
operation. Read moreSource§impl AzaleaRead for Vec3
impl AzaleaRead for Vec3
fn azalea_read(buf: &mut Cursor<&[u8]>) -> Result<Vec3, BufReadError>
Source§impl AzaleaWrite for Vec3
impl AzaleaWrite for Vec3
Source§impl<'de> Deserialize<'de> for Vec3
impl<'de> Deserialize<'de> for Vec3
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Vec3, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Vec3, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl DivAssign<f64> for Vec3
impl DivAssign<f64> for Vec3
Source§fn div_assign(&mut self, divisor: f64)
fn div_assign(&mut self, divisor: f64)
/=
operation. Read moreSource§impl From<&LastSentPosition> for Vec3
impl From<&LastSentPosition> for Vec3
Source§fn from(value: &LastSentPosition) -> Vec3
fn from(value: &LastSentPosition) -> Vec3
Source§impl FromStr for Vec3
Parses a string in the format “X Y Z” into a Vec3.
impl FromStr for Vec3
Parses a string in the format “X Y Z” into a Vec3.
The input string should contain three floating-point values separated by
spaces, representing the x, y, and z components of the vector respectively.
This can be used to parse user input or from Vec3::to_string
.
Source§impl MulAssign<f64> for Vec3
impl MulAssign<f64> for Vec3
Source§fn mul_assign(&mut self, multiplier: f64)
fn mul_assign(&mut self, multiplier: f64)
*=
operation. Read moreSource§impl Serialize for Vec3
impl Serialize for Vec3
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl Copy for Vec3
impl StructuralPartialEq for Vec3
Auto Trait Implementations§
impl Freeze for Vec3
impl RefUnwindSafe for Vec3
impl Send for Vec3
impl Sync for Vec3
impl Unpin for Vec3
impl UnwindSafe for Vec3
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Creates Self
using default()
.