From 9c0b6f6631f861cb1582c6bba41d2931ee26bf16 Mon Sep 17 00:00:00 2001 From: mat Date: Thu, 16 Jun 2022 20:59:19 -0500 Subject: 22w24a & update packets when they're modified --- codegen/lib/download.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'codegen/lib/download.py') 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: -- cgit v1.2.3 From 392c553d5688f3d5ad19c4a861c0239c914e3578 Mon Sep 17 00:00:00 2001 From: mat Date: Tue, 21 Jun 2022 19:48:01 -0500 Subject: Force the generator mod to support snapshots --- codegen/lib/download.py | 25 ++++++++++++++++++++++++- codegen/lib/extract.py | 14 ++++++++++++-- 2 files changed, 36 insertions(+), 3 deletions(-) (limited to 'codegen/lib/download.py') diff --git a/codegen/lib/download.py b/codegen/lib/download.py index e9712f8d..db21145c 100644 --- a/codegen/lib/download.py +++ b/codegen/lib/download.py @@ -1,4 +1,5 @@ from lib.utils import get_dir_location +import xml.etree.ElementTree as ET from .mappings import Mappings import requests import json @@ -118,11 +119,33 @@ def get_yarn_data(version_id: str): return version +def get_fabric_api_versions(): + # https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api/maven-metadata.xml + if not os.path.exists(get_dir_location('downloads/fabric_api_versions.json')): + print('\033[92mDownloading Fabric API versions...\033[m') + fabric_api_versions_xml_text = requests.get( + 'https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api/maven-metadata.xml').text + # parse xml + fabric_api_versions_data_xml = ET.fromstring( + fabric_api_versions_xml_text) + fabric_api_versions = [] + for version_el in fabric_api_versions_data_xml.find('versioning').find('versions').findall('version'): + fabric_api_versions.append(version_el.text) + + with open(get_dir_location('downloads/fabric_api_versions.json'), 'w') as f: + f.write(json.dumps(fabric_api_versions)) + else: + with open(get_dir_location('downloads/fabric_api_versions.json'), 'r') as f: + fabric_api_versions = json.loads(f.read()) + return fabric_api_versions + + def clear_version_cache(): print('\033[92mClearing version cache...\033[m') files = [ 'version_manifest.json', - 'yarn_versions.json' + 'yarn_versions.json', + 'fabric_api_versions.json' ] for file in files: if os.path.exists(get_dir_location(f'downloads/{file}')): diff --git a/codegen/lib/extract.py b/codegen/lib/extract.py index 893b8d5c..4c2d2399 100644 --- a/codegen/lib/extract.py +++ b/codegen/lib/extract.py @@ -1,6 +1,6 @@ # Extracting data from the Minecraft jars -from lib.download import get_server_jar, get_burger, get_client_jar, get_generator_mod, get_yarn_data +from lib.download import get_server_jar, get_burger, get_client_jar, get_generator_mod, get_yarn_data, get_fabric_api_versions from lib.utils import get_dir_location import json import os @@ -61,7 +61,9 @@ def get_generator_mod_data(version_id: str, category: str): # looks like 1.19+build.1 yarn_version = yarn_data['version'] - # the mod has the minecraft version hard-coded by default, so we just change the gradle.properties + fabric_api_version = get_fabric_api_versions()[-1] + + # the mod has the minecraft version hard-coded by default, so we just change the gradle.properties and fabric.mod.json with open(get_dir_location(f'{generator_mod_dir}/gradle.properties'), 'r') as f: lines = f.readlines() with open(get_dir_location(f'{generator_mod_dir}/gradle.properties'), 'w') as f: @@ -70,7 +72,15 @@ def get_generator_mod_data(version_id: str, category: str): line = f'minecraft_version={version_id}\n' if line.startswith('yarn_mappings='): line = f'yarn_mappings={yarn_version}\n' + if line.startswith('fabric_version='): + line = f'fabric_version={fabric_api_version}\n' f.write(line) + # edit the fabric.mod.json to support this version + with open(get_dir_location(f'{generator_mod_dir}/src/main/resources/fabric.mod.json'), 'r') as f: + fabric_mod_json = json.load(f) + fabric_mod_json['depends']['minecraft'] = '*' + with open(get_dir_location(f'{generator_mod_dir}/src/main/resources/fabric.mod.json'), 'w') as f: + json.dump(fabric_mod_json, f, indent=2) os.system( f'cd {generator_mod_dir} && gradlew runServer' -- cgit v1.2.3 From deef5d27c08daa709e5ebebc382aadff7450fca6 Mon Sep 17 00:00:00 2001 From: mat Date: Tue, 21 Jun 2022 19:57:18 -0500 Subject: Update to 1.19.1-pre1 --- README.md | 2 +- azalea-protocol/src/packets/mod.rs | 2 +- codegen/lib/code/version.py | 6 +++--- codegen/lib/download.py | 8 +++++++- codegen/migrate.py | 8 ++++++++ 5 files changed, 20 insertions(+), 6 deletions(-) (limited to 'codegen/lib/download.py') diff --git a/README.md b/README.md index 0bccbc6e..aea4de20 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ A collection of Rust crates primarily for creating Minecraft bots.

-*Currently supported Minecraft version: `22w24a`.* +*Currently supported Minecraft version: `1.19.1-pre1`.* 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 8425b0e9..0dd79a47 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 = 1073741916; +pub const PROTOCOL_VERSION: u32 = 1073741917; #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, FromPrimitive)] pub enum ConnectionProtocol { diff --git a/codegen/lib/code/version.py b/codegen/lib/code/version.py index 511d30d1..13d9472d 100644 --- a/codegen/lib/code/version.py +++ b/codegen/lib/code/version.py @@ -36,7 +36,7 @@ def set_version_id(version_id: str) -> None: def get_protocol_version() -> str: # azalea-protocol/src/packets/mod.rs # pub const PROTOCOL_VERSION: u32 = 758; - with open('../azalea-protocol/src/packets/mod.rs', 'r') as f: + with open(get_dir_location('../azalea-protocol/src/packets/mod.rs'), 'r') as f: mod_rs = f.read().splitlines() for line in mod_rs: if line.strip().startswith('pub const PROTOCOL_VERSION'): @@ -46,7 +46,7 @@ def get_protocol_version() -> str: def set_protocol_version(protocol_version: str) -> None: - with open('../azalea-protocol/src/packets/mod.rs', 'r') as f: + with open(get_dir_location('../azalea-protocol/src/packets/mod.rs'), 'r') as f: mod_rs = f.read().splitlines() for i, line in enumerate(mod_rs): if line.strip().startswith('pub const PROTOCOL_VERSION'): @@ -56,5 +56,5 @@ def set_protocol_version(protocol_version: str) -> None: raise Exception( 'Could not find protocol version in azalea-protocol/src/packets/mod.rs') - with open('../azalea-protocol/src/packets/mod.rs', 'w') as f: + with open(get_dir_location('../azalea-protocol/src/packets/mod.rs'), 'w') as f: f.write('\n'.join(mod_rs)) diff --git a/codegen/lib/download.py b/codegen/lib/download.py index db21145c..d9e2e63f 100644 --- a/codegen/lib/download.py +++ b/codegen/lib/download.py @@ -129,7 +129,13 @@ def get_fabric_api_versions(): fabric_api_versions_data_xml = ET.fromstring( fabric_api_versions_xml_text) fabric_api_versions = [] - for version_el in fabric_api_versions_data_xml.find('versioning').find('versions').findall('version'): + + versioning_el = fabric_api_versions_data_xml.find('versioning') + assert versioning_el + versions_el = versioning_el.find('versions') + assert versions_el + + for version_el in versions_el.findall('version'): fabric_api_versions.append(version_el.text) with open(get_dir_location('downloads/fabric_api_versions.json'), 'w') as f: diff --git a/codegen/migrate.py b/codegen/migrate.py index 62924bb9..fa7b01a6 100644 --- a/codegen/migrate.py +++ b/codegen/migrate.py @@ -9,6 +9,14 @@ import sys lib.download.clear_version_cache() +if len(sys.argv) == 1: + print('\033[91mYou must provide a version to migrate to.\033[m') + version_manifest = lib.download.get_version_manifest() + newest_version = version_manifest['latest']['snapshot'] + print(f'Hint: newest version is \033[1m{newest_version}\033[m') + exit() + + old_version_id = lib.code.version.get_version_id() old_mappings = lib.download.get_mappings_for_version(old_version_id) old_burger_data = lib.extract.get_burger_data_for_version(old_version_id) -- cgit v1.2.3