diff options
Diffstat (limited to 'codegen/lib/code')
| -rw-r--r-- | codegen/lib/code/data_components.py | 14 | ||||
| -rw-r--r-- | codegen/lib/code/entity.py | 2 |
2 files changed, 13 insertions, 3 deletions
diff --git a/codegen/lib/code/data_components.py b/codegen/lib/code/data_components.py index 57e30172..b7e94c28 100644 --- a/codegen/lib/code/data_components.py +++ b/codegen/lib/code/data_components.py @@ -180,7 +180,9 @@ def update_default_variants(version_id: str): use std::collections::HashMap; use azalea_chat::translatable_component::TranslatableComponent; -use azalea_registry::{Attribute, Block, EntityKind, HolderSet, Item, MobEffect, SoundEvent}; +use azalea_registry::{ + Attribute, Block, DataRegistry, EntityKind, HolderSet, Item, MobEffect, SoundEvent, +}; use simdnbt::owned::NbtCompound; use crate::{ @@ -383,6 +385,10 @@ use crate::{ # create a struct based on the defaults t = f"{target_rust_type} {{" for k, v in python_value.items(): + if k == 'type': + # azalea's convention is to use "kind" instead of "type" + k = 'kind' + # get the type of the fields inner_type = enum_and_struct_fields.get(target_rust_type, {}).get( k, "FIXME_UNKNOWN_TYPE" @@ -411,13 +417,17 @@ use crate::{ [python_value], f"Vec<{holderset_type}>" ) return f"HolderSet::Direct {{ contents: {main_vec} }}" - elif target_rust_type.startswith("azalea_registry::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': + # 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))' else: # enum variant return f"{target_rust_type}::{lib.utils.to_camel_case(python_value.split(':')[-1])}" diff --git a/codegen/lib/code/entity.py b/codegen/lib/code/entity.py index 18a7a04b..e9da0404 100644 --- a/codegen/lib/code/entity.py +++ b/codegen/lib/code/entity.py @@ -124,7 +124,7 @@ use super::{ ArmadilloStateKind, CopperGolemStateKind, EntityDataItem, EntityDataValue, OptionalUnsignedInt, Pose, Quaternion, Rotations, SnifferStateKind, VillagerData, WeatheringCopperStateKind, }; -use crate::particle::Particle; +use crate::{HumanoidArm, particle::Particle}; #[derive(Error, Debug)] pub enum UpdateMetadataError { |
