#![allow(
unused_imports,
unused_variables,
unused_mut,
unused_parens,
unused_braces,
clippy::all,
clippy::pedantic,
non_camel_case_types,
non_snake_case
)]
use crate::codec::{Decode, DecodeResult, Encode, EncodeResult, McWrite, Reader, decode_exact};
use crate::error::{DecodeError, EncodeError};
use crate::nbt::{AnonNbt, RawNbt};
use crate::packet::{Direction, PacketSet, RawPacket, State};
#[cfg(feature = "testgen")]
use crate::testgen::{Gen, Generate};
use crate::types::{BlockPos, ByteString, Holder, HolderSet, LpVec3, PositionLayout, Uuid};
use bytes::{BufMut, Bytes, BytesMut};
#[cfg(feature = "v26_1")]
#[derive(Debug, Clone, PartialEq)]
pub struct EncryptionBegin<const V: i32> {
pub server_id: ByteString,
pub public_key: Bytes,
pub verify_token: Bytes,
pub should_authenticate: bool,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for EncryptionBegin<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_string()?;
let v2 = r.read_byte_array()?;
let v3 = r.read_byte_array()?;
let v4 = r.read_bool()?;
Self {
server_id: v1,
public_key: v2,
verify_token: v3,
should_authenticate: v4,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for EncryptionBegin<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_string(&(*self).server_id)?;
w.put_byte_array(&(*self).public_key)?;
w.put_byte_array(&(*self).verify_token)?;
w.put_bool((*self).should_authenticate);
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for EncryptionBegin<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.string();
let v2 = g.bytes();
let v3 = g.bytes();
let v4 = g.bool();
Self {
server_id: v1,
public_key: v2,
verify_token: v3,
should_authenticate: v4,
}
}
}
}
#[cfg(feature = "v26_1")]
#[derive(Debug, Clone, PartialEq)]
pub struct SuccessProperties {
pub name: ByteString,
pub value: ByteString,
pub signature: Option<ByteString>,
}
#[cfg(feature = "v26_1")]
#[derive(Debug, Clone, PartialEq)]
pub struct Success<const V: i32> {
pub uuid: Uuid,
pub username: ByteString,
pub properties: Vec<crate::defs::p775::login::clientbound::SuccessProperties>,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for Success<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_uuid()?;
let v2 = r.read_string()?;
let v3 = {
let v4 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 3)?
};
let mut v5 = Vec::with_capacity(v4.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v4 {
v5.push({
let v6 = r.read_string()?;
let v7 = r.read_string()?;
let v8 = if r.read_bool()? {
Some(r.read_string()?)
} else {
None
};
crate::defs::p775::login::clientbound::SuccessProperties {
name: v6,
value: v7,
signature: v8,
}
});
}
v5
};
Self {
uuid: v1,
username: v2,
properties: v3,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for Success<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_uuid(&(*self).uuid);
w.put_string(&(*self).username)?;
w.put_len_varint((*self).properties.len())?;
for v1 in (*self).properties.iter() {
w.put_string(&(*v1).name)?;
w.put_string(&(*v1).value)?;
match &(*v1).signature {
Some(v2) => {
w.put_u8(1);
w.put_string(&(*v2))?;
}
None => w.put_u8(0),
}
}
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for Success<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.uuid();
let v2 = g.string();
let v3 = {
let v4 = g.count();
let mut v5 = Vec::with_capacity(v4.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v4 {
v5.push({
let v6 = g.string();
let v7 = g.string();
let v8 = if g.bool() { Some(g.string()) } else { None };
crate::defs::p775::login::clientbound::SuccessProperties {
name: v6,
value: v7,
signature: v8,
}
});
}
v5
};
Self {
uuid: v1,
username: v2,
properties: v3,
}
}
}
}
#[cfg(feature = "v26_1")]
#[derive(Debug, Clone, PartialEq)]
pub struct CookieRequest<const V: i32> {
pub cookie: ByteString,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for CookieRequest<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_string()?;
Self { cookie: v1 }
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for CookieRequest<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_string(&(*self).cookie)?;
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for CookieRequest<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.string();
Self { cookie: v1 }
}
}
}