aboutsummaryrefslogtreecommitdiff
path: root/codegen/lib
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 /codegen/lib
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 'codegen/lib')
-rw-r--r--codegen/lib/code/data_components.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/codegen/lib/code/data_components.py b/codegen/lib/code/data_components.py
index b7e94c28..d4c13118 100644
--- a/codegen/lib/code/data_components.py
+++ b/codegen/lib/code/data_components.py
@@ -180,6 +180,7 @@ def update_default_variants(version_id: str):
use std::collections::HashMap;
use azalea_chat::translatable_component::TranslatableComponent;
+use azalea_core::attribute_modifier_operation::AttributeModifierOperation;
use azalea_registry::{
Attribute, Block, DataRegistry, EntityKind, HolderSet, Item, MobEffect, SoundEvent,
};
@@ -385,9 +386,9 @@ use crate::{
# create a struct based on the defaults
t = f"{target_rust_type} {{"
for k, v in python_value.items():
- if k == 'type':
+ if k == "type":
# azalea's convention is to use "kind" instead of "type"
- k = 'kind'
+ k = "kind"
# get the type of the fields
inner_type = enum_and_struct_fields.get(target_rust_type, {}).get(
@@ -417,17 +418,19 @@ use crate::{
[python_value], f"Vec<{holderset_type}>"
)
return f"HolderSet::Direct {{ contents: {main_vec} }}"
- elif target_rust_type.startswith("azalea_registry::Holder<") or target_rust_type.startswith("Holder<"):
+ elif target_rust_type.startswith(
+ "azalea_registry::Holder<"
+ ) or target_rust_type.startswith("Holder<"):
holder_type = target_rust_type.split("<", 1)[1].split(",", 1)[0]
inner_type = python_to_rust_value(python_value, holder_type)
return f"azalea_registry::Holder::Reference({inner_type})"
elif target_rust_type == "Identifier":
# convert minecraft:air into Identifier::from_static("minecraft:air")
return f'"{python_value}".into()'
- elif target_rust_type == 'DamageType':
+ elif target_rust_type == "DamageType":
# TODO: this is intentionally incorrect, see the comment in
# azalea-registry/src/data.rs to see how to fix this properly
- return 'DamageType::Registry(azalea_registry::DamageKind::new_raw(0))'
+ return "DamageType::Registry(azalea_registry::DamageKind::new_raw(0))"
else:
# enum variant
return f"{target_rust_type}::{lib.utils.to_camel_case(python_value.split(':')[-1])}"