64 lines
1.7 KiB
Rust
64 lines
1.7 KiB
Rust
use potato_data::{
|
|
identifier::Identifier,
|
|
registry::{
|
|
banner_pattern::BannerPattern, chat_type::ChatType, damage_type::DamageType,
|
|
dimension_type::DimensionType, painting_variant::PaintingVariant,
|
|
trim_material::TrimMaterial, trim_pattern::TrimPattern, wolf_variant::WolfVariant,
|
|
worldgen::biome::Biome,
|
|
},
|
|
};
|
|
use potato_protocol_derive::{Packet, PacketEncodable};
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
use crate::packet_encodable::Nbt;
|
|
|
|
#[derive(Debug, Packet)]
|
|
#[packet(configuration_id = crate::ids::configuration::clientbound::REGISTRY_DATA)]
|
|
pub struct RegistryDataPacket {
|
|
pub registry_id: Identifier,
|
|
pub entries: Vec<RegistryDataEntry>,
|
|
}
|
|
|
|
#[derive(Debug, PacketEncodable)]
|
|
pub struct RegistryDataEntry {
|
|
pub id: Identifier,
|
|
pub data: Option<Nbt<RegistryData>>,
|
|
}
|
|
|
|
#[derive(Debug, Serialize, Deserialize)]
|
|
#[serde(untagged)]
|
|
pub enum RegistryData {
|
|
TrimMaterial(Box<TrimMaterial>),
|
|
TrimPattern(Box<TrimPattern>),
|
|
BannerPattern(Box<BannerPattern>),
|
|
Biome(Box<Biome>),
|
|
ChatType(Box<ChatType>),
|
|
DamageType(Box<DamageType>),
|
|
DimensionType(Box<DimensionType>),
|
|
WolfVariant(Box<WolfVariant>),
|
|
PaintingVariant(Box<PaintingVariant>),
|
|
}
|
|
|
|
macro_rules! impl_from_registry {
|
|
($($variant:ident),*) => {
|
|
$(
|
|
impl From<&$variant> for RegistryData {
|
|
fn from(value: &$variant) -> Self {
|
|
RegistryData::$variant(Box::new(value.clone()))
|
|
}
|
|
}
|
|
)*
|
|
};
|
|
}
|
|
|
|
impl_from_registry!(
|
|
TrimMaterial,
|
|
TrimPattern,
|
|
BannerPattern,
|
|
Biome,
|
|
ChatType,
|
|
DamageType,
|
|
DimensionType,
|
|
WolfVariant,
|
|
PaintingVariant
|
|
);
|