Skip to main content

azalea_core/
attribute_modifier_operation.rs

1use std::str::FromStr;
2
3use azalea_buf::AzBuf;
4use azalea_codec::Codec;
5
6#[derive(AzBuf, Clone, Copy, Debug, PartialEq, Codec)]
7#[codec(default_snake_case_key)]
8pub enum AttributeModifierOperation {
9    AddValue,
10    AddMultipliedBase,
11    AddMultipliedTotal,
12}
13
14impl FromStr for AttributeModifierOperation {
15    type Err = ();
16
17    fn from_str(s: &str) -> Result<Self, Self::Err> {
18        let value: AttributeModifierOperation = match s {
19            "add_value" => Self::AddValue,
20            "add_multiplied_base" => Self::AddMultipliedBase,
21            "add_multiplied_total" => Self::AddMultipliedTotal,
22            _ => return Err(()),
23        };
24        Ok(value)
25    }
26}