aboutsummaryrefslogtreecommitdiff
path: root/azalea-protocol/src/mc_buf/write.rs
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2022-01-03 00:14:41 -0600
committermat <github@matdoes.dev>2022-01-03 00:14:41 -0600
commit96eba2b39a596dd19c29a93aaa3b5bb9b700ba62 (patch)
tree9a585864e81fd01da15bdc9ca5e4e3e7a69eb1f4 /azalea-protocol/src/mc_buf/write.rs
parent394f996df27bedc68be6c1f9e9764e8f78ba6282 (diff)
downloadazalea-drasl-96eba2b39a596dd19c29a93aaa3b5bb9b700ba62.tar.xz
difficulty packet
Diffstat (limited to 'azalea-protocol/src/mc_buf/write.rs')
-rw-r--r--azalea-protocol/src/mc_buf/write.rs19
1 files changed, 18 insertions, 1 deletions
diff --git a/azalea-protocol/src/mc_buf/write.rs b/azalea-protocol/src/mc_buf/write.rs
index 6fbe6eab..fd9faeb4 100644
--- a/azalea-protocol/src/mc_buf/write.rs
+++ b/azalea-protocol/src/mc_buf/write.rs
@@ -1,6 +1,9 @@
use async_trait::async_trait;
-use azalea_core::{game_type::GameType, resource_location::ResourceLocation};
+use azalea_core::{
+ difficulty::Difficulty, game_type::GameType, resource_location::ResourceLocation,
+};
use byteorder::{BigEndian, WriteBytesExt};
+use num_traits::FromPrimitive;
use std::io::Write;
use super::MAX_STRING_LENGTH;
@@ -255,6 +258,13 @@ impl McBufWritable for bool {
}
}
+// i8
+impl McBufWritable for i8 {
+ fn write_into(&self, buf: &mut Vec<u8>) -> Result<(), std::io::Error> {
+ buf.write_byte(*self as u8)
+ }
+}
+
// GameType
impl McBufWritable for GameType {
fn write_into(&self, buf: &mut Vec<u8>) -> Result<(), std::io::Error> {
@@ -284,3 +294,10 @@ impl McBufWritable for azalea_nbt::Tag {
buf.write_nbt(self)
}
}
+
+// Difficulty
+impl McBufWritable for Difficulty {
+ fn write_into(&self, buf: &mut Vec<u8>) -> Result<(), std::io::Error> {
+ u8::write_into(&self.id(), buf)
+ }
+}