aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormat <git@matdoes.dev>2025-12-11 18:04:14 -1400
committermat <git@matdoes.dev>2025-12-11 18:04:14 -1400
commit918214e8ba4eae65daf5d2da17aa0022f2ae5212 (patch)
tree6e3a689960c478f3a398cb0e6bc988aff22e2815
parente2c7132dfb6a513b28a061bacb7a3cd9386f9706 (diff)
downloadazalea-drasl-918214e8ba4eae65daf5d2da17aa0022f2ae5212.tar.xz
fix data component codegen
-rw-r--r--azalea-inventory/src/default_components/generated.rs29
-rw-r--r--codegen/lib/code/data_components.py12
-rw-r--r--codegen/lib/code/entity.py2
3 files changed, 23 insertions, 20 deletions
diff --git a/azalea-inventory/src/default_components/generated.rs b/azalea-inventory/src/default_components/generated.rs
index 290cb431..97885a7c 100644
--- a/azalea-inventory/src/default_components/generated.rs
+++ b/azalea-inventory/src/default_components/generated.rs
@@ -10,7 +10,6 @@ use azalea_core::attribute_modifier_operation::AttributeModifierOperation;
use azalea_registry::{
DataRegistry, HolderSet,
builtin::{Attribute, BlockKind, EntityKind, ItemKind, MobEffect, SoundEvent},
- data,
};
use simdnbt::owned::NbtCompound;
@@ -2989,33 +2988,33 @@ impl DefaultableComponent for Bees {
impl DefaultableComponent for BlockState {
fn default_for_item(item: ItemKind) -> Option<Self> {
let value = match item {
- ItemKind::BeeNest => HashMap::from_iter([("honey_level".to_string(), "0".to_string())]),
- ItemKind::Beehive => HashMap::from_iter([("honey_level".to_string(), "0".to_string())]),
+ ItemKind::BeeNest => HashMap::from_iter([("honey_level".to_owned(), "0".to_owned())]),
+ ItemKind::Beehive => HashMap::from_iter([("honey_level".to_owned(), "0".to_owned())]),
ItemKind::CopperGolemStatue => {
- HashMap::from_iter([("copper_golem_pose".to_string(), "standing".to_string())])
+ HashMap::from_iter([("copper_golem_pose".to_owned(), "standing".to_owned())])
}
ItemKind::ExposedCopperGolemStatue => {
- HashMap::from_iter([("copper_golem_pose".to_string(), "standing".to_string())])
+ HashMap::from_iter([("copper_golem_pose".to_owned(), "standing".to_owned())])
}
- ItemKind::Light => HashMap::from_iter([("level".to_string(), "15".to_string())]),
+ ItemKind::Light => HashMap::from_iter([("level".to_owned(), "15".to_owned())]),
ItemKind::OxidizedCopperGolemStatue => {
- HashMap::from_iter([("copper_golem_pose".to_string(), "standing".to_string())])
+ HashMap::from_iter([("copper_golem_pose".to_owned(), "standing".to_owned())])
}
- ItemKind::TestBlock => HashMap::from_iter([("mode".to_string(), "start".to_string())]),
+ ItemKind::TestBlock => HashMap::from_iter([("mode".to_owned(), "start".to_owned())]),
ItemKind::WaxedCopperGolemStatue => {
- HashMap::from_iter([("copper_golem_pose".to_string(), "standing".to_string())])
+ HashMap::from_iter([("copper_golem_pose".to_owned(), "standing".to_owned())])
}
ItemKind::WaxedExposedCopperGolemStatue => {
- HashMap::from_iter([("copper_golem_pose".to_string(), "standing".to_string())])
+ HashMap::from_iter([("copper_golem_pose".to_owned(), "standing".to_owned())])
}
ItemKind::WaxedOxidizedCopperGolemStatue => {
- HashMap::from_iter([("copper_golem_pose".to_string(), "standing".to_string())])
+ HashMap::from_iter([("copper_golem_pose".to_owned(), "standing".to_owned())])
}
ItemKind::WaxedWeatheredCopperGolemStatue => {
- HashMap::from_iter([("copper_golem_pose".to_string(), "standing".to_string())])
+ HashMap::from_iter([("copper_golem_pose".to_owned(), "standing".to_owned())])
}
ItemKind::WeatheredCopperGolemStatue => {
- HashMap::from_iter([("copper_golem_pose".to_string(), "standing".to_string())])
+ HashMap::from_iter([("copper_golem_pose".to_owned(), "standing".to_owned())])
}
_ => return None,
};
@@ -6281,7 +6280,9 @@ impl DefaultableComponent for Fireworks {
impl DefaultableComponent for Instrument {
fn default_for_item(item: ItemKind) -> Option<Self> {
let value = match item {
- ItemKind::GoatHorn => Instrument::Registry(data::Instrument::new_raw(0)),
+ ItemKind::GoatHorn => {
+ Instrument::Registry(azalea_registry::data::Instrument::new_raw(0))
+ }
_ => return None,
};
Some(value)
diff --git a/codegen/lib/code/data_components.py b/codegen/lib/code/data_components.py
index 38060662..abbe2eb6 100644
--- a/codegen/lib/code/data_components.py
+++ b/codegen/lib/code/data_components.py
@@ -182,7 +182,8 @@ use std::collections::HashMap;
use azalea_chat::translatable_component::TranslatableComponent;
use azalea_core::attribute_modifier_operation::AttributeModifierOperation;
use azalea_registry::{
- Attribute, BlockKind, DataRegistry, EntityKind, HolderSet, ItemKind, MobEffect, SoundEvent,
+ DataRegistry, HolderSet,
+ builtin::{Attribute, BlockKind, EntityKind, ItemKind, MobEffect, SoundEvent},
};
use simdnbt::owned::NbtCompound;
@@ -298,14 +299,14 @@ use crate::{
hashmap_key = hashmap_key.strip()
hashmap_value = hashmap_value.strip()
- # HashMap::from_iter([("honey_level".to_string(), "0".to_string())])
+ # HashMap::from_iter([("honey_level".to_owned(), "0".to_owned())])
t = "HashMap::from_iter(["
for k, v in python_value.items():
t += f"({python_to_rust_value(k, hashmap_key)}, {python_to_rust_value(v, hashmap_value)}),"
t = t.rstrip(",") + "])"
return t
elif target_rust_type == "String":
- return f'"{python_value}".to_string()'
+ return f'"{python_value}".to_owned()'
elif target_rust_type == "&str":
if isinstance(python_value, dict):
return python_to_rust_value(
@@ -410,8 +411,9 @@ use crate::{
fields_for_rust_type = enum_and_struct_fields.get(target_rust_type, [])
if "Referenced(Identifier)" in fields_for_rust_type:
return f"{target_rust_type}::Referenced({python_to_rust_value(python_value, 'Identifier')})"
- elif "Registry(registry::Instrument)" in fields_for_rust_type:
- return f"{target_rust_type}::Registry({python_to_rust_value(python_value, 'azalea_registry::Instrument')})"
+ elif "Registry(data::Instrument)" in fields_for_rust_type:
+ # TODO
+ return f"{target_rust_type}::Registry(azalea_registry::data::Instrument::new_raw(0))"
elif target_rust_type.startswith("HolderSet<"):
holderset_type = target_rust_type.split("<", 1)[1].split(",", 1)[0]
main_vec = python_to_rust_value(
diff --git a/codegen/lib/code/entity.py b/codegen/lib/code/entity.py
index 2fc66b0f..02167dfa 100644
--- a/codegen/lib/code/entity.py
+++ b/codegen/lib/code/entity.py
@@ -476,7 +476,7 @@ impl From<EntityDataValue> for UpdateMetadataError {
default = "true" if default else "false"
elif type_name == "String":
string_escaped = default.replace('"', '\\"')
- default = f'"{string_escaped}".to_string()'
+ default = f'"{string_escaped}".to_owned()'
elif type_name == "BlockPos":
default = f"BlockPos::new{default}"
elif type_name == "OptionalBlockPos": # Option<BlockPos>