diff options
| author | mat <27899617+mat-1@users.noreply.github.com> | 2025-03-16 13:41:17 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-03-16 13:41:17 -0500 |
| commit | b0bd992adcff71ee294dd05060e00e652f62a7b2 (patch) | |
| tree | 0a36d8b37befbc75c8c65cc2c8779c3df66bd87b /azalea-core/src/position.rs | |
| parent | a95408cbcc05b5bd04a084b0a286b571069206f6 (diff) | |
| download | azalea-drasl-b0bd992adcff71ee294dd05060e00e652f62a7b2.tar.xz | |
Fluid physics fixes (#210)
* start fixing code related to fluid physics
* implement force_solid for blocks
* afk pool test
Diffstat (limited to 'azalea-core/src/position.rs')
| -rwxr-xr-x | azalea-core/src/position.rs | 25 |
1 files changed, 25 insertions, 0 deletions
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<ChunkSectionPos> 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<Vec3> for ChunkSectionPos { + fn from(pos: Vec3) -> Self { + ChunkSectionPos::from(&pos) + } +} impl From<&BlockPos> for ChunkBlockPos { #[inline] |
