aboutsummaryrefslogtreecommitdiff
path: root/codegen/lib/code/entity.py
diff options
context:
space:
mode:
authormat <27899617+mat-1@users.noreply.github.com>2025-12-12 00:56:02 -0600
committerGitHub <noreply@github.com>2025-12-12 00:56:02 -0600
commitf9c25665c203d6377ace62f1e95381d037d8fd9e (patch)
tree8b4131d20fe661d3cc1175ec27f801fe61df41ea /codegen/lib/code/entity.py
parent82ad975242292d5875780b4398b62637674bf50a (diff)
downloadazalea-drasl-f9c25665c203d6377ace62f1e95381d037d8fd9e.tar.xz
Refactor azalea-registry (#294)
* move registries in azalea-registry into separate modules * rename Item and Block to ItemKind and BlockKind * remove 'extra' registries from azalea-registry * hide deprecated items from docs * use DamageKindKey instead of Identifier when parsing registries * store tag entries as a Vec instead of a HashSet * sort tag values by protocol id * update changelog
Diffstat (limited to 'codegen/lib/code/entity.py')
-rw-r--r--codegen/lib/code/entity.py24
1 files changed, 12 insertions, 12 deletions
diff --git a/codegen/lib/code/entity.py b/codegen/lib/code/entity.py
index e9da0404..2fc66b0f 100644
--- a/codegen/lib/code/entity.py
+++ b/codegen/lib/code/entity.py
@@ -114,7 +114,7 @@ use azalea_core::{
position::{BlockPos, Vec3f32},
};
use azalea_inventory::{ItemStack, components};
-use azalea_registry::DataRegistry;
+use azalea_registry::{DataRegistry, builtin::EntityKind};
use bevy_ecs::{bundle::Bundle, component::Component};
use derive_more::{Deref, DerefMut};
use thiserror::Error;
@@ -456,15 +456,15 @@ impl From<EntityDataValue> for UpdateMetadataError {
default = "simdnbt::owned::NbtCompound::default()"
# elif type_name == 'CatVariant':
# # TODO: the default should be Tabby but we don't have a way to get that from here
- # default = 'azalea_registry::CatVariant::new_raw(0)'
+ # default = 'azalea_registry::data::CatVariant::new_raw(0)'
# elif type_name == 'PaintingVariant':
- # default = 'azalea_registry::PaintingVariant::Kebab'
+ # default = 'azalea_registry::data::PaintingVariant::Kebab'
# elif type_name == 'FrogVariant':
- # default = 'azalea_registry::FrogVariant::Temperate'
+ # default = 'azalea_registry::data::FrogVariant::Temperate'
elif type_name.endswith("Variant"):
- default = f"azalea_registry::{type_name}::new_raw(0)"
+ default = f"azalea_registry::data::{type_name}::new_raw(0)"
elif type_name == "VillagerData":
- default = "VillagerData { kind: azalea_registry::VillagerKind::Plains, profession: azalea_registry::VillagerProfession::None, level: 0 }"
+ default = "VillagerData { kind: azalea_registry::builtin::VillagerKind::Plains, profession: azalea_registry::builtin::VillagerProfession::None, level: 0 }"
else:
default = (
f"{type_name}::default()"
@@ -581,7 +581,7 @@ impl From<EntityDataValue> for UpdateMetadataError {
code.append(
"""pub fn apply_metadata(
entity: &mut bevy_ecs::system::EntityCommands,
- entity_kind: azalea_registry::EntityKind,
+ entity_kind: EntityKind,
items: Vec<EntityDataItem>,
) -> Result<(), UpdateMetadataError> {
match entity_kind {"""
@@ -591,7 +591,7 @@ impl From<EntityDataValue> for UpdateMetadataError {
# not actually an entity
continue
struct_name: str = upper_first_letter(to_camel_case(entity_id))
- code.append(f" azalea_registry::EntityKind::{struct_name} => {{")
+ code.append(f" EntityKind::{struct_name} => {{")
code.append(" for d in items {")
code.append(f" {struct_name}::apply_metadata(entity, d)?;")
code.append(" }")
@@ -601,15 +601,15 @@ impl From<EntityDataValue> for UpdateMetadataError {
code.append("}")
code.append("")
- # pub fn apply_default_metadata(entity: &mut bevy_ecs::system::EntityCommands, kind: azalea_registry::EntityKind) {
+ # pub fn apply_default_metadata(entity: &mut bevy_ecs::system::EntityCommands, kind: EntityKind) {
# match kind {
- # azalea_registry::EntityKind::AreaEffectCloud => {
+ # EntityKind::AreaEffectCloud => {
# entity.insert(AreaEffectCloudMetadataBundle::default());
# }
# }
# }
code.append(
- "pub fn apply_default_metadata(entity: &mut bevy_ecs::system::EntityCommands, kind: azalea_registry::EntityKind) {"
+ "pub fn apply_default_metadata(entity: &mut bevy_ecs::system::EntityCommands, kind: EntityKind) {"
)
code.append(" match kind {")
for entity_id in burger_entity_metadata:
@@ -617,7 +617,7 @@ impl From<EntityDataValue> for UpdateMetadataError {
# not actually an entity
continue
struct_name: str = upper_first_letter(to_camel_case(entity_id))
- code.append(f" azalea_registry::EntityKind::{struct_name} => {{")
+ code.append(f" EntityKind::{struct_name} => {{")
code.append(
f" entity.insert({struct_name}MetadataBundle::default());"
)