aboutsummaryrefslogtreecommitdiff
path: root/azalea-protocol/src/mc_buf/read.rs
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2022-04-20 16:28:31 +0000
committermat <github@matdoes.dev>2022-04-20 16:28:39 +0000
commit8bd97c6c96f2c3c1ef4edfc1ff9d59f9af664972 (patch)
treed435eea3d11b59e1d93124b1293d1c50fc063792 /azalea-protocol/src/mc_buf/read.rs
parentc5f10af09d1d2fee640b946da9ec5ca1bcd1e62d (diff)
downloadazalea-drasl-8bd97c6c96f2c3c1ef4edfc1ff9d59f9af664972.tar.xz
add player abilities packet
Diffstat (limited to 'azalea-protocol/src/mc_buf/read.rs')
-rw-r--r--azalea-protocol/src/mc_buf/read.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/azalea-protocol/src/mc_buf/read.rs b/azalea-protocol/src/mc_buf/read.rs
index 20b69238..e036643e 100644
--- a/azalea-protocol/src/mc_buf/read.rs
+++ b/azalea-protocol/src/mc_buf/read.rs
@@ -24,6 +24,7 @@ pub trait Readable {
async fn read_long(&mut self) -> Result<i64, String>;
async fn read_resource_location(&mut self) -> Result<ResourceLocation, String>;
async fn read_short(&mut self) -> Result<i16, String>;
+ async fn read_float(&mut self) -> Result<f32, String>;
}
#[async_trait]
@@ -189,6 +190,13 @@ where
Err(_) => Err("Error reading short".to_string()),
}
}
+
+ async fn read_float(&mut self) -> Result<f32, String> {
+ match AsyncReadExt::read_f32(self).await {
+ Ok(r) => Ok(r),
+ Err(_) => Err("Error reading float".to_string()),
+ }
+ }
}
#[async_trait]
@@ -362,6 +370,17 @@ impl McBufReadable for i8 {
}
}
+// f32
+#[async_trait]
+impl McBufReadable for f32 {
+ async fn read_into<R>(buf: &mut R) -> Result<Self, String>
+ where
+ R: AsyncRead + std::marker::Unpin + std::marker::Send,
+ {
+ buf.read_float().await
+ }
+}
+
// GameType
#[async_trait]
impl McBufReadable for GameType {