This also allows now to create custom packets with a custom packet id which is not in the packets.json
27 lines
697 B
Rust
27 lines
697 B
Rust
use bytes::BufMut;
|
|
use pumpkin_data::packet::clientbound::CONFIG_SELECT_KNOWN_PACKS;
|
|
use pumpkin_macros::client_packet;
|
|
|
|
use crate::{bytebuf::ByteBufMut, ClientPacket, KnownPack};
|
|
|
|
#[client_packet(CONFIG_SELECT_KNOWN_PACKS)]
|
|
pub struct CKnownPacks<'a> {
|
|
known_packs: &'a [KnownPack<'a>],
|
|
}
|
|
|
|
impl<'a> CKnownPacks<'a> {
|
|
pub fn new(known_packs: &'a [KnownPack]) -> Self {
|
|
Self { known_packs }
|
|
}
|
|
}
|
|
|
|
impl ClientPacket for CKnownPacks<'_> {
|
|
fn write(&self, bytebuf: &mut impl BufMut) {
|
|
bytebuf.put_list::<KnownPack>(self.known_packs, |p, v| {
|
|
p.put_string(v.namespace);
|
|
p.put_string(v.id);
|
|
p.put_string(v.version);
|
|
});
|
|
}
|
|
}
|