aboutsummaryrefslogtreecommitdiff
path: root/codegen/lib/extract.py
diff options
context:
space:
mode:
authormat <27899617+mat-1@users.noreply.github.com>2024-06-13 19:52:05 -0500
committerGitHub <noreply@github.com>2024-06-13 19:52:05 -0500
commitf66d2d476759085601fc398afcac7d8b1940ebf7 (patch)
tree6faf7bb89996eb7c37b2a4dc72c1f08b02a4ef0d /codegen/lib/extract.py
parent38eab50b4fc53f10c3f607935e47b65a8c4f3ef9 (diff)
downloadazalea-drasl-f66d2d476759085601fc398afcac7d8b1940ebf7.tar.xz
1.21 (#145)
* 24w18a (data driven enchantments not implemented yet) * 1.21
Diffstat (limited to 'codegen/lib/extract.py')
-rwxr-xr-xcodegen/lib/extract.py34
1 files changed, 21 insertions, 13 deletions
diff --git a/codegen/lib/extract.py b/codegen/lib/extract.py
index d3bd46d3..da69b753 100755
--- a/codegen/lib/extract.py
+++ b/codegen/lib/extract.py
@@ -1,8 +1,8 @@
# Extracting data from the Minecraft jars
from typing import TYPE_CHECKING
-from lib.download import get_server_jar, get_burger, get_client_jar, get_pixlyzer, get_yarn_data, get_fabric_api_versions, get_fabric_loader_versions
-from lib.utils import get_dir_location
+from lib.download import get_mappings_for_version, get_server_jar, get_burger, get_client_jar, get_pixlyzer, get_yarn_data, get_fabric_api_versions, get_fabric_loader_versions
+from lib.utils import get_dir_location, to_camel_case, upper_first_letter
from zipfile import ZipFile
import subprocess
import requests
@@ -281,14 +281,22 @@ def get_en_us_lang(version_id: str):
# this is very much not ideal.
if TYPE_CHECKING: from codegen.lib.mappings import Mappings
-def get_packet_list(burger_data, mappings: 'Mappings'):
- packet_list = list(burger_data[0]['packets']['packet'].values())
-
- current_packet_id = 0
- for packet in packet_list:
- if packet['id'] == -1:
- packet['id'] = current_packet_id
- print(packet)
- current_packet_id += 1
-
- return packet_list
+def get_packet_list(version_id: str):
+ if version_id != '1.21':
+ return []
+
+ generate_data_from_server_jar(version_id)
+ with open(get_dir_location(f'__cache__/generated-{version_id}/reports/packets.json'), 'r') as f:
+ packets_report = json.load(f)
+ 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:'):]))
+ packet_list.append({
+ 'state': state,
+ 'direction': direction,
+ 'name': packet_resourcelocation,
+ 'id': packet_value['protocol_id']
+ })