azalea_registry/
data.rs

1use azalea_buf::AzBuf;
2
3/// A registry which has its values decided by the server in the
4/// `ClientboundRegistryData` packet.
5///
6/// These can be resolved into their actual values with
7/// `ResolvableDataRegistry` from azalea-core.
8pub trait DataRegistry {
9    const NAME: &'static str;
10
11    fn protocol_id(&self) -> u32;
12}
13
14#[derive(Debug, Clone, Copy, AzBuf, PartialEq, Eq, Hash)]
15pub struct Enchantment {
16    #[var]
17    id: u32,
18}
19impl DataRegistry for Enchantment {
20    const NAME: &'static str = "enchantment";
21    fn protocol_id(&self) -> u32 {
22        self.id
23    }
24}
25
26#[derive(Debug, Clone, Copy, AzBuf, PartialEq, Eq, Hash)]
27pub struct DimensionType {
28    #[var]
29    id: u32,
30}
31impl DimensionType {
32    pub fn new_raw(id: u32) -> Self {
33        Self { id }
34    }
35}
36impl DataRegistry for DimensionType {
37    const NAME: &'static str = "dimension_type";
38    fn protocol_id(&self) -> u32 {
39        self.id
40    }
41}