From 26d619c9a329087a23d6577ee74bd764f50cd773 Mon Sep 17 00:00:00 2001 From: mat <27899617+mat-1@users.noreply.github.com> Date: Tue, 9 Dec 2025 13:29:59 -0600 Subject: Enchantments (#286) * start implementing enchants * store parsed registries * more work on enchants * implement deserializer for some entity effects * mostly working definitions for enchants * fix tests * detect equipment changes * fix errors * update changelog * fix some imports * remove outdated todo * add basic test for enchants applying attributes * use git simdnbt --- azalea-core/src/attribute_modifier_operation.rs | 33 +++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 azalea-core/src/attribute_modifier_operation.rs (limited to 'azalea-core/src/attribute_modifier_operation.rs') diff --git a/azalea-core/src/attribute_modifier_operation.rs b/azalea-core/src/attribute_modifier_operation.rs new file mode 100644 index 00000000..ff92a44a --- /dev/null +++ b/azalea-core/src/attribute_modifier_operation.rs @@ -0,0 +1,33 @@ +use std::str::FromStr; + +use azalea_buf::AzBuf; +use serde::Serialize; +use simdnbt::{FromNbtTag, borrow::NbtTag}; + +#[derive(Clone, Copy, PartialEq, AzBuf, Debug, Serialize)] +#[serde(rename_all = "snake_case")] +pub enum AttributeModifierOperation { + AddValue, + AddMultipliedBase, + AddMultipliedTotal, +} + +impl FromStr for AttributeModifierOperation { + type Err = (); + + fn from_str(s: &str) -> Result { + 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 { + let v = tag.string()?; + Self::from_str(&v.to_str()).ok() + } +} -- cgit v1.2.3