aboutsummaryrefslogtreecommitdiff
path: root/codegen/lib
diff options
context:
space:
mode:
authormat <27899617+mat-1@users.noreply.github.com>2025-12-09 11:23:45 -0600
committerGitHub <noreply@github.com>2025-12-09 11:23:45 -0600
commit84cd261118c9d1e3145d4d1751c0d22098cd8cd8 (patch)
treef9beeb5697a4b895423ef24989044fca8afc5594 /codegen/lib
parent676707aab320339b4c7406ee4f494b530f44e926 (diff)
downloadazalea-drasl-84cd261118c9d1e3145d4d1751c0d22098cd8cd8.tar.xz
1.21.11 (#273)
* run codegen for 25w44a * 25w44a * 25w46a * rename ResourceLocation to Identifier per mojmap changes * update changelog * 1.21.11-pre1 * 1.21.11-pre2 * 1.21.11-pre3 * add AttackRange fields from pre4 * 1.21.11-rc3 * 1.21.11
Diffstat (limited to 'codegen/lib')
-rw-r--r--codegen/lib/code/data_components.py14
-rw-r--r--codegen/lib/code/entity.py2
-rw-r--r--codegen/lib/download.py5
3 files changed, 17 insertions, 4 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 {
diff --git a/codegen/lib/download.py b/codegen/lib/download.py
index de6e2f2d..fa963188 100644
--- a/codegen/lib/download.py
+++ b/codegen/lib/download.py
@@ -137,7 +137,10 @@ def get_latest_fabric_api_version():
maven_metadata_xml = json.load(f)
tree = ET.ElementTree(ET.fromstring(maven_metadata_xml))
- return tree.find(".//latest").text
+ name = tree.find(".//latest").text
+ if name.endswith('_unobfuscated'):
+ name = name[:-len('_unobfuscated')]
+ return name
def get_latest_fabric_kotlin_version():