1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
use std::str::FromStr;
use azalea_buf::AzBuf;
use simdnbt::{FromNbtTag, borrow::NbtTag};
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
#[derive(AzBuf, Clone, Copy, Debug, PartialEq)]
#[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
pub enum AttributeModifierOperation {
AddValue,
AddMultipliedBase,
AddMultipliedTotal,
}
impl FromStr for AttributeModifierOperation {
type Err = ();
fn from_str(s: &str) -> Result<Self, Self::Err> {
let value: AttributeModifierOperation = match s {
"add_value" => Self::AddValue,
"add_multiplied_base" => Self::AddMultipliedBase,
"add_multiplied_total" => Self::AddMultipliedTotal,
_ => return Err(()),
};
Ok(value)
}
}
impl FromNbtTag for AttributeModifierOperation {
fn from_nbt_tag(tag: NbtTag) -> Option<Self> {
let v = tag.string()?;
Self::from_str(&v.to_str()).ok()
}
}
|