aboutsummaryrefslogtreecommitdiff
path: root/azalea-core/src/attribute_modifier_operation.rs
diff options
context:
space:
mode:
authormat <27899617+mat-1@users.noreply.github.com>2025-12-09 13:29:59 -0600
committerGitHub <noreply@github.com>2025-12-09 13:29:59 -0600
commit26d619c9a329087a23d6577ee74bd764f50cd773 (patch)
tree8020fe902257764a23a445c6ed9987ea4848189d /azalea-core/src/attribute_modifier_operation.rs
parent84cd261118c9d1e3145d4d1751c0d22098cd8cd8 (diff)
downloadazalea-drasl-26d619c9a329087a23d6577ee74bd764f50cd773.tar.xz
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
Diffstat (limited to 'azalea-core/src/attribute_modifier_operation.rs')
-rw-r--r--azalea-core/src/attribute_modifier_operation.rs33
1 files changed, 33 insertions, 0 deletions
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<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()
+ }
+}