aboutsummaryrefslogtreecommitdiff
path: root/azalea-core/src/position.rs
diff options
context:
space:
mode:
authormat <27899617+mat-1@users.noreply.github.com>2025-01-10 16:45:27 -0600
committerGitHub <noreply@github.com>2025-01-10 16:45:27 -0600
commit0d16f01571ec8315f3979eae46981e559ade1cf9 (patch)
treeea43c32a57b0e6a67579d75a134dfbc009d09781 /azalea-core/src/position.rs
parent615d8f9d2ac56b3244d328587243301da253eafd (diff)
downloadazalea-drasl-0d16f01571ec8315f3979eae46981e559ade1cf9.tar.xz
Fluid physics (#199)
* start implementing fluid physics * Initial implementation of fluid pushing * different travel function in water * bubble columns * jumping in water * cleanup * change ultrawarm to be required * fix for clippy
Diffstat (limited to 'azalea-core/src/position.rs')
-rwxr-xr-xazalea-core/src/position.rs49
1 files changed, 47 insertions, 2 deletions
diff --git a/azalea-core/src/position.rs b/azalea-core/src/position.rs
index 819d72cf..cba58415 100755
--- a/azalea-core/src/position.rs
+++ b/azalea-core/src/position.rs
@@ -8,11 +8,12 @@ use std::{
fmt,
hash::Hash,
io::{Cursor, Write},
- ops::{Add, AddAssign, Mul, Rem, Sub},
+ ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Rem, Sub},
};
use azalea_buf::{AzBuf, AzaleaRead, AzaleaWrite, BufReadError};
+use crate::direction::Direction;
use crate::math;
use crate::resource_location::ResourceLocation;
@@ -138,7 +139,6 @@ macro_rules! vec3_impl {
}
}
}
-
impl Add for $name {
type Output = $name;
@@ -147,6 +147,18 @@ macro_rules! vec3_impl {
(&self).add(&rhs)
}
}
+ impl Add<$type> for $name {
+ type Output = Self;
+
+ #[inline]
+ fn add(self, rhs: $type) -> Self::Output {
+ Self {
+ x: self.x + rhs,
+ y: self.y + rhs,
+ z: self.z + rhs,
+ }
+ }
+ }
impl AddAssign for $name {
#[inline]
@@ -203,6 +215,35 @@ macro_rules! vec3_impl {
}
}
}
+ impl MulAssign<$type> for $name {
+ #[inline]
+ fn mul_assign(&mut self, multiplier: $type) {
+ self.x *= multiplier;
+ self.y *= multiplier;
+ self.z *= multiplier;
+ }
+ }
+
+ impl Div<$type> for $name {
+ type Output = Self;
+
+ #[inline]
+ fn div(self, divisor: $type) -> Self::Output {
+ Self {
+ x: self.x / divisor,
+ y: self.y / divisor,
+ z: self.z / divisor,
+ }
+ }
+ }
+ impl DivAssign<$type> for $name {
+ #[inline]
+ fn div_assign(&mut self, divisor: $type) {
+ self.x /= divisor;
+ self.y /= divisor;
+ self.z /= divisor;
+ }
+ }
impl From<($type, $type, $type)> for $name {
#[inline]
@@ -345,6 +386,10 @@ impl BlockPos {
z: self.z.max(other.z),
}
}
+
+ pub fn offset_with_direction(self, direction: Direction) -> Self {
+ self + direction.normal()
+ }
}
/// Chunk coordinates are used to represent where a chunk is in the world. You