#![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 = "v1_16_5")]
#[derive(Debug, Clone, PartialEq)]
pub struct Success<const V: i32> {
pub uuid: Uuid,
pub username: ByteString,
}
#[cfg(feature = "v1_16_5")]
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()?;
Self {
uuid: v1,
username: v2,
}
})
}
}
#[cfg(feature = "v1_16_5")]
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)?;
Ok(())
}
}
#[cfg(feature = "v1_16_5")]
#[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();
Self {
uuid: v1,
username: v2,
}
}
}
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
#[derive(Debug, Clone, PartialEq)]
pub struct LoginPluginRequest<const V: i32> {
pub message_id: i32,
pub channel: ByteString,
pub data: Bytes,
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
impl<const V: i32> Decode for LoginPluginRequest<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = r.read_string()?;
let v3 = r.read_rest();
Self {
message_id: v1,
channel: v2,
data: v3,
}
})
}
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
impl<const V: i32> Encode for LoginPluginRequest<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).message_id);
w.put_string(&(*self).channel)?;
w.put_slice(&(*self).data);
Ok(())
}
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for LoginPluginRequest<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = g.string();
let v3 = g.bytes();
Self {
message_id: v1,
channel: v2,
data: v3,
}
}
}
}