diff options
author | metamuffin <metamuffin@disroot.org> | 2022-10-17 21:11:40 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2022-10-17 21:11:40 +0200 |
commit | bcfc5827a949172aedbd6c7cd1881a47db42c46d (patch) | |
tree | a2108ffcc669059826a0828ee1fe0a703225a04a /src/dimension.rs | |
parent | fd1ce9167662f37880b40e8eab4c125c7f2b2b6a (diff) | |
download | trash-map-bcfc5827a949172aedbd6c7cd1881a47db42c46d.tar trash-map-bcfc5827a949172aedbd6c7cd1881a47db42c46d.tar.bz2 trash-map-bcfc5827a949172aedbd6c7cd1881a47db42c46d.tar.zst |
start with http
Diffstat (limited to 'src/dimension.rs')
-rw-r--r-- | src/dimension.rs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/dimension.rs b/src/dimension.rs index 39a7fff..6c3bea8 100644 --- a/src/dimension.rs +++ b/src/dimension.rs @@ -1,6 +1,6 @@ use chashmap::{CHashMap, ReadGuard, WriteGuard}; use fastanvil::{Block, Chunk, CurrentJavaChunk, Region, RegionFileLoader, RegionLoader}; -use log::{info, debug}; +use log::{debug, info}; use std::{fs::File, path::Path}; pub struct Dimension { @@ -8,6 +8,7 @@ pub struct Dimension { regions: CHashMap<(isize, isize), Option<Region<File>>>, chunks: CHashMap<(isize, isize), Option<CurrentJavaChunk>>, } + impl Dimension { pub fn new(path: &str) -> Self { let loader = fastanvil::RegionFileLoader::new(Path::new(path).to_path_buf()); @@ -17,6 +18,7 @@ impl Dimension { chunks: Default::default(), } } + pub fn region( &self, rx: isize, @@ -34,6 +36,7 @@ impl Dimension { self.region(rx, rz) } } + pub fn chunk( &self, cx: isize, @@ -55,10 +58,11 @@ impl Dimension { self.chunk(cx, cz) } } + pub fn block(&self, x: isize, y: isize, z: isize) -> Option<Block> { self.chunk(x / 16, z / 16) .as_ref()? - .block(x.rem_euclid(16) as usize, y, z.rem_euclid(16) as usize) + .block((x % 16).abs() as usize, y, (z % 16).abs() as usize) .map(|e| e.to_owned()) } } |