mirror of
https://github.com/mat-1/azalea.git
synced 2025-08-02 14:26:04 +00:00
22w24a & update packets when they're modified
This commit is contained in:
parent
70cc7dfbed
commit
9c0b6f6631
4 changed files with 19 additions and 11 deletions
|
@ -7,7 +7,7 @@ A Rust crate for creating Minecraft bots.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<!-- The line below is automatically read and updated by the migrate script, so don't change it manually. -->
|
<!-- The line below is automatically read and updated by the migrate script, so don't change it manually. -->
|
||||||
*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.
|
I named this Azalea because it sounds like a cool word and this is a cool library. This project was heavily inspired by PrismarineJS.
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ use crate::{
|
||||||
use num_derive::FromPrimitive;
|
use num_derive::FromPrimitive;
|
||||||
use num_traits::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)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, FromPrimitive)]
|
||||||
pub enum ConnectionProtocol {
|
pub enum ConnectionProtocol {
|
||||||
|
|
|
@ -23,7 +23,7 @@ def get_version_manifest():
|
||||||
print(
|
print(
|
||||||
f'\033[92mDownloading version manifest...\033[m')
|
f'\033[92mDownloading version manifest...\033[m')
|
||||||
version_manifest_data = requests.get(
|
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:
|
with open(f'downloads/version_manifest.json', 'w') as f:
|
||||||
json.dump(version_manifest_data, f)
|
json.dump(version_manifest_data, f)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -19,18 +19,24 @@ new_packet_list = list(new_burger_data[0]['packets']['packet'].values())
|
||||||
|
|
||||||
|
|
||||||
old_packets: dict[PacketIdentifier, str] = {}
|
old_packets: dict[PacketIdentifier, str] = {}
|
||||||
|
old_packets_data: dict[PacketIdentifier, dict] = {}
|
||||||
new_packets: dict[PacketIdentifier, str] = {}
|
new_packets: dict[PacketIdentifier, str] = {}
|
||||||
|
new_packets_data: dict[PacketIdentifier, dict] = {}
|
||||||
|
|
||||||
for packet in old_packet_list:
|
for packet in old_packet_list:
|
||||||
assert packet['class'].endswith('.class')
|
assert packet['class'].endswith('.class')
|
||||||
packet_name = old_mappings.get_class(packet['class'][:-6])
|
packet_name = old_mappings.get_class(packet['class'][:-6])
|
||||||
old_packets[PacketIdentifier(
|
packet_ident = PacketIdentifier(
|
||||||
packet['id'], packet['direction'].lower(), fix_state(packet['state']))] = packet_name
|
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:
|
for packet in new_packet_list:
|
||||||
assert packet['class'].endswith('.class')
|
assert packet['class'].endswith('.class')
|
||||||
packet_name = new_mappings.get_class(packet['class'][:-6])
|
packet_name = new_mappings.get_class(packet['class'][:-6])
|
||||||
new_packets[PacketIdentifier(
|
packet_ident = PacketIdentifier(
|
||||||
packet['id'], packet['direction'].lower(), fix_state(packet['state']))] = packet_name
|
packet['id'], packet['direction'].lower(), fix_state(packet['state']))
|
||||||
|
new_packets[packet_ident] = packet_name
|
||||||
|
new_packets_data[packet_ident] = packet
|
||||||
|
|
||||||
# find removed packets
|
# find removed packets
|
||||||
removed_packets: list[PacketIdentifier] = []
|
removed_packets: list[PacketIdentifier] = []
|
||||||
|
@ -63,13 +69,15 @@ for (direction, state), packets in group_packets(list(changed_packets.keys())).i
|
||||||
|
|
||||||
print()
|
print()
|
||||||
|
|
||||||
# find added packets
|
# find added/changed packets
|
||||||
added_packets: list[PacketIdentifier] = []
|
added_or_changed_packets: list[PacketIdentifier] = []
|
||||||
for packet, packet_name in new_packets.items():
|
for packet, packet_name in new_packets.items():
|
||||||
if packet_name not in old_packets.values():
|
if packet_name not in old_packets.values():
|
||||||
added_packets.append(packet)
|
added_or_changed_packets.append(packet)
|
||||||
print('Added packet:', packet, packet_name)
|
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(
|
lib.code.packet.generate_packet(
|
||||||
new_burger_data[0]['packets']['packet'], new_mappings, packet.packet_id, packet.direction, packet.state)
|
new_burger_data[0]['packets']['packet'], new_mappings, packet.packet_id, packet.direction, packet.state)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue