aboutsummaryrefslogtreecommitdiff
path: root/codegen/lib/code
diff options
context:
space:
mode:
Diffstat (limited to 'codegen/lib/code')
-rw-r--r--codegen/lib/code/data_components.py12
-rw-r--r--codegen/lib/code/entity.py5
-rw-r--r--codegen/lib/code/packet.py14
3 files changed, 24 insertions, 7 deletions
diff --git a/codegen/lib/code/data_components.py b/codegen/lib/code/data_components.py
index d29096d2..bba952e1 100644
--- a/codegen/lib/code/data_components.py
+++ b/codegen/lib/code/data_components.py
@@ -315,6 +315,18 @@ use crate::{
list(python_value.values())[0], target_rust_type
)
return str(python_value)
+ elif target_rust_type == "NbtCompound":
+ # NbtCompound::from_values([
+ # ("id".into(), "minecraft:allay".into()),
+ # ]),
+ t = "NbtCompound::from_values(vec!["
+ for k, v in python_value.items():
+ if isinstance(v, str):
+ t += f'("{k}".into(), "{v}".into()),'
+ else:
+ t += f'("{k}".into(), {python_to_rust_value(v, "FIXME_UNKNOWN_NBT")}),'
+ t = t.rstrip(",") + "])"
+ return t
if isinstance(python_value, dict):
if target_rust_type == "ResourceLocation" and len(python_value) == 1:
diff --git a/codegen/lib/code/entity.py b/codegen/lib/code/entity.py
index eb2677ad..1c2a0d48 100644
--- a/codegen/lib/code/entity.py
+++ b/codegen/lib/code/entity.py
@@ -121,8 +121,9 @@ use thiserror::Error;
use uuid::Uuid;
use super::{
- ArmadilloStateKind, EntityDataItem, EntityDataValue, OptionalUnsignedInt, Pose, Quaternion,
- Rotations, SnifferStateKind, VillagerData,
+ ArmadilloStateKind, CopperGolemStateKind, EntityDataItem, EntityDataValue, OptionalUnsignedInt,
+ Pose, Quaternion, ResolvableProfile, Rotations, SnifferStateKind, VillagerData,
+ WeatheringCopperStateKind,
};
use crate::particle::Particle;
diff --git a/codegen/lib/code/packet.py b/codegen/lib/code/packet.py
index 994e21e5..1337ac2e 100644
--- a/codegen/lib/code/packet.py
+++ b/codegen/lib/code/packet.py
@@ -20,8 +20,8 @@ PACKETS_DIR = "../azalea-protocol/src/packets"
def generate_packet(packets_report, packet_name, direction, state):
- mojmap_state = AZALEA_TO_MOJMAP_STATE_NAME_MAPPING.get(state, state)
- _packet_report = packets_report[mojmap_state][direction]["minecraft:" + packet_name]
+ # mojmap_state = AZALEA_TO_MOJMAP_STATE_NAME_MAPPING.get(state, state)
+ # _packet_report = packets_report[mojmap_state][direction]["minecraft:" + packet_name]
code = []
@@ -46,7 +46,11 @@ def generate_packet(packets_report, packet_name, direction, state):
def get_packet_module_name(packet_name: str, direction: str):
- return f"{direction[0]}_{packet_name}"
+ return f"{direction[0]}_{get_packet_partial_module_name(packet_name)}"
+
+
+def get_packet_partial_module_name(packet_name: str):
+ return packet_name.replace("/", "_")
def set_packets(packets_report):
@@ -75,14 +79,14 @@ def set_packets(packets_report):
code.append(f"declare_state_packets!({to_camel_case(state)}Packet,")
code.append(" Clientbound => [")
for packet_id, packet_name in enumerate(clientbound_packets):
- code.append(f" {packet_name},")
+ code.append(f" {get_packet_partial_module_name(packet_name)},")
expected_packet_module_names.add(
get_packet_module_name(packet_name, "clientbound")
)
code.append(" ],")
code.append(" Serverbound => [")
for packet_id, packet_name in enumerate(serverbound_packets):
- code.append(f" {packet_name},")
+ code.append(f" {get_packet_partial_module_name(packet_name)},")
expected_packet_module_names.add(
get_packet_module_name(packet_name, "serverbound")
)