aboutsummaryrefslogtreecommitdiff
path: root/data-code-generator/packetcodegen.py
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2022-05-07 18:26:19 -0500
committermat <github@matdoes.dev>2022-05-07 18:26:19 -0500
commitc10b732510868819a652b76e31278906914d699d (patch)
tree3c1039ec3d200bc16ead375bc0f418194ca68d19 /data-code-generator/packetcodegen.py
parentaa3ba64aa45abcafb6aa9c1981730d3270a3b0a5 (diff)
downloadazalea-drasl-c10b732510868819a652b76e31278906914d699d.tar.xz
improve data generator and add packet
Diffstat (limited to 'data-code-generator/packetcodegen.py')
-rw-r--r--data-code-generator/packetcodegen.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/data-code-generator/packetcodegen.py b/data-code-generator/packetcodegen.py
index 4c59b72b..12855d08 100644
--- a/data-code-generator/packetcodegen.py
+++ b/data-code-generator/packetcodegen.py
@@ -70,8 +70,7 @@ def write_packet_file(state, packet_name_snake_case, code):
f.write(code)
-def generate(burger_packets, mappings: Mappings):
- packet_ids = [75]
+def generate(burger_packets, mappings: Mappings, packet_ids):
for packet in burger_packets.values():
if packet['id'] not in packet_ids:
continue
@@ -79,6 +78,10 @@ def generate(burger_packets, mappings: Mappings):
direction = packet['direction'].lower() # serverbound or clientbound
state = {'PLAY': 'game'}.get(packet['state'], packet['state'].lower())
+ # TODO: have something better to control this
+ if state != 'game' or direction != 'clientbound':
+ continue
+
generated_packet_code = []
uses = set()
generated_packet_code.append(
@@ -86,7 +89,8 @@ def generate(burger_packets, mappings: Mappings):
uses.add(f'packet_macros::{to_camel_case(state)}Packet')
obfuscated_class_name = packet['class'].split('.')[0]
- class_name = mappings.get_class(obfuscated_class_name).split('.')[-1]
+ class_name = mappings.get_class(
+ obfuscated_class_name).split('.')[-1].split('$')[0]
generated_packet_code.append(
f'pub struct {to_camel_case(class_name)} {{')