diff --git a/Cargo.lock b/Cargo.lock index 04af64699..b3e8d2655 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -534,15 +534,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "crossbeam-channel" -version = "0.5.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33480d6946193aa8033910124896ca395333cae7e2d1113d1fef6c3272217df2" -dependencies = [ - "crossbeam-utils", -] - [[package]] name = "crossbeam-deque" version = "0.8.5" @@ -1856,7 +1847,6 @@ version = "0.1.0-dev" dependencies = [ "base64 0.22.1", "bytes", - "crossbeam-channel", "ctrlc", "digest 0.11.0-pre.9", "hmac", @@ -1886,7 +1876,6 @@ dependencies = [ "simple_logger", "thiserror", "tokio", - "toml", "uuid", ] @@ -1917,8 +1906,6 @@ dependencies = [ name = "pumpkin-entity" version = "0.1.0" dependencies = [ - "num-derive", - "num-traits", "pumpkin-core", ] @@ -1966,8 +1953,6 @@ dependencies = [ "pumpkin-macros", "pumpkin-world", "serde", - "serde_json", - "take_mut", "thiserror", "uuid", ] @@ -2657,12 +2642,6 @@ dependencies = [ "winx", ] -[[package]] -name = "take_mut" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f764005d11ee5f36500a149ace24e00e3da98b0158b3e2d53a7495660d3f4d60" - [[package]] name = "target-lexicon" version = "0.12.16" diff --git a/pumpkin-entity/Cargo.toml b/pumpkin-entity/Cargo.toml index 2b96f7651..60d12a21e 100644 --- a/pumpkin-entity/Cargo.toml +++ b/pumpkin-entity/Cargo.toml @@ -4,7 +4,4 @@ version.workspace = true edition.workspace = true [dependencies] -pumpkin-core = { path = "../pumpkin-core"} - -num-traits = "0.2" -num-derive = "0.4" \ No newline at end of file +pumpkin-core = { path = "../pumpkin-core"} \ No newline at end of file diff --git a/pumpkin-protocol/Cargo.toml b/pumpkin-protocol/Cargo.toml index 383b7ffe0..0c0ab1296 100644 --- a/pumpkin-protocol/Cargo.toml +++ b/pumpkin-protocol/Cargo.toml @@ -13,8 +13,6 @@ bytes = "1.7" uuid.workspace = true serde.workspace = true -# to parse strings to json responses -serde_json = "1.0" flate2 = "1.0.33" @@ -26,6 +24,6 @@ num-derive = "0.4" # encryption aes = "0.8.4" cfb8 = "0.8.1" -take_mut = "0.2.2" + itertools = "0.13.0" fastnbt = { git = "https://github.com/owengage/fastnbt.git" } diff --git a/pumpkin-protocol/src/bytebuf/packet_id.rs b/pumpkin-protocol/src/bytebuf/packet_id.rs index a422e247a..3a1004aab 100644 --- a/pumpkin-protocol/src/bytebuf/packet_id.rs +++ b/pumpkin-protocol/src/bytebuf/packet_id.rs @@ -83,12 +83,13 @@ where P: Packet + Serialize, { fn write(&self, bytebuf: &mut ByteBuffer) { - take_mut::take(bytebuf, |bytebuf| { - let mut serializer = serializer::Serializer::new(bytebuf); - self.serialize(&mut serializer) - .expect("Could not serialize packet"); - serializer.into() - }); + let mut serializer = serializer::Serializer::new(ByteBuffer::empty()); + self.serialize(&mut serializer) + .expect("Could not serialize packet"); + // We write the packet in an empty bytebuffer and then put it into our current one. + // In the future we may do packet batching thats the reason i don't let every packet create a new bytebuffer and use + // an existing instead + bytebuf.put(serializer.output.buf()); } } diff --git a/pumpkin-protocol/src/bytebuf/serializer.rs b/pumpkin-protocol/src/bytebuf/serializer.rs index 825288c2a..599852339 100644 --- a/pumpkin-protocol/src/bytebuf/serializer.rs +++ b/pumpkin-protocol/src/bytebuf/serializer.rs @@ -9,7 +9,7 @@ use thiserror::Error; use super::ByteBuffer; pub struct Serializer { - output: ByteBuffer, + pub output: ByteBuffer, } impl Serializer { diff --git a/pumpkin-registry/src/lib.rs b/pumpkin-registry/src/lib.rs index 2fb7d1a1b..ee9a3eeca 100644 --- a/pumpkin-registry/src/lib.rs +++ b/pumpkin-registry/src/lib.rs @@ -33,12 +33,12 @@ impl Registry { registry_id: "minecraft:worldgen/biome".to_string(), registry_entries: vec![ RegistryEntry { - entry_id: "minecraft:snowy_taiga", + entry_id: "minecraft:plains", data: fastnbt::to_bytes_with_opts(&Biome::default(), SerOpts::network_nbt()) .unwrap(), }, RegistryEntry { - entry_id: "minecraft:plains", + entry_id: "minecraft:snowy_taiga", data: fastnbt::to_bytes_with_opts(&Biome::default(), SerOpts::network_nbt()) .unwrap(), }, diff --git a/pumpkin-world/src/biome.rs b/pumpkin-world/src/biome.rs index 3196e6ed6..6af83f6e0 100644 --- a/pumpkin-world/src/biome.rs +++ b/pumpkin-world/src/biome.rs @@ -1,9 +1,11 @@ use serde::{Deserialize, Serialize}; // TODO make this work with the protocol +// Send by the registry #[derive(Serialize, Deserialize, Clone, Copy)] #[non_exhaustive] pub enum Biome { Plains, + SnowyTiga, // TODO list all Biomes } diff --git a/pumpkin-world/src/level.rs b/pumpkin-world/src/level.rs index aded912cd..51578bde6 100644 --- a/pumpkin-world/src/level.rs +++ b/pumpkin-world/src/level.rs @@ -277,7 +277,7 @@ impl Level { match compression { Compression::Gzip => { let mut z = GzDecoder::new(&compressed_data[..]); - let mut chunk_data = Vec::new(); + let mut chunk_data = Vec::with_capacity(compressed_data.len()); match z.read_to_end(&mut chunk_data) { Ok(_) => {} Err(e) => { @@ -288,7 +288,7 @@ impl Level { } Compression::Zlib => { let mut z = ZlibDecoder::new(&compressed_data[..]); - let mut chunk_data = Vec::new(); + let mut chunk_data = Vec::with_capacity(compressed_data.len()); match z.read_to_end(&mut chunk_data) { Ok(_) => {} Err(e) => { diff --git a/pumpkin/Cargo.toml b/pumpkin/Cargo.toml index 0131cc4b2..1b23270df 100644 --- a/pumpkin/Cargo.toml +++ b/pumpkin/Cargo.toml @@ -21,7 +21,6 @@ pumpkin-registry = { path = "../pumpkin-registry"} # config serde.workspace = true serde_json = "1.0" -toml = "0.8" bytes = "1.7" @@ -59,7 +58,6 @@ log.workspace = true # networking mio = { version = "1.0.2", features = ["os-poll", "net"]} -crossbeam-channel = "0.5.13" uuid.workspace = true tokio.workspace = true