aboutsummaryrefslogtreecommitdiff
path: root/codegen
diff options
context:
space:
mode:
authormat <git@matdoes.dev>2025-11-13 12:34:47 +0930
committermat <git@matdoes.dev>2025-11-13 07:04:52 +0400
commitfbaae39cdf9c5a7a34005a51a37b85f7cdd5ea00 (patch)
tree3126fb34a4e0ac979a1103a8227a2b9a136c1553 /codegen
parenta4312599f7c04709a92b7be238dcf577bafbb14f (diff)
downloadazalea-drasl-fbaae39cdf9c5a7a34005a51a37b85f7cdd5ea00.tar.xz
rename ResourceLocation to Identifier ahead of mojmap changes
Diffstat (limited to 'codegen')
-rw-r--r--codegen/lib/code/data_components.py12
-rw-r--r--codegen/lib/code/utils.py4
-rw-r--r--codegen/lib/extract.py10
3 files changed, 13 insertions, 13 deletions
diff --git a/codegen/lib/code/data_components.py b/codegen/lib/code/data_components.py
index 89796a91..57e30172 100644
--- a/codegen/lib/code/data_components.py
+++ b/codegen/lib/code/data_components.py
@@ -220,7 +220,7 @@ use crate::{
"probability": "f32",
}
enum_and_struct_fields["ConsumeEffect::RemoveEffects"] = {
- "effects": "HolderSet<MobEffect, ResourceLocation>",
+ "effects": "HolderSet<MobEffect, Identifier>",
}
enum_and_struct_fields["ConsumeEffect::ClearAllEffects"] = {}
enum_and_struct_fields["ConsumeEffect::TeleportRandomly"] = {
@@ -342,7 +342,7 @@ use crate::{
return t
if isinstance(python_value, dict):
- if target_rust_type == "ResourceLocation" and len(python_value) == 1:
+ if target_rust_type == "Identifier" and len(python_value) == 1:
return python_to_rust_value(
list(python_value.values())[0], target_rust_type
)
@@ -401,8 +401,8 @@ use crate::{
return str(python_value).lower()
if isinstance(python_value, str):
fields_for_rust_type = enum_and_struct_fields.get(target_rust_type, [])
- if "Referenced(ResourceLocation)" in fields_for_rust_type:
- return f"{target_rust_type}::Referenced({python_to_rust_value(python_value, 'ResourceLocation')})"
+ 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 target_rust_type.startswith("HolderSet<"):
@@ -415,8 +415,8 @@ use crate::{
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 == "ResourceLocation":
- # convert minecraft:air into ResourceLocation::from_static("minecraft:air")
+ elif target_rust_type == "Identifier":
+ # convert minecraft:air into Identifier::from_static("minecraft:air")
return f'"{python_value}".into()'
else:
# enum variant
diff --git a/codegen/lib/code/utils.py b/codegen/lib/code/utils.py
index b8970628..bbb8f647 100644
--- a/codegen/lib/code/utils.py
+++ b/codegen/lib/code/utils.py
@@ -57,8 +57,8 @@ def burger_type_to_rust_type(
field_type_rs = "FormattedText"
uses.add("azalea_chat::FormattedText")
elif burger_type == "identifier":
- field_type_rs = "ResourceLocation"
- uses.add("azalea_core::resource_location::ResourceLocation")
+ field_type_rs = "Identifier"
+ uses.add("azalea_core::resource_location::Identifier")
elif burger_type == "uuid":
field_type_rs = "Uuid"
uses.add("uuid::Uuid")
diff --git a/codegen/lib/extract.py b/codegen/lib/extract.py
index 357059f6..b575b697 100644
--- a/codegen/lib/extract.py
+++ b/codegen/lib/extract.py
@@ -254,16 +254,16 @@ def get_packet_list(version_id: str):
packet_list = []
for state, state_value in packets_report.items():
for direction, direction_value in state_value.items():
- for packet_resourcelocation, packet_value in direction_value.items():
- assert packet_resourcelocation.startswith("minecraft:")
- packet_resourcelocation = upper_first_letter(
- to_camel_case(packet_resourcelocation[len("minecraft:") :])
+ for packet_identifier, packet_value in direction_value.items():
+ assert packet_identifier.startswith("minecraft:")
+ packet_identifier = upper_first_letter(
+ to_camel_case(packet_identifier[len("minecraft:") :])
)
packet_list.append(
{
"state": state,
"direction": direction,
- "name": packet_resourcelocation,
+ "name": packet_identifier,
"id": packet_value["protocol_id"],
}
)