From c10b732510868819a652b76e31278906914d699d Mon Sep 17 00:00:00 2001 From: mat Date: Sat, 7 May 2022 18:26:19 -0500 Subject: improve data generator and add packet --- data-code-generator/packetcodegen.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'data-code-generator/packetcodegen.py') 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)} {{') -- cgit v1.2.3