aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/deserialize.rs43
-rw-r--r--src/lib.rs14
-rw-r--r--src/nbt.rs172
-rw-r--r--src/protocol.rs50
-rw-r--r--src/serialize.rs7
-rw-r--r--src/status.rs73
-rw-r--r--src/test_macros.rs27
-rw-r--r--src/types.rs330
-rw-r--r--src/utils.rs34
-rw-r--r--src/uuid.rs70
-rw-r--r--src/v1_15_2.rs2253
11 files changed, 2161 insertions, 912 deletions
diff --git a/src/deserialize.rs b/src/deserialize.rs
index 694c6e5..f87cb49 100644
--- a/src/deserialize.rs
+++ b/src/deserialize.rs
@@ -12,7 +12,7 @@ pub enum DeserializeErr {
NbtBadLength(isize),
NbtInvalidStartTag(u8),
CannotUnderstandValue(String),
- FailedJsonDeserialize(String)
+ FailedJsonDeserialize(String),
}
impl<'b, R> Into<DeserializeResult<'b, R>> for DeserializeErr {
@@ -37,10 +37,7 @@ impl<'b, R> Into<DeserializeResult<'b, R>> for Deserialized<'b, R> {
impl<'b, R> Deserialized<'b, R> {
#[inline]
pub fn create(value: R, data: &'b [u8]) -> Self {
- Deserialized {
- value,
- data,
- }
+ Deserialized { value, data }
}
#[inline]
@@ -50,57 +47,55 @@ impl<'b, R> Deserialized<'b, R> {
#[inline]
pub fn replace<T>(self, other: T) -> Deserialized<'b, T> {
- Deserialized{
+ Deserialized {
value: other,
data: self.data,
}
}
#[inline]
- pub fn map<F, T>(self, f: F) -> Deserialized<'b, T> where F: FnOnce(R) -> T {
- Deserialized{
+ pub fn map<F, T>(self, f: F) -> Deserialized<'b, T>
+ where
+ F: FnOnce(R) -> T,
+ {
+ Deserialized {
value: f(self.value),
data: self.data,
}
}
#[inline]
- pub fn try_map<F, T>(self, f: F) -> DeserializeResult<'b, T> where
- F: FnOnce(R) -> Result<T, DeserializeErr>
+ pub fn try_map<F, T>(self, f: F) -> DeserializeResult<'b, T>
+ where
+ F: FnOnce(R) -> Result<T, DeserializeErr>,
{
match f(self.value) {
- Ok(new_value) => Ok(Deserialized{
+ Ok(new_value) => Ok(Deserialized {
value: new_value,
data: self.data,
}),
- Err(err) => Err(err)
+ Err(err) => Err(err),
}
}
#[inline]
- pub fn and_then<F, T>(self, f: F) -> DeserializeResult<'b, T> where
- F: FnOnce(R, &'b[u8]) -> DeserializeResult<'b, T>
+ pub fn and_then<F, T>(self, f: F) -> DeserializeResult<'b, T>
+ where
+ F: FnOnce(R, &'b [u8]) -> DeserializeResult<'b, T>,
{
f(self.value, self.data)
}
}
-
impl<'b, R> From<(R, &'b [u8])> for Deserialized<'b, R> {
fn from(v: (R, &'b [u8])) -> Self {
let (value, data) = v;
- Deserialized {
- value,
- data,
- }
+ Deserialized { value, data }
}
}
-pub type DeserializeResult<'b, R>
-= Result<
- Deserialized<'b, R>,
- DeserializeErr>;
+pub type DeserializeResult<'b, R> = Result<Deserialized<'b, R>, DeserializeErr>;
pub trait Deserialize: Sized {
fn mc_deserialize(data: &[u8]) -> DeserializeResult<Self>;
-} \ No newline at end of file
+}
diff --git a/src/lib.rs b/src/lib.rs
index 1d99ee6..8805699 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -5,20 +5,20 @@
#[cfg(test)]
extern crate test;
-mod serialize;
mod deserialize;
-pub mod utils;
+pub mod nbt;
#[macro_export]
pub mod protocol;
-pub mod uuid;
-pub mod nbt;
+mod serialize;
+pub mod status;
pub mod types;
+pub mod utils;
+pub mod uuid;
pub mod v1_15_2;
-pub mod status;
-pub use serialize::*;
pub use deserialize::*;
+pub use serialize::*;
#[cfg(test)]
#[macro_export]
-mod test_macros; \ No newline at end of file
+mod test_macros;
diff --git a/src/nbt.rs b/src/nbt.rs
index f784454..27eb051 100644
--- a/src/nbt.rs
+++ b/src/nbt.rs
@@ -1,7 +1,9 @@
-use std::fmt;
-use crate::{DeserializeResult, DeserializeErr, Deserialized};
-use crate::utils::{read_short, take, read_int, read_long, read_one_byte, write_long, write_int, write_short};
use crate::protocol::TestRandom;
+use crate::utils::{
+ read_int, read_long, read_one_byte, read_short, take, write_int, write_long, write_short,
+};
+use crate::{DeserializeErr, DeserializeResult, Deserialized};
+use std::fmt;
#[derive(Clone, Debug, PartialEq)]
pub struct NamedTag {
@@ -34,12 +36,15 @@ impl TestRandom for NamedTag {
impl fmt::Display for NamedTag {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- f.write_fmt(format_args!("TAG_{}('{}'): ", self.payload.tag_type_name(), self.name))?;
+ f.write_fmt(format_args!(
+ "TAG_{}('{}'): ",
+ self.payload.tag_type_name(),
+ self.name
+ ))?;
self.payload.write_contents(f)
}
}
-
#[derive(Clone, Debug, PartialEq)]
pub enum Tag {
Byte(i8),
@@ -140,7 +145,7 @@ impl TestRandom for Tag {
4 => Tag::Float(f32::test_gen_random()),
5 => Tag::Double(f64::test_gen_random()),
6 => Tag::String(String::test_gen_random()),
- other => panic!("impossible {}", other)
+ other => panic!("impossible {}", other),
});
}
@@ -160,19 +165,34 @@ impl TestRandom for Tag {
}
#[inline]
-fn write_contents<F>(contents: &Vec<F>) -> String where F: fmt::Display {
- format!("{} entries\n{{\n{}\n}}", contents.len(), contents.iter()
- .flat_map(move |elem| elem.to_string().split("\n").map(String::from).collect::<Vec<String>>())
- .map(move |line| " ".to_owned() + line.as_str())
- .collect::<Vec<String>>()
- .join("\n"))
+fn write_contents<F>(contents: &Vec<F>) -> String
+where
+ F: fmt::Display,
+{
+ format!(
+ "{} entries\n{{\n{}\n}}",
+ contents.len(),
+ contents
+ .iter()
+ .flat_map(move |elem| elem
+ .to_string()
+ .split("\n")
+ .map(String::from)
+ .collect::<Vec<String>>())
+ .map(move |line| " ".to_owned() + line.as_str())
+ .collect::<Vec<String>>()
+ .join("\n")
+ )
}
// deserialization first
// reads from the root level
fn read_nbt_data(data: &[u8]) -> DeserializeResult<NamedTag> {
- let Deserialized { value: tag_type_id, data: _ } = read_one_byte(data)?;
+ let Deserialized {
+ value: tag_type_id,
+ data: _,
+ } = read_one_byte(data)?;
match tag_type_id {
0x0A => read_named_tag(data),
other => Err(DeserializeErr::NbtInvalidStartTag(other)),
@@ -182,8 +202,12 @@ fn read_nbt_data(data: &[u8]) -> DeserializeResult<NamedTag> {
// reads any named tag: read id -> read name -> read tag with id -> name tag with name
#[inline]
pub fn read_named_tag(data: &[u8]) -> DeserializeResult<NamedTag> {
- let Deserialized { value: tag_type_id, data } = read_one_byte(data)?;
- if tag_type_id == 0x00 { // tag end
+ let Deserialized {
+ value: tag_type_id,
+ data,
+ } = read_one_byte(data)?;
+ if tag_type_id == 0x00 {
+ // tag end
Deserialized::ok(Tag::End.with_name(""), data)
} else {
let Deserialized { value: name, data } = read_string(data)?;
@@ -244,7 +268,8 @@ fn read_tag_double(data: &[u8]) -> DeserializeResult<Tag> {
#[inline]
fn read_tag_byte_array(data: &[u8]) -> DeserializeResult<Tag> {
- Ok(read_int(data)?.and_then(move |size, rest| take(size as usize)(rest))?
+ Ok(read_int(data)?
+ .and_then(move |size, rest| take(size as usize)(rest))?
.map(move |arr| Tag::ByteArray(Vec::from(arr))))
}
@@ -254,19 +279,28 @@ fn read_tag_string(data: &[u8]) -> DeserializeResult<Tag> {
}
fn read_tag_list(data: &[u8]) -> DeserializeResult<Tag> {
- let Deserialized { value: contents_tag_type_id, data } = read_one_byte(data)?;
- let Deserialized { value: list_length, data } = read_int(data)?;
+ let Deserialized {
+ value: contents_tag_type_id,
+ data,
+ } = read_one_byte(data)?;
+ let Deserialized {
+ value: list_length,
+ data,
+ } = read_int(data)?;
if list_length <= 0 {
if contents_tag_type_id != 0x00 {
Err(DeserializeErr::NbtBadLength(list_length as isize))
} else {
- Deserialized::ok(Tag::List(vec!()), data)
+ Deserialized::ok(Tag::List(vec![]), data)
}
} else {
let mut out_vec = Vec::with_capacity(list_length as usize);
let mut remaining_data = data;
for _ in 0..list_length {
- let Deserialized { value: element, data: rest } = read_tag(contents_tag_type_id, &remaining_data)?;
+ let Deserialized {
+ value: element,
+ data: rest,
+ } = read_tag(contents_tag_type_id, &remaining_data)?;
out_vec.push(element);
remaining_data = rest;
}
@@ -279,7 +313,10 @@ fn read_tag_compound(data: &[u8]) -> DeserializeResult<Tag> {
let mut out = Vec::new();
let mut remaining_data = data;
loop {
- let Deserialized { value: elem, data: rest } = read_named_tag(remaining_data)?;
+ let Deserialized {
+ value: elem,
+ data: rest,
+ } = read_named_tag(remaining_data)?;
remaining_data = rest;
if elem.is_end() {
break;
@@ -295,7 +332,8 @@ fn read_tag_int_array(data: &[u8]) -> DeserializeResult<Tag> {
read_array_tag(
data,
move |data| Ok(read_int(data)?.map(move |r| r as i32)),
- Tag::IntArray)
+ Tag::IntArray,
+ )
}
#[inline]
@@ -303,13 +341,19 @@ fn read_tag_long_array(data: &[u8]) -> DeserializeResult<Tag> {
read_array_tag(
data,
move |data| Ok(read_long(data)?.map(move |r| r as i64)),
- Tag::LongArray)
+ Tag::LongArray,
+ )
}
#[inline]
-fn read_array_tag<'a, R, F, M>(data: &'a [u8], parser: F, finalizer: M) -> DeserializeResult<'a, Tag> where
+fn read_array_tag<'a, R, F, M>(
+ data: &'a [u8],
+ parser: F,
+ finalizer: M,
+) -> DeserializeResult<'a, Tag>
+where
F: Fn(&'a [u8]) -> DeserializeResult<'a, R>,
- M: Fn(Vec<R>) -> Tag
+ M: Fn(Vec<R>) -> Tag,
{
let Deserialized { value: count, data } = read_int(data)?.map(move |v| v as i32);
if count < 0 {
@@ -318,7 +362,10 @@ fn read_array_tag<'a, R, F, M>(data: &'a [u8], parser: F, finalizer: M) -> Deser
let mut out = Vec::with_capacity(count as usize);
let mut data_remaining = data;
for _ in 0..count {
- let Deserialized { value: elem, data: rest } = parser(data_remaining)?;
+ let Deserialized {
+ value: elem,
+ data: rest,
+ } = parser(data_remaining)?;
data_remaining = rest;
out.push(elem);
}
@@ -330,12 +377,11 @@ fn read_array_tag<'a, R, F, M>(data: &'a [u8], parser: F, finalizer: M) -> Deser
#[inline]
fn read_string(data: &[u8]) -> DeserializeResult<String> {
read_short(data)?
- .and_then(move |length, data|
- take(length as usize)(data))?
- .try_map(move |bytes|
- String::from_utf8(Vec::from(bytes)).map_err(move |err| {
- DeserializeErr::BadStringEncoding(err)
- }))
+ .and_then(move |length, data| take(length as usize)(data))?
+ .try_map(move |bytes| {
+ String::from_utf8(Vec::from(bytes))
+ .map_err(move |err| DeserializeErr::BadStringEncoding(err))
+ })
}
// serialize
@@ -343,12 +389,13 @@ impl NamedTag {
pub fn bytes(&self) -> Vec<u8> {
let type_id = self.payload.id();
if type_id == 0x00 {
- vec!(0x00)
+ vec![0x00]
} else {
let payload_bytes = self.payload.bytes();
let name_len = self.name.len();
let name_len_bytes = write_short(name_len as u16);
- let mut out = Vec::with_capacity(1 + name_len_bytes.len() + name_len + payload_bytes.len());
+ let mut out =
+ Vec::with_capacity(1 + name_len_bytes.len() + name_len + payload_bytes.len());
out.push(type_id);
out.extend_from_slice(&name_len_bytes);
out.extend(self.name.bytes());
@@ -379,7 +426,7 @@ impl Tag {
pub fn bytes(&self) -> Vec<u8> {
match self {
- Tag::Byte(b) => vec!(*b as u8),
+ Tag::Byte(b) => vec![*b as u8],
Tag::Short(v) => Vec::from(write_short(*v as u16)),
Tag::Int(v) => Vec::from(write_int(*v as u32)),
Tag::Long(v) => Vec::from(write_long(*v as u64)),
@@ -412,7 +459,9 @@ impl Tag {
let elem_id = elem.id();
if let Some(old_id) = id.replace(elem_id) {
if old_id != elem_id {
- panic!("list contains tags of different types, cannot serialize");
+ panic!(
+ "list contains tags of different types, cannot serialize"
+ );
}
}
}
@@ -467,9 +516,9 @@ impl Tag {
#[cfg(test)]
mod tests {
use super::*;
- use std::io::Read;
use flate2::read::GzDecoder;
use std::fs::File;
+ use std::io::Read;
#[test]
fn test_read_bignbt_example() {
@@ -521,29 +570,53 @@ mod tests {
let (unzipped, result) = read_bigtest_with_bytes();
let serialized = result.bytes();
assert_eq!(unzipped, serialized);
- let Deserialized { value: unserialized, data: _ } = NamedTag::root_compound_tag_from_bytes(serialized.as_slice()).expect("deserialize serialized nbt");
+ let Deserialized {
+ value: unserialized,
+ data: _,
+ } = NamedTag::root_compound_tag_from_bytes(serialized.as_slice())
+ .expect("deserialize serialized nbt");
assert_eq!(unserialized, result);
}
#[test]
fn test_int_array() {
- let original = Tag::Compound(vec!(
- Tag::IntArray(vec!(1, 2, -5, 123127, -12373, 0, 0, 4, 2)).with_name("test ints")
- )).with_name("test");
+ let original = Tag::Compound(vec![Tag::IntArray(vec![
+ 1, 2, -5, 123127, -12373, 0, 0, 4, 2,
+ ])
+ .with_name("test ints")])
+ .with_name("test");
let bytes = original.bytes();
- let Deserialized { value: unserialized, data: _ } = NamedTag::root_compound_tag_from_bytes(bytes.as_slice()).expect("deserialize int array");
+ let Deserialized {
+ value: unserialized,
+ data: _,
+ } = NamedTag::root_compound_tag_from_bytes(bytes.as_slice())
+ .expect("deserialize int array");
assert_eq!(original, unserialized);
}
#[test]
fn test_long_array() {
- let original = Tag::Compound(vec!(
- Tag::LongArray(vec!(1, 2, -5, 123127999999, -1237399999, 0, 0, 4, 2)).with_name("test ints")
- )).with_name("test");
+ let original = Tag::Compound(vec![Tag::LongArray(vec![
+ 1,
+ 2,
+ -5,
+ 123127999999,
+ -1237399999,
+ 0,
+ 0,
+ 4,
+ 2,
+ ])
+ .with_name("test ints")])
+ .with_name("test");
let bytes = original.bytes();
- let Deserialized { value: unserialized, data: _ } = NamedTag::root_compound_tag_from_bytes(bytes.as_slice()).expect("deserialize int array");
+ let Deserialized {
+ value: unserialized,
+ data: _,
+ } = NamedTag::root_compound_tag_from_bytes(bytes.as_slice())
+ .expect("deserialize int array");
assert_eq!(original, unserialized);
}
@@ -559,7 +632,10 @@ mod tests {
fn read_bigtest_with_bytes() -> (Vec<u8>, NamedTag) {
let unzipped = read_compressed_file("src/testdata/bigtest.nbt").expect("read nbt data");
- let Deserialized { value: result, data: rest } = NamedTag::root_compound_tag_from_bytes(unzipped.as_slice()).expect("deserialize nbt");
+ let Deserialized {
+ value: result,
+ data: rest,
+ } = NamedTag::root_compound_tag_from_bytes(unzipped.as_slice()).expect("deserialize nbt");
assert_eq!(rest.len(), 0);
(unzipped, result)
@@ -586,4 +662,4 @@ mod tests {
gz.read_to_end(&mut out)?;
Ok(out)
}
-} \ No newline at end of file
+}
diff --git a/src/protocol.rs b/src/protocol.rs
index e768fdb..4eb1094 100644
--- a/src/protocol.rs
+++ b/src/protocol.rs
@@ -1,4 +1,4 @@
-use crate::{Serialize, Deserialize, DeserializeErr};
+use crate::{Deserialize, DeserializeErr, Serialize};
use std::fmt::Debug;
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)]
@@ -56,7 +56,9 @@ pub trait TestRandom {
#[macro_export]
macro_rules! as_item {
- ($i:item) => { $i };
+ ($i:item) => {
+ $i
+ };
}
#[macro_export]
@@ -405,11 +407,17 @@ macro_rules! proto_byte_flag {
macro_rules! counted_array_type {
($name: ident, $countert: ty, $tousize_fn: ident, $fromusize_fn: ident) => {
#[derive(Debug, Clone, PartialEq)]
- pub struct $name<T> where T: Debug + Clone + PartialEq {
- pub data: Vec<T>
+ pub struct $name<T>
+ where
+ T: Debug + Clone + PartialEq,
+ {
+ pub data: Vec<T>,
}
- impl<T> Serialize for $name<T> where T: Serialize + Debug + Clone + PartialEq {
+ impl<T> Serialize for $name<T>
+ where
+ T: Serialize + Debug + Clone + PartialEq,
+ {
fn mc_serialize<S: Serializer>(&self, to: &mut S) -> SerializeResult {
let count: $countert = $fromusize_fn(self.data.len());
to.serialize_other(&count)?;
@@ -422,14 +430,23 @@ macro_rules! counted_array_type {
}
}
- impl<T> Deserialize for $name<T> where T: Deserialize + Debug + Clone + PartialEq {
+ impl<T> Deserialize for $name<T>
+ where
+ T: Deserialize + Debug + Clone + PartialEq,
+ {
fn mc_deserialize(data: &[u8]) -> DeserializeResult<'_, Self> {
- let Deserialized{value: raw_count, mut data} = <$countert>::mc_deserialize(data)?;
+ let Deserialized {
+ value: raw_count,
+ mut data,
+ } = <$countert>::mc_deserialize(data)?;
let count: usize = $tousize_fn(raw_count);
let mut out = Vec::with_capacity(count);
for _ in 0..count {
- let Deserialized{value: next, data: rest} = T::mc_deserialize(data)?;
+ let Deserialized {
+ value: next,
+ data: rest,
+ } = T::mc_deserialize(data)?;
data = rest;
out.push(next);
}
@@ -438,20 +455,29 @@ macro_rules! counted_array_type {
}
}
- impl<T> Into<Vec<T>> for $name<T> where T: Debug + Clone + PartialEq {
+ impl<T> Into<Vec<T>> for $name<T>
+ where
+ T: Debug + Clone + PartialEq,
+ {
fn into(self) -> Vec<T> {
self.data
}
}
- impl<T> From<Vec<T>> for $name<T> where T: Debug + Clone + PartialEq {
+ impl<T> From<Vec<T>> for $name<T>
+ where
+ T: Debug + Clone + PartialEq,
+ {
fn from(data: Vec<T>) -> Self {
Self { data }
}
}
#[cfg(test)]
- impl<T> TestRandom for $name<T> where T: TestRandom + Debug + Clone + PartialEq {
+ impl<T> TestRandom for $name<T>
+ where
+ T: TestRandom + Debug + Clone + PartialEq,
+ {
fn test_gen_random() -> Self {
let elem_count: usize = rand::random::<usize>() % 32;
let mut out = Vec::with_capacity(elem_count);
@@ -462,5 +488,5 @@ macro_rules! counted_array_type {
Self { data: out }
}
}
- }
+ };
}
diff --git a/src/serialize.rs b/src/serialize.rs
index 5eb8f2a..3239b66 100644
--- a/src/serialize.rs
+++ b/src/serialize.rs
@@ -1,7 +1,7 @@
#[derive(Debug)]
pub enum SerializeErr {
FailedJsonEncode(String),
- InconsistentPlayerActions(String)
+ InconsistentPlayerActions(String),
}
pub type SerializeResult = Result<(), SerializeErr>;
@@ -11,14 +11,13 @@ pub trait Serialize: Sized {
}
pub trait Serializer: Sized {
-
fn serialize_bytes(&mut self, data: &[u8]) -> SerializeResult;
fn serialize_byte(&mut self, byte: u8) -> SerializeResult {
- self.serialize_bytes(vec!(byte).as_slice())
+ self.serialize_bytes(vec![byte].as_slice())
}
fn serialize_other<S: Serialize>(&mut self, other: &S) -> SerializeResult {
other.mc_serialize(self)
}
-} \ No newline at end of file
+}
diff --git a/src/status.rs b/src/status.rs
index 7d254aa..22f75bf 100644
--- a/src/status.rs
+++ b/src/status.rs
@@ -1,9 +1,12 @@
+use crate::protocol::TestRandom;
use crate::types::Chat;
-use crate::{SerializeResult, SerializeErr, Serialize as McSerialize, Deserialize as McDeserialize, DeserializeResult, DeserializeErr};
use crate::uuid::UUID4;
-use serde::{Serialize, Serializer, Deserialize, Deserializer};
+use crate::{
+ Deserialize as McDeserialize, DeserializeErr, DeserializeResult, Serialize as McSerialize,
+ SerializeErr, SerializeResult,
+};
+use serde::{Deserialize, Deserializer, Serialize, Serializer};
use std::fmt;
-use crate::protocol::TestRandom;
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub struct StatusSpec {
@@ -16,9 +19,11 @@ pub struct StatusSpec {
impl McSerialize for StatusSpec {
fn mc_serialize<S: crate::Serializer>(&self, to: &mut S) -> SerializeResult {
- serde_json::to_string(self).map_err(move |err| {
- SerializeErr::FailedJsonEncode(format!("failed to serialize json status {}", err))
- })?.mc_serialize(to)
+ serde_json::to_string(self)
+ .map_err(move |err| {
+ SerializeErr::FailedJsonEncode(format!("failed to serialize json status {}", err))
+ })?
+ .mc_serialize(to)
}
}
@@ -26,22 +31,24 @@ impl McDeserialize for StatusSpec {
fn mc_deserialize(data: &[u8]) -> DeserializeResult<'_, Self> {
String::mc_deserialize(data)?.try_map(move |v| {
serde_json::from_str(v.as_str()).map_err(move |err| {
- DeserializeErr::CannotUnderstandValue(format!("failed to deserialize json status {}", err))
+ DeserializeErr::CannotUnderstandValue(format!(
+ "failed to deserialize json status {}",
+ err
+ ))
})
})
}
}
-
#[cfg(test)]
impl TestRandom for StatusSpec {
fn test_gen_random() -> Self {
Self {
- version: StatusVersionSpec{
+ version: StatusVersionSpec {
protocol: rand::random(),
name: String::test_gen_random(),
},
- players: StatusPlayersSpec{
+ players: StatusPlayersSpec {
sample: Vec::default(),
max: rand::random(),
online: rand::random(),
@@ -80,8 +87,9 @@ pub struct StatusFaviconSpec {
}
impl Serialize for StatusFaviconSpec {
- fn serialize<S>(&self, serializer: S) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where
- S: Serializer
+ fn serialize<S>(&self, serializer: S) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
+ where
+ S: Serializer,
{
let data_base64 = base64::encode(self.data.as_slice());
let content = format!("data:{};base64,{}", self.content_type, data_base64);
@@ -90,8 +98,9 @@ impl Serialize for StatusFaviconSpec {
}
impl<'de> Deserialize<'de> for StatusFaviconSpec {
- fn deserialize<D>(deserializer: D) -> Result<Self, <D as Deserializer<'de>>::Error> where
- D: Deserializer<'de>
+ fn deserialize<D>(deserializer: D) -> Result<Self, <D as Deserializer<'de>>::Error>
+ where
+ D: Deserializer<'de>,
{
struct Visitor;
impl serde::de::Visitor<'_> for Visitor {
@@ -107,8 +116,8 @@ impl<'de> Deserialize<'de> for StatusFaviconSpec {
// regex to parse valid base64 content
const PATTERN: &str = r"^data:([A-Za-z/]+);base64,([-A-Za-z0-9+/]*={0,3})$";
lazy_static! {
- static ref RE: Regex = Regex::new(PATTERN).expect("regex is valid");
- }
+ static ref RE: Regex = Regex::new(PATTERN).expect("regex is valid");
+ }
// try to use regex on the input
// RE.captures_iter(v).next() means "try to get the first capture iterator"
@@ -117,20 +126,30 @@ impl<'de> Deserialize<'de> for StatusFaviconSpec {
// wrap the content_type and parsed data in StatusFaviconSpec
// then we convert the option to a result using map and unwrap_or_else
let mut captures: regex::CaptureMatches<'_, '_> = RE.captures_iter(v);
- captures.next().and_then(move |captures|
- captures.get(1).and_then(move |content_type|
- captures.get(2).and_then(move |raw_base64|
- base64::decode(raw_base64.as_str().as_bytes()).map(move |data| {
- StatusFaviconSpec {
- content_type: content_type.as_str().to_owned(),
- data,
- }
- }).ok())))
+ captures
+ .next()
+ .and_then(move |captures| {
+ captures.get(1).and_then(move |content_type| {
+ captures.get(2).and_then(move |raw_base64| {
+ base64::decode(raw_base64.as_str().as_bytes())
+ .map(move |data| StatusFaviconSpec {
+ content_type: content_type.as_str().to_owned(),
+ data,
+ })
+ .ok()
+ })
+ })
+ })
.map(move |result| Ok(result))
- .unwrap_or_else(|| Err(serde::de::Error::invalid_value(serde::de::Unexpected::Str(v), &self)))
+ .unwrap_or_else(|| {
+ Err(serde::de::Error::invalid_value(
+ serde::de::Unexpected::Str(v),
+ &self,
+ ))
+ })
}
}
deserializer.deserialize_str(Visitor {})
}
-} \ No newline at end of file
+}
diff --git a/src/test_macros.rs b/src/test_macros.rs
index cc573a7..d8fc76b 100644
--- a/src/test_macros.rs
+++ b/src/test_macros.rs
@@ -1,4 +1,4 @@
-use crate::{Serializer, SerializeResult};
+use crate::{SerializeResult, Serializer};
#[cfg(test)]
#[macro_export]
macro_rules! packet_test_cases {
@@ -11,12 +11,13 @@ macro_rules! packet_test_cases {
packet.mc_serialize(&mut out).expect("serialize succeeds");
let bytes = out.into_bytes();
- let raw_packet = RawPacket{
+ let raw_packet = RawPacket {
id: packet.id(),
data: bytes,
};
- let deserialized = <$pnam>::mc_deserialize(raw_packet).expect("deserialize succeeds");
+ let deserialized =
+ <$pnam>::mc_deserialize(raw_packet).expect("deserialize succeeds");
assert_eq!(packet, deserialized);
}
}
@@ -25,12 +26,16 @@ macro_rules! packet_test_cases {
fn $benchnams(b: &mut Bencher) {
let packet = $pnam::$varnam($bodnam::test_gen_random());
let mut serializer = BenchSerializer::default();
- packet.mc_serialize(&mut serializer).expect("serialize succeeds");
+ packet
+ .mc_serialize(&mut serializer)
+ .expect("serialize succeeds");
b.bytes = serializer.len() as u64;
serializer.reset();
b.iter(|| {
- packet.mc_serialize(&mut serializer).expect("serialize succeeds");
+ packet
+ .mc_serialize(&mut serializer)
+ .expect("serialize succeeds");
serializer.reset();
})
}
@@ -39,11 +44,13 @@ macro_rules! packet_test_cases {
fn $benchnamd(b: &mut Bencher) {
let packet = $pnam::$varnam($bodnam::test_gen_random());
let mut serializer = BytesSerializer::default();
- packet.mc_serialize(&mut serializer).expect("serialize succeeds");
+ packet
+ .mc_serialize(&mut serializer)
+ .expect("serialize succeeds");
let bytes = serializer.into_bytes();
b.bytes = bytes.len() as u64;
- let raw_packet = RawPacket{
+ let raw_packet = RawPacket {
id: packet.id(),
data: bytes,
};
@@ -51,13 +58,13 @@ macro_rules! packet_test_cases {
$pnam::mc_deserialize(raw_packet.clone()).expect("deserialize succeeds");
})
}
- }
+ };
}
#[cfg(test)]
#[derive(Clone, Debug, Default, PartialEq)]
pub struct BenchSerializer {
- data: Vec<u8>
+ data: Vec<u8>,
}
#[cfg(test)]
@@ -77,4 +84,4 @@ impl BenchSerializer {
pub fn len(&self) -> usize {
self.data.len()
}
-} \ No newline at end of file
+}
diff --git a/src/types.rs b/src/types.rs
index 9d8f595..2082b56 100644
--- a/src/types.rs
+++ b/src/types.rs
@@ -1,8 +1,8 @@
// ... PRIMITIVE TYPES ...
-use crate::*;
use crate::utils::*;
use crate::uuid::UUID4;
+use crate::*;
#[cfg(test)]
use crate::protocol::TestRandom;
@@ -16,12 +16,10 @@ impl Serialize for bool {
impl Deserialize for bool {
fn mc_deserialize(data: &[u8]) -> DeserializeResult<'_, Self> {
- read_one_byte(data)?.try_map(move |b| {
- match b {
- 0x00 => Ok(false),
- 0x01 => Ok(true),
- other => Err(DeserializeErr::InvalidBool(other))
- }
+ read_one_byte(data)?.try_map(move |b| match b {
+ 0x00 => Ok(false),
+ 0x01 => Ok(true),
+ other => Err(DeserializeErr::InvalidBool(other)),
})
}
}
@@ -103,7 +101,9 @@ impl Serialize for i16 {
impl Deserialize for i16 {
fn mc_deserialize(data: &[u8]) -> DeserializeResult<'_, Self> {
- u16::mc_deserialize(data)?.map(move |other| other as i16).into()
+ u16::mc_deserialize(data)?
+ .map(move |other| other as i16)
+ .into()
}
}
@@ -158,7 +158,6 @@ impl TestRandom for i64 {
// float
impl Serialize for f32 {
-
//noinspection ALL
fn mc_serialize<S: Serializer>(&self, to: &mut S) -> SerializeResult {
let data = (*self).to_be_bytes();
@@ -168,7 +167,9 @@ impl Serialize for f32 {
impl Deserialize for f32 {
fn mc_deserialize(data: &[u8]) -> DeserializeResult<'_, Self> {
- i32::mc_deserialize(data)?.map(move |r| f32::from_bits(r as u32)).into()
+ i32::mc_deserialize(data)?
+ .map(move |r| f32::from_bits(r as u32))
+ .into()
}
}
@@ -190,7 +191,9 @@ impl Serialize for f64 {
impl Deserialize for f64 {
fn mc_deserialize(data: &[u8]) -> DeserializeResult<'_, Self> {
- i64::mc_deserialize(data)?.map(move |r| f64::from_bits(r as u64)).into()
+ i64::mc_deserialize(data)?
+ .map(move |r| f64::from_bits(r as u64))
+ .into()
}
}
@@ -205,8 +208,10 @@ impl TestRandom for f64 {
const VAR_INT_BYTES: usize = 5;
const VAR_LONG_BYTES: usize = 10;
-const DESERIALIZE_VAR_INT: impl for<'b> Fn(&'b [u8]) -> DeserializeResult<'b, u64> = deserialize_var_num(VAR_INT_BYTES);
-const DESERIALIZE_VAR_LONG: impl for<'b> Fn(&'b [u8]) -> DeserializeResult<'b, u64> = deserialize_var_num(VAR_LONG_BYTES);
+const DESERIALIZE_VAR_INT: impl for<'b> Fn(&'b [u8]) -> DeserializeResult<'b, u64> =
+ deserialize_var_num(VAR_INT_BYTES);
+const DESERIALIZE_VAR_LONG: impl for<'b> Fn(&'b [u8]) -> DeserializeResult<'b, u64> =
+ deserialize_var_num(VAR_LONG_BYTES);
#[derive(Copy, Clone, PartialOrd, PartialEq, Debug, Default, Hash, Ord, Eq)]
pub struct VarInt(pub i32);
@@ -309,7 +314,9 @@ fn serialize_var_num(data: u64, out: &mut [u8]) -> &[u8] {
&out[..byte_idx]
}
-const fn deserialize_var_num(max_bytes: usize) -> impl for<'b> Fn(&'b [u8]) -> DeserializeResult<'b, u64> {
+const fn deserialize_var_num(
+ max_bytes: usize,
+) -> impl for<'b> Fn(&'b [u8]) -> DeserializeResult<'b, u64> {
move |orig_data| {
let mut data = orig_data;
let mut v: u64 = 0;
@@ -321,7 +328,10 @@ const fn deserialize_var_num(max_bytes: usize) -> impl for<'b> Fn(&'b [u8]) -> D
if i == max_bytes {
return DeserializeErr::VarNumTooLong(Vec::from(&orig_data[..i])).into();
}
- let Deserialized { value: byte, data: rest } = read_one_byte(data)?;
+ let Deserialized {
+ value: byte,
+ data: rest,
+ } = read_one_byte(data)?;
data = rest;
has_more = byte & 0x80 != 0;
v |= ((byte as u64) & 0x7F) << bit_place;
@@ -348,8 +358,7 @@ impl Deserialize for String {
Err(DeserializeErr::NegativeLength(length))
} else {
take(length.0 as usize)(rest)?.try_map(move |taken| {
- String::from_utf8(taken.to_vec())
- .map_err(DeserializeErr::BadStringEncoding)
+ String::from_utf8(taken.to_vec()).map_err(DeserializeErr::BadStringEncoding)
})
}
})
@@ -412,13 +421,14 @@ impl Serialize for IntPosition {
impl Deserialize for IntPosition {
fn mc_deserialize(data: &[u8]) -> DeserializeResult<'_, Self> {
- let Deserialized{ value: raw, data } = i64::mc_deserialize(data)?;
+ let Deserialized { value: raw, data } = i64::mc_deserialize(data)?;
let raw_unsigned = raw as u64;
let mut x = ((raw_unsigned >> 38) as u32) & 0x3FFFFFF;
let mut z = ((raw_unsigned >> 12) & 0x3FFFFFF) as u32;
let mut y = ((raw_unsigned & 0xFFF) as u16) & 0xFFF;
- if (x & 0x2000000) != 0 { // is the 26th bit set
+ if (x & 0x2000000) != 0 {
+ // is the 26th bit set
// if so, treat the rest as a positive integer, and treat 26th bit as -2^25
// 2^25 == 0x2000000
// 0x1FFFFFF == 2^26 - 1 (all places set to 1 except 26th place)
@@ -431,11 +441,14 @@ impl Deserialize for IntPosition {
z = (((z & 0x1FFFFFF) as i32) - 0x2000000) as u32;
}
- Deserialized::ok(IntPosition{
- x: x as i32,
- y: y as i16,
- z: z as i32
- }, data)
+ Deserialized::ok(
+ IntPosition {
+ x: x as i32,
+ y: y as i16,
+ z: z as i32,
+ },
+ data,
+ )
}
}
@@ -445,18 +458,14 @@ impl TestRandom for IntPosition {
let x: i32 = ((rand::random::<u32>() % (1 << 26)) as i32) - (1 << 25);
let z: i32 = ((rand::random::<u32>() % (1 << 26)) as i32) - (1 << 25);
let y: i16 = ((rand::random::<u16>() % (1 << 12)) as i16) - (1 << 11);
- Self{
- x,
- y,
- z
- }
+ Self { x, y, z }
}
}
// angle
#[derive(Copy, Clone, PartialEq, Hash, Debug)]
pub struct Angle {
- pub value: u8
+ pub value: u8,
}
impl Serialize for Angle {
@@ -467,17 +476,15 @@ impl Serialize for Angle {
impl Deserialize for Angle {
fn mc_deserialize(data: &[u8]) -> DeserializeResult<'_, Self> {
- Ok(read_one_byte(data)?.map(move |b| {
- Angle { value: b }
- }))
+ Ok(read_one_byte(data)?.map(move |b| Angle { value: b }))
}
}
#[cfg(test)]
impl TestRandom for Angle {
fn test_gen_random() -> Self {
- Self{
- value: rand::random()
+ Self {
+ value: rand::random(),
}
}
}
@@ -493,25 +500,27 @@ impl Serialize for UUID4 {
impl Deserialize for UUID4 {
fn mc_deserialize(data: &[u8]) -> DeserializeResult<'_, Self> {
- take(16)(data)?.map(move |bytes| {
- let raw = (bytes[0] as u128) << 120 |
- (bytes[1] as u128) << 112 |
- (bytes[2] as u128) << 104 |
- (bytes[3] as u128) << 96 |
- (bytes[4] as u128) << 88 |
- (bytes[5] as u128) << 80 |
- (bytes[6] as u128) << 72 |
- (bytes[7] as u128) << 64 |
- (bytes[8] as u128) << 56 |
- (bytes[9] as u128) << 48 |
- (bytes[10] as u128) << 40 |
- (bytes[11] as u128) << 32 |
- (bytes[12] as u128) << 24 |
- (bytes[13] as u128) << 16 |
- (bytes[14] as u128) << 8 |
- bytes[15] as u128;
- UUID4::from(raw)
- }).into()
+ take(16)(data)?
+ .map(move |bytes| {
+ let raw = (bytes[0] as u128) << 120
+ | (bytes[1] as u128) << 112
+ | (bytes[2] as u128) << 104
+ | (bytes[3] as u128) << 96
+ | (bytes[4] as u128) << 88
+ | (bytes[5] as u128) << 80
+ | (bytes[6] as u128) << 72
+ | (bytes[7] as u128) << 64
+ | (bytes[8] as u128) << 56
+ | (bytes[9] as u128) << 48
+ | (bytes[10] as u128) << 40
+ | (bytes[11] as u128) << 32
+ | (bytes[12] as u128) << 24
+ | (bytes[13] as u128) << 16
+ | (bytes[14] as u128) << 8
+ | bytes[15] as u128;
+ UUID4::from(raw)
+ })
+ .into()
}
}
@@ -526,7 +535,7 @@ impl TestRandom for UUID4 {
#[derive(Clone, PartialEq, Debug)]
pub struct NamedNbtTag {
- pub root: nbt::NamedTag
+ pub root: nbt::NamedTag,
}
impl Serialize for NamedNbtTag {
@@ -538,7 +547,10 @@ impl Serialize for NamedNbtTag {
impl Deserialize for NamedNbtTag {
fn mc_deserialize(data: &[u8]) -> DeserializeResult<'_, Self> {
- Ok(nbt::NamedTag::root_compound_tag_from_bytes(data)?.map(move |root| NamedNbtTag { root }))
+ Ok(
+ nbt::NamedTag::root_compound_tag_from_bytes(data)?
+ .map(move |root| NamedNbtTag { root }),
+ )
}
}
@@ -557,13 +569,15 @@ impl Into<nbt::NamedTag> for NamedNbtTag {
#[cfg(test)]
impl TestRandom for NamedNbtTag {
fn test_gen_random() -> Self {
- Self { root: nbt::NamedTag::test_gen_random() }
+ Self {
+ root: nbt::NamedTag::test_gen_random(),
+ }
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct FixedInt {
- raw: i32
+ raw: i32,
}
impl Serialize for FixedInt {
@@ -574,15 +588,15 @@ impl Serialize for FixedInt {
impl Deserialize for FixedInt {
fn mc_deserialize(data: &[u8]) -> DeserializeResult<'_, Self> {
- Ok(i32::mc_deserialize(data)?.map(move |raw| {
- FixedInt{ raw }
- }))
+ Ok(i32::mc_deserialize(data)?.map(move |raw| FixedInt { raw }))
}
}
impl FixedInt {
pub fn new(data: f64, fractional_bytes: usize) -> Self {
- Self { raw: (data * ((1 << fractional_bytes) as f64)) as i32 }
+ Self {
+ raw: (data * ((1 << fractional_bytes) as f64)) as i32,
+ }
}
pub fn into_float(self, fractional_bytes: usize) -> f64 {
@@ -614,12 +628,13 @@ pub struct Chat {
#[serde(skip_serializing_if = "Option::is_none")]
pub color: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
- pub extra: Option<Vec<Chat>>
+ pub extra: Option<Vec<Chat>>,
}
impl ToString for Chat {
fn to_string(&self) -> String {
- self.extra.as_ref()
+ self.extra
+ .as_ref()
.into_iter()
.flat_map(|v| v.into_iter())
.map(|item| item.to_string())
@@ -646,7 +661,7 @@ pub enum ColorCode {
Red,
LightPurple,
Yellow,
- White
+ White,
}
impl ColorCode {
@@ -668,7 +683,7 @@ impl ColorCode {
'd' => Some(ColorCode::LightPurple),
'e' => Some(ColorCode::Yellow),
'f' => Some(ColorCode::White),
- _ => None
+ _ => None,
}
}
@@ -711,7 +726,7 @@ impl ColorCode {
"light_purple" => Some(ColorCode::LightPurple),
"yellow" => Some(ColorCode::Yellow),
"white" => Some(ColorCode::White),
- _ => None
+ _ => None,
}
}
@@ -745,7 +760,7 @@ pub enum Formatter {
Strikethrough,
Underline,
Italic,
- Reset
+ Reset,
}
impl Formatter {
@@ -757,7 +772,7 @@ impl Formatter {
'n' => Some(Formatter::Underline),
'o' => Some(Formatter::Italic),
'r' => Some(Formatter::Reset),
- _ => ColorCode::from_code(i).map(Formatter::Color)
+ _ => ColorCode::from_code(i).map(Formatter::Color),
}
}
@@ -769,7 +784,7 @@ impl Formatter {
Formatter::Strikethrough => 'm',
Formatter::Underline => 'n',
Formatter::Italic => 'o',
- Formatter::Reset => 'r'
+ Formatter::Reset => 'r',
}
}
@@ -781,7 +796,7 @@ impl Formatter {
"underline" => Some(Formatter::Underline),
"italic" => Some(Formatter::Italic),
"reset" => Some(Formatter::Reset),
- _ => ColorCode::from_name(name).map(Formatter::Color)
+ _ => ColorCode::from_name(name).map(Formatter::Color),
}
}
@@ -800,7 +815,7 @@ impl Formatter {
impl ToString for Formatter {
fn to_string(&self) -> String {
- vec!(SECTION_SYMBOL, self.code()).into_iter().collect()
+ vec![SECTION_SYMBOL, self.code()].into_iter().collect()
}
}
@@ -809,15 +824,25 @@ impl Chat {
self.to_traditional_parts(Vec::<Formatter>::new().as_ref(), None)
}
- fn to_traditional_parts(&self, formatters: &Vec<Formatter>, color: Option<ColorCode>) -> String {
+ fn to_traditional_parts(
+ &self,
+ formatters: &Vec<Formatter>,
+ color: Option<ColorCode>,
+ ) -> String {
let mut own_formatters = formatters.clone();
Self::update_formatter(&mut own_formatters, Formatter::Bold, &self.bold);
Self::update_formatter(&mut own_formatters, Formatter::Italic, &self.italic);
Self::update_formatter(&mut own_formatters, Formatter::Underline, &self.underlined);
- Self::update_formatter(&mut own_formatters, Formatter::Strikethrough, &self.strikethrough);
+ Self::update_formatter(
+ &mut own_formatters,
+ Formatter::Strikethrough,
+ &self.strikethrough,
+ );
Self::update_formatter(&mut own_formatters, Formatter::Obfuscated, &self.obfuscated);
- let own_color_option = self.color.as_ref()
+ let own_color_option = self
+ .color
+ .as_ref()
.map(String::as_str)
.and_then(ColorCode::from_name)
.or(color);
@@ -826,21 +851,21 @@ impl Chat {
.map(Formatter::Color)
.map(|f| f.to_string());
- let own_formatter =
- own_formatters
- .clone()
- .into_iter()
- .map(|f| f.to_string())
- .fold(String::new(), |acc, v| acc + v.as_str());
+ let own_formatter = own_formatters
+ .clone()
+ .into_iter()
+ .map(|f| f.to_string())
+ .fold(String::new(), |acc, v| acc + v.as_str());
let own_color_str = match own_color {
Some(v) => v,
- None => String::new()
+ None => String::new(),
};
- let own_out = own_formatter + own_color_str.as_str() + self.text.as_str();
+ let own_out = own_formatter + own_color_str.as_str() + self.text.as_str();
- self.extra.as_ref()
+ self.extra
+ .as_ref()
.into_iter()
.flat_map(|v| v.into_iter())
.map(|child| child.to_traditional_parts(&own_formatters, own_color_option))
@@ -854,7 +879,7 @@ impl Chat {
}
pub fn from_text(text: &str) -> Chat {
- Chat{
+ Chat {
text: text.to_owned(),
bold: None,
italic: None,
@@ -869,9 +894,11 @@ impl Chat {
impl Serialize for Chat {
fn mc_serialize<S: Serializer>(&self, to: &mut S) -> SerializeResult {
- serde_json::to_string(self).map_err(move |err| {
- SerializeErr::FailedJsonEncode(format!("failed to serialize chat {:?}", err))
- })?.mc_serialize(to)
+ serde_json::to_string(self)
+ .map_err(move |err| {
+ SerializeErr::FailedJsonEncode(format!("failed to serialize chat {:?}", err))
+ })?
+ .mc_serialize(to)
}
}
@@ -879,7 +906,10 @@ impl Deserialize for Chat {
fn mc_deserialize(data: &[u8]) -> DeserializeResult<'_, Self> {
String::mc_deserialize(data)?.try_map(move |str| {
serde_json::from_str(str.as_str()).map_err(move |err| {
- DeserializeErr::FailedJsonDeserialize(format!("failed to deserialize chat {:?}", err))
+ DeserializeErr::FailedJsonDeserialize(format!(
+ "failed to deserialize chat {:?}",
+ err
+ ))
})
})
}
@@ -895,7 +925,7 @@ impl TestRandom for Chat {
#[derive(Default)]
pub struct BytesSerializer {
- data: Vec<u8>
+ data: Vec<u8>,
}
impl Serializer for BytesSerializer {
@@ -907,7 +937,7 @@ impl Serializer for BytesSerializer {
impl BytesSerializer {
pub fn with_capacity(cap: usize) -> Self {
- BytesSerializer{
+ BytesSerializer {
data: Vec::with_capacity(cap),
}
}
@@ -917,21 +947,25 @@ impl BytesSerializer {
}
}
-impl<T> Serialize for Option<T> where T: Serialize {
+impl<T> Serialize for Option<T>
+where
+ T: Serialize,
+{
fn mc_serialize<S: Serializer>(&self, to: &mut S) -> SerializeResult {
match self {
Some(value) => {
to.serialize_other(&true)?;
to.serialize_other(value)
- },
- None => {
- to.serialize_other(&false)
}
+ None => to.serialize_other(&false),
}
}
}
-impl<T> Deserialize for Option<T> where T: Deserialize {
+impl<T> Deserialize for Option<T>
+where
+ T: Deserialize,
+{
fn mc_deserialize(data: &[u8]) -> DeserializeResult<'_, Self> {
bool::mc_deserialize(data)?.and_then(move |is_present, data| {
if is_present {
@@ -944,7 +978,10 @@ impl<T> Deserialize for Option<T> where T: Deserialize {
}
#[cfg(test)]
-impl<T> TestRandom for Option<T> where T: TestRandom {
+impl<T> TestRandom for Option<T>
+where
+ T: TestRandom,
+{
fn test_gen_random() -> Self {
let is_present: bool = rand::random();
if is_present {
@@ -976,8 +1013,14 @@ impl Serialize for Slot {
impl Deserialize for Slot {
fn mc_deserialize(data: &[u8]) -> DeserializeResult<'_, Self> {
- let Deserialized{ value: item_id, data } = VarInt::mc_deserialize(data)?;
- let Deserialized{ value: item_count, data } = i8::mc_deserialize(data)?;
+ let Deserialized {
+ value: item_id,
+ data,
+ } = VarInt::mc_deserialize(data)?;
+ let Deserialized {
+ value: item_count,
+ data,
+ } = i8::mc_deserialize(data)?;
if data.is_empty() {
return Err(DeserializeErr::Eof);
}
@@ -985,10 +1028,16 @@ impl Deserialize for Slot {
let id = data[0];
let rest = &data[1..];
Ok(match id {
- 0x00 => Deserialized{ value: None, data: rest },
- _ => nbt::read_named_tag(data)?.map(move |tag| Some(tag))
- }.map(move |nbt| {
- Slot{ item_id, item_count, nbt }
+ 0x00 => Deserialized {
+ value: None,
+ data: rest,
+ },
+ _ => nbt::read_named_tag(data)?.map(move |tag| Some(tag)),
+ }
+ .map(move |nbt| Slot {
+ item_id,
+ item_count,
+ nbt,
}))
}
}
@@ -1000,10 +1049,10 @@ impl TestRandom for Slot {
let item_count = i8::test_gen_random() % 65;
let nbt = <Option<nbt::NamedTag>>::test_gen_random();
- Self{
+ Self {
item_id,
item_count,
- nbt
+ nbt,
}
}
}
@@ -1112,62 +1161,61 @@ mod tests {
#[test]
fn test_nbt() {
- test_type(NamedNbtTag {root: nbt::Tag::Compound(vec!(
- nbt::Tag::String("test 123".to_owned()).with_name("abc 123")
- )).with_name("root")})
+ test_type(NamedNbtTag {
+ root: nbt::Tag::Compound(vec![
+ nbt::Tag::String("test 123".to_owned()).with_name("abc 123")
+ ])
+ .with_name("root"),
+ })
}
#[test]
fn test_int_position() {
- test_type(IntPosition{
+ test_type(IntPosition {
x: 12312,
y: -32,
z: 321312,
});
- test_type(IntPosition{
+ test_type(IntPosition {
x: 12312,
y: -32,
z: -321312,
});
- test_type(IntPosition{
+ test_type(IntPosition {
x: -12312,
y: -32,
z: -321312,
});
- test_type(IntPosition{
+ test_type(IntPosition {
x: -12312,
y: 32,
z: 321312,
});
- test_type(IntPosition{
- x: 0,
- y: 0,
- z: 0,
- });
+ test_type(IntPosition { x: 0, y: 0, z: 0 });
- test_type(IntPosition{
+ test_type(IntPosition {
x: 48,
y: 232,
z: 12,
});
- test_type(IntPosition{
+ test_type(IntPosition {
x: 33554431,
y: 2047,
z: 33554431,
});
- test_type(IntPosition{
+ test_type(IntPosition {
x: -33554432,
y: -2048,
z: -33554432,
});
- test_type(IntPosition{
+ test_type(IntPosition {
x: 3,
y: 0,
z: 110655,
@@ -1183,34 +1231,38 @@ mod tests {
#[test]
fn test_angle() {
- test_type(Angle{
- value: 0,
- });
- test_type(Angle{
- value: 24,
- });
- test_type(Angle{
- value: 255,
- });
- test_type(Angle{
- value: 8,
- });
+ test_type(Angle { value: 0 });
+ test_type(Angle { value: 24 });
+ test_type(Angle { value: 255 });
+ test_type(Angle { value: 8 });
}
fn test_type<S: Serialize + Deserialize + PartialEq + Debug>(value: S) {
let bytes = {
let mut test = BytesSerializer::default();
- value.mc_serialize(&mut test).expect("serialization should succeed");
+ value
+ .mc_serialize(&mut test)
+ .expect("serialization should succeed");
test.into_bytes()
};
- let deserialized = S::mc_deserialize(bytes.as_slice()).expect("deserialization should succeed");
+ let deserialized =
+ S::mc_deserialize(bytes.as_slice()).expect("deserialization should succeed");
assert!(deserialized.data.is_empty());
- assert_eq!(deserialized.value, value, "deserialized value == serialized value");
+ assert_eq!(
+ deserialized.value, value,
+ "deserialized value == serialized value"
+ );
let re_serialized = {
let mut test = BytesSerializer::default();
- deserialized.value.mc_serialize(&mut test).expect("serialization should succeed");
+ deserialized
+ .value
+ .mc_serialize(&mut test)
+ .expect("serialization should succeed");
test.into_bytes()
};
- assert_eq!(re_serialized, bytes, "serialized value == original serialized bytes");
+ assert_eq!(
+ re_serialized, bytes,
+ "serialized value == original serialized bytes"
+ );
}
-} \ No newline at end of file
+}
diff --git a/src/utils.rs b/src/utils.rs
index 7371d1c..1c3ddde 100644
--- a/src/utils.rs
+++ b/src/utils.rs
@@ -1,10 +1,10 @@
-use crate::{DeserializeResult, DeserializeErr, Deserialized};
+use crate::{DeserializeErr, DeserializeResult, Deserialized};
#[inline]
pub fn read_one_byte(data: &[u8]) -> DeserializeResult<u8> {
match data.split_first() {
Some((byte, rest)) => Deserialized::ok(*byte, rest),
- None => Err(DeserializeErr::Eof)
+ None => Err(DeserializeErr::Eof),
}
}
@@ -22,14 +22,14 @@ pub const fn take(amount: usize) -> impl for<'b> Fn(&'b [u8]) -> DeserializeResu
#[inline]
pub fn read_long(data: &[u8]) -> DeserializeResult<u64> {
Ok(take(8)(data)?.map(move |bytes| {
- (bytes[0] as u64) << 56 |
- (bytes[1] as u64) << 48 |
- (bytes[2] as u64) << 40 |
- (bytes[3] as u64) << 32 |
- (bytes[4] as u64) << 24 |
- (bytes[5] as u64) << 16 |
- (bytes[6] as u64) << 8 |
- (bytes[7] as u64)
+ (bytes[0] as u64) << 56
+ | (bytes[1] as u64) << 48
+ | (bytes[2] as u64) << 40
+ | (bytes[3] as u64) << 32
+ | (bytes[4] as u64) << 24
+ | (bytes[5] as u64) << 16
+ | (bytes[6] as u64) << 8
+ | (bytes[7] as u64)
}))
}
@@ -50,10 +50,10 @@ pub fn write_long(v: u64) -> [u8; 8] {
#[inline]
pub fn read_int(data: &[u8]) -> DeserializeResult<u32> {
Ok(take(4)(data)?.map(move |bytes| {
- (bytes[0] as u32) << 24 |
- (bytes[1] as u32) << 16 |
- (bytes[2] as u32) << 8 |
- (bytes[3] as u32)
+ (bytes[0] as u32) << 24
+ | (bytes[1] as u32) << 16
+ | (bytes[2] as u32) << 8
+ | (bytes[3] as u32)
}))
}
@@ -64,9 +64,7 @@ pub fn write_int(v: u32) -> [u8; 4] {
#[inline]
pub fn read_short(data: &[u8]) -> DeserializeResult<u16> {
- Ok(take(2)(data)?.map(move |bytes| {
- (bytes[0] as u16) << 8 | (bytes[1] as u16)
- }))
+ Ok(take(2)(data)?.map(move |bytes| (bytes[0] as u16) << 8 | (bytes[1] as u16)))
}
#[inline]
@@ -129,4 +127,4 @@ pub fn parse_hex_char(data: u8) -> Option<u8> {
} else {
None
}
-} \ No newline at end of file
+}
diff --git a/src/uuid.rs b/src/uuid.rs
index 23a4e1b..019fbd2 100644
--- a/src/uuid.rs
+++ b/src/uuid.rs
@@ -1,12 +1,12 @@
-use std::fmt::{Display, Formatter, Debug};
+use crate::utils::*;
use lazy_static::lazy_static;
use regex::Regex;
-use serde::{Serializer, Deserializer};
-use crate::utils::*;
+use serde::{Deserializer, Serializer};
+use std::fmt::{Debug, Display, Formatter};
#[derive(Copy, Clone, PartialEq, Hash, Eq)]
pub struct UUID4 {
- raw: u128
+ raw: u128,
}
impl Display for UUID4 {
@@ -25,22 +25,24 @@ impl Debug for UUID4 {
impl From<u128> for UUID4 {
fn from(raw: u128) -> Self {
- UUID4 {
- raw
- }
+ UUID4 { raw }
}
}
impl serde::Serialize for UUID4 {
- fn serialize<S>(&self, serializer: S) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where
- S: Serializer {
+ fn serialize<S>(&self, serializer: S) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
+ where
+ S: Serializer,
+ {
serializer.serialize_str(self.to_string().as_str())
}
}
impl<'de> serde::Deserialize<'de> for UUID4 {
- fn deserialize<D>(deserializer: D) -> Result<Self, <D as Deserializer<'de>>::Error> where
- D: Deserializer<'de> {
+ fn deserialize<D>(deserializer: D) -> Result<Self, <D as Deserializer<'de>>::Error>
+ where
+ D: Deserializer<'de>,
+ {
struct Visitor;
impl serde::de::Visitor<'_> for Visitor {
type Value = UUID4;
@@ -53,12 +55,15 @@ impl<'de> serde::Deserialize<'de> for UUID4 {
if let Some(id) = UUID4::parse(v) {
Ok(id)
} else {
- Err(serde::de::Error::invalid_value(serde::de::Unexpected::Str(v), &self))
+ Err(serde::de::Error::invalid_value(
+ serde::de::Unexpected::Str(v),
+ &self,
+ ))
}
}
}
- deserializer.deserialize_str(Visitor{})
+ deserializer.deserialize_str(Visitor {})
}
}
@@ -67,17 +72,23 @@ impl UUID4 {
const PATTERN: &str = r"^([A-Fa-f0-9]{8})-?([A-Fa-f0-9]{4})-?([A-Fa-f0-9]{4})-?([A-Fa-f0-9]{4})-?([A-Fa-f0-9]{12})$";
// let re = Regex::new(PATTERN).expect("regex is valid");
lazy_static! {
- static ref RE: Regex = Regex::new(PATTERN)
- .expect("regex is valid");
+ static ref RE: Regex = Regex::new(PATTERN).expect("regex is valid");
}
- RE.captures_iter(from).filter_map(move |c|
- c.get(1).map(move |g| g.as_str()).and_then(move |g0|
- c.get(2).map(move |g| g.as_str()).and_then(move |g1|
- c.get(3).map(move |g| g.as_str()).and_then(move |g2|
- c.get(4).map(move |g| g.as_str()).and_then(move |g3|
- c.get(5).map(move |g4|
- RawUUID4 { parts: [g0, g1, g2, g3, g4.as_str()] }))))))
+ RE.captures_iter(from)
+ .filter_map(move |c| {
+ c.get(1).map(move |g| g.as_str()).and_then(move |g0| {
+ c.get(2).map(move |g| g.as_str()).and_then(move |g1| {
+ c.get(3).map(move |g| g.as_str()).and_then(move |g2| {
+ c.get(4).map(move |g| g.as_str()).and_then(move |g3| {
+ c.get(5).map(move |g4| RawUUID4 {
+ parts: [g0, g1, g2, g3, g4.as_str()],
+ })
+ })
+ })
+ })
+ })
+ })
.nth(0)
.and_then(move |raw| raw.parse())
}
@@ -142,16 +153,14 @@ mod tests {
#[test]
fn test_uuid4_parse() {
- UUID4::parse(VALID_UUID)
- .expect("should parse valid uuid correctly");
+ UUID4::parse(VALID_UUID).expect("should parse valid uuid correctly");
}
#[test]
fn test_parsed_uuid4_to_hex() {
- let uuid_hex =
- UUID4::parse(VALID_UUID)
- .expect("should parse valid uuid correctly")
- .hex();
+ let uuid_hex = UUID4::parse(VALID_UUID)
+ .expect("should parse valid uuid correctly")
+ .hex();
assert_eq!(uuid_hex.as_str(), VALID_UUID)
}
@@ -167,7 +176,8 @@ mod tests {
fn test_random_uuid4_hex() {
let src_uuid = UUID4::random();
let uuid_hex = src_uuid.hex();
- let uuid_parsed = UUID4::parse(uuid_hex.as_str()).expect("should parse generated uuid correctly");
+ let uuid_parsed =
+ UUID4::parse(uuid_hex.as_str()).expect("should parse generated uuid correctly");
assert_eq!(src_uuid, uuid_parsed);
let uuid_parsed_hex = uuid_parsed.hex();
assert_eq!(uuid_hex, uuid_parsed_hex);
@@ -182,4 +192,4 @@ mod tests {
fn test_debug_uuid() {
println!("got uuid {:?}", UUID4::random());
}
-} \ No newline at end of file
+}
diff --git a/src/v1_15_2.rs b/src/v1_15_2.rs
index 08871a3..df31dab 100644
--- a/src/v1_15_2.rs
+++ b/src/v1_15_2.rs
@@ -1,4 +1,4 @@
-use crate::{*, uuid::*, types::*};
+use crate::{types::*, uuid::*, *};
use std::fmt::Debug;
#[cfg(test)]
@@ -36,7 +36,8 @@ impl State {
Status => "Status",
Login => "Login",
Play => "Play",
- }.to_owned()
+ }
+ .to_owned()
}
}
@@ -816,7 +817,12 @@ fn varint_to_usize(v: VarInt) -> usize {
fn varint_from_usize(u: usize) -> VarInt {
u.into()
}
-counted_array_type!(VarIntCountedArray, VarInt, varint_to_usize, varint_from_usize);
+counted_array_type!(
+ VarIntCountedArray,
+ VarInt,
+ varint_to_usize,
+ varint_from_usize
+);
#[inline]
fn i16_to_usize(v: i16) -> usize {
@@ -864,7 +870,12 @@ impl Serialize for RemainingBytes {
impl Deserialize for RemainingBytes {
fn mc_deserialize(data: &[u8]) -> DeserializeResult<'_, Self> {
- Deserialized::ok(RemainingBytes { data: Vec::from(data) }, &[])
+ Deserialized::ok(
+ RemainingBytes {
+ data: Vec::from(data),
+ },
+ &[],
+ )
}
}
@@ -889,7 +900,7 @@ impl TestRandom for RemainingBytes {
out.push(rand::random());
}
- Self{ data: out }
+ Self { data: out }
}
}
@@ -1029,19 +1040,19 @@ impl Serialize for BlockChangeHorizontalPosition {
impl Deserialize for BlockChangeHorizontalPosition {
fn mc_deserialize(data: &[u8]) -> DeserializeResult<'_, Self> {
- Ok(u8::mc_deserialize(data)?.map(move |b| {
- BlockChangeHorizontalPosition {
+ Ok(
+ u8::mc_deserialize(data)?.map(move |b| BlockChangeHorizontalPosition {
rel_x: (b >> 4) & 0xF,
rel_z: b & 0xF,
- }
- }))
+ }),
+ )
}
}
#[cfg(test)]
impl TestRandom for BlockChangeHorizontalPosition {
fn test_gen_random() -> Self {
- BlockChangeHorizontalPosition{
+ BlockChangeHorizontalPosition {
rel_x: rand::random(),
rel_z: rand::random(),
}
@@ -1088,16 +1099,31 @@ impl Serialize for BossBarAction {
impl Deserialize for BossBarAction {
fn mc_deserialize(data: &[u8]) -> DeserializeResult<'_, Self> {
- let Deserialized { value: type_id, data } = VarInt::mc_deserialize(data)?;
+ let Deserialized {
+ value: type_id,
+ data,
+ } = VarInt::mc_deserialize(data)?;
use BossBarAction::*;
match type_id.0 {
0x00 => Ok(BossBarAddSpec::mc_deserialize(data)?.map(move |body| Add(body))),
0x01 => Deserialized::ok(Remove, data),
- 0x02 => Ok(BossBarUpdateHealthSpec::mc_deserialize(data)?.map(move |body| UpdateHealth(body))),
- 0x03 => Ok(BossBarUpdateTitleSpec::mc_deserialize(data)?.map(move |body| UpdateTitle(body))),
- 0x04 => Ok(BossBarUpdateStyleSpec::mc_deserialize(data)?.map(move |body| UpdateStyle(body))),
- 0x05 => Ok(BossBarUpdateFlagsSpec::mc_deserialize(data)?.map(move |body| UpdateFlags(body))),
- other => Err(DeserializeErr::CannotUnderstandValue(format!("invalid boss bar action id {:x}", other)))
+ 0x02 => {
+ Ok(BossBarUpdateHealthSpec::mc_deserialize(data)?
+ .map(move |body| UpdateHealth(body)))
+ }
+ 0x03 => Ok(
+ BossBarUpdateTitleSpec::mc_deserialize(data)?.map(move |body| UpdateTitle(body))
+ ),
+ 0x04 => Ok(
+ BossBarUpdateStyleSpec::mc_deserialize(data)?.map(move |body| UpdateStyle(body))
+ ),
+ 0x05 => Ok(
+ BossBarUpdateFlagsSpec::mc_deserialize(data)?.map(move |body| UpdateFlags(body))
+ ),
+ other => Err(DeserializeErr::CannotUnderstandValue(format!(
+ "invalid boss bar action id {:x}",
+ other
+ ))),
}
}
}
@@ -1142,13 +1168,9 @@ __protocol_body_def_helper!(BossBarAddSpec {
flags: BossBarFlags
});
-__protocol_body_def_helper!(BossBarUpdateHealthSpec {
- health: f32
-});
+__protocol_body_def_helper!(BossBarUpdateHealthSpec { health: f32 });
-__protocol_body_def_helper!(BossBarUpdateTitleSpec {
- title: String
-});
+__protocol_body_def_helper!(BossBarUpdateTitleSpec { title: String });
__protocol_body_def_helper!(BossBarUpdateStyleSpec {
color: BossBarColor,
@@ -1245,25 +1267,17 @@ impl Serialize for GameChangeReason {
ThunderLevelChange(_) => 0x08,
PufferfishSting => 0x09,
ElderGuardianMobAppearance => 0x0A,
- Respawn(_) => 0x0B
+ Respawn(_) => 0x0B,
})?;
let value = match self {
- ChangeGameMode(body) => {
- body.as_byte() as f32
- }
- WinGame(body) => {
- body.as_byte() as f32
- }
- Demo(body) => {
- body.as_byte() as f32
- }
+ ChangeGameMode(body) => body.as_byte() as f32,
+ WinGame(body) => body.as_byte() as f32,
+ Demo(body) => body.as_byte() as f32,
RainLevelChange(body) => *body,
ThunderLevelChange(body) => *body,
- Respawn(body) => {
- body.as_byte() as f32
- }
- _ => 0 as f32
+ Respawn(body) => body.as_byte() as f32,
+ _ => 0 as f32,
};
to.serialize_other(&value)
}
@@ -1271,7 +1285,10 @@ impl Serialize for GameChangeReason {
impl Deserialize for GameChangeReason {
fn mc_deserialize(data: &[u8]) -> DeserializeResult<'_, Self> {
- let Deserialized { value: reason_id, data } = u8::mc_deserialize(data)?;
+ let Deserialized {
+ value: reason_id,
+ data,
+ } = u8::mc_deserialize(data)?;
let Deserialized { value, data } = f32::mc_deserialize(data)?;
use GameChangeReason::*;
let out = match reason_id {
@@ -1281,15 +1298,33 @@ impl Deserialize for GameChangeReason {
0x03 => Ok(ChangeGameMode(
GameMode::from_byte(value as u8)
.map(move |v| Ok(v))
- .unwrap_or_else(|| Err(DeserializeErr::CannotUnderstandValue(format!("unknown gamemode value {}", value))))?)),
+ .unwrap_or_else(|| {
+ Err(DeserializeErr::CannotUnderstandValue(format!(
+ "unknown gamemode value {}",
+ value
+ )))
+ })?,
+ )),
0x04 => Ok(WinGame(
WinGameAction::from_byte(value as u8)
.map(move |v| Ok(v))
- .unwrap_or_else(|| Err(DeserializeErr::CannotUnderstandValue(format!("unknown WinGame value {}", value))))?)),
+ .unwrap_or_else(|| {
+ Err(DeserializeErr::CannotUnderstandValue(format!(
+ "unknown WinGame value {}",
+ value
+ )))
+ })?,
+ )),
0x05 => Ok(Demo(
DemoEvent::from_byte(value as u8)
.map(move |v| Ok(v))
- .unwrap_or_else(|| Err(DeserializeErr::CannotUnderstandValue(format!("unknown DemoEvent value {}", value))))?)),
+ .unwrap_or_else(|| {
+ Err(DeserializeErr::CannotUnderstandValue(format!(
+ "unknown DemoEvent value {}",
+ value
+ )))
+ })?,
+ )),
0x06 => Ok(ArrowHitPlayer),
0x07 => Ok(RainLevelChange(value)),
0x08 => Ok(ThunderLevelChange(value)),
@@ -1298,8 +1333,17 @@ impl Deserialize for GameChangeReason {
0x0B => Ok(Respawn(
RespawnRequestType::from_byte(value as u8)
.map(move |v| Ok(v))
- .unwrap_or_else(|| Err(DeserializeErr::CannotUnderstandValue(format!("invalid respawn reason {}", value))))?)),
- other => Err(DeserializeErr::CannotUnderstandValue(format!("invalid game change reason id {}", other)))
+ .unwrap_or_else(|| {
+ Err(DeserializeErr::CannotUnderstandValue(format!(
+ "invalid respawn reason {}",
+ value
+ )))
+ })?,
+ )),
+ other => Err(DeserializeErr::CannotUnderstandValue(format!(
+ "invalid game change reason id {}",
+ other
+ ))),
}?;
Deserialized::ok(out, data)
@@ -1377,11 +1421,14 @@ impl Serialize for MapColumns {
impl Deserialize for MapColumns {
fn mc_deserialize(data: &[u8]) -> DeserializeResult<'_, Self> {
- let Deserialized { value: columns, data: rest } = u8::mc_deserialize(data)?;
+ let Deserialized {
+ value: columns,
+ data: rest,
+ } = u8::mc_deserialize(data)?;
use MapColumns::*;
match columns {
0x00 => Deserialized::ok(NoUpdates, rest),
- _ => Ok(MapColumnsSpec::mc_deserialize(data)?.map(move |v| Updated(v)))
+ _ => Ok(MapColumnsSpec::mc_deserialize(data)?.map(move |v| Updated(v))),
}
}
}
@@ -1391,7 +1438,7 @@ impl Into<Option<MapColumnsSpec>> for MapColumns {
use MapColumns::*;
match self {
NoUpdates => None,
- Updated(body) => Some(body)
+ Updated(body) => Some(body),
}
}
}
@@ -1401,7 +1448,7 @@ impl From<Option<MapColumnsSpec>> for MapColumns {
use MapColumns::*;
match other {
Some(body) => Updated(body),
- None => NoUpdates
+ None => NoUpdates,
}
}
}
@@ -1488,7 +1535,7 @@ impl Serialize for CombatEvent {
to.serialize_other(&VarInt(match self {
Enter => 0x00,
End(_) => 0x01,
- EntityDead(_) => 0x02
+ EntityDead(_) => 0x02,
}))?;
match self {
@@ -1503,14 +1550,22 @@ impl Serialize for CombatEvent {
impl Deserialize for CombatEvent {
fn mc_deserialize(data: &[u8]) -> DeserializeResult<'_, Self> {
- let Deserialized { value: action_id, data } = VarInt::mc_deserialize(data)?;
+ let Deserialized {
+ value: action_id,
+ data,
+ } = VarInt::mc_deserialize(data)?;
use CombatEvent::*;
match action_id.0 {
0x00 => Deserialized::ok(Enter, data),
0x01 => Ok(CombatEndSpec::mc_deserialize(data)?.map(move |body| End(body))),
- 0x02 => Ok(CombatEntityDeadSpec::mc_deserialize(data)?.map(move |body| EntityDead(body))),
- other => Err(DeserializeErr::CannotUnderstandValue(format!("invalid combat event id {:?}", other)))
+ 0x02 => {
+ Ok(CombatEntityDeadSpec::mc_deserialize(data)?.map(move |body| EntityDead(body)))
+ }
+ other => Err(DeserializeErr::CannotUnderstandValue(format!(
+ "invalid combat event id {:?}",
+ other
+ ))),
}
}
}
@@ -1525,17 +1580,23 @@ impl TestRandom for CombatEvent {
#[derive(Clone, PartialEq, Debug)]
pub struct PlayerInfoAction<A: Clone + PartialEq + Debug> {
pub uuid: UUID4,
- pub action: A
+ pub action: A,
}
-impl<A> Serialize for PlayerInfoAction<A> where A: Serialize + Clone + PartialEq + Debug {
+impl<A> Serialize for PlayerInfoAction<A>
+where
+ A: Serialize + Clone + PartialEq + Debug,
+{
fn mc_serialize<S: Serializer>(&self, to: &mut S) -> SerializeResult {
to.serialize_other(&self.uuid)?;
to.serialize_other(&self.action)
}
}
-impl<A> Deserialize for PlayerInfoAction<A> where A: Deserialize + Clone + PartialEq + Debug {
+impl<A> Deserialize for PlayerInfoAction<A>
+where
+ A: Deserialize + Clone + PartialEq + Debug,
+{
fn mc_deserialize(data: &[u8]) -> DeserializeResult<'_, Self> {
let Deserialized { value: uuid, data } = UUID4::mc_deserialize(data)?;
Ok(A::mc_deserialize(data)?.map(move |action| Self { uuid, action }))
@@ -1548,7 +1609,7 @@ pub enum PlayerInfoActionList {
UpdateGameMode(Vec<PlayerInfoAction<GameMode>>),
UpdateLatency(Vec<PlayerInfoAction<VarInt>>),
UpdateDisplayName(Vec<PlayerInfoAction<Option<Chat>>>),
- Remove(Vec<UUID4>)
+ Remove(Vec<UUID4>),
}
__protocol_body_def_helper!(PlayerAddActionSpec {
@@ -1566,7 +1627,6 @@ __protocol_body_def_helper!(PlayerAddProperty {
});
impl PlayerInfoActionList {
-
pub fn player_ids(&self) -> Vec<UUID4> {
use PlayerInfoActionList::*;
@@ -1575,7 +1635,7 @@ impl PlayerInfoActionList {
UpdateGameMode(vec) => vec.iter().map(move |v| v.uuid).collect(),
UpdateLatency(vec) => vec.iter().map(move |v| v.uuid).collect(),
UpdateDisplayName(vec) => vec.iter().map(move |v| v.uuid).collect(),
- Remove(vec) => vec.clone()
+ Remove(vec) => vec.clone(),
}
}
@@ -1587,8 +1647,9 @@ impl PlayerInfoActionList {
UpdateGameMode(_) => 0x01,
UpdateLatency(_) => 0x02,
UpdateDisplayName(_) => 0x03,
- Remove(_) => 0x04
- }.into()
+ Remove(_) => 0x04,
+ }
+ .into()
}
pub fn len(&self) -> usize {
@@ -1599,7 +1660,7 @@ impl PlayerInfoActionList {
UpdateGameMode(vec) => vec.len(),
UpdateLatency(vec) => vec.len(),
UpdateDisplayName(vec) => vec.len(),
- Remove(vec) => vec.len()
+ Remove(vec) => vec.len(),
}
}
}
@@ -1626,8 +1687,14 @@ impl Serialize for PlayerInfoActionList {
impl Deserialize for PlayerInfoActionList {
fn mc_deserialize(data: &[u8]) -> DeserializeResult<'_, Self> {
- let Deserialized { value: action_id, data } = VarInt::mc_deserialize(data)?;
- let Deserialized { value: raw_count, mut data } = VarInt::mc_deserialize(data)?;
+ let Deserialized {
+ value: action_id,
+ data,
+ } = VarInt::mc_deserialize(data)?;
+ let Deserialized {
+ value: raw_count,
+ mut data,
+ } = VarInt::mc_deserialize(data)?;
let count = raw_count.0 as usize;
@@ -1636,9 +1703,14 @@ impl Deserialize for PlayerInfoActionList {
0x00 => Ok(deserialize_vec_directly(count, &mut data)?.map(move |v| Add(v))),
0x01 => Ok(deserialize_vec_directly(count, &mut data)?.map(move |v| UpdateGameMode(v))),
0x02 => Ok(deserialize_vec_directly(count, &mut data)?.map(move |v| UpdateLatency(v))),
- 0x03 => Ok(deserialize_vec_directly(count, &mut data)?.map(move |v| UpdateDisplayName(v))),
+ 0x03 => {
+ Ok(deserialize_vec_directly(count, &mut data)?.map(move |v| UpdateDisplayName(v)))
+ }
0x04 => Ok(deserialize_vec_directly(count, &mut data)?.map(move |v| Remove(v))),
- other => Err(DeserializeErr::CannotUnderstandValue(format!("invalid player info action id {}", other))),
+ other => Err(DeserializeErr::CannotUnderstandValue(format!(
+ "invalid player info action id {}",
+ other
+ ))),
}
}
}
@@ -1646,13 +1718,14 @@ impl Deserialize for PlayerInfoActionList {
#[cfg(test)]
impl TestRandom for PlayerInfoActionList {
fn test_gen_random() -> Self {
- PlayerInfoActionList::Remove({
- vec!(UUID4::random())
- })
+ PlayerInfoActionList::Remove({ vec![UUID4::random()] })
}
}
-fn serialize_vec_directly<I: Serialize, S: Serializer>(items: &Vec<I>, to: &mut S) -> SerializeResult {
+fn serialize_vec_directly<I: Serialize, S: Serializer>(
+ items: &Vec<I>,
+ to: &mut S,
+) -> SerializeResult {
for item in items {
to.serialize_other(item)?;
}
@@ -1660,10 +1733,16 @@ fn serialize_vec_directly<I: Serialize, S: Serializer>(items: &Vec<I>, to: &mut
Ok(())
}
-fn deserialize_vec_directly<I: Deserialize>(count: usize, mut data: &[u8]) -> DeserializeResult<Vec<I>> {
+fn deserialize_vec_directly<I: Deserialize>(
+ count: usize,
+ mut data: &[u8],
+) -> DeserializeResult<Vec<I>> {
let mut out = Vec::with_capacity(count);
for _ in 0..count {
- let Deserialized { value: item, data: rest } = I::mc_deserialize(data)?;
+ let Deserialized {
+ value: item,
+ data: rest,
+ } = I::mc_deserialize(data)?;
data = rest;
out.push(item);
}
@@ -1731,12 +1810,10 @@ pub enum WorldBorderAction {
SetCenter(WorldBorderSetCenterSpec),
Initialize(WorldBorderInitiaializeSpec),
SetWarningTime(WorldBorderWarningTimeSpec),
- SetWarningBlocks(WorldBorderWarningBlocksSpec)
+ SetWarningBlocks(WorldBorderWarningBlocksSpec),
}
-__protocol_body_def_helper!(WorldBorderSetSizeSpec {
- diameter: f64
-});
+__protocol_body_def_helper!(WorldBorderSetSizeSpec { diameter: f64 });
__protocol_body_def_helper!(WorldBorderLerpSizeSpec {
old_diameter: f64,
@@ -1744,10 +1821,7 @@ __protocol_body_def_helper!(WorldBorderLerpSizeSpec {
speed: VarLong
});
-__protocol_body_def_helper!(WorldBorderSetCenterSpec {
- x: f64,
- z: f64
-});
+__protocol_body_def_helper!(WorldBorderSetCenterSpec { x: f64, z: f64 });
__protocol_body_def_helper!(WorldBorderInitiaializeSpec {
x: f64,
@@ -1778,7 +1852,8 @@ impl WorldBorderAction {
Initialize(_) => 0x03,
SetWarningTime(_) => 0x04,
SetWarningBlocks(_) => 0x05,
- }.into()
+ }
+ .into()
}
}
@@ -1801,17 +1876,29 @@ impl Serialize for WorldBorderAction {
impl Deserialize for WorldBorderAction {
fn mc_deserialize(data: &[u8]) -> DeserializeResult<'_, Self> {
- let Deserialized{ value: id, data } = VarInt::mc_deserialize(data)?;
+ let Deserialized { value: id, data } = VarInt::mc_deserialize(data)?;
use WorldBorderAction::*;
match id.0 {
- 0x00 => Ok(WorldBorderSetSizeSpec::mc_deserialize(data)?.map(move |body| SetSize(body))),
- 0x01 => Ok(WorldBorderLerpSizeSpec::mc_deserialize(data)?.map(move |body| LerpSize(body))),
- 0x02 => Ok(WorldBorderSetCenterSpec::mc_deserialize(data)?.map(move |body| SetCenter(body))),
- 0x03 => Ok(WorldBorderInitiaializeSpec::mc_deserialize(data)?.map(move |body| Initialize(body))),
- 0x04 => Ok(WorldBorderWarningTimeSpec::mc_deserialize(data)?.map(move |body| SetWarningTime(body))),
- 0x05 => Ok(WorldBorderWarningBlocksSpec::mc_deserialize(data)?.map(move |body| SetWarningBlocks(body))),
- other => Err(DeserializeErr::CannotUnderstandValue(format!("invalid world border action id {}", other)))
+ 0x00 => {
+ Ok(WorldBorderSetSizeSpec::mc_deserialize(data)?.map(move |body| SetSize(body)))
+ }
+ 0x01 => {
+ Ok(WorldBorderLerpSizeSpec::mc_deserialize(data)?.map(move |body| LerpSize(body)))
+ }
+ 0x02 => Ok(
+ WorldBorderSetCenterSpec::mc_deserialize(data)?.map(move |body| SetCenter(body))
+ ),
+ 0x03 => Ok(WorldBorderInitiaializeSpec::mc_deserialize(data)?
+ .map(move |body| Initialize(body))),
+ 0x04 => Ok(WorldBorderWarningTimeSpec::mc_deserialize(data)?
+ .map(move |body| SetWarningTime(body))),
+ 0x05 => Ok(WorldBorderWarningBlocksSpec::mc_deserialize(data)?
+ .map(move |body| SetWarningBlocks(body))),
+ other => Err(DeserializeErr::CannotUnderstandValue(format!(
+ "invalid world border action id {}",
+ other
+ ))),
}
}
}
@@ -1819,8 +1906,8 @@ impl Deserialize for WorldBorderAction {
#[cfg(test)]
impl TestRandom for WorldBorderAction {
fn test_gen_random() -> Self {
- WorldBorderAction::SetSize(WorldBorderSetSizeSpec{
- diameter: f64::test_gen_random()
+ WorldBorderAction::SetSize(WorldBorderSetSizeSpec {
+ diameter: f64::test_gen_random(),
})
}
}
@@ -1830,7 +1917,7 @@ pub enum ScoreboardPosition {
List,
Sidebar,
BelowName,
- TeamSpecific(i8)
+ TeamSpecific(i8),
}
impl ScoreboardPosition {
@@ -1840,7 +1927,7 @@ impl ScoreboardPosition {
List => 0x00,
Sidebar => 0x01,
BelowName => 0x02,
- TeamSpecific(team_id) => 0x03 + team_id
+ TeamSpecific(team_id) => 0x03 + team_id,
}
}
}
@@ -1863,7 +1950,10 @@ impl Deserialize for ScoreboardPosition {
if other >= 3 && other <= 12 {
Ok(TeamSpecific(other - 0x03))
} else {
- Err(DeserializeErr::CannotUnderstandValue(format!("invalid scoreboard position id {}", id)))
+ Err(DeserializeErr::CannotUnderstandValue(format!(
+ "invalid scoreboard position id {}",
+ id
+ )))
}
}
}?;
@@ -1891,7 +1981,7 @@ proto_varint_enum!(EquipmentSlot,
pub enum ScoreboardObjectiveAction {
Create(ScoreboardObjectiveSpec),
Remove,
- UpdateText(ScoreboardObjectiveSpec)
+ UpdateText(ScoreboardObjectiveSpec),
}
proto_varint_enum!(ScoreboardObjectiveKind,
@@ -1910,7 +2000,7 @@ impl ScoreboardObjectiveAction {
match self {
Create(_) => 0x00,
Remove => 0x01,
- UpdateText(_) => 0x02
+ UpdateText(_) => 0x02,
}
}
}
@@ -1924,20 +2014,27 @@ impl Serialize for ScoreboardObjectiveAction {
match self {
Create(body) => to.serialize_other(body),
UpdateText(body) => to.serialize_other(body),
- _ => Ok(())
+ _ => Ok(()),
}
}
}
impl Deserialize for ScoreboardObjectiveAction {
fn mc_deserialize(data: &[u8]) -> DeserializeResult<'_, Self> {
- let Deserialized{ value: id, data } = i8::mc_deserialize(data)?;
+ let Deserialized { value: id, data } = i8::mc_deserialize(data)?;
use ScoreboardObjectiveAction::*;
match id {
- 0x00 => Ok(ScoreboardObjectiveSpec::mc_deserialize(data)?.map(move |body| Create(body))),
+ 0x00 => {
+ Ok(ScoreboardObjectiveSpec::mc_deserialize(data)?.map(move |body| Create(body)))
+ }
0x01 => Deserialized::ok(Remove, data),
- 0x02 => Ok(ScoreboardObjectiveSpec::mc_deserialize(data)?.map(move |body| UpdateText(body))),
- other => Err(DeserializeErr::CannotUnderstandValue(format!("invalid scoreboard objective action id {}", other)))
+ 0x02 => Ok(
+ ScoreboardObjectiveSpec::mc_deserialize(data)?.map(move |body| UpdateText(body))
+ ),
+ other => Err(DeserializeErr::CannotUnderstandValue(format!(
+ "invalid scoreboard objective action id {}",
+ other
+ ))),
}
}
}
@@ -2025,7 +2122,7 @@ __protocol_body_def_helper!(InteractAtSpec {
pub enum InteractKind {
Interact,
Attack,
- InteractAt(InteractAtSpec)
+ InteractAt(InteractAtSpec),
}
impl InteractKind {
@@ -2035,7 +2132,8 @@ impl InteractKind {
Interact => 0x00,
Attack => 0x01,
InteractAt(_) => 0x02,
- }.into()
+ }
+ .into()
}
}
@@ -2047,21 +2145,24 @@ impl Serialize for InteractKind {
use InteractKind::*;
match self {
InteractAt(body) => to.serialize_other(body),
- _ => Ok(())
+ _ => Ok(()),
}
}
}
impl Deserialize for InteractKind {
fn mc_deserialize(data: &[u8]) -> DeserializeResult<'_, Self> {
- let Deserialized{ value: id, data } = VarInt::mc_deserialize(data)?;
+ let Deserialized { value: id, data } = VarInt::mc_deserialize(data)?;
use InteractKind::*;
match id.0 {
0x00 => Deserialized::ok(Interact, data),
0x01 => Deserialized::ok(Attack, data),
0x02 => Ok(InteractAtSpec::mc_deserialize(data)?.map(move |body| InteractAt(body))),
- other => Err(DeserializeErr::CannotUnderstandValue(format!("invalid entity interact kind id {}", other)))
+ other => Err(DeserializeErr::CannotUnderstandValue(format!(
+ "invalid entity interact kind id {}",
+ other
+ ))),
}
}
}
@@ -2171,7 +2272,7 @@ proto_byte_flag!(UpdateStructureBlockFlags,
#[derive(Clone, PartialEq, Debug)]
pub struct RecipeSpec {
pub recipe: Recipe,
- pub id: String
+ pub id: String,
}
#[derive(Clone, PartialEq, Debug)]
@@ -2196,7 +2297,7 @@ pub enum Recipe {
Blasting(RecipeSmeltingSpec),
Smoking(RecipeSmeltingSpec),
CampfireCooking(RecipeSmeltingSpec),
- StoneCutting(RecipeStonecuttingSpec)
+ StoneCutting(RecipeStonecuttingSpec),
}
impl Recipe {
@@ -2224,7 +2325,8 @@ impl Recipe {
Smoking(_) => "minecraft:smoking",
CampfireCooking(_) => "minecraft:campfire_cooking",
StoneCutting(_) => "minecraft:stonecutting",
- }.to_owned()
+ }
+ .to_owned()
}
fn serialize_body<S: Serializer>(&self, to: &mut S) -> SerializeResult {
@@ -2237,7 +2339,7 @@ impl Recipe {
Smoking(body) => to.serialize_other(body),
CampfireCooking(body) => to.serialize_other(body),
StoneCutting(body) => to.serialize_other(body),
- _ => Ok(())
+ _ => Ok(()),
}
}
}
@@ -2254,34 +2356,75 @@ impl Serialize for RecipeSpec {
impl Deserialize for RecipeSpec {
fn mc_deserialize(data: &[u8]) -> DeserializeResult<'_, Self> {
let Deserialized { value: _type, data } = String::mc_deserialize(data)?;
- let Deserialized { value: recipe_id, data } = String::mc_deserialize(data)?;
+ let Deserialized {
+ value: recipe_id,
+ data,
+ } = String::mc_deserialize(data)?;
use Recipe::*;
Ok(match _type.as_str() {
- "minecraft:crafting_shapeless" => Ok(RecipeCraftingShapelessSpec::mc_deserialize(data)?.map(move |b| CraftingShapeless(b))),
- "minecraft:crafting_shaped" => Ok(RecipeCraftingShapedSpec::mc_deserialize(data)?.map(move |b| CraftingShaped(b))),
+ "minecraft:crafting_shapeless" => {
+ Ok(RecipeCraftingShapelessSpec::mc_deserialize(data)?
+ .map(move |b| CraftingShapeless(b)))
+ }
+ "minecraft:crafting_shaped" => {
+ Ok(RecipeCraftingShapedSpec::mc_deserialize(data)?.map(move |b| CraftingShaped(b)))
+ }
"minecraft:crafting_special_armordye" => Deserialized::ok(CraftingArmorDye, data),
"minecraft:crafting_special_bookcloning" => Deserialized::ok(CraftingBookCloning, data),
"minecraft:crafting_special_mapcloning" => Deserialized::ok(CraftingMapCloning, data),
- "minecraft:crafting_special_mapextending" => Deserialized::ok(CraftingMapExtending, data),
- "minecraft:crafting_special_firework_rocket" => Deserialized::ok(CraftingFireworkRocket, data),
- "minecraft:crafting_special_firework_star" => Deserialized::ok(CraftingFireworkStar, data),
- "minecraft:crafting_special_firework_star_fade" => Deserialized::ok(CraftingFireworkStarFade, data),
+ "minecraft:crafting_special_mapextending" => {
+ Deserialized::ok(CraftingMapExtending, data)
+ }
+ "minecraft:crafting_special_firework_rocket" => {
+ Deserialized::ok(CraftingFireworkRocket, data)
+ }
+ "minecraft:crafting_special_firework_star" => {
+ Deserialized::ok(CraftingFireworkStar, data)
+ }
+ "minecraft:crafting_special_firework_star_fade" => {
+ Deserialized::ok(CraftingFireworkStarFade, data)
+ }
"minecraft:crafting_special_repairitem" => Deserialized::ok(CraftingRepairItem, data),
"minecraft:crafting_special_tippedarrow" => Deserialized::ok(CraftingTippedArrow, data),
- "minecraft:crafting_special_bannerduplicate" => Deserialized::ok(CraftingBannerDuplicate, data),
- "minecraft:crafting_special_banneraddpattern" => Deserialized::ok(CraftingBannerAddPattern, data),
- "minecraft:crafting_special_shielddecoration" => Deserialized::ok(CraftingShieldDecoration, data),
- "minecraft:crafting_special_shulkerboxcoloring" => Deserialized::ok(CraftingShulkerBoxColoring, data),
- "minecraft:crafting_special_suspiciousstew" => Deserialized::ok(CraftingSuspiciousStew, data),
- "minecraft:smelting" => Ok(RecipeSmeltingSpec::mc_deserialize(data)?.map(move |b| Smelting(b))),
- "minecraft:blasting" => Ok(RecipeSmeltingSpec::mc_deserialize(data)?.map(move |b| Blasting(b))),
- "minecraft:smoking" => Ok(RecipeSmeltingSpec::mc_deserialize(data)?.map(move |b| Smoking(b))),
- "minecraft:campfire_cooking" => Ok(RecipeSmeltingSpec::mc_deserialize(data)?.map(move |b| CampfireCooking(b))),
- "minecraft:stonecutting" => Ok(RecipeStonecuttingSpec::mc_deserialize(data)?.map(move |b| StoneCutting(b))),
- other => Err(DeserializeErr::CannotUnderstandValue(format!("invalid crafting recipe kind {:?}", other)))
- }?.map(move |recipe_body| {
- RecipeSpec{ id: recipe_id, recipe: recipe_body }
+ "minecraft:crafting_special_bannerduplicate" => {
+ Deserialized::ok(CraftingBannerDuplicate, data)
+ }
+ "minecraft:crafting_special_banneraddpattern" => {
+ Deserialized::ok(CraftingBannerAddPattern, data)
+ }
+ "minecraft:crafting_special_shielddecoration" => {
+ Deserialized::ok(CraftingShieldDecoration, data)
+ }
+ "minecraft:crafting_special_shulkerboxcoloring" => {
+ Deserialized::ok(CraftingShulkerBoxColoring, data)
+ }
+ "minecraft:crafting_special_suspiciousstew" => {
+ Deserialized::ok(CraftingSuspiciousStew, data)
+ }
+ "minecraft:smelting" => {
+ Ok(RecipeSmeltingSpec::mc_deserialize(data)?.map(move |b| Smelting(b)))
+ }
+ "minecraft:blasting" => {
+ Ok(RecipeSmeltingSpec::mc_deserialize(data)?.map(move |b| Blasting(b)))
+ }
+ "minecraft:smoking" => {
+ Ok(RecipeSmeltingSpec::mc_deserialize(data)?.map(move |b| Smoking(b)))
+ }
+ "minecraft:campfire_cooking" => {
+ Ok(RecipeSmeltingSpec::mc_deserialize(data)?.map(move |b| CampfireCooking(b)))
+ }
+ "minecraft:stonecutting" => {
+ Ok(RecipeStonecuttingSpec::mc_deserialize(data)?.map(move |b| StoneCutting(b)))
+ }
+ other => Err(DeserializeErr::CannotUnderstandValue(format!(
+ "invalid crafting recipe kind {:?}",
+ other
+ ))),
+ }?
+ .map(move |recipe_body| RecipeSpec {
+ id: recipe_id,
+ recipe: recipe_body,
}))
}
}
@@ -2330,20 +2473,41 @@ impl Serialize for RecipeCraftingShapedSpec {
impl Deserialize for RecipeCraftingShapedSpec {
fn mc_deserialize(data: &[u8]) -> DeserializeResult<'_, Self> {
let Deserialized { value: width, data } = <VarInt>::mc_deserialize(data)?;
- let Deserialized { value: height, data } = <VarInt>::mc_deserialize(data)?;
- let Deserialized { value: group, mut data } = <String>::mc_deserialize(data)?;
+ let Deserialized {
+ value: height,
+ data,
+ } = <VarInt>::mc_deserialize(data)?;
+ let Deserialized {
+ value: group,
+ mut data,
+ } = <String>::mc_deserialize(data)?;
let ingredients_count = width.0 as usize * height.0 as usize;
let mut ingredients: Vec<RecipeIngredient> = Vec::with_capacity(ingredients_count);
for _ in 0..ingredients_count {
- let Deserialized { value: elem, data: rest } = RecipeIngredient::mc_deserialize(data)?;
+ let Deserialized {
+ value: elem,
+ data: rest,
+ } = RecipeIngredient::mc_deserialize(data)?;
data = rest;
ingredients.push(elem);
}
- let Deserialized { value: result, data } = <Option<Slot>>::mc_deserialize(data)?;
+ let Deserialized {
+ value: result,
+ data,
+ } = <Option<Slot>>::mc_deserialize(data)?;
- Deserialized::ok(Self { width, height, group, ingredients, result }, data)
+ Deserialized::ok(
+ Self {
+ width,
+ height,
+ group,
+ ingredients,
+ result,
+ },
+ data,
+ )
}
}
@@ -2354,7 +2518,7 @@ impl TestRandom for RecipeCraftingShapedSpec {
width: VarInt::test_gen_random(),
height: VarInt::test_gen_random(),
group: String::test_gen_random(),
- ingredients: vec!(RecipeIngredient::test_gen_random()),
+ ingredients: vec![RecipeIngredient::test_gen_random()],
result: <Option<Slot>>::test_gen_random(),
}
}
@@ -2388,7 +2552,7 @@ pub struct ChunkData {
pub heightmaps: NamedNbtTag,
pub biomes: Option<[i32; 1024]>,
pub data: VarIntCountedArray<u8>,
- pub block_entities: Vec<NamedNbtTag>
+ pub block_entities: Vec<NamedNbtTag>,
}
impl Serialize for ChunkData {
@@ -2420,11 +2584,26 @@ impl Serialize for ChunkData {
impl Deserialize for ChunkData {
fn mc_deserialize(data: &[u8]) -> DeserializeResult<'_, Self> {
- let Deserialized { value: chunk_x, data } = i32::mc_deserialize(data)?;
- let Deserialized { value: chunk_z, data } = i32::mc_deserialize(data)?;
- let Deserialized { value: is_full_chunk, data } = bool::mc_deserialize(data)?;
- let Deserialized { value: primary_bit_mask, data } = VarInt::mc_deserialize(data)?;
- let Deserialized { value: heightmaps, mut data } = NamedNbtTag::mc_deserialize(data)?;
+ let Deserialized {
+ value: chunk_x,
+ data,
+ } = i32::mc_deserialize(data)?;
+ let Deserialized {
+ value: chunk_z,
+ data,
+ } = i32::mc_deserialize(data)?;
+ let Deserialized {
+ value: is_full_chunk,
+ data,
+ } = bool::mc_deserialize(data)?;
+ let Deserialized {
+ value: primary_bit_mask,
+ data,
+ } = VarInt::mc_deserialize(data)?;
+ let Deserialized {
+ value: heightmaps,
+ mut data,
+ } = NamedNbtTag::mc_deserialize(data)?;
let biomes = if is_full_chunk {
let mut biomes: [i32; 1024] = [0i32; 1024];
for elem in &mut biomes {
@@ -2436,39 +2615,51 @@ impl Deserialize for ChunkData {
} else {
None
};
- let Deserialized { value: chunk_data, data } = VarIntCountedArray::<u8>::mc_deserialize(data)?;
- let Deserialized { value: n_block_entities_raw, mut data } = VarInt::mc_deserialize(data)?;
+ let Deserialized {
+ value: chunk_data,
+ data,
+ } = VarIntCountedArray::<u8>::mc_deserialize(data)?;
+ let Deserialized {
+ value: n_block_entities_raw,
+ mut data,
+ } = VarInt::mc_deserialize(data)?;
let n_block_entities = n_block_entities_raw.0 as usize;
let mut block_entities = Vec::with_capacity(n_block_entities);
for _ in 0..n_block_entities {
- let Deserialized { value: entity, data: rest } = NamedNbtTag::mc_deserialize(data)?;
+ let Deserialized {
+ value: entity,
+ data: rest,
+ } = NamedNbtTag::mc_deserialize(data)?;
data = rest;
block_entities.push(entity);
}
- Deserialized::ok(ChunkData{
- chunk_x,
- chunk_z,
- primary_bit_mask,
- heightmaps,
- biomes,
- data: chunk_data,
- block_entities,
- }, data)
+ Deserialized::ok(
+ ChunkData {
+ chunk_x,
+ chunk_z,
+ primary_bit_mask,
+ heightmaps,
+ biomes,
+ data: chunk_data,
+ block_entities,
+ },
+ data,
+ )
}
}
#[cfg(test)]
impl TestRandom for ChunkData {
fn test_gen_random() -> Self {
- ChunkData{
+ ChunkData {
chunk_x: rand::random(),
chunk_z: rand::random(),
primary_bit_mask: VarInt::test_gen_random(),
heightmaps: NamedNbtTag::test_gen_random(),
biomes: None,
data: <VarIntCountedArray<u8>>::test_gen_random(),
- block_entities: vec![]
+ block_entities: vec![],
}
}
}
@@ -2478,448 +2669,1324 @@ pub mod tests {
use super::*;
use crate::packet_test_cases;
- use crate::protocol::{RawPacket, Packet};
- use crate::types::BytesSerializer;
+ use crate::protocol::{Packet, RawPacket};
use crate::test_macros::BenchSerializer;
+ use crate::types::BytesSerializer;
use test::Bencher;
- packet_test_cases!(Packet578, Handshake, HandshakeSpec,
- test_handshake, bench_write_handshake, bench_read_handshake);
-
- packet_test_cases!(Packet578, StatusRequest, StatusRequestSpec,
- test_status_request, bench_write_status_request, bench_read_status_request);
-
- packet_test_cases!(Packet578, StatusPing, StatusPingSpec,
- test_status_ping, bench_write_status_ping, bench_read_status_ping);
-
- packet_test_cases!(Packet578, StatusResponse, StatusResponseSpec,
- test_status_response, bench_write_status_response, bench_read_status_response);
-
- packet_test_cases!(Packet578, StatusPong, StatusPongSpec,
- test_status_pong, bench_write_status_pong, bench_read_status_pong);
-
- packet_test_cases!(Packet578, LoginDisconnect, LoginDisconnectSpec,
- test_login_disconnect, bench_write_login_disconnect, bench_read_login_disconnect);
-
- packet_test_cases!(Packet578, LoginEncryptionRequest, LoginEncryptionRequestSpec,
- test_login_encryption_request, bench_write_login_encryption_request, bench_read_login_encryption_request);
-
- packet_test_cases!(Packet578, LoginSuccess, LoginSuccessSpec,
- test_login_success, bench_write_login_success, bench_read_login_success);
-
- packet_test_cases!(Packet578, LoginSetCompression, LoginSetCompressionSpec,
- test_login_set_compression, bench_write_login_set_compression, bench_read_login_set_compression);
-
- packet_test_cases!(Packet578, LoginPluginRequest, LoginPluginRequestSpec,
- test_login_plugin_request, bench_write_login_plugin_request, bench_read_login_plugin_request);
-
- packet_test_cases!(Packet578, LoginStart, LoginStartSpec,
- test_login_start, bench_write_login_start, bench_read_login_start);
-
- packet_test_cases!(Packet578, LoginEncryptionResponse, LoginEncryptionResponseSpec,
- test_login_encryption_response, bench_write_login_encryption_response, bench_read_login_encryption_response);
-
- packet_test_cases!(Packet578, LoginPluginResponse, LoginPluginResponseSpec,
- test_login_plugin_response, bench_write_login_plugin_response, bench_read_login_plugin_response);
-
- packet_test_cases!(Packet578, PlaySpawnEntity, PlaySpawnEntitySpec,
- test_play_spawn_entity, bench_write_play_spawn_entity, bench_read_play_spawn_entity);
-
- packet_test_cases!(Packet578, PlaySpawnExperienceOrb, PlaySpawnExperienceOrbSpec,
- test_play_spawn_experience_orb, bench_write_play_spawn_experience_orb, bench_read_play_spawn_experience_orb);
-
- packet_test_cases!(Packet578, PlaySpawnWeatherEntity, PlaySpawnWeatherEntitySpec,
- test_play_spawn_weather_entity, bench_write_play_spawn_weather_entity, bench_read_play_spawn_weather_entity);
-
- packet_test_cases!(Packet578, PlaySpawnLivingEntity, PlaySpawnLivingEntitySpec,
- test_play_spawn_living_entity, bench_write_play_spawn_living_entity, bench_read_play_spawn_living_entity);
-
- packet_test_cases!(Packet578, PlaySpawnPainting, PlaySpawnPaintingSpec,
- test_play_spawn_painting, bench_write_play_spawn_painting, bench_read_play_spawn_painting);
-
- packet_test_cases!(Packet578, PlaySpawnPlayer, PlaySpawnPlayerSpec,
- test_play_spawn_player, bench_write_play_spawn_player, bench_read_play_spawn_player);
-
- packet_test_cases!(Packet578, PlayEntityAnimation, PlayEntityAnimationSpec,
- test_play_entity_animation, bench_write_play_entity_animation, bench_read_play_entity_animation);
-
- packet_test_cases!(Packet578, PlayStatistics, PlayStatisticsSpec,
- test_play_statistics, bench_write_play_statistics, bench_read_play_statistics);
-
- packet_test_cases!(Packet578, PlayAcknowledgePlayerDigging, PlayAcknowledgePlayerDiggingSpec,
- test_play_acknowledge_player_digging, bench_write_play_acknowledge_player_digging, bench_read_play_acknowledge_player_digging);
-
- packet_test_cases!(Packet578, PlayBlockBreakAnimation, PlayBlockBreakAnimationSpec,
- test_play_block_break_animation, bench_write_play_block_break_animation, bench_read_play_block_break_animation);
-
- packet_test_cases!(Packet578, PlayBlockEntityData, PlayBlockEntityDataSpec,
- test_play_block_entity_data, bench_write_play_block_entity_data, bench_read_play_block_entity_data);
-
- packet_test_cases!(Packet578, PlayBlockAction, PlayBlockActionSpec,
- test_play_block_action, bench_write_play_block_action, bench_read_play_block_action);
-
- packet_test_cases!(Packet578, PlayBlockChange, PlayBlockChangeSpec,
- test_play_block_change, bench_write_play_block_change, bench_read_play_block_change);
-
- packet_test_cases!(Packet578, PlayBossBar, PlayBossBarSpec,
- test_play_boss_bar, bench_write_play_boss_bar, bench_read_play_boss_bar);
-
- packet_test_cases!(Packet578, PlayServerDifficulty, PlayServerDifficultySpec,
- test_play_server_difficulty, bench_write_play_server_difficulty, bench_read_play_server_difficulty);
-
- packet_test_cases!(Packet578, PlayServerChatMessage, PlayServerChatMessageSpec,
- test_play_server_chat_message, bench_write_play_server_chat_message, bench_read_play_server_chat_message);
-
- packet_test_cases!(Packet578, PlayMultiBlockChange, PlayMultiBlockChangeSpec,
- test_play_multi_block_change, bench_write_play_multi_block_change, bench_read_play_multi_block_change);
-
- packet_test_cases!(Packet578, PlayTabComplete, PlayTabCompleteSpec,
- test_play_tab_complete, bench_write_play_tab_complete, bench_read_play_tab_complete);
-
- packet_test_cases!(Packet578, PlayDeclareCommands, PlayDeclareCommandsSpec,
- test_play_declare_commands, bench_write_play_declare_commands, bench_read_play_declare_commands);
-
- packet_test_cases!(Packet578, PlayServerWindowConfirmation, PlayServerWindowConfirmationSpec,
- test_play_server_window_confirmation, bench_write_play_server_window_confirmation, bench_read_play_server_window_confirmation);
-
- packet_test_cases!(Packet578, PlayServerCloseWindow, PlayServerCloseWindowSpec,
- test_play_server_close_window, bench_write_play_server_close_window, bench_read_play_server_close_window);
-
- packet_test_cases!(Packet578, PlayWindowItems, PlayWindowItemsSpec,
- test_play_window_items, bench_write_play_window_items, bench_read_play_window_items);
-
- packet_test_cases!(Packet578, PlayWindowProperty, PlayWindowPropertySpec,
- test_play_window_property, bench_write_play_window_property, bench_read_play_window_property);
-
- packet_test_cases!(Packet578, PlaySetSlot, PlaySetSlotSpec,
- test_play_set_slot, bench_write_play_set_slot, bench_read_play_set_slot);
-
- packet_test_cases!(Packet578, PlaySetCooldown, PlaySetCooldownSpec,
- test_play_set_cooldown, bench_write_play_set_cooldown, bench_read_play_set_cooldown);
-
- packet_test_cases!(Packet578, PlayServerPluginMessage, PlayServerPluginMessageSpec,
- test_play_server_plugin_message, bench_write_play_server_plugin_message, bench_read_play_server_plugin_message);
-
- packet_test_cases!(Packet578, PlayNamedSoundEffect, PlayNamedSoundEffectSpec,
- test_play_named_sound_effect, bench_write_play_named_sound_effect, bench_read_play_named_sound_effect);
-
- packet_test_cases!(Packet578, PlayDisconnect, PlayDisconnectSpec,
- test_play_disconnect, bench_write_play_disconnect, bench_read_play_disconnect);
-
- packet_test_cases!(Packet578, PlayEntityStatus, PlayEntityStatusSpec,
- test_play_entity_status, bench_write_play_entity_status, bench_read_play_entity_status);
-
- packet_test_cases!(Packet578, PlayExposion, PlayExposionSpec,
- test_play_exposion, bench_write_play_exposion, bench_read_play_exposion);
-
- packet_test_cases!(Packet578, PlayUnloadChunk, PlayUnloadChunkSpec,
- test_play_unload_chunk, bench_write_play_unload_chunk, bench_read_play_unload_chunk);
-
- packet_test_cases!(Packet578, PlayChangeGameState, PlayChangeGameStateSpec,
- test_play_change_game_state, bench_write_play_change_game_state, bench_read_play_change_game_state);
-
- packet_test_cases!(Packet578, PlayOpenHorseWindow, PlayOpenHorseWindowSpec,
- test_play_open_horse_window, bench_write_play_open_horse_window, bench_read_play_open_horse_window);
-
- packet_test_cases!(Packet578, PlayServerKeepAlive, PlayServerKeepAliveSpec,
- test_play_server_keep_alive, bench_write_play_server_keep_alive, bench_read_play_server_keep_alive);
-
- packet_test_cases!(Packet578, PlayChunkData, PlayChunkDataWrapper,
- test_play_chunk_data, bench_write_play_chunk_data, bench_read_play_chunk_data);
-
- packet_test_cases!(Packet578, PlayEffect, PlayEffectSpec,
- test_play_effect, bench_write_play_effect, bench_read_play_effect);
-
- packet_test_cases!(Packet578, PlayParticle, PlayParticleSpec,
- test_play_particle, bench_write_play_particle, bench_read_play_particle);
-
- packet_test_cases!(Packet578, PlayUpdateLight, PlayUpdateLoightSpec,
- test_play_update_light, bench_write_play_update_light, bench_read_play_update_light);
-
- packet_test_cases!(Packet578, PlayJoinGame, PlayJoinGameSpec,
- test_play_join_game, bench_write_play_join_game, bench_read_play_join_game);
-
- packet_test_cases!(Packet578, PlayMapData, PlayMapDataSpec,
- test_play_map_data, bench_write_play_map_data, bench_read_play_map_data);
-
- packet_test_cases!(Packet578, PlayTradeList, PlayTradeListSpec,
- test_play_trade_list, bench_write_play_trade_list, bench_read_play_trade_list);
-
- packet_test_cases!(Packet578, PlayEntityPosition, PlayEntityPositionSpec,
- test_play_entity_position, bench_write_play_entity_position, bench_read_play_entity_position);
-
- packet_test_cases!(Packet578, PlayEntityPositionAndRotation, PlayEntityPositionAndRotationSpec,
- test_play_entity_position_and_rotation, bench_write_play_entity_position_and_rotation, bench_read_play_entity_position_and_rotation);
-
- packet_test_cases!(Packet578, PlayEntityRotation, PlayEntityRotationSpec,
- test_play_entity_rotation, bench_write_play_entity_rotation, bench_read_play_entity_rotation);
-
- packet_test_cases!(Packet578, PlayEntityMovement, PlayEntityMovementSpec,
- test_play_entity_movement, bench_write_play_entity_movement, bench_read_play_entity_movement);
-
- packet_test_cases!(Packet578, PlayServerVehicleMove, PlayEntityVehicleMoveSpec,
- test_play_server_vehicle_move, bench_write_play_server_vehicle_move, bench_read_play_server_vehicle_move);
-
- packet_test_cases!(Packet578, PlayOpenBook, PlayOpenBookSpec,
- test_play_open_book, bench_write_play_open_book, bench_read_play_open_book);
-
- packet_test_cases!(Packet578, PlayOpenWindow, PlayOpenWindowSpec,
- test_play_open_window, bench_write_play_open_window, bench_read_play_open_window);
-
- packet_test_cases!(Packet578, PlayOpenSignEditor, PlayOpenSignEditorSpec,
- test_play_open_sign_editor, bench_write_play_open_sign_editor, bench_read_play_open_sign_editor);
-
- packet_test_cases!(Packet578, PlayCraftRecipeResponse, PlayCraftRecipeResponseSpec,
- test_play_craft_recipe_response, bench_write_play_craft_recipe_response, bench_read_play_craft_recipe_response);
-
- packet_test_cases!(Packet578, PlayServerPlayerAbilities, PlayServerPlayerAbilitiesSpec,
- test_play_server_player_abilities, bench_write_play_server_player_abilities, bench_read_play_server_player_abilities);
-
- packet_test_cases!(Packet578, PlayCombatEvent, PlayCombatEventSpec,
- test_play_combat_event, bench_write_play_combat_event, bench_read_play_combat_event);
-
- packet_test_cases!(Packet578, PlayPlayerInfo, PlayPlayerInfoSpec,
- test_play_player_info, bench_write_play_player_info, bench_read_play_player_info);
-
- packet_test_cases!(Packet578, PlayFacePlayer, PlayFacePlayerSpec,
- test_play_face_player, bench_write_play_face_player, bench_read_play_face_player);
-
- packet_test_cases!(Packet578, PlayServerPlayerPositionAndLook, PlayServerPlayerPositionAndLookSpec,
- test_play_server_player_position_and_look, bench_write_play_server_player_position_and_look, bench_read_play_server_player_position_and_look);
-
- packet_test_cases!(Packet578, PlayUnlockRecipes, PlayUnlockRecipesSpec,
- test_play_unlock_recipes, bench_write_play_unlock_recipes, bench_read_play_unlock_recipes);
-
- packet_test_cases!(Packet578, PlayDestroyEntities, PlayDestroyEntitiesSpec,
- test_play_destroy_entities, bench_write_play_destroy_entities, bench_read_play_destroy_entities);
-
- packet_test_cases!(Packet578, PlayRemoveEntityEffect, PlayRemoveEntityEffectSpec,
- test_play_remove_entity_effect, bench_write_play_remove_entity_effect, bench_read_play_remove_entity_effect);
-
- packet_test_cases!(Packet578, PlayResourcePackSend, PlayResourcePackSendSpec,
- test_play_resource_pack_send, bench_write_play_resource_pack_send, bench_read_play_resource_pack_send);
-
- packet_test_cases!(Packet578, PlayRespawn, PlayRespawnSpec,
- test_play_respawn, bench_write_play_respawn, bench_read_play_respawn);
-
- packet_test_cases!(Packet578, PlayEntityHeadLook, PlayEntityHeadLookSpec,
- test_play_entity_head_look, bench_write_play_entity_head_look, bench_read_play_entity_head_look);
-
- packet_test_cases!(Packet578, PlaySelectAdvancementTab, PlaySelectAdvancementTabSpec,
- test_play_select_advancement_tab, bench_write_play_select_advancement_tab, bench_read_play_select_advancement_tab);
-
- packet_test_cases!(Packet578, PlayWorldBorder, PlayWorldBorderSpec,
- test_play_world_border, bench_write_play_world_border, bench_read_play_world_border);
-
- packet_test_cases!(Packet578, PlayCamera, PlayCameraSpec,
- test_play_camera, bench_write_play_camera, bench_read_play_camera);
-
- packet_test_cases!(Packet578, PlayServerHeldItemChange, PlayServerHeldItemChangeSpec,
- test_play_server_held_item_change, bench_write_play_server_held_item_change, bench_read_play_server_held_item_change);
-
- packet_test_cases!(Packet578, PlayUpdateViewPosition, PlayUpdateViewPositionSpec,
- test_play_update_view_position, bench_write_play_update_view_position, bench_read_play_update_view_position);
-
- packet_test_cases!(Packet578, PlayUpdateViewDistance, PlayUpdateViewDistanceSpec,
- test_play_update_view_distance, bench_write_play_update_view_distance, bench_read_play_update_view_distance);
-
- packet_test_cases!(Packet578, PlayDisplayScoreboard, PlayDisplayScoreboardSpec,
- test_play_display_scoreboard, bench_write_play_display_scoreboard, bench_read_play_display_scoreboard);
-
- packet_test_cases!(Packet578, PlayEntityMetadata, PlayEntityMetadataSpec,
- test_play_entity_metadata, bench_write_play_entity_metadata, bench_read_play_entity_metadata);
-
- packet_test_cases!(Packet578, PlayAttachEntity, PlayAttachEntitySpec,
- test_play_attach_entity, bench_write_play_attach_entity, bench_read_play_attach_entity);
-
- packet_test_cases!(Packet578, PlayEntityVelocity, PlayEntityVelocitySpec,
- test_play_entity_velocity, bench_write_play_entity_velocity, bench_read_play_entity_velocity);
-
- packet_test_cases!(Packet578, PlayEntityEquipment, PlayEntityEquiptmentSpec,
- test_play_entity_equipment, bench_write_play_entity_equipment, bench_read_play_entity_equipment);
-
- packet_test_cases!(Packet578, PlaySetExperience, PlaySetExperienceSpec,
- test_play_set_experience, bench_write_play_set_experience, bench_read_play_set_experience);
-
- packet_test_cases!(Packet578, PlayUpdatehealth, PlayUpdateHealthSpec,
- test_play_updatehealth, bench_write_play_updatehealth, bench_read_play_updatehealth);
-
- packet_test_cases!(Packet578, PlayScoreboardObjective, PlayScoreboardObjectiveSpec,
- test_play_scoreboard_objective, bench_write_play_scoreboard_objective, bench_read_play_scoreboard_objective);
-
- packet_test_cases!(Packet578, PlaySetPassengers, PlaySetPassengersSpec,
- test_play_set_passengers, bench_write_play_set_passengers, bench_read_play_set_passengers);
-
- packet_test_cases!(Packet578, PlaySpawnPosition, PlaySpawnPositionSpec,
- test_play_spawn_position, bench_write_play_spawn_position, bench_read_play_spawn_position);
-
- packet_test_cases!(Packet578, PlayTimeUpdate, PlayTimeUpdateSpec,
- test_play_time_update, bench_write_play_time_update, bench_read_play_time_update);
-
- packet_test_cases!(Packet578, PlayEntitySoundEffect, PlayEntitySoundEffectSpec,
- test_play_entity_sound_effect, bench_write_play_entity_sound_effect, bench_read_play_entity_sound_effect);
-
- packet_test_cases!(Packet578, PlaySoundEffect, PlaySoundEffectSpec,
- test_play_sound_effect, bench_write_play_sound_effect, bench_read_play_sound_effect);
-
- packet_test_cases!(Packet578, PlayerPlayerListHeaderAndFooter, PlayPlayerListHeaderAndFooterSpec,
- test_player_player_list_header_and_footer, bench_write_player_player_list_header_and_footer, bench_read_player_player_list_header_and_footer);
-
- packet_test_cases!(Packet578, PlayNbtQueryResponse, PlayNbtQueryResponseSpec,
- test_play_nbt_query_response, bench_write_play_nbt_query_response, bench_read_play_nbt_query_response);
-
- packet_test_cases!(Packet578, PlayCollectItem, PlayCollectItemSpec,
- test_play_collect_item, bench_write_play_collect_item, bench_read_play_collect_item);
-
- packet_test_cases!(Packet578, PlayEntityTeleport, PlayEntityTeleportSpec,
- test_play_entity_teleport, bench_write_play_entity_teleport, bench_read_play_entity_teleport);
-
- packet_test_cases!(Packet578, PlayAdvancements, PlayAdvancementsSpec,
- test_play_advancements, bench_write_play_advancements, bench_read_play_advancements);
-
- packet_test_cases!(Packet578, PlayEntityProperties, PlayEntityPropertiesSpec,
- test_play_entity_properties, bench_write_play_entity_properties, bench_read_play_entity_properties);
-
- packet_test_cases!(Packet578, PlayEntityEffect, PlayEntityEffectSpec,
- test_play_entity_effect, bench_write_play_entity_effect, bench_read_play_entity_effect);
-
- packet_test_cases!(Packet578, PlayDeclareRecipes, PlayDeclareRecipesSpec,
- test_play_declare_recipes, bench_write_play_declare_recipes, bench_read_play_declare_recipes);
-
- packet_test_cases!(Packet578, PlayTags, PlayTagsSpec,
- test_play_tags, bench_write_play_tags, bench_read_play_tags);
-
- packet_test_cases!(Packet578, PlayTeleportConfirm, PlayTeleportConfirmSpec,
- test_play_teleport_confirm, bench_write_play_teleport_confirm, bench_read_play_teleport_confirm);
-
- packet_test_cases!(Packet578, PlayQueryBlockNbt, PlayQueryBlockNbtSpec,
- test_play_query_block_nbt, bench_write_play_query_block_nbt, bench_read_play_query_block_nbt);
-
- packet_test_cases!(Packet578, PlayQueryEntityNbt, PlayQueryEntityNbtSpec,
- test_play_query_entity_nbt, bench_write_play_query_entity_nbt, bench_read_play_query_entity_nbt);
-
- packet_test_cases!(Packet578, PlaySetDifficulty, PlaySetDifficultySpec,
- test_play_set_difficulty, bench_write_play_set_difficulty, bench_read_play_set_difficulty);
-
- packet_test_cases!(Packet578, PlayClientChatMessage, PlayClientChatMessageSpec,
- test_play_client_chat_message, bench_write_play_client_chat_message, bench_read_play_client_chat_message);
-
- packet_test_cases!(Packet578, PlayClientStatus, PlayClientStatusSpec,
- test_play_client_status, bench_write_play_client_status, bench_read_play_client_status);
-
- packet_test_cases!(Packet578, PlayClientSettings, PlayClientSettingsSpec,
- test_play_client_settings, bench_write_play_client_settings, bench_read_play_client_settings);
-
- packet_test_cases!(Packet578, PlayClientTabComplete, PlayClientTabCompleteSpec,
- test_play_client_tab_complete, bench_write_play_client_tab_complete, bench_read_play_client_tab_complete);
-
- packet_test_cases!(Packet578, PlayClientWindowConfirmation, PlayClientWindowConfirmationSpec,
- test_play_client_window_confirmation, bench_write_play_client_window_confirmation, bench_read_play_client_window_confirmation);
-
- packet_test_cases!(Packet578, PlayClickWindowButton, PlayClickWindowButtonSpec,
- test_play_click_window_button, bench_write_play_click_window_button, bench_read_play_click_window_button);
-
- packet_test_cases!(Packet578, PlayClickWindow, PlayClickWindowSpec,
- test_play_click_window, bench_write_play_click_window, bench_read_play_click_window);
-
- packet_test_cases!(Packet578, PlayClientCloseWindow, PlayClientCloseWindowSpec,
- test_play_client_close_window, bench_write_play_client_close_window, bench_read_play_client_close_window);
-
- packet_test_cases!(Packet578, PlayClientPluginMessage, PlayClientPluginMessageSpec,
- test_play_client_plugin_message, bench_write_play_client_plugin_message, bench_read_play_client_plugin_message);
-
- packet_test_cases!(Packet578, PlayEditBook, PlayEditBookSpec,
- test_play_edit_book, bench_write_play_edit_book, bench_read_play_edit_book);
-
- packet_test_cases!(Packet578, PlayInteractEntity, PlayInteractEntitySpec,
- test_play_interact_entity, bench_write_play_interact_entity, bench_read_play_interact_entity);
-
- packet_test_cases!(Packet578, PlayClientKeepAlive, PlayClientKeepAliveSpec,
- test_play_client_keep_alive, bench_write_play_client_keep_alive, bench_read_play_client_keep_alive);
-
- packet_test_cases!(Packet578, PlayLockDifficulty, PlayLockDifficultySpec,
- test_play_lock_difficulty, bench_write_play_lock_difficulty, bench_read_play_lock_difficulty);
-
- packet_test_cases!(Packet578, PlayPlayerPosition, PlayPlayerPositionSpec,
- test_play_player_position, bench_write_play_player_position, bench_read_play_player_position);
-
- packet_test_cases!(Packet578, PlayClientPlayerPositionAndRotation, PlayClientPlayerPositionAndRotationSpec,
- test_play_client_player_position_and_rotation, bench_write_play_client_player_position_and_rotation, bench_read_play_client_player_position_and_rotation);
-
- packet_test_cases!(Packet578, PlayPlayerRotation, PlayPlayerRotationSpec,
- test_play_player_rotation, bench_write_play_player_rotation, bench_read_play_player_rotation);
-
- packet_test_cases!(Packet578, PlayPlayerMovement, PlayPlayerMovementSpec,
- test_play_player_movement, bench_write_play_player_movement, bench_read_play_player_movement);
-
- packet_test_cases!(Packet578, PlayClientVehicleMove, PlayClientVehicleMoveSpec,
- test_play_client_vehicle_move, bench_write_play_client_vehicle_move, bench_read_play_client_vehicle_move);
-
- packet_test_cases!(Packet578, PlaySteerBoat, PlaySteerBoatSpec,
- test_play_steer_boat, bench_write_play_steer_boat, bench_read_play_steer_boat);
-
- packet_test_cases!(Packet578, PlayPickItem, PlayPickItemSpec,
- test_play_pick_item, bench_write_play_pick_item, bench_read_play_pick_item);
-
- packet_test_cases!(Packet578, PlayCraftRecipeRequest, PlayCraftRecipeRequestSpec,
- test_play_craft_recipe_request, bench_write_play_craft_recipe_request, bench_read_play_craft_recipe_request);
-
- packet_test_cases!(Packet578, PlayClientPlayerAbilities, PlayClientPlayerAbilitiesSpec,
- test_play_client_player_abilities, bench_write_play_client_player_abilities, bench_read_play_client_player_abilities);
-
- packet_test_cases!(Packet578, PlayPlayerDigging, PlayPlayerDiggingSpec,
- test_play_player_digging, bench_write_play_player_digging, bench_read_play_player_digging);
-
- packet_test_cases!(Packet578, PlayEntityAction, PlayEntityActionSpec,
- test_play_entity_action, bench_write_play_entity_action, bench_read_play_entity_action);
-
- packet_test_cases!(Packet578, PlaySteerVehicle, PlaySteerVehicleSpec,
- test_play_steer_vehicle, bench_write_play_steer_vehicle, bench_read_play_steer_vehicle);
-
- packet_test_cases!(Packet578, PlayNameItem, PlayNameItemSpec,
- test_play_name_item, bench_write_play_name_item, bench_read_play_name_item);
-
- packet_test_cases!(Packet578, PlayResourcePackStatus, PlayResourcePackStatusSpec,
- test_play_resource_pack_status, bench_write_play_resource_pack_status, bench_read_play_resource_pack_status);
-
- packet_test_cases!(Packet578, PlaySelectTrade, PlaySelectTradeSpec,
- test_play_select_trade, bench_write_play_select_trade, bench_read_play_select_trade);
-
- packet_test_cases!(Packet578, PlaySetBeaconEffect, PlaySetBeaconEffectSpec,
- test_play_set_beacon_effect, bench_write_play_set_beacon_effect, bench_read_play_set_beacon_effect);
-
- packet_test_cases!(Packet578, PlayClientHeldItemChange, PlayClientHeldItemChangeSpec,
- test_play_client_held_item_change, bench_write_play_client_held_item_change, bench_read_play_client_held_item_change);
-
- packet_test_cases!(Packet578, PlayUpdateCommandBlock, PlayUpdateCommandBlockSpec,
- test_play_update_command_block, bench_write_play_update_command_block, bench_read_play_update_command_block);
-
- packet_test_cases!(Packet578, PlayUpdateCommandBlockMinecart, PlayUpdateCommandBlockMinecartSpec,
- test_play_update_command_block_minecart, bench_write_play_update_command_block_minecart, bench_read_play_update_command_block_minecart);
-
- packet_test_cases!(Packet578, PlayCreativeInventoryAction, PlayCreativeInventoryActionSpec,
- test_play_creative_inventory_action, bench_write_play_creative_inventory_action, bench_read_play_creative_inventory_action);
-
- packet_test_cases!(Packet578, PlayUpdateJigsawBlock, PlayUpdateJigsawBlockSpec,
- test_play_update_jigsaw_block, bench_write_play_update_jigsaw_block, bench_read_play_update_jigsaw_block);
-
- packet_test_cases!(Packet578, PlayUpdateStructureBlock, PlayUpdateStructureBlockSpec,
- test_play_update_structure_block, bench_write_play_update_structure_block, bench_read_play_update_structure_block);
-
- packet_test_cases!(Packet578, PlayUpdateSign, PlayUpdateSignSpec,
- test_play_update_sign, bench_write_play_update_sign, bench_read_play_update_sign);
-
- packet_test_cases!(Packet578, PlayClientAnimation, PlayClientAnimationSpec,
- test_play_client_animation, bench_write_play_client_animation, bench_read_play_client_animation);
-
- packet_test_cases!(Packet578, PlaySpectate, PlaySpectateSpec,
- test_play_spectate, bench_write_play_spectate, bench_read_play_spectate);
-
- packet_test_cases!(Packet578, PlayBlockPlacement, PlayBlockPlacementSpec,
- test_play_block_placement, bench_write_play_block_placement, bench_read_play_block_placement);
-
- packet_test_cases!(Packet578, PlayUseItem, PlayUseItemSpec,
- test_play_use_item, bench_write_play_use_item, bench_read_play_use_item);
+ packet_test_cases!(
+ Packet578,
+ Handshake,
+ HandshakeSpec,
+ test_handshake,
+ bench_write_handshake,
+ bench_read_handshake
+ );
+
+ packet_test_cases!(
+ Packet578,
+ StatusRequest,
+ StatusRequestSpec,
+ test_status_request,
+ bench_write_status_request,
+ bench_read_status_request
+ );
+
+ packet_test_cases!(
+ Packet578,
+ StatusPing,
+ StatusPingSpec,
+ test_status_ping,
+ bench_write_status_ping,
+ bench_read_status_ping
+ );
+
+ packet_test_cases!(
+ Packet578,
+ StatusResponse,
+ StatusResponseSpec,
+ test_status_response,
+ bench_write_status_response,
+ bench_read_status_response
+ );
+
+ packet_test_cases!(
+ Packet578,
+ StatusPong,
+ StatusPongSpec,
+ test_status_pong,
+ bench_write_status_pong,
+ bench_read_status_pong
+ );
+
+ packet_test_cases!(
+ Packet578,
+ LoginDisconnect,
+ LoginDisconnectSpec,
+ test_login_disconnect,
+ bench_write_login_disconnect,
+ bench_read_login_disconnect
+ );
+
+ packet_test_cases!(
+ Packet578,
+ LoginEncryptionRequest,
+ LoginEncryptionRequestSpec,
+ test_login_encryption_request,
+ bench_write_login_encryption_request,
+ bench_read_login_encryption_request
+ );
+
+ packet_test_cases!(
+ Packet578,
+ LoginSuccess,
+ LoginSuccessSpec,
+ test_login_success,
+ bench_write_login_success,
+ bench_read_login_success
+ );
+
+ packet_test_cases!(
+ Packet578,
+ LoginSetCompression,
+ LoginSetCompressionSpec,
+ test_login_set_compression,
+ bench_write_login_set_compression,
+ bench_read_login_set_compression
+ );
+
+ packet_test_cases!(
+ Packet578,
+ LoginPluginRequest,
+ LoginPluginRequestSpec,
+ test_login_plugin_request,
+ bench_write_login_plugin_request,
+ bench_read_login_plugin_request
+ );
+
+ packet_test_cases!(
+ Packet578,
+ LoginStart,
+ LoginStartSpec,
+ test_login_start,
+ bench_write_login_start,
+ bench_read_login_start
+ );
+
+ packet_test_cases!(
+ Packet578,
+ LoginEncryptionResponse,
+ LoginEncryptionResponseSpec,
+ test_login_encryption_response,
+ bench_write_login_encryption_response,
+ bench_read_login_encryption_response
+ );
+
+ packet_test_cases!(
+ Packet578,
+ LoginPluginResponse,
+ LoginPluginResponseSpec,
+ test_login_plugin_response,
+ bench_write_login_plugin_response,
+ bench_read_login_plugin_response
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlaySpawnEntity,
+ PlaySpawnEntitySpec,
+ test_play_spawn_entity,
+ bench_write_play_spawn_entity,
+ bench_read_play_spawn_entity
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlaySpawnExperienceOrb,
+ PlaySpawnExperienceOrbSpec,
+ test_play_spawn_experience_orb,
+ bench_write_play_spawn_experience_orb,
+ bench_read_play_spawn_experience_orb
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlaySpawnWeatherEntity,
+ PlaySpawnWeatherEntitySpec,
+ test_play_spawn_weather_entity,
+ bench_write_play_spawn_weather_entity,
+ bench_read_play_spawn_weather_entity
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlaySpawnLivingEntity,
+ PlaySpawnLivingEntitySpec,
+ test_play_spawn_living_entity,
+ bench_write_play_spawn_living_entity,
+ bench_read_play_spawn_living_entity
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlaySpawnPainting,
+ PlaySpawnPaintingSpec,
+ test_play_spawn_painting,
+ bench_write_play_spawn_painting,
+ bench_read_play_spawn_painting
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlaySpawnPlayer,
+ PlaySpawnPlayerSpec,
+ test_play_spawn_player,
+ bench_write_play_spawn_player,
+ bench_read_play_spawn_player
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayEntityAnimation,
+ PlayEntityAnimationSpec,
+ test_play_entity_animation,
+ bench_write_play_entity_animation,
+ bench_read_play_entity_animation
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayStatistics,
+ PlayStatisticsSpec,
+ test_play_statistics,
+ bench_write_play_statistics,
+ bench_read_play_statistics
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayAcknowledgePlayerDigging,
+ PlayAcknowledgePlayerDiggingSpec,
+ test_play_acknowledge_player_digging,
+ bench_write_play_acknowledge_player_digging,
+ bench_read_play_acknowledge_player_digging
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayBlockBreakAnimation,
+ PlayBlockBreakAnimationSpec,
+ test_play_block_break_animation,
+ bench_write_play_block_break_animation,
+ bench_read_play_block_break_animation
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayBlockEntityData,
+ PlayBlockEntityDataSpec,
+ test_play_block_entity_data,
+ bench_write_play_block_entity_data,
+ bench_read_play_block_entity_data
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayBlockAction,
+ PlayBlockActionSpec,
+ test_play_block_action,
+ bench_write_play_block_action,
+ bench_read_play_block_action
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayBlockChange,
+ PlayBlockChangeSpec,
+ test_play_block_change,
+ bench_write_play_block_change,
+ bench_read_play_block_change
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayBossBar,
+ PlayBossBarSpec,
+ test_play_boss_bar,
+ bench_write_play_boss_bar,
+ bench_read_play_boss_bar
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayServerDifficulty,
+ PlayServerDifficultySpec,
+ test_play_server_difficulty,
+ bench_write_play_server_difficulty,
+ bench_read_play_server_difficulty
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayServerChatMessage,
+ PlayServerChatMessageSpec,
+ test_play_server_chat_message,
+ bench_write_play_server_chat_message,
+ bench_read_play_server_chat_message
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayMultiBlockChange,
+ PlayMultiBlockChangeSpec,
+ test_play_multi_block_change,
+ bench_write_play_multi_block_change,
+ bench_read_play_multi_block_change
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayTabComplete,
+ PlayTabCompleteSpec,
+ test_play_tab_complete,
+ bench_write_play_tab_complete,
+ bench_read_play_tab_complete
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayDeclareCommands,
+ PlayDeclareCommandsSpec,
+ test_play_declare_commands,
+ bench_write_play_declare_commands,
+ bench_read_play_declare_commands
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayServerWindowConfirmation,
+ PlayServerWindowConfirmationSpec,
+ test_play_server_window_confirmation,
+ bench_write_play_server_window_confirmation,
+ bench_read_play_server_window_confirmation
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayServerCloseWindow,
+ PlayServerCloseWindowSpec,
+ test_play_server_close_window,
+ bench_write_play_server_close_window,
+ bench_read_play_server_close_window
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayWindowItems,
+ PlayWindowItemsSpec,
+ test_play_window_items,
+ bench_write_play_window_items,
+ bench_read_play_window_items
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayWindowProperty,
+ PlayWindowPropertySpec,
+ test_play_window_property,
+ bench_write_play_window_property,
+ bench_read_play_window_property
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlaySetSlot,
+ PlaySetSlotSpec,
+ test_play_set_slot,
+ bench_write_play_set_slot,
+ bench_read_play_set_slot
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlaySetCooldown,
+ PlaySetCooldownSpec,
+ test_play_set_cooldown,
+ bench_write_play_set_cooldown,
+ bench_read_play_set_cooldown
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayServerPluginMessage,
+ PlayServerPluginMessageSpec,
+ test_play_server_plugin_message,
+ bench_write_play_server_plugin_message,
+ bench_read_play_server_plugin_message
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayNamedSoundEffect,
+ PlayNamedSoundEffectSpec,
+ test_play_named_sound_effect,
+ bench_write_play_named_sound_effect,
+ bench_read_play_named_sound_effect
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayDisconnect,
+ PlayDisconnectSpec,
+ test_play_disconnect,
+ bench_write_play_disconnect,
+ bench_read_play_disconnect
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayEntityStatus,
+ PlayEntityStatusSpec,
+ test_play_entity_status,
+ bench_write_play_entity_status,
+ bench_read_play_entity_status
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayExposion,
+ PlayExposionSpec,
+ test_play_exposion,
+ bench_write_play_exposion,
+ bench_read_play_exposion
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayUnloadChunk,
+ PlayUnloadChunkSpec,
+ test_play_unload_chunk,
+ bench_write_play_unload_chunk,
+ bench_read_play_unload_chunk
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayChangeGameState,
+ PlayChangeGameStateSpec,
+ test_play_change_game_state,
+ bench_write_play_change_game_state,
+ bench_read_play_change_game_state
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayOpenHorseWindow,
+ PlayOpenHorseWindowSpec,
+ test_play_open_horse_window,
+ bench_write_play_open_horse_window,
+ bench_read_play_open_horse_window
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayServerKeepAlive,
+ PlayServerKeepAliveSpec,
+ test_play_server_keep_alive,
+ bench_write_play_server_keep_alive,
+ bench_read_play_server_keep_alive
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayChunkData,
+ PlayChunkDataWrapper,
+ test_play_chunk_data,
+ bench_write_play_chunk_data,
+ bench_read_play_chunk_data
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayEffect,
+ PlayEffectSpec,
+ test_play_effect,
+ bench_write_play_effect,
+ bench_read_play_effect
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayParticle,
+ PlayParticleSpec,
+ test_play_particle,
+ bench_write_play_particle,
+ bench_read_play_particle
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayUpdateLight,
+ PlayUpdateLoightSpec,
+ test_play_update_light,
+ bench_write_play_update_light,
+ bench_read_play_update_light
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayJoinGame,
+ PlayJoinGameSpec,
+ test_play_join_game,
+ bench_write_play_join_game,
+ bench_read_play_join_game
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayMapData,
+ PlayMapDataSpec,
+ test_play_map_data,
+ bench_write_play_map_data,
+ bench_read_play_map_data
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayTradeList,
+ PlayTradeListSpec,
+ test_play_trade_list,
+ bench_write_play_trade_list,
+ bench_read_play_trade_list
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayEntityPosition,
+ PlayEntityPositionSpec,
+ test_play_entity_position,
+ bench_write_play_entity_position,
+ bench_read_play_entity_position
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayEntityPositionAndRotation,
+ PlayEntityPositionAndRotationSpec,
+ test_play_entity_position_and_rotation,
+ bench_write_play_entity_position_and_rotation,
+ bench_read_play_entity_position_and_rotation
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayEntityRotation,
+ PlayEntityRotationSpec,
+ test_play_entity_rotation,
+ bench_write_play_entity_rotation,
+ bench_read_play_entity_rotation
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayEntityMovement,
+ PlayEntityMovementSpec,
+ test_play_entity_movement,
+ bench_write_play_entity_movement,
+ bench_read_play_entity_movement
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayServerVehicleMove,
+ PlayEntityVehicleMoveSpec,
+ test_play_server_vehicle_move,
+ bench_write_play_server_vehicle_move,
+ bench_read_play_server_vehicle_move
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayOpenBook,
+ PlayOpenBookSpec,
+ test_play_open_book,
+ bench_write_play_open_book,
+ bench_read_play_open_book
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayOpenWindow,
+ PlayOpenWindowSpec,
+ test_play_open_window,
+ bench_write_play_open_window,
+ bench_read_play_open_window
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayOpenSignEditor,
+ PlayOpenSignEditorSpec,
+ test_play_open_sign_editor,
+ bench_write_play_open_sign_editor,
+ bench_read_play_open_sign_editor
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayCraftRecipeResponse,
+ PlayCraftRecipeResponseSpec,
+ test_play_craft_recipe_response,
+ bench_write_play_craft_recipe_response,
+ bench_read_play_craft_recipe_response
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayServerPlayerAbilities,
+ PlayServerPlayerAbilitiesSpec,
+ test_play_server_player_abilities,
+ bench_write_play_server_player_abilities,
+ bench_read_play_server_player_abilities
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayCombatEvent,
+ PlayCombatEventSpec,
+ test_play_combat_event,
+ bench_write_play_combat_event,
+ bench_read_play_combat_event
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayPlayerInfo,
+ PlayPlayerInfoSpec,
+ test_play_player_info,
+ bench_write_play_player_info,
+ bench_read_play_player_info
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayFacePlayer,
+ PlayFacePlayerSpec,
+ test_play_face_player,
+ bench_write_play_face_player,
+ bench_read_play_face_player
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayServerPlayerPositionAndLook,
+ PlayServerPlayerPositionAndLookSpec,
+ test_play_server_player_position_and_look,
+ bench_write_play_server_player_position_and_look,
+ bench_read_play_server_player_position_and_look
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayUnlockRecipes,
+ PlayUnlockRecipesSpec,
+ test_play_unlock_recipes,
+ bench_write_play_unlock_recipes,
+ bench_read_play_unlock_recipes
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayDestroyEntities,
+ PlayDestroyEntitiesSpec,
+ test_play_destroy_entities,
+ bench_write_play_destroy_entities,
+ bench_read_play_destroy_entities
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayRemoveEntityEffect,
+ PlayRemoveEntityEffectSpec,
+ test_play_remove_entity_effect,
+ bench_write_play_remove_entity_effect,
+ bench_read_play_remove_entity_effect
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayResourcePackSend,
+ PlayResourcePackSendSpec,
+ test_play_resource_pack_send,
+ bench_write_play_resource_pack_send,
+ bench_read_play_resource_pack_send
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayRespawn,
+ PlayRespawnSpec,
+ test_play_respawn,
+ bench_write_play_respawn,
+ bench_read_play_respawn
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayEntityHeadLook,
+ PlayEntityHeadLookSpec,
+ test_play_entity_head_look,
+ bench_write_play_entity_head_look,
+ bench_read_play_entity_head_look
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlaySelectAdvancementTab,
+ PlaySelectAdvancementTabSpec,
+ test_play_select_advancement_tab,
+ bench_write_play_select_advancement_tab,
+ bench_read_play_select_advancement_tab
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayWorldBorder,
+ PlayWorldBorderSpec,
+ test_play_world_border,
+ bench_write_play_world_border,
+ bench_read_play_world_border
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayCamera,
+ PlayCameraSpec,
+ test_play_camera,
+ bench_write_play_camera,
+ bench_read_play_camera
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayServerHeldItemChange,
+ PlayServerHeldItemChangeSpec,
+ test_play_server_held_item_change,
+ bench_write_play_server_held_item_change,
+ bench_read_play_server_held_item_change
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayUpdateViewPosition,
+ PlayUpdateViewPositionSpec,
+ test_play_update_view_position,
+ bench_write_play_update_view_position,
+ bench_read_play_update_view_position
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayUpdateViewDistance,
+ PlayUpdateViewDistanceSpec,
+ test_play_update_view_distance,
+ bench_write_play_update_view_distance,
+ bench_read_play_update_view_distance
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayDisplayScoreboard,
+ PlayDisplayScoreboardSpec,
+ test_play_display_scoreboard,
+ bench_write_play_display_scoreboard,
+ bench_read_play_display_scoreboard
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayEntityMetadata,
+ PlayEntityMetadataSpec,
+ test_play_entity_metadata,
+ bench_write_play_entity_metadata,
+ bench_read_play_entity_metadata
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayAttachEntity,
+ PlayAttachEntitySpec,
+ test_play_attach_entity,
+ bench_write_play_attach_entity,
+ bench_read_play_attach_entity
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayEntityVelocity,
+ PlayEntityVelocitySpec,
+ test_play_entity_velocity,
+ bench_write_play_entity_velocity,
+ bench_read_play_entity_velocity
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayEntityEquipment,
+ PlayEntityEquiptmentSpec,
+ test_play_entity_equipment,
+ bench_write_play_entity_equipment,
+ bench_read_play_entity_equipment
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlaySetExperience,
+ PlaySetExperienceSpec,
+ test_play_set_experience,
+ bench_write_play_set_experience,
+ bench_read_play_set_experience
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayUpdatehealth,
+ PlayUpdateHealthSpec,
+ test_play_updatehealth,
+ bench_write_play_updatehealth,
+ bench_read_play_updatehealth
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayScoreboardObjective,
+ PlayScoreboardObjectiveSpec,
+ test_play_scoreboard_objective,
+ bench_write_play_scoreboard_objective,
+ bench_read_play_scoreboard_objective
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlaySetPassengers,
+ PlaySetPassengersSpec,
+ test_play_set_passengers,
+ bench_write_play_set_passengers,
+ bench_read_play_set_passengers
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlaySpawnPosition,
+ PlaySpawnPositionSpec,
+ test_play_spawn_position,
+ bench_write_play_spawn_position,
+ bench_read_play_spawn_position
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayTimeUpdate,
+ PlayTimeUpdateSpec,
+ test_play_time_update,
+ bench_write_play_time_update,
+ bench_read_play_time_update
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayEntitySoundEffect,
+ PlayEntitySoundEffectSpec,
+ test_play_entity_sound_effect,
+ bench_write_play_entity_sound_effect,
+ bench_read_play_entity_sound_effect
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlaySoundEffect,
+ PlaySoundEffectSpec,
+ test_play_sound_effect,
+ bench_write_play_sound_effect,
+ bench_read_play_sound_effect
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayerPlayerListHeaderAndFooter,
+ PlayPlayerListHeaderAndFooterSpec,
+ test_player_player_list_header_and_footer,
+ bench_write_player_player_list_header_and_footer,
+ bench_read_player_player_list_header_and_footer
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayNbtQueryResponse,
+ PlayNbtQueryResponseSpec,
+ test_play_nbt_query_response,
+ bench_write_play_nbt_query_response,
+ bench_read_play_nbt_query_response
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayCollectItem,
+ PlayCollectItemSpec,
+ test_play_collect_item,
+ bench_write_play_collect_item,
+ bench_read_play_collect_item
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayEntityTeleport,
+ PlayEntityTeleportSpec,
+ test_play_entity_teleport,
+ bench_write_play_entity_teleport,
+ bench_read_play_entity_teleport
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayAdvancements,
+ PlayAdvancementsSpec,
+ test_play_advancements,
+ bench_write_play_advancements,
+ bench_read_play_advancements
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayEntityProperties,
+ PlayEntityPropertiesSpec,
+ test_play_entity_properties,
+ bench_write_play_entity_properties,
+ bench_read_play_entity_properties
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayEntityEffect,
+ PlayEntityEffectSpec,
+ test_play_entity_effect,
+ bench_write_play_entity_effect,
+ bench_read_play_entity_effect
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayDeclareRecipes,
+ PlayDeclareRecipesSpec,
+ test_play_declare_recipes,
+ bench_write_play_declare_recipes,
+ bench_read_play_declare_recipes
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayTags,
+ PlayTagsSpec,
+ test_play_tags,
+ bench_write_play_tags,
+ bench_read_play_tags
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayTeleportConfirm,
+ PlayTeleportConfirmSpec,
+ test_play_teleport_confirm,
+ bench_write_play_teleport_confirm,
+ bench_read_play_teleport_confirm
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayQueryBlockNbt,
+ PlayQueryBlockNbtSpec,
+ test_play_query_block_nbt,
+ bench_write_play_query_block_nbt,
+ bench_read_play_query_block_nbt
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayQueryEntityNbt,
+ PlayQueryEntityNbtSpec,
+ test_play_query_entity_nbt,
+ bench_write_play_query_entity_nbt,
+ bench_read_play_query_entity_nbt
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlaySetDifficulty,
+ PlaySetDifficultySpec,
+ test_play_set_difficulty,
+ bench_write_play_set_difficulty,
+ bench_read_play_set_difficulty
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayClientChatMessage,
+ PlayClientChatMessageSpec,
+ test_play_client_chat_message,
+ bench_write_play_client_chat_message,
+ bench_read_play_client_chat_message
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayClientStatus,
+ PlayClientStatusSpec,
+ test_play_client_status,
+ bench_write_play_client_status,
+ bench_read_play_client_status
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayClientSettings,
+ PlayClientSettingsSpec,
+ test_play_client_settings,
+ bench_write_play_client_settings,
+ bench_read_play_client_settings
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayClientTabComplete,
+ PlayClientTabCompleteSpec,
+ test_play_client_tab_complete,
+ bench_write_play_client_tab_complete,
+ bench_read_play_client_tab_complete
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayClientWindowConfirmation,
+ PlayClientWindowConfirmationSpec,
+ test_play_client_window_confirmation,
+ bench_write_play_client_window_confirmation,
+ bench_read_play_client_window_confirmation
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayClickWindowButton,
+ PlayClickWindowButtonSpec,
+ test_play_click_window_button,
+ bench_write_play_click_window_button,
+ bench_read_play_click_window_button
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayClickWindow,
+ PlayClickWindowSpec,
+ test_play_click_window,
+ bench_write_play_click_window,
+ bench_read_play_click_window
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayClientCloseWindow,
+ PlayClientCloseWindowSpec,
+ test_play_client_close_window,
+ bench_write_play_client_close_window,
+ bench_read_play_client_close_window
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayClientPluginMessage,
+ PlayClientPluginMessageSpec,
+ test_play_client_plugin_message,
+ bench_write_play_client_plugin_message,
+ bench_read_play_client_plugin_message
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayEditBook,
+ PlayEditBookSpec,
+ test_play_edit_book,
+ bench_write_play_edit_book,
+ bench_read_play_edit_book
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayInteractEntity,
+ PlayInteractEntitySpec,
+ test_play_interact_entity,
+ bench_write_play_interact_entity,
+ bench_read_play_interact_entity
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayClientKeepAlive,
+ PlayClientKeepAliveSpec,
+ test_play_client_keep_alive,
+ bench_write_play_client_keep_alive,
+ bench_read_play_client_keep_alive
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayLockDifficulty,
+ PlayLockDifficultySpec,
+ test_play_lock_difficulty,
+ bench_write_play_lock_difficulty,
+ bench_read_play_lock_difficulty
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayPlayerPosition,
+ PlayPlayerPositionSpec,
+ test_play_player_position,
+ bench_write_play_player_position,
+ bench_read_play_player_position
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayClientPlayerPositionAndRotation,
+ PlayClientPlayerPositionAndRotationSpec,
+ test_play_client_player_position_and_rotation,
+ bench_write_play_client_player_position_and_rotation,
+ bench_read_play_client_player_position_and_rotation
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayPlayerRotation,
+ PlayPlayerRotationSpec,
+ test_play_player_rotation,
+ bench_write_play_player_rotation,
+ bench_read_play_player_rotation
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayPlayerMovement,
+ PlayPlayerMovementSpec,
+ test_play_player_movement,
+ bench_write_play_player_movement,
+ bench_read_play_player_movement
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayClientVehicleMove,
+ PlayClientVehicleMoveSpec,
+ test_play_client_vehicle_move,
+ bench_write_play_client_vehicle_move,
+ bench_read_play_client_vehicle_move
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlaySteerBoat,
+ PlaySteerBoatSpec,
+ test_play_steer_boat,
+ bench_write_play_steer_boat,
+ bench_read_play_steer_boat
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayPickItem,
+ PlayPickItemSpec,
+ test_play_pick_item,
+ bench_write_play_pick_item,
+ bench_read_play_pick_item
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayCraftRecipeRequest,
+ PlayCraftRecipeRequestSpec,
+ test_play_craft_recipe_request,
+ bench_write_play_craft_recipe_request,
+ bench_read_play_craft_recipe_request
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayClientPlayerAbilities,
+ PlayClientPlayerAbilitiesSpec,
+ test_play_client_player_abilities,
+ bench_write_play_client_player_abilities,
+ bench_read_play_client_player_abilities
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayPlayerDigging,
+ PlayPlayerDiggingSpec,
+ test_play_player_digging,
+ bench_write_play_player_digging,
+ bench_read_play_player_digging
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayEntityAction,
+ PlayEntityActionSpec,
+ test_play_entity_action,
+ bench_write_play_entity_action,
+ bench_read_play_entity_action
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlaySteerVehicle,
+ PlaySteerVehicleSpec,
+ test_play_steer_vehicle,
+ bench_write_play_steer_vehicle,
+ bench_read_play_steer_vehicle
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayNameItem,
+ PlayNameItemSpec,
+ test_play_name_item,
+ bench_write_play_name_item,
+ bench_read_play_name_item
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayResourcePackStatus,
+ PlayResourcePackStatusSpec,
+ test_play_resource_pack_status,
+ bench_write_play_resource_pack_status,
+ bench_read_play_resource_pack_status
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlaySelectTrade,
+ PlaySelectTradeSpec,
+ test_play_select_trade,
+ bench_write_play_select_trade,
+ bench_read_play_select_trade
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlaySetBeaconEffect,
+ PlaySetBeaconEffectSpec,
+ test_play_set_beacon_effect,
+ bench_write_play_set_beacon_effect,
+ bench_read_play_set_beacon_effect
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayClientHeldItemChange,
+ PlayClientHeldItemChangeSpec,
+ test_play_client_held_item_change,
+ bench_write_play_client_held_item_change,
+ bench_read_play_client_held_item_change
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayUpdateCommandBlock,
+ PlayUpdateCommandBlockSpec,
+ test_play_update_command_block,
+ bench_write_play_update_command_block,
+ bench_read_play_update_command_block
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayUpdateCommandBlockMinecart,
+ PlayUpdateCommandBlockMinecartSpec,
+ test_play_update_command_block_minecart,
+ bench_write_play_update_command_block_minecart,
+ bench_read_play_update_command_block_minecart
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayCreativeInventoryAction,
+ PlayCreativeInventoryActionSpec,
+ test_play_creative_inventory_action,
+ bench_write_play_creative_inventory_action,
+ bench_read_play_creative_inventory_action
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayUpdateJigsawBlock,
+ PlayUpdateJigsawBlockSpec,
+ test_play_update_jigsaw_block,
+ bench_write_play_update_jigsaw_block,
+ bench_read_play_update_jigsaw_block
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayUpdateStructureBlock,
+ PlayUpdateStructureBlockSpec,
+ test_play_update_structure_block,
+ bench_write_play_update_structure_block,
+ bench_read_play_update_structure_block
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayUpdateSign,
+ PlayUpdateSignSpec,
+ test_play_update_sign,
+ bench_write_play_update_sign,
+ bench_read_play_update_sign
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayClientAnimation,
+ PlayClientAnimationSpec,
+ test_play_client_animation,
+ bench_write_play_client_animation,
+ bench_read_play_client_animation
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlaySpectate,
+ PlaySpectateSpec,
+ test_play_spectate,
+ bench_write_play_spectate,
+ bench_read_play_spectate
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayBlockPlacement,
+ PlayBlockPlacementSpec,
+ test_play_block_placement,
+ bench_write_play_block_placement,
+ bench_read_play_block_placement
+ );
+
+ packet_test_cases!(
+ Packet578,
+ PlayUseItem,
+ PlayUseItemSpec,
+ test_play_use_item,
+ bench_write_play_use_item,
+ bench_read_play_use_item
+ );
// trust me, this is some cutting edge shit
// I'm definitely not generating code using a unit test
@@ -2952,4 +4019,4 @@ pub mod tests {
parts.join("_")
}
-} \ No newline at end of file
+}