ghast-protocol 0.5.1

Minecraft Java Edition network protocol for the ghast client library: generated per-version packets, framing, compression, encryption, NBT
Documentation
// @generated by ghast-codegen-protocol from PrismarineJS minecraft-data 3.119.0
// (data/pc/26.1/protocol.json + codegen/protocol/delta/776.json + codegen/protocol/delta/777.json). Do not edit; run `cargo run -p ghast-codegen-protocol`.
// minecraft-data is MIT licensed, Copyright (c) 2015 PrismarineJS; see the NOTICE file
// in crates/ghast-protocol/src/generated/.

//! Clientbound packets of the configuration state.

#![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_3")]
/// `post_effects` (clientbound configuration).
#[derive(Debug, Clone, PartialEq)]
pub struct PostEffects<const V: i32> {
    /// `effects`
    pub effects: Vec<ByteString>,
}
#[cfg(feature = "v26_3")]
impl<const V: i32> Decode for PostEffects<V> {
    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
        Ok({
            let v1 = {
                let v2 = {
                    let c = r.read_varint()?;
                    r.check_count(i64::from(c), 1)?
                };
                let mut v3 = Vec::with_capacity(v2.min(crate::codec::PREALLOC_LIMIT));
                for _ in 0..v2 {
                    v3.push(r.read_string()?);
                }
                v3
            };
            Self { effects: v1 }
        })
    }
}
#[cfg(feature = "v26_3")]
impl<const V: i32> Encode for PostEffects<V> {
    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
        w.put_len_varint((*self).effects.len())?;
        for v1 in (*self).effects.iter() {
            w.put_string(&(*v1))?;
        }
        Ok(())
    }
}
#[cfg(feature = "v26_3")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for PostEffects<V> {
    fn generate(g: &mut Gen) -> Self {
        {
            let v1 = {
                let v2 = g.count();
                let mut v3 = Vec::with_capacity(v2.min(crate::codec::PREALLOC_LIMIT));
                for _ in 0..v2 {
                    v3.push(g.string());
                }
                v3
            };
            Self { effects: v1 }
        }
    }
}