From b0bd992adcff71ee294dd05060e00e652f62a7b2 Mon Sep 17 00:00:00 2001 From: mat <27899617+mat-1@users.noreply.github.com> Date: Sun, 16 Mar 2025 13:41:17 -0500 Subject: Fluid physics fixes (#210) * start fixing code related to fluid physics * implement force_solid for blocks * afk pool test --- azalea-core/src/position.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'azalea-core/src/position.rs') diff --git a/azalea-core/src/position.rs b/azalea-core/src/position.rs index cba58415..5d923d39 100755 --- a/azalea-core/src/position.rs +++ b/azalea-core/src/position.rs @@ -309,6 +309,21 @@ impl Vec3 { let z = self.z * (x_delta as f64) - self.x * (y_delta as f64); Vec3 { x, y, z } } + + pub fn to_block_pos_floor(&self) -> BlockPos { + BlockPos { + x: self.x.floor() as i32, + y: self.y.floor() as i32, + z: self.z.floor() as i32, + } + } + pub fn to_block_pos_ceil(&self) -> BlockPos { + BlockPos { + x: self.x.ceil() as i32, + y: self.y.ceil() as i32, + z: self.z.ceil() as i32, + } + } } /// The coordinates of a block in the world. For entities (if the coordinate @@ -600,6 +615,16 @@ impl From for ChunkPos { ChunkPos { x: pos.x, z: pos.z } } } +impl From<&Vec3> for ChunkSectionPos { + fn from(pos: &Vec3) -> Self { + ChunkSectionPos::from(&BlockPos::from(pos)) + } +} +impl From for ChunkSectionPos { + fn from(pos: Vec3) -> Self { + ChunkSectionPos::from(&pos) + } +} impl From<&BlockPos> for ChunkBlockPos { #[inline] -- cgit v1.2.3