1
2
Fork 0
mirror of https://github.com/mat-1/azalea.git synced 2025-08-02 14:26:04 +00:00

update some From methods to use rem_euclid

This commit is contained in:
Ubuntu 2022-11-01 15:51:04 +00:00
parent 17a55728f7
commit 3950b9cf95

View file

@ -233,9 +233,9 @@ impl From<ChunkSectionPos> for ChunkPos {
impl From<&BlockPos> for ChunkBlockPos {
fn from(pos: &BlockPos) -> Self {
ChunkBlockPos {
x: pos.x.rem_euclid(16).unsigned_abs() as u8,
x: pos.x.rem_euclid(16) as u8,
y: pos.y,
z: pos.z.rem_euclid(16).unsigned_abs() as u8,
z: pos.z.rem_euclid(16) as u8,
}
}
}
@ -243,9 +243,9 @@ impl From<&BlockPos> for ChunkBlockPos {
impl From<&BlockPos> for ChunkSectionBlockPos {
fn from(pos: &BlockPos) -> Self {
ChunkSectionBlockPos {
x: pos.x.rem(16).unsigned_abs() as u8,
y: pos.y.rem(16).unsigned_abs() as u8,
z: pos.z.rem(16).unsigned_abs() as u8,
x: pos.x.rem_euclid(16) as u8,
y: pos.y.rem_euclid(16) as u8,
z: pos.z.rem_euclid(16) as u8,
}
}
}
@ -254,7 +254,7 @@ impl From<&ChunkBlockPos> for ChunkSectionBlockPos {
fn from(pos: &ChunkBlockPos) -> Self {
ChunkSectionBlockPos {
x: pos.x,
y: pos.y.rem(16).unsigned_abs() as u8,
y: pos.y.rem_euclid(16) as u8,
z: pos.z,
}
}
@ -392,8 +392,11 @@ mod tests {
assert_eq!(block_pos, BlockPos::new(49, -43, -3));
}
#{test}
#[test]
fn test_into_chunk_section_block_pos() {
let block_pos = BlockPos::new(0, -60, 0);
let section_pos = ChunkSectionBlockPos::from(&block_pos);
assert_eq!(section_pos, ChunkSectionBlockPos::new(0, 4, 0));
// TODO
}
}