From 9c0b6f6631f861cb1582c6bba41d2931ee26bf16 Mon Sep 17 00:00:00 2001 From: mat Date: Thu, 16 Jun 2022 20:59:19 -0500 Subject: [PATCH] 22w24a & update packets when they're modified --- README.md | 2 +- azalea-protocol/src/packets/mod.rs | 2 +- codegen/lib/download.py | 2 +- codegen/migrate.py | 24 ++++++++++++++++-------- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index e57b4728..4d564270 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ A Rust crate for creating Minecraft bots.

-*Currently supported Minecraft version: `1.19`.* +*Currently supported Minecraft version: `22w24a`.* I named this Azalea because it sounds like a cool word and this is a cool library. This project was heavily inspired by PrismarineJS. diff --git a/azalea-protocol/src/packets/mod.rs b/azalea-protocol/src/packets/mod.rs index 1cc79b79..8425b0e9 100755 --- a/azalea-protocol/src/packets/mod.rs +++ b/azalea-protocol/src/packets/mod.rs @@ -12,7 +12,7 @@ use crate::{ use num_derive::FromPrimitive; use num_traits::FromPrimitive; -pub const PROTOCOL_VERSION: u32 = 759; +pub const PROTOCOL_VERSION: u32 = 1073741916; #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, FromPrimitive)] pub enum ConnectionProtocol { diff --git a/codegen/lib/download.py b/codegen/lib/download.py index 7d14a3a3..58074634 100644 --- a/codegen/lib/download.py +++ b/codegen/lib/download.py @@ -23,7 +23,7 @@ def get_version_manifest(): print( f'\033[92mDownloading version manifest...\033[m') version_manifest_data = requests.get( - 'https://launchermeta.mojang.com/mc/game/version_manifest.json').json() + 'https://piston-meta.mojang.com/mc/game/version_manifest.json').json() with open(f'downloads/version_manifest.json', 'w') as f: json.dump(version_manifest_data, f) else: diff --git a/codegen/migrate.py b/codegen/migrate.py index 98b701bf..95a6ac4d 100644 --- a/codegen/migrate.py +++ b/codegen/migrate.py @@ -19,18 +19,24 @@ new_packet_list = list(new_burger_data[0]['packets']['packet'].values()) old_packets: dict[PacketIdentifier, str] = {} +old_packets_data: dict[PacketIdentifier, dict] = {} new_packets: dict[PacketIdentifier, str] = {} +new_packets_data: dict[PacketIdentifier, dict] = {} for packet in old_packet_list: assert packet['class'].endswith('.class') packet_name = old_mappings.get_class(packet['class'][:-6]) - old_packets[PacketIdentifier( - packet['id'], packet['direction'].lower(), fix_state(packet['state']))] = packet_name + packet_ident = PacketIdentifier( + packet['id'], packet['direction'].lower(), fix_state(packet['state'])) + old_packets[packet_ident] = packet_name + old_packets_data[packet_ident] = packet for packet in new_packet_list: assert packet['class'].endswith('.class') packet_name = new_mappings.get_class(packet['class'][:-6]) - new_packets[PacketIdentifier( - packet['id'], packet['direction'].lower(), fix_state(packet['state']))] = packet_name + packet_ident = PacketIdentifier( + packet['id'], packet['direction'].lower(), fix_state(packet['state'])) + new_packets[packet_ident] = packet_name + new_packets_data[packet_ident] = packet # find removed packets removed_packets: list[PacketIdentifier] = [] @@ -63,13 +69,15 @@ for (direction, state), packets in group_packets(list(changed_packets.keys())).i print() -# find added packets -added_packets: list[PacketIdentifier] = [] +# find added/changed packets +added_or_changed_packets: list[PacketIdentifier] = [] for packet, packet_name in new_packets.items(): if packet_name not in old_packets.values(): - added_packets.append(packet) + added_or_changed_packets.append(packet) print('Added packet:', packet, packet_name) -for packet in added_packets: + if new_packets_data[packet].get('instructions') != old_packets_data[packet].get('instructions'): + print('hmm') +for packet in added_or_changed_packets: lib.code.packet.generate_packet( new_burger_data[0]['packets']['packet'], new_mappings, packet.packet_id, packet.direction, packet.state)