aboutsummaryrefslogtreecommitdiff
path: root/codegen/lib/code/packet.py
diff options
context:
space:
mode:
Diffstat (limited to 'codegen/lib/code/packet.py')
-rw-r--r--codegen/lib/code/packet.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/codegen/lib/code/packet.py b/codegen/lib/code/packet.py
index 58cf8c38..36e0ba0c 100644
--- a/codegen/lib/code/packet.py
+++ b/codegen/lib/code/packet.py
@@ -128,8 +128,7 @@ def set_packets(packet_ids: list[int], packet_class_names: list[str], direction:
required_modules = []
- # set to true by default to ignore the `pub mod` lines since we add these later
- ignore_lines = True
+ ignore_lines = False
for line in mod_rs:
if line.strip() == 'Serverbound => {':
@@ -157,13 +156,15 @@ def set_packets(packet_ids: list[int], packet_class_names: list[str], direction:
continue
elif line.strip() in ('}', '},'):
ignore_lines = False
+ elif line.strip().startswith('pub mod '):
+ continue
if not ignore_lines:
new_mod_rs.append(line)
# 0x00: clientbound_status_response_packet::ClientboundStatusResponsePacket,
if line.strip().startswith('0x'):
required_modules.append(
- line.strip().split(':')[1].split('::')[0])
+ line.strip().split(':')[1].split('::')[0].strip())
for i, required_module in enumerate(required_modules):
if required_module not in mod_rs:
@@ -232,7 +233,13 @@ def remove_packet_ids(removing_packet_ids: list[int], direction: str, state: str
new_packet_class_names = []
for packet_id, packet_class_name in zip(existing_packet_ids, existing_packet_class_names):
- if packet_id not in removing_packet_ids:
+ if packet_id in removing_packet_ids:
+ try:
+ os.remove(
+ f'../azalea-protocol/src/packets/{state}/{packet_class_name}.rs')
+ except:
+ pass
+ else:
new_packet_ids.append(packet_id)
new_packet_class_names.append(packet_class_name)