diff options
Diffstat (limited to 'azalea-world/src')
| -rw-r--r-- | azalea-world/src/chunk_storage.rs | 11 | ||||
| -rw-r--r-- | azalea-world/src/entity/data.rs | 6 | ||||
| -rw-r--r-- | azalea-world/src/lib.rs | 4 | ||||
| -rw-r--r-- | azalea-world/src/palette.rs | 6 |
4 files changed, 14 insertions, 13 deletions
diff --git a/azalea-world/src/chunk_storage.rs b/azalea-world/src/chunk_storage.rs index 9d81b28f..566b3198 100644 --- a/azalea-world/src/chunk_storage.rs +++ b/azalea-world/src/chunk_storage.rs @@ -7,8 +7,9 @@ use azalea_buf::{McBufReadable, McBufWritable}; use azalea_core::floor_mod; use azalea_core::{BlockPos, ChunkBlockPos, ChunkPos, ChunkSectionBlockPos}; use std::fmt::Debug; +use std::io::Cursor; use std::{ - io::{Read, Write}, + io::Write, ops::{Index, IndexMut}, sync::{Arc, Mutex}, }; @@ -100,7 +101,7 @@ impl ChunkStorage { pub fn replace_with_packet_data( &mut self, pos: &ChunkPos, - data: &mut impl Read, + data: &mut Cursor<&[u8]>, ) -> Result<(), BufReadError> { if !self.in_range(pos) { println!( @@ -137,14 +138,14 @@ impl IndexMut<&ChunkPos> for ChunkStorage { impl Chunk { pub fn read_with_dimension( - buf: &mut impl Read, + buf: &mut Cursor<&[u8]>, data: &Dimension, ) -> Result<Self, BufReadError> { Self::read_with_dimension_height(buf, data.height()) } pub fn read_with_dimension_height( - buf: &mut impl Read, + buf: &mut Cursor<&[u8]>, dimension_height: u32, ) -> Result<Self, BufReadError> { let section_count = dimension_height / SECTION_HEIGHT; @@ -216,7 +217,7 @@ impl Debug for ChunkStorage { } impl McBufReadable for Section { - fn read_from(buf: &mut impl Read) -> Result<Self, BufReadError> { + fn read_from(buf: &mut Cursor<&[u8]>) -> Result<Self, BufReadError> { let block_count = u16::read_from(buf)?; // this is commented out because the vanilla server is wrong diff --git a/azalea-world/src/entity/data.rs b/azalea-world/src/entity/data.rs index ba8a2157..3fd07ecb 100644 --- a/azalea-world/src/entity/data.rs +++ b/azalea-world/src/entity/data.rs @@ -2,7 +2,7 @@ use azalea_buf::{BufReadError, McBufVarReadable}; use azalea_buf::{McBuf, McBufReadable, McBufWritable}; use azalea_chat::component::Component; use azalea_core::{BlockPos, Direction, GlobalPos, Particle, Slot}; -use std::io::{Read, Write}; +use std::io::{Cursor, Write}; use uuid::Uuid; #[derive(Clone, Debug)] @@ -17,7 +17,7 @@ pub struct EntityDataItem { } impl McBufReadable for EntityMetadata { - fn read_from(buf: &mut impl Read) -> Result<Self, BufReadError> { + fn read_from(buf: &mut Cursor<&[u8]>) -> Result<Self, BufReadError> { let mut metadata = Vec::new(); loop { let index = u8::read_from(buf)?; @@ -74,7 +74,7 @@ pub enum EntityDataValue { } impl McBufReadable for EntityDataValue { - fn read_from(buf: &mut impl Read) -> Result<Self, BufReadError> { + fn read_from(buf: &mut Cursor<&[u8]>) -> Result<Self, BufReadError> { let data_type = u32::var_read_from(buf)?; Ok(match data_type { 0 => EntityDataValue::Byte(u8::read_from(buf)?), diff --git a/azalea-world/src/lib.rs b/azalea-world/src/lib.rs index 4f51d655..08b7ebf4 100644 --- a/azalea-world/src/lib.rs +++ b/azalea-world/src/lib.rs @@ -14,7 +14,7 @@ pub use chunk_storage::{Chunk, ChunkStorage}; use entity::{EntityData, EntityMut, EntityRef}; pub use entity_storage::EntityStorage; use std::{ - io::Read, + io::Cursor, ops::{Index, IndexMut}, sync::{Arc, Mutex}, }; @@ -47,7 +47,7 @@ impl Dimension { pub fn replace_with_packet_data( &mut self, pos: &ChunkPos, - data: &mut impl Read, + data: &mut Cursor<&[u8]>, ) -> Result<(), BufReadError> { self.chunk_storage.replace_with_packet_data(pos, data) } diff --git a/azalea-world/src/palette.rs b/azalea-world/src/palette.rs index ddb0c587..a467ea93 100644 --- a/azalea-world/src/palette.rs +++ b/azalea-world/src/palette.rs @@ -1,5 +1,5 @@ use azalea_buf::{BufReadError, McBufReadable, McBufVarReadable, McBufWritable}; -use std::io::{Read, Write}; +use std::io::{Cursor, Write}; use crate::BitStorage; @@ -33,7 +33,7 @@ impl PalettedContainer { } pub fn read_with_type( - buf: &mut impl Read, + buf: &mut Cursor<&[u8]>, container_type: &'static PalettedContainerType, ) -> Result<Self, BufReadError> { let bits_per_entry = u8::read_from(buf)?; @@ -256,7 +256,7 @@ impl PaletteType { } } - pub fn read(&self, buf: &mut impl Read) -> Result<Palette, BufReadError> { + pub fn read(&self, buf: &mut Cursor<&[u8]>) -> Result<Palette, BufReadError> { Ok(match self { PaletteType::SingleValue => Palette::SingleValue(u32::var_read_from(buf)?), PaletteType::Linear => Palette::Linear(Vec::<u32>::var_read_from(buf)?), |
