From a24d00d99819166a147af77dc50ff61dff5cb04a Mon Sep 17 00:00:00 2001 From: mat Date: Sun, 1 May 2022 23:35:30 -0500 Subject: impl Write instead of Vec for consistency --- azalea-protocol/src/mc_buf/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'azalea-protocol/src/mc_buf/mod.rs') diff --git a/azalea-protocol/src/mc_buf/mod.rs b/azalea-protocol/src/mc_buf/mod.rs index a61ad3c3..a82334fb 100755 --- a/azalea-protocol/src/mc_buf/mod.rs +++ b/azalea-protocol/src/mc_buf/mod.rs @@ -5,7 +5,7 @@ mod write; use packet_macros::{McBufReadable, McBufWritable}; pub use read::{read_varint_async, McBufReadable, McBufVarintReadable, Readable}; -use std::ops::{Deref, Index}; +use std::ops::Deref; pub use write::{McBufVarintWritable, McBufWritable, Writable}; // const DEFAULT_NBT_QUOTA: u32 = 2097152; -- cgit v1.2.3 From 1e2ec611003770ce889d69545604f164e2ea8fff Mon Sep 17 00:00:00 2001 From: mat Date: Mon, 2 May 2022 00:24:29 -0500 Subject: write some more azalea-world code --- Cargo.lock | 3 + azalea-protocol/src/mc_buf/mod.rs | 6 ++ .../clientbound_level_chunk_with_light_packet.rs | 6 -- azalea-world/Cargo.toml | 3 +- azalea-world/src/lib.rs | 118 ++++++++++++++++++--- 5 files changed, 117 insertions(+), 19 deletions(-) (limited to 'azalea-protocol/src/mc_buf/mod.rs') diff --git a/Cargo.lock b/Cargo.lock index 7f6ef343..b0fe3c05 100755 --- a/Cargo.lock +++ b/Cargo.lock @@ -164,6 +164,9 @@ dependencies = [ [[package]] name = "azalea-world" version = "0.1.0" +dependencies = [ + "azalea-protocol", +] [[package]] name = "bitflags" diff --git a/azalea-protocol/src/mc_buf/mod.rs b/azalea-protocol/src/mc_buf/mod.rs index a82334fb..74d69441 100755 --- a/azalea-protocol/src/mc_buf/mod.rs +++ b/azalea-protocol/src/mc_buf/mod.rs @@ -1,5 +1,11 @@ //! Utilities for reading and writing for the Minecraft protocol +// TODO: have a separate azalea-protocol-definitions crate to house everything in mc_buf +// We need to do this to prevent cyclic dependencies. +// For example with azalea-protocol depending on azalea-world, +// it could be changed to azalea-protocol depending on azalea-world +// and azalea-world depending on azalea-protocol-definitions. + mod read; mod write; diff --git a/azalea-protocol/src/packets/game/clientbound_level_chunk_with_light_packet.rs b/azalea-protocol/src/packets/game/clientbound_level_chunk_with_light_packet.rs index abd936dc..0ab581ec 100644 --- a/azalea-protocol/src/packets/game/clientbound_level_chunk_with_light_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_level_chunk_with_light_packet.rs @@ -28,9 +28,3 @@ pub struct BlockEntity { } pub struct ChunkSection {} - -impl ClientboundLevelChunkPacketData { - pub fn read(world_height: u32) { - // let section_count - } -} diff --git a/azalea-world/Cargo.toml b/azalea-world/Cargo.toml index afae93a7..54326fb7 100644 --- a/azalea-world/Cargo.toml +++ b/azalea-world/Cargo.toml @@ -1,8 +1,9 @@ [package] +edition = "2021" name = "azalea-world" version = "0.1.0" -edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +azalea-protocol = {path = "../azalea-protocol"} diff --git a/azalea-world/src/lib.rs b/azalea-world/src/lib.rs index 20043bbf..e6b90ad5 100644 --- a/azalea-world/src/lib.rs +++ b/azalea-world/src/lib.rs @@ -1,3 +1,6 @@ +use azalea_protocol::mc_buf::{McBufReadable, McBufWritable, Readable, Writable}; +use std::io::{Read, Write}; + #[cfg(test)] mod tests { #[test] @@ -7,22 +10,92 @@ mod tests { } } +const SECTION_HEIGHT: u32 = 16; + pub struct Chunk { - sections: Vec
, + pub sections: Vec
, +} + +impl Chunk { + fn read_with_world_height(buf: &mut impl Read, world_height: u32) -> Result { + let section_count = world_height / SECTION_HEIGHT; + let mut sections = Vec::with_capacity(section_count as usize); + for _ in 0..section_count { + let section = Section::read_into(buf)?; + sections.push(section); + } + Ok(Chunk { sections }) + } } +impl McBufWritable for Chunk { + fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { + for section in &self.sections { + section.write_into(buf)?; + } + Ok(()) + } +} + +#[derive(Clone, Debug)] pub struct Section { - states: PalettedContainer, - biomes: PalettedContainer, + pub block_count: u16, + pub states: PalettedContainer, + pub biomes: PalettedContainer, +} + +impl McBufReadable for Section { + fn read_into(buf: &mut impl Read) -> Result { + let block_count = u16::read_into(buf)?; + let states = PalettedContainer::read_into(buf)?; + let biomes = PalettedContainer::read_into(buf)?; + Ok(Section { + block_count, + states, + biomes, + }) + } +} + +impl McBufWritable for Section { + fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { + self.block_count.write_into(buf)?; + self.states.write_into(buf)?; + self.biomes.write_into(buf)?; + Ok(()) + } } +#[derive(Clone, Debug)] pub struct PalettedContainer { - bits_per_entry: u8, - palette: Palette, + pub bits_per_entry: u8, + pub palette: Palette, /// Compacted list of indices pointing to entry IDs in the Palette. - data: Vec, + pub data: Vec, +} + +impl McBufReadable for PalettedContainer { + fn read_into(buf: &mut impl Read) -> Result { + let bits_per_entry = buf.read_byte()?; + let palette = Palette::read_with_bits_per_entry(buf, bits_per_entry)?; + let data = Vec::::read_into(buf)?; + Ok(PalettedContainer { + bits_per_entry, + palette, + data, + }) + } +} +impl McBufWritable for PalettedContainer { + fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { + buf.write_byte(self.bits_per_entry)?; + self.palette.write_into(buf)?; + self.data.write_into(buf)?; + Ok(()) + } } +#[derive(Clone, Debug)] pub enum Palette { /// ID of the corresponding entry in its global palette SingleValue(u32), @@ -32,12 +105,33 @@ pub enum Palette { } impl Palette { - fn choose_palette_for_states(bits_per_entry: u8) -> &'static Palette { - match bits_per_entry { - 0 => &Palette::SingleValue, - 1..=4 => &Palette::LinearPalette, - 5..=8 => &Palette::HashmapPalette, - _ => &Palette::GlobalPalette, + pub fn read_with_bits_per_entry( + buf: &mut impl Read, + bits_per_entry: u8, + ) -> Result { + Ok(match bits_per_entry { + 0 => Palette::SingleValue(u32::read_into(buf)?), + 1..=4 => Palette::LinearPalette(Vec::::read_into(buf)?), + 5..=8 => Palette::HashmapPalette(Vec::::read_into(buf)?), + _ => Palette::GlobalPalette, + }) + } +} + +impl McBufWritable for Palette { + fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { + match self { + Palette::SingleValue(value) => { + value.write_into(buf)?; + } + Palette::LinearPalette(values) => { + values.write_into(buf)?; + } + Palette::HashmapPalette(values) => { + values.write_into(buf)?; + } + Palette::GlobalPalette => {} } + Ok(()) } } -- cgit v1.2.3 From 8e42e1c5dfc54314585b564696044780e0407c2f Mon Sep 17 00:00:00 2001 From: mat Date: Mon, 2 May 2022 23:07:06 +0000 Subject: more chunk and readme stuff --- Cargo.lock | 1 + README.md | 10 +++++++--- azalea-client/Cargo.toml | 1 + azalea-client/src/connect.rs | 3 ++- azalea-protocol/src/mc_buf/mod.rs | 6 ------ .../packets/game/clientbound_level_chunk_with_light_packet.rs | 1 - azalea-world/src/lib.rs | 6 +++++- 7 files changed, 16 insertions(+), 12 deletions(-) (limited to 'azalea-protocol/src/mc_buf/mod.rs') diff --git a/Cargo.lock b/Cargo.lock index b0fe3c05..3633a1af 100755 --- a/Cargo.lock +++ b/Cargo.lock @@ -99,6 +99,7 @@ dependencies = [ "azalea-core", "azalea-crypto", "azalea-protocol", + "azalea-world", "tokio", ] diff --git a/README.md b/README.md index 909ae47e..4c90ba42 100755 --- a/README.md +++ b/README.md @@ -1,20 +1,24 @@ # Azalea -A Rust crate for creating Minecraft bots. -

Azalea

+A Rust crate for creating Minecraft bots. + I named this Azalea because it sounds like a cool word and this is a cool library. This project was heavily inspired by PrismarineJS. +## Why + +I wanted a fun excuse to do something cool with Rust, and I also felt like I could do better than [Mineflayer](https://github.com/prismarinejs/mineflayer) in some areas. + ## Goals - Do everything a vanilla client can do - Be easy to use - Bypass most/all anticheats - Support the latest Minecraft version -- Be fast +- Be fast and memory efficient ## Example code diff --git a/azalea-client/Cargo.toml b/azalea-client/Cargo.toml index 55caadeb..1156f8de 100755 --- a/azalea-client/Cargo.toml +++ b/azalea-client/Cargo.toml @@ -10,4 +10,5 @@ azalea-auth = {path = "../azalea-auth"} azalea-core = {path = "../azalea-core"} azalea-crypto = {path = "../azalea-crypto"} azalea-protocol = {path = "../azalea-protocol"} +azalea-world = {path = "../azalea-world"} tokio = {version = "1.18.0", features = ["sync"]} diff --git a/azalea-client/src/connect.rs b/azalea-client/src/connect.rs index b628051a..be268eee 100755 --- a/azalea-client/src/connect.rs +++ b/azalea-client/src/connect.rs @@ -13,6 +13,7 @@ use azalea_protocol::{ }, resolver, ServerAddress, }; +use azalea_world::Chunk; use std::sync::Arc; use tokio::sync::mpsc::{self, UnboundedReceiver, UnboundedSender}; use tokio::sync::Mutex; @@ -233,7 +234,7 @@ impl Client { } GamePacket::ClientboundLevelChunkWithLightPacket(p) => { println!("Got chunk with light packet {} {}", p.x, p.z); - // p.chunk_data + // let chunk = Chunk::read_with_world_height(&mut p.chunk_data); } GamePacket::ClientboundLightUpdatePacket(p) => { println!("Got light update packet {:?}", p); diff --git a/azalea-protocol/src/mc_buf/mod.rs b/azalea-protocol/src/mc_buf/mod.rs index 74d69441..a82334fb 100755 --- a/azalea-protocol/src/mc_buf/mod.rs +++ b/azalea-protocol/src/mc_buf/mod.rs @@ -1,11 +1,5 @@ //! Utilities for reading and writing for the Minecraft protocol -// TODO: have a separate azalea-protocol-definitions crate to house everything in mc_buf -// We need to do this to prevent cyclic dependencies. -// For example with azalea-protocol depending on azalea-world, -// it could be changed to azalea-protocol depending on azalea-world -// and azalea-world depending on azalea-protocol-definitions. - mod read; mod write; diff --git a/azalea-protocol/src/packets/game/clientbound_level_chunk_with_light_packet.rs b/azalea-protocol/src/packets/game/clientbound_level_chunk_with_light_packet.rs index 0ab581ec..6810ceb2 100644 --- a/azalea-protocol/src/packets/game/clientbound_level_chunk_with_light_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_level_chunk_with_light_packet.rs @@ -27,4 +27,3 @@ pub struct BlockEntity { data: azalea_nbt::Tag, } -pub struct ChunkSection {} diff --git a/azalea-world/src/lib.rs b/azalea-world/src/lib.rs index e6b90ad5..8e60a6d6 100644 --- a/azalea-world/src/lib.rs +++ b/azalea-world/src/lib.rs @@ -12,12 +12,16 @@ mod tests { const SECTION_HEIGHT: u32 = 16; +pub struct World { + +} + pub struct Chunk { pub sections: Vec
, } impl Chunk { - fn read_with_world_height(buf: &mut impl Read, world_height: u32) -> Result { + pub fn read_with_world_height(buf: &mut impl Read, world_height: u32) -> Result { let section_count = world_height / SECTION_HEIGHT; let mut sections = Vec::with_capacity(section_count as usize); for _ in 0..section_count { -- cgit v1.2.3 From 4dac004635e50682d9ebe8812fdf654a0c1808f1 Mon Sep 17 00:00:00 2001 From: mat Date: Thu, 5 May 2022 22:12:54 -0500 Subject: Fix chunk decoding --- azalea-protocol/src/mc_buf/mod.rs | 2 ++ azalea-protocol/src/mc_buf/read.rs | 11 ++++++++ azalea-protocol/src/mc_buf/write.rs | 7 +++++ azalea-world/src/bit_storage.rs | 9 ++++--- azalea-world/src/lib.rs | 19 ++++++++++--- azalea-world/src/palette.rs | 54 ++++++++++++++++++++++++++++++------- bot/src/main.rs | 2 +- 7 files changed, 85 insertions(+), 19 deletions(-) (limited to 'azalea-protocol/src/mc_buf/mod.rs') diff --git a/azalea-protocol/src/mc_buf/mod.rs b/azalea-protocol/src/mc_buf/mod.rs index a82334fb..debf2991 100755 --- a/azalea-protocol/src/mc_buf/mod.rs +++ b/azalea-protocol/src/mc_buf/mod.rs @@ -12,6 +12,8 @@ pub use write::{McBufVarintWritable, McBufWritable, Writable}; const MAX_STRING_LENGTH: u16 = 32767; // const MAX_COMPONENT_STRING_LENGTH: u32 = 262144; +// TODO: maybe get rid of the readable/writable traits so there's not two ways to do the same thing and improve McBufReadable/McBufWritable + // TODO: have a definitions.rs in mc_buf that contains UnsizedByteArray and BitSet /// A Vec that isn't prefixed by a VarInt with the size. diff --git a/azalea-protocol/src/mc_buf/read.rs b/azalea-protocol/src/mc_buf/read.rs index e1ae321c..a8c44bdf 100755 --- a/azalea-protocol/src/mc_buf/read.rs +++ b/azalea-protocol/src/mc_buf/read.rs @@ -255,6 +255,17 @@ impl McBufVarintReadable for i32 { } } +impl McBufVarintReadable for Vec { + fn varint_read_into(buf: &mut impl Read) -> Result { + let length = u32::varint_read_into(buf)?; + let mut vec = Vec::with_capacity(length as usize); + for _ in 0..length { + vec.push(T::varint_read_into(buf)?); + } + Ok(vec) + } +} + impl McBufReadable for UnsizedByteArray { fn read_into(buf: &mut impl Read) -> Result { Ok(UnsizedByteArray(buf.read_bytes()?)) diff --git a/azalea-protocol/src/mc_buf/write.rs b/azalea-protocol/src/mc_buf/write.rs index 3a4a02f8..cc5f2284 100755 --- a/azalea-protocol/src/mc_buf/write.rs +++ b/azalea-protocol/src/mc_buf/write.rs @@ -210,6 +210,13 @@ impl McBufVarintWritable for u32 { } } +// Vec varint +impl McBufVarintWritable for Vec { + fn varint_write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { + buf.write_list(self, |buf, i| i.varint_write_into(buf)) + } +} + // u16 impl McBufWritable for u16 { fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { diff --git a/azalea-world/src/bit_storage.rs b/azalea-world/src/bit_storage.rs index 5ced67fe..9cc3a053 100644 --- a/azalea-world/src/bit_storage.rs +++ b/azalea-world/src/bit_storage.rs @@ -1,4 +1,4 @@ -use std::{error::Error, fmt, ops::Index}; +use std::{error::Error, fmt}; // this is from minecraft's code // yeah idk either @@ -70,6 +70,7 @@ const MAGIC: [(i32, i32, i32); 64] = [ ]; /// A compact list of integers with the given number of bits per entry. +#[derive(Clone)] pub struct BitStorage { data: Vec, bits: usize, @@ -135,7 +136,7 @@ impl BitStorage { pub fn cell_index(&self, index: u64) -> usize { let first = self.divide_mul as u64; - let second = self.divide_mul as u64; + let second = self.divide_add as u64; (index * first + second >> 32 >> self.divide_shift) .try_into() @@ -182,8 +183,8 @@ mod tests { let data = [ 1, 2, 2, 3, 4, 4, 5, 6, 6, 4, 8, 0, 7, 4, 3, 13, 15, 16, 9, 14, 10, 12, 0, 2, ]; - let expected_compact: [u64; 2] = [0x0020863148418841, 0x01018A7260F68C87]; - let storage = BitStorage::new(5, data.len(), Some(expected_compact.to_vec())).unwrap(); + let compact_data: [u64; 2] = [0x0020863148418841, 0x01018A7260F68C87]; + let storage = BitStorage::new(5, data.len(), Some(compact_data.to_vec())).unwrap(); for (i, expected) in data.iter().enumerate() { assert_eq!(storage.get(i), *expected); diff --git a/azalea-world/src/lib.rs b/azalea-world/src/lib.rs index 54961401..abeac181 100644 --- a/azalea-world/src/lib.rs +++ b/azalea-world/src/lib.rs @@ -11,6 +11,8 @@ use std::{ sync::{Arc, Mutex}, }; +use crate::palette::PalettedContainerType; + #[cfg(test)] mod tests { #[test] @@ -43,7 +45,7 @@ impl World { // let existing_chunk = &self.storage[pos]; let chunk = Arc::new(Mutex::new(Chunk::read_with_world(data, self)?)); - println!("Loaded chunk {:?}", chunk); + println!("Loaded chunk {:?}", pos); self.storage[pos] = Some(chunk); Ok(()) @@ -121,7 +123,9 @@ impl Chunk { pub fn read_with_world_height(buf: &mut impl Read, world_height: u32) -> Result { let section_count = world_height / SECTION_HEIGHT; let mut sections = Vec::with_capacity(section_count as usize); - for _ in 0..section_count { + println!("\n\nreading {} sections", section_count); + for i in 0..section_count { + println!("reading section #{}", i); let section = Section::read_into(buf)?; sections.push(section); } @@ -148,8 +152,15 @@ pub struct Section { impl McBufReadable for Section { fn read_into(buf: &mut impl Read) -> Result { let block_count = u16::read_into(buf)?; - let states = PalettedContainer::read_into(buf)?; - let biomes = PalettedContainer::read_into(buf)?; + println!("block count: {}\n", block_count); + // assert!( + // block_count <= 16 * 16 * 16, + // "A section has more blocks than what should be possible. This is a bug!" + // ); + let states = PalettedContainer::read_with_type(buf, &PalettedContainerType::BlockStates)?; + println!("! read states, reading biomes next"); + let biomes = PalettedContainer::read_with_type(buf, &PalettedContainerType::Biomes)?; + println!(); Ok(Section { block_count, states, diff --git a/azalea-world/src/palette.rs b/azalea-world/src/palette.rs index 69900fe6..47354c94 100644 --- a/azalea-world/src/palette.rs +++ b/azalea-world/src/palette.rs @@ -1,20 +1,43 @@ +use azalea_protocol::mc_buf::{ + McBufReadable, McBufVarintReadable, McBufWritable, Readable, Writable, +}; use std::io::{Read, Write}; -use azalea_protocol::mc_buf::{McBufReadable, McBufWritable, Readable, Writable}; +#[derive(Clone, Debug, Copy)] +pub enum PalettedContainerType { + Biomes, + BlockStates, +} #[derive(Clone, Debug)] pub struct PalettedContainer { pub bits_per_entry: u8, pub palette: Palette, /// Compacted list of indices pointing to entry IDs in the Palette. - pub data: Vec, + pub data: Vec, } -impl McBufReadable for PalettedContainer { - fn read_into(buf: &mut impl Read) -> Result { +impl PalettedContainer { + pub fn read_with_type( + buf: &mut impl Read, + type_: &'static PalettedContainerType, + ) -> Result { let bits_per_entry = buf.read_byte()?; - let palette = Palette::read_with_bits_per_entry(buf, bits_per_entry)?; - let data = Vec::::read_into(buf)?; + let palette = match type_ { + PalettedContainerType::BlockStates => { + Palette::block_states_read_with_bits_per_entry(buf, bits_per_entry)? + } + PalettedContainerType::Biomes => { + Palette::biomes_read_with_bits_per_entry(buf, bits_per_entry)? + } + }; + + let data = Vec::::read_into(buf)?; + debug_assert!( + bits_per_entry != 0 || data.is_empty(), + "Bits per entry is 0 but data is not empty." + ); + Ok(PalettedContainer { bits_per_entry, palette, @@ -41,14 +64,25 @@ pub enum Palette { } impl Palette { - pub fn read_with_bits_per_entry( + pub fn block_states_read_with_bits_per_entry( + buf: &mut impl Read, + bits_per_entry: u8, + ) -> Result { + Ok(match bits_per_entry { + 0 => Palette::SingleValue(u32::varint_read_into(buf)?), + 1..=4 => Palette::Linear(Vec::::varint_read_into(buf)?), + 5..=8 => Palette::Hashmap(Vec::::varint_read_into(buf)?), + _ => Palette::Global, + }) + } + + pub fn biomes_read_with_bits_per_entry( buf: &mut impl Read, bits_per_entry: u8, ) -> Result { Ok(match bits_per_entry { - 0 => Palette::SingleValue(u32::read_into(buf)?), - 1..=4 => Palette::Linear(Vec::::read_into(buf)?), - 5..=8 => Palette::Hashmap(Vec::::read_into(buf)?), + 0 => Palette::SingleValue(u32::varint_read_into(buf)?), + 1..=3 => Palette::Linear(Vec::::varint_read_into(buf)?), _ => Palette::Global, }) } diff --git a/bot/src/main.rs b/bot/src/main.rs index 167f4edc..7cf056bf 100644 --- a/bot/src/main.rs +++ b/bot/src/main.rs @@ -5,7 +5,7 @@ async fn main() { println!("Hello, world!"); // let address = "95.111.249.143:10000"; - let address = "172.23.192.1:65111"; + let address = "172.23.192.1:62522"; // let response = azalea_client::ping::ping_server(&address.try_into().unwrap()) // .await // .unwrap(); -- cgit v1.2.3 From 93730a550aed964d122bc08f5353e8eb0c5c9f31 Mon Sep 17 00:00:00 2001 From: mat Date: Sat, 14 May 2022 19:55:33 -0500 Subject: start adding ClientboundLevelParticlesPacket --- azalea-protocol/packet-macros/src/lib.rs | 13 +++++++++ azalea-protocol/src/mc_buf/definitions.rs | 33 +++++++++++++--------- azalea-protocol/src/mc_buf/mod.rs | 4 +-- .../src/packets/game/clientbound_animate_packet.rs | 4 +-- .../src/packets/game/clientbound_chat_packet.rs | 4 +-- .../packets/game/clientbound_game_event_packet.rs | 4 +-- .../clientbound_level_chunk_with_light_packet.rs | 6 ++-- .../game/clientbound_level_particles_packet.rs | 17 +++++++++++ .../game/clientbound_light_update_packet.rs | 4 +-- .../packets/game/clientbound_player_info_packet.rs | 14 ++++----- .../src/packets/game/clientbound_recipe_packet.rs | 4 +-- .../clientbound_section_blocks_update_packet.rs | 2 +- .../src/packets/game/clientbound_sound_packet.rs | 4 +-- .../game/clientbound_update_advancements_packet.rs | 12 ++++---- .../game/clientbound_update_attributes_packet.rs | 6 ++-- .../game/clientbound_update_recipes_packet.rs | 12 ++++---- azalea-protocol/src/packets/game/mod.rs | 8 ++++-- azalea-protocol/src/packets/mod.rs | 2 +- 18 files changed, 95 insertions(+), 58 deletions(-) create mode 100644 azalea-protocol/src/packets/game/clientbound_level_particles_packet.rs (limited to 'azalea-protocol/src/mc_buf/mod.rs') diff --git a/azalea-protocol/packet-macros/src/lib.rs b/azalea-protocol/packet-macros/src/lib.rs index 87b216c0..59fb91eb 100755 --- a/azalea-protocol/packet-macros/src/lib.rs +++ b/azalea-protocol/packet-macros/src/lib.rs @@ -157,6 +157,19 @@ pub fn derive_mcbufwritable(input: TokenStream) -> TokenStream { create_impl_mcbufwritable(&ident, &data).into() } +#[proc_macro_derive(McBuf, attributes(var))] +pub fn derive_mcbuf(input: TokenStream) -> TokenStream { + let DeriveInput { ident, data, .. } = parse_macro_input!(input); + + let writable = create_impl_mcbufwritable(&ident, &data); + let readable = create_impl_mcbufreadable(&ident, &data); + quote! { + #writable + #readable + } + .into() +} + fn as_packet_derive(input: TokenStream, state: proc_macro2::TokenStream) -> TokenStream { let DeriveInput { ident, data, .. } = parse_macro_input!(input); diff --git a/azalea-protocol/src/mc_buf/definitions.rs b/azalea-protocol/src/mc_buf/definitions.rs index a59fc574..3867b3fc 100644 --- a/azalea-protocol/src/mc_buf/definitions.rs +++ b/azalea-protocol/src/mc_buf/definitions.rs @@ -1,8 +1,9 @@ use crate::mc_buf::read::{McBufReadable, Readable}; use crate::mc_buf::write::{McBufWritable, Writable}; +use crate::mc_buf::McBufVarReadable; use azalea_chat::component::Component; use azalea_core::{BlockPos, Direction, Slot}; -use packet_macros::{McBufReadable, McBufWritable}; +use packet_macros::McBuf; use std::io::{Read, Write}; use std::ops::Deref; use uuid::Uuid; @@ -32,7 +33,7 @@ impl From<&str> for UnsizedByteArray { } /// Represents Java's BitSet, a list of bits. -#[derive(Debug, Clone, PartialEq, Eq, Hash, McBufReadable, McBufWritable)] +#[derive(Debug, Clone, PartialEq, Eq, Hash, McBuf)] pub struct BitSet { data: Vec, } @@ -159,7 +160,7 @@ impl McBufWritable for EntityDataValue { } } -#[derive(Clone, Debug, Copy, McBufReadable, McBufWritable)] +#[derive(Clone, Debug, Copy, McBuf)] pub enum Pose { Standing = 0, FallFlying = 1, @@ -171,7 +172,7 @@ pub enum Pose { Dying = 7, } -#[derive(Debug, Clone, McBufReadable, McBufWritable)] +#[derive(Debug, Clone, McBuf)] pub struct VillagerData { #[var] type_: u32, @@ -181,7 +182,7 @@ pub struct VillagerData { level: u32, } -#[derive(Debug, Clone, McBufReadable, McBufWritable)] +#[derive(Debug, Clone, McBuf)] pub struct Particle { #[var] pub id: i32, @@ -280,12 +281,12 @@ pub enum ParticleData { Scrape, } -#[derive(Debug, Clone, McBufReadable, McBufWritable)] +#[derive(Debug, Clone, McBuf)] pub struct BlockParticle { #[var] pub block_state: i32, } -#[derive(Debug, Clone, McBufReadable, McBufWritable)] +#[derive(Debug, Clone, McBuf)] pub struct DustParticle { /// Red value, 0-1 pub red: f32, @@ -297,7 +298,7 @@ pub struct DustParticle { pub scale: f32, } -#[derive(Debug, Clone, McBufReadable, McBufWritable)] +#[derive(Debug, Clone, McBuf)] pub struct DustColorTransitionParticle { /// Red value, 0-1 pub from_red: f32, @@ -315,12 +316,12 @@ pub struct DustColorTransitionParticle { pub to_blue: f32, } -#[derive(Debug, Clone, McBufReadable, McBufWritable)] +#[derive(Debug, Clone, McBuf)] pub struct ItemParticle { pub item: Slot, } -#[derive(Debug, Clone, McBufReadable, McBufWritable)] +#[derive(Debug, Clone, McBuf)] pub struct VibrationParticle { pub origin: BlockPos, pub position_type: String, @@ -331,9 +332,8 @@ pub struct VibrationParticle { pub ticks: u32, } -impl McBufReadable for ParticleData { - fn read_into(buf: &mut impl Read) -> Result { - let id = buf.read_varint()?; +impl ParticleData { + pub fn read_from_particle_id(buf: &mut impl Read, id: u32) -> Result { Ok(match id { 0 => ParticleData::AmbientEntityEffect, 1 => ParticleData::AngryVillager, @@ -428,6 +428,13 @@ impl McBufReadable for ParticleData { } } +impl McBufReadable for ParticleData { + fn read_into(buf: &mut impl Read) -> Result { + let id = u32::var_read_into(buf)?; + ParticleData::read_from_particle_id(buf, id) + } +} + impl McBufWritable for ParticleData { fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { todo!() diff --git a/azalea-protocol/src/mc_buf/mod.rs b/azalea-protocol/src/mc_buf/mod.rs index 94e4af0b..548ba7c2 100644 --- a/azalea-protocol/src/mc_buf/mod.rs +++ b/azalea-protocol/src/mc_buf/mod.rs @@ -4,10 +4,8 @@ mod definitions; mod read; mod write; -pub use definitions::{BitSet, EntityMetadata, UnsizedByteArray}; -use packet_macros::{McBufReadable, McBufWritable}; +pub use definitions::{BitSet, EntityMetadata, ParticleData, UnsizedByteArray}; pub use read::{read_varint_async, McBufReadable, McBufVarReadable, Readable}; -use std::ops::Deref; pub use write::{McBufVarWritable, McBufWritable, Writable}; // const DEFAULT_NBT_QUOTA: u32 = 2097152; diff --git a/azalea-protocol/src/packets/game/clientbound_animate_packet.rs b/azalea-protocol/src/packets/game/clientbound_animate_packet.rs index 84a20381..6ac4bd99 100644 --- a/azalea-protocol/src/packets/game/clientbound_animate_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_animate_packet.rs @@ -1,4 +1,4 @@ -use packet_macros::{GamePacket, McBufReadable, McBufWritable}; +use packet_macros::{GamePacket, McBuf}; #[derive(Clone, Debug, GamePacket)] pub struct ClientboundAnimatePacket { @@ -9,7 +9,7 @@ pub struct ClientboundAnimatePacket { // minecraft actually uses a u8 for this, but a varint still works and makes it // so i don't have to add a special handler -#[derive(Clone, Debug, Copy, McBufReadable, McBufWritable)] +#[derive(Clone, Debug, Copy, McBuf)] pub enum AnimationAction { SwingMainHand = 0, Hurt = 1, diff --git a/azalea-protocol/src/packets/game/clientbound_chat_packet.rs b/azalea-protocol/src/packets/game/clientbound_chat_packet.rs index 3786993a..7a52337e 100644 --- a/azalea-protocol/src/packets/game/clientbound_chat_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_chat_packet.rs @@ -1,5 +1,5 @@ use azalea_chat::component::Component; -use packet_macros::{GamePacket, McBufReadable, McBufWritable}; +use packet_macros::{GamePacket, McBuf}; use uuid::Uuid; #[derive(Clone, Debug, GamePacket)] @@ -9,7 +9,7 @@ pub struct ClientboundChatPacket { pub sender: Uuid, } -#[derive(Clone, Debug, Copy, McBufReadable, McBufWritable)] +#[derive(Clone, Debug, Copy, McBuf)] pub enum ChatType { Chat = 0, System = 1, diff --git a/azalea-protocol/src/packets/game/clientbound_game_event_packet.rs b/azalea-protocol/src/packets/game/clientbound_game_event_packet.rs index c3ae2299..faba0a6e 100644 --- a/azalea-protocol/src/packets/game/clientbound_game_event_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_game_event_packet.rs @@ -1,4 +1,4 @@ -use packet_macros::{GamePacket, McBufReadable, McBufWritable}; +use packet_macros::{GamePacket, McBuf}; #[derive(Clone, Debug, GamePacket)] pub struct ClientboundGameEventPacket { @@ -6,7 +6,7 @@ pub struct ClientboundGameEventPacket { pub param: f32, } -#[derive(Clone, Debug, Copy, McBufReadable, McBufWritable)] +#[derive(Clone, Debug, Copy, McBuf)] pub enum EventType { NoRespawnBlockAvailable = 0, StartRaining = 1, diff --git a/azalea-protocol/src/packets/game/clientbound_level_chunk_with_light_packet.rs b/azalea-protocol/src/packets/game/clientbound_level_chunk_with_light_packet.rs index edcb5777..dab36050 100644 --- a/azalea-protocol/src/packets/game/clientbound_level_chunk_with_light_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_level_chunk_with_light_packet.rs @@ -1,4 +1,4 @@ -use packet_macros::{GamePacket, McBufReadable, McBufWritable}; +use packet_macros::{GamePacket, McBuf}; use super::clientbound_light_update_packet::ClientboundLightUpdatePacketData; @@ -10,7 +10,7 @@ pub struct ClientboundLevelChunkWithLightPacket { pub light_data: ClientboundLightUpdatePacketData, } -#[derive(Clone, Debug, McBufReadable, McBufWritable)] +#[derive(Clone, Debug, McBuf)] pub struct ClientboundLevelChunkPacketData { pub heightmaps: azalea_nbt::Tag, // we can't parse the data in azalea-protocol because it dependso on context from other packets @@ -18,7 +18,7 @@ pub struct ClientboundLevelChunkPacketData { pub block_entities: Vec, } -#[derive(Clone, Debug, McBufReadable, McBufWritable)] +#[derive(Clone, Debug, McBuf)] pub struct BlockEntity { pub packed_xz: u8, pub y: u16, diff --git a/azalea-protocol/src/packets/game/clientbound_level_particles_packet.rs b/azalea-protocol/src/packets/game/clientbound_level_particles_packet.rs new file mode 100644 index 00000000..0194d08d --- /dev/null +++ b/azalea-protocol/src/packets/game/clientbound_level_particles_packet.rs @@ -0,0 +1,17 @@ +use crate::mc_buf::ParticleData; +use packet_macros::GamePacket; + +#[derive(Clone, Debug, GamePacket)] +pub struct ClientboundLevelParticlesPacket { + pub particle_id: u32, + pub override_limiter: bool, + pub x: f64, + pub y: f64, + pub z: f64, + pub x_dist: f32, + pub y_dist: f32, + pub z_dist: f32, + pub max_speed: f32, + pub count: i32, + pub data: ParticleData, +} diff --git a/azalea-protocol/src/packets/game/clientbound_light_update_packet.rs b/azalea-protocol/src/packets/game/clientbound_light_update_packet.rs index e83d1e87..0c75b356 100644 --- a/azalea-protocol/src/packets/game/clientbound_light_update_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_light_update_packet.rs @@ -1,5 +1,5 @@ use crate::mc_buf::BitSet; -use packet_macros::{GamePacket, McBufReadable, McBufWritable}; +use packet_macros::{GamePacket, McBuf}; #[derive(Clone, Debug, GamePacket)] pub struct ClientboundLightUpdatePacket { @@ -8,7 +8,7 @@ pub struct ClientboundLightUpdatePacket { pub light_data: ClientboundLightUpdatePacketData, } -#[derive(Clone, Debug, McBufReadable, McBufWritable)] +#[derive(Clone, Debug, McBuf)] pub struct ClientboundLightUpdatePacketData { trust_edges: bool, sky_y_mask: BitSet, diff --git a/azalea-protocol/src/packets/game/clientbound_player_info_packet.rs b/azalea-protocol/src/packets/game/clientbound_player_info_packet.rs index 8e7ce4fd..db306ade 100644 --- a/azalea-protocol/src/packets/game/clientbound_player_info_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_player_info_packet.rs @@ -1,6 +1,6 @@ use crate::mc_buf::{McBufReadable, McBufWritable, Readable, Writable}; use azalea_chat::component::Component; -use packet_macros::{GamePacket, McBufReadable, McBufWritable}; +use packet_macros::{GamePacket, McBuf}; use std::io::{Read, Write}; use uuid::Uuid; @@ -18,14 +18,14 @@ pub enum Action { RemovePlayer(Vec), } -#[derive(Clone, Debug, McBufReadable, McBufWritable)] +#[derive(Clone, Debug, McBuf)] pub struct PlayerProperty { name: String, value: String, signature: Option, } -#[derive(Clone, Debug, McBufReadable, McBufWritable)] +#[derive(Clone, Debug, McBuf)] pub struct AddPlayer { uuid: Uuid, name: String, @@ -37,26 +37,26 @@ pub struct AddPlayer { display_name: Option, } -#[derive(Clone, Debug, McBufReadable, McBufWritable)] +#[derive(Clone, Debug, McBuf)] pub struct UpdateGameMode { uuid: Uuid, #[var] gamemode: u32, } -#[derive(Clone, Debug, McBufReadable, McBufWritable)] +#[derive(Clone, Debug, McBuf)] pub struct UpdateLatency { uuid: Uuid, #[var] ping: i32, } -#[derive(Clone, Debug, McBufReadable, McBufWritable)] +#[derive(Clone, Debug, McBuf)] pub struct UpdateDisplayName { uuid: Uuid, display_name: Option, } -#[derive(Clone, Debug, McBufReadable, McBufWritable)] +#[derive(Clone, Debug, McBuf)] pub struct RemovePlayer { uuid: Uuid, } diff --git a/azalea-protocol/src/packets/game/clientbound_recipe_packet.rs b/azalea-protocol/src/packets/game/clientbound_recipe_packet.rs index fa0d58f0..9a9623ad 100644 --- a/azalea-protocol/src/packets/game/clientbound_recipe_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_recipe_packet.rs @@ -1,6 +1,6 @@ use crate::mc_buf::{McBufReadable, McBufWritable, Readable, Writable}; use azalea_core::resource_location::ResourceLocation; -use packet_macros::{GamePacket, McBufReadable, McBufWritable}; +use packet_macros::{GamePacket, McBuf}; use std::io::{Read, Write}; #[derive(Clone, Debug, GamePacket)] @@ -11,7 +11,7 @@ pub struct ClientboundRecipePacket { pub to_highlight: Vec, } -#[derive(Clone, Debug, McBufReadable, McBufWritable)] +#[derive(Clone, Debug, McBuf)] pub struct RecipeBookSettings { pub gui_open: bool, pub filtering_craftable: bool, diff --git a/azalea-protocol/src/packets/game/clientbound_section_blocks_update_packet.rs b/azalea-protocol/src/packets/game/clientbound_section_blocks_update_packet.rs index 7f57a126..91d579a8 100644 --- a/azalea-protocol/src/packets/game/clientbound_section_blocks_update_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_section_blocks_update_packet.rs @@ -37,7 +37,7 @@ impl McBufWritable for BlockStateWithPosition { fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { let data = (self.state as u64) << 12 | ((self.pos.x as u64) << 8 | (self.pos.z as u64) << 4 | (self.pos.y as u64)); - u64::var_write_into(&data, buf); + u64::var_write_into(&data, buf)?; Ok(()) } } diff --git a/azalea-protocol/src/packets/game/clientbound_sound_packet.rs b/azalea-protocol/src/packets/game/clientbound_sound_packet.rs index 67e832fe..8094227b 100644 --- a/azalea-protocol/src/packets/game/clientbound_sound_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_sound_packet.rs @@ -1,4 +1,4 @@ -use packet_macros::{GamePacket, McBufReadable, McBufWritable}; +use packet_macros::{GamePacket, McBuf}; #[derive(Clone, Debug, GamePacket)] pub struct ClientboundSoundPacket { @@ -13,7 +13,7 @@ pub struct ClientboundSoundPacket { pub pitch: f32, } -#[derive(Clone, Debug, Copy, McBufReadable, McBufWritable)] +#[derive(Clone, Debug, Copy, McBuf)] pub enum SoundSource { Master = 0, Music = 1, diff --git a/azalea-protocol/src/packets/game/clientbound_update_advancements_packet.rs b/azalea-protocol/src/packets/game/clientbound_update_advancements_packet.rs index fe2c226d..0bd18319 100644 --- a/azalea-protocol/src/packets/game/clientbound_update_advancements_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_update_advancements_packet.rs @@ -1,7 +1,7 @@ use crate::packets::{McBufReadable, McBufWritable}; use azalea_chat::component::Component; use azalea_core::{resource_location::ResourceLocation, Slot}; -use packet_macros::{GamePacket, McBufReadable, McBufWritable}; +use packet_macros::{GamePacket, McBuf}; use std::{ collections::HashMap, io::{Read, Write}, @@ -15,7 +15,7 @@ pub struct ClientboundUpdateAdvancementsPacket { pub progress: HashMap, } -#[derive(Clone, Debug, McBufReadable, McBufWritable)] +#[derive(Clone, Debug, McBuf)] pub struct Advancement { parent_id: Option, display: Option, @@ -25,7 +25,7 @@ pub struct Advancement { // requirements_strategy: RequirementsStrategy.AND } -#[derive(Clone, Debug, McBufReadable, McBufWritable)] +#[derive(Clone, Debug, McBuf)] pub struct DisplayInfo { pub title: Component, pub description: Component, @@ -71,7 +71,7 @@ impl McBufWritable for DisplayFlags { } } -#[derive(Clone, Debug, Copy, McBufReadable, McBufWritable)] +#[derive(Clone, Debug, Copy, McBuf)] pub enum FrameType { Task = 0, Challenge = 1, @@ -79,12 +79,12 @@ pub enum FrameType { } // nothing is written here -#[derive(Clone, Debug, McBufReadable, McBufWritable)] +#[derive(Clone, Debug, McBuf)] pub struct Criterion {} pub type AdvancementProgress = HashMap; -#[derive(Clone, Debug, McBufReadable, McBufWritable)] +#[derive(Clone, Debug, McBuf)] pub struct CriterionProgress { date: Option, } diff --git a/azalea-protocol/src/packets/game/clientbound_update_attributes_packet.rs b/azalea-protocol/src/packets/game/clientbound_update_attributes_packet.rs index 3d83e6fb..2b382c9f 100644 --- a/azalea-protocol/src/packets/game/clientbound_update_attributes_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_update_attributes_packet.rs @@ -1,6 +1,6 @@ use crate::mc_buf::{McBufReadable, McBufWritable, Readable, Writable}; use azalea_core::resource_location::ResourceLocation; -use packet_macros::{GamePacket, McBufReadable, McBufWritable}; +use packet_macros::{GamePacket, McBuf}; use std::io::{Read, Write}; use uuid::Uuid; @@ -11,14 +11,14 @@ pub struct ClientboundUpdateAttributesPacket { pub attributes: Vec, } -#[derive(Clone, Debug, McBufReadable, McBufWritable)] +#[derive(Clone, Debug, McBuf)] pub struct AttributeSnapshot { pub attribute: ResourceLocation, pub base: f64, pub modifiers: Vec, } -#[derive(Clone, Debug, McBufReadable, McBufWritable)] +#[derive(Clone, Debug, McBuf)] pub struct Modifier { pub uuid: Uuid, pub amount: f64, diff --git a/azalea-protocol/src/packets/game/clientbound_update_recipes_packet.rs b/azalea-protocol/src/packets/game/clientbound_update_recipes_packet.rs index 5b4c5cd9..e7756248 100644 --- a/azalea-protocol/src/packets/game/clientbound_update_recipes_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_update_recipes_packet.rs @@ -1,7 +1,7 @@ use std::io::{Read, Write}; use azalea_core::{resource_location::ResourceLocation, Slot}; -use packet_macros::{GamePacket, McBufReadable, McBufWritable}; +use packet_macros::{GamePacket, McBuf}; use crate::mc_buf::{McBufReadable, McBufWritable, Readable, Writable}; @@ -16,7 +16,7 @@ pub struct Recipe { pub data: RecipeData, } -#[derive(Clone, Debug, McBufReadable, McBufWritable)] +#[derive(Clone, Debug, McBuf)] pub struct ShapelessRecipe { /// Used to group similar recipes together in the recipe book. /// Tag is present in recipe JSON @@ -68,7 +68,7 @@ impl McBufReadable for ShapedRecipe { } } -#[derive(Clone, Debug, McBufReadable, McBufWritable)] +#[derive(Clone, Debug, McBuf)] pub struct CookingRecipe { group: String, ingredient: Ingredient, @@ -77,13 +77,13 @@ pub struct CookingRecipe { #[var] cooking_time: u32, } -#[derive(Clone, Debug, McBufReadable, McBufWritable)] +#[derive(Clone, Debug, McBuf)] pub struct StoneCuttingRecipe { group: String, ingredient: Ingredient, result: Slot, } -#[derive(Clone, Debug, McBufReadable, McBufWritable)] +#[derive(Clone, Debug, McBuf)] pub struct SmithingRecipe { base: Ingredient, addition: Ingredient, @@ -116,7 +116,7 @@ pub enum RecipeData { Smithing(SmithingRecipe), } -#[derive(Clone, Debug, McBufReadable, McBufWritable)] +#[derive(Clone, Debug, McBuf)] pub struct Ingredient { pub allowed: Vec, } diff --git a/azalea-protocol/src/packets/game/mod.rs b/azalea-protocol/src/packets/game/mod.rs index f8ead9d6..883e03aa 100755 --- a/azalea-protocol/src/packets/game/mod.rs +++ b/azalea-protocol/src/packets/game/mod.rs @@ -16,6 +16,7 @@ pub mod clientbound_initialize_border_packet; pub mod clientbound_keep_alive_packet; pub mod clientbound_level_chunk_with_light_packet; pub mod clientbound_level_event_packet; +pub mod clientbound_level_particles_packet; pub mod clientbound_light_update_packet; pub mod clientbound_login_packet; pub mod clientbound_move_entity_pos_packet; @@ -58,10 +59,10 @@ declare_state_packets!( 0x00: clientbound_add_entity_packet::ClientboundAddEntityPacket, 0x02: clientbound_add_mob_packet::ClientboundAddMobPacket, 0x04: clientbound_add_player_packet::ClientboundAddPlayerPacket, - 0x6: clientbound_animate_packet::ClientboundAnimatePacket, - 0xc: clientbound_block_update_packet::ClientboundBlockUpdatePacket, + 0x06: clientbound_animate_packet::ClientboundAnimatePacket, + 0x0c: clientbound_block_update_packet::ClientboundBlockUpdatePacket, 0x0e: clientbound_change_difficulty_packet::ClientboundChangeDifficultyPacket, - 0xf: clientbound_chat_packet::ClientboundChatPacket, + 0x0f: clientbound_chat_packet::ClientboundChatPacket, 0x12: clientbound_declare_commands_packet::ClientboundDeclareCommandsPacket, 0x14: clientbound_container_set_content_packet::ClientboundContainerSetContentPacket, 0x1a: clientbound_disconnect_packet::ClientboundDisconnectPacket, @@ -72,6 +73,7 @@ declare_state_packets!( 0x21: clientbound_keep_alive_packet::ClientboundKeepAlivePacket, 0x22: clientbound_level_chunk_with_light_packet::ClientboundLevelChunkWithLightPacket, 0x23: clientbound_level_event_packet::ClientboundLevelEventPacket, + 0x24: clientbound_level_particles_packet::ClientboundLevelParticlesPacket, 0x25: clientbound_light_update_packet::ClientboundLightUpdatePacket, 0x26: clientbound_login_packet::ClientboundLoginPacket, 0x29: clientbound_move_entity_pos_packet::ClientboundMoveEntityPosPacket, diff --git a/azalea-protocol/src/packets/mod.rs b/azalea-protocol/src/packets/mod.rs index a706646d..16e97068 100755 --- a/azalea-protocol/src/packets/mod.rs +++ b/azalea-protocol/src/packets/mod.rs @@ -43,7 +43,7 @@ where fn write(&self, buf: &mut impl Write) -> Result<(), std::io::Error>; } -impl McBufReadable for ConnectionProtocol { +impl crate::mc_buf::McBufReadable for ConnectionProtocol { fn read_into(buf: &mut impl Read) -> Result { ConnectionProtocol::from_i32(buf.read_varint()?) .ok_or_else(|| "Invalid intention".to_string()) -- cgit v1.2.3