From 0d16f01571ec8315f3979eae46981e559ade1cf9 Mon Sep 17 00:00:00 2001 From: mat <27899617+mat-1@users.noreply.github.com> Date: Fri, 10 Jan 2025 16:45:27 -0600 Subject: 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 --- azalea-core/src/position.rs | 49 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) (limited to 'azalea-core/src/position.rs') 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 -- cgit v1.2.3