Add pumpkin-world
also refactor player
This commit is contained in:
1 parent
31aa333410
commit
ae69bbc7f1
20 files changed
+342
-268
No files matched your search
@@ -0,0 +1,10 @@
|
||||
[package]
|
||||
name = "pumpkin-world"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
|
||||
[dependencies]
|
||||
pumpkin-protocol = { path = "../pumpkin-protocol"}
|
||||
fastanvil = "0.31"
|
||||
fastnbt = { git = "https://github.com/owengage/fastnbt.git" }
|
||||
fastsnbt = "0.2"
|
||||
@@ -0,0 +1,20 @@
|
||||
use fastnbt::{nbt, SerOpts};
|
||||
|
||||
pub const BLOCKS_AND_BIOMES: [u8; 2000] = [0x80; 2000];
|
||||
pub const SKY_LIGHT_ARRAYS: [FixedArray<u8, 2048>; 26] = [FixedArray([0xff; 2048]); 26];
|
||||
|
||||
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
|
||||
#[repr(transparent)]
|
||||
pub struct FixedArray<T, const N: usize>(pub [T; N]);
|
||||
|
||||
pub struct TestChunk {
|
||||
pub heightmap: Vec<u8>,
|
||||
}
|
||||
|
||||
impl TestChunk {
|
||||
pub fn new() -> Self {
|
||||
let bytes = fastnbt::to_bytes(&nbt!({"MOTION_BLOCKING": [L; 123, 256]})).unwrap();
|
||||
|
||||
Self { heightmap: bytes }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
use std::{fs::File, path::Path};
|
||||
|
||||
use fastanvil::{complete, Chunk, Region};
|
||||
|
||||
pub mod chunk;
|
||||
|
||||
pub struct World {
|
||||
pub region: Region<File>,
|
||||
}
|
||||
|
||||
impl World {
|
||||
pub fn load<P: AsRef<Path>>(path: P) -> Self {
|
||||
let file = std::fs::File::open(path).unwrap();
|
||||
|
||||
let region = Region::from_stream(file).unwrap();
|
||||
Self { region }
|
||||
}
|
||||
|
||||
/* pub fn load_chunk(&mut self, x: usize, y: usize) -> Chunk {
|
||||
let data = self.region.read_chunk(x, y).unwrap().unwrap();
|
||||
|
||||
let complete_chunk = complete::Chunk::from_bytes(&data).unwrap();
|
||||
|
||||
}
|
||||
*/
|
||||
}
|
||||
Reference in new issue
Block a user