1
2
Fork 0
mirror of https://github.com/mat-1/azalea.git synced 2025-08-02 14:26:04 +00:00

re-add some things to migrate.py and update +mc version numbers automatically

This commit is contained in:
mat 2024-11-27 23:53:46 +00:00
parent b623845342
commit 1f9cb0c8c3
26 changed files with 107 additions and 96 deletions

42
Cargo.lock generated
View file

@ -190,7 +190,7 @@ checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26"
[[package]]
name = "azalea"
version = "0.10.3+mc1.21.1"
version = "0.10.3+mc1.21.4-pre3"
dependencies = [
"anyhow",
"azalea-auth",
@ -229,7 +229,7 @@ dependencies = [
[[package]]
name = "azalea-auth"
version = "0.10.3+mc1.21.1"
version = "0.10.3+mc1.21.4-pre3"
dependencies = [
"azalea-buf",
"azalea-crypto",
@ -249,7 +249,7 @@ dependencies = [
[[package]]
name = "azalea-block"
version = "0.10.3+mc1.21.4"
version = "0.10.3+mc1.21.4-pre3"
dependencies = [
"azalea-block-macros",
"azalea-buf",
@ -258,7 +258,7 @@ dependencies = [
[[package]]
name = "azalea-block-macros"
version = "0.10.3+mc1.21.1"
version = "0.10.3+mc1.21.4-pre3"
dependencies = [
"proc-macro2",
"quote",
@ -267,7 +267,7 @@ dependencies = [
[[package]]
name = "azalea-brigadier"
version = "0.10.3+mc1.21.1"
version = "0.10.3+mc1.21.4-pre3"
dependencies = [
"azalea-buf",
"azalea-chat",
@ -278,7 +278,7 @@ dependencies = [
[[package]]
name = "azalea-buf"
version = "0.10.3+mc1.21.1"
version = "0.10.3+mc1.21.4-pre3"
dependencies = [
"azalea-buf-macros",
"byteorder",
@ -291,7 +291,7 @@ dependencies = [
[[package]]
name = "azalea-buf-macros"
version = "0.10.3+mc1.21.1"
version = "0.10.3+mc1.21.4-pre3"
dependencies = [
"proc-macro2",
"quote",
@ -300,7 +300,7 @@ dependencies = [
[[package]]
name = "azalea-chat"
version = "0.10.3+mc1.21.1"
version = "0.10.3+mc1.21.4-pre3"
dependencies = [
"azalea-buf",
"azalea-language",
@ -313,7 +313,7 @@ dependencies = [
[[package]]
name = "azalea-client"
version = "0.10.3+mc1.21.1"
version = "0.10.3+mc1.21.4-pre3"
dependencies = [
"anyhow",
"azalea-auth",
@ -347,7 +347,7 @@ dependencies = [
[[package]]
name = "azalea-core"
version = "0.10.3+mc1.21.1"
version = "0.10.3+mc1.21.4-pre3"
dependencies = [
"azalea-buf",
"azalea-registry",
@ -361,7 +361,7 @@ dependencies = [
[[package]]
name = "azalea-crypto"
version = "0.10.3+mc1.21.1"
version = "0.10.3+mc1.21.4-pre3"
dependencies = [
"aes",
"azalea-buf",
@ -378,7 +378,7 @@ dependencies = [
[[package]]
name = "azalea-entity"
version = "0.10.3+mc1.21.1"
version = "0.10.3+mc1.21.4-pre3"
dependencies = [
"azalea-block",
"azalea-buf",
@ -401,7 +401,7 @@ dependencies = [
[[package]]
name = "azalea-inventory"
version = "0.10.3+mc1.21.4"
version = "0.10.3+mc1.21.4-pre3"
dependencies = [
"azalea-buf",
"azalea-chat",
@ -414,7 +414,7 @@ dependencies = [
[[package]]
name = "azalea-inventory-macros"
version = "0.10.3+mc1.21.1"
version = "0.10.3+mc1.21.4-pre3"
dependencies = [
"proc-macro2",
"quote",
@ -423,7 +423,7 @@ dependencies = [
[[package]]
name = "azalea-language"
version = "0.10.3+mc1.21.1"
version = "0.10.3+mc1.21.4-pre3"
dependencies = [
"serde",
"serde_json",
@ -431,7 +431,7 @@ dependencies = [
[[package]]
name = "azalea-physics"
version = "0.10.3+mc1.21.1"
version = "0.10.3+mc1.21.4-pre3"
dependencies = [
"azalea-block",
"azalea-core",
@ -447,7 +447,7 @@ dependencies = [
[[package]]
name = "azalea-protocol"
version = "0.10.3+mc1.21.1"
version = "0.10.3+mc1.21.4-pre3"
dependencies = [
"anyhow",
"async-recursion",
@ -484,7 +484,7 @@ dependencies = [
[[package]]
name = "azalea-protocol-macros"
version = "0.10.3+mc1.21.1"
version = "0.10.3+mc1.21.4-pre3"
dependencies = [
"proc-macro2",
"quote",
@ -493,7 +493,7 @@ dependencies = [
[[package]]
name = "azalea-registry"
version = "0.10.3+mc1.21.1"
version = "0.10.3+mc1.21.4-pre3"
dependencies = [
"azalea-buf",
"azalea-registry-macros",
@ -503,7 +503,7 @@ dependencies = [
[[package]]
name = "azalea-registry-macros"
version = "0.10.3+mc1.21.1"
version = "0.10.3+mc1.21.4-pre3"
dependencies = [
"quote",
"syn",
@ -511,7 +511,7 @@ dependencies = [
[[package]]
name = "azalea-world"
version = "0.10.3+mc1.21.1"
version = "0.10.3+mc1.21.4-pre3"
dependencies = [
"azalea-block",
"azalea-buf",

View file

@ -4,7 +4,7 @@ edition = "2021"
license = "MIT"
name = "azalea-auth"
repository = "https://github.com/azalea-rs/azalea/tree/main/azalea-auth"
version = "0.10.3+mc1.21.1"
version = "0.10.3+mc1.21.4-pre3"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View file

@ -4,7 +4,7 @@ edition = "2021"
license = "MIT"
name = "azalea-block"
repository = "https://github.com/azalea-rs/azalea/tree/main/azalea-block"
version = "0.10.3+mc1.21.4"
version = "0.10.3+mc1.21.4-pre3"
[lib]

View file

@ -4,7 +4,7 @@ edition = "2021"
license = "MIT"
name = "azalea-block-macros"
repository = "https://github.com/azalea-rs/azalea/tree/main/azalea-block/azalea-block-macros"
version = "0.10.3+mc1.21.1"
version = "0.10.3+mc1.21.4-pre3"
[lib]
proc-macro = true

View file

@ -4,7 +4,7 @@ edition = "2021"
license = "MIT"
name = "azalea-brigadier"
repository = "https://github.com/azalea-rs/azalea/tree/main/azalea-brigadier"
version = "0.10.3+mc1.21.1"
version = "0.10.3+mc1.21.4-pre3"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View file

@ -4,7 +4,7 @@ edition = "2021"
license = "MIT"
name = "azalea-buf"
repository = "https://github.com/azalea-rs/azalea/tree/main/azalea-buf"
version = "0.10.3+mc1.21.1"
version = "0.10.3+mc1.21.4-pre3"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View file

@ -4,7 +4,7 @@ edition = "2021"
license = "MIT"
name = "azalea-buf-macros"
repository = "https://github.com/azalea-rs/azalea/tree/main/azalea-buf"
version = "0.10.3+mc1.21.1"
version = "0.10.3+mc1.21.4-pre3"
[lib]
proc-macro = true

View file

@ -4,7 +4,7 @@ edition = "2021"
license = "MIT"
name = "azalea-chat"
repository = "https://github.com/azalea-rs/azalea/tree/main/azalea-chat"
version = "0.10.3+mc1.21.1"
version = "0.10.3+mc1.21.4-pre3"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View file

@ -4,7 +4,7 @@ edition = "2021"
license = "MIT"
name = "azalea-client"
repository = "https://github.com/azalea-rs/azalea/tree/main/azalea-client"
version = "0.10.3+mc1.21.1"
version = "0.10.3+mc1.21.4-pre3"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View file

@ -4,7 +4,7 @@ edition = "2021"
license = "MIT"
name = "azalea-core"
repository = "https://github.com/azalea-rs/azalea/tree/main/azalea-core"
version = "0.10.3+mc1.21.1"
version = "0.10.3+mc1.21.4-pre3"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View file

@ -3,7 +3,7 @@ description = "Cryptography features used in Minecraft."
edition = "2021"
license = "MIT"
name = "azalea-crypto"
version = "0.10.3+mc1.21.1"
version = "0.10.3+mc1.21.4-pre3"
repository = "https://github.com/azalea-rs/azalea/tree/main/azalea-crypto"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View file

@ -1,6 +1,6 @@
[package]
name = "azalea-entity"
version = "0.10.3+mc1.21.1"
version = "0.10.3+mc1.21.4-pre3"
edition = "2021"
description = "Things related to Minecraft entities used by Azalea"
repository = "https://github.com/azalea-rs/azalea/tree/main/azalea-entity"

View file

@ -4,7 +4,7 @@ edition = "2021"
license = "MIT"
name = "azalea-inventory"
repository = "https://github.com/azalea-rs/azalea/tree/main/azalea-inventory-macros"
version = "0.10.3+mc1.21.4"
version = "0.10.3+mc1.21.4-pre3"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View file

@ -4,7 +4,7 @@ edition = "2021"
license = "MIT"
name = "azalea-inventory-macros"
repository = "https://github.com/azalea-rs/azalea/tree/main/azalea-inventory/azalea-inventory-macros"
version = "0.10.3+mc1.21.1"
version = "0.10.3+mc1.21.4-pre3"
[lib]
proc-macro = true

View file

@ -4,7 +4,7 @@ edition = "2021"
license = "MIT"
name = "azalea-language"
repository = "https://github.com/azalea-rs/azalea/tree/main/azalea-language"
version = "0.10.3+mc1.21.1"
version = "0.10.3+mc1.21.4-pre3"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View file

@ -4,7 +4,7 @@ edition = "2021"
license = "MIT"
name = "azalea-physics"
repository = "https://github.com/azalea-rs/azalea/tree/main/azalea-physics"
version = "0.10.3+mc1.21.1"
version = "0.10.3+mc1.21.4-pre3"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View file

@ -4,7 +4,7 @@ edition = "2021"
license = "MIT"
name = "azalea-protocol"
repository = "https://github.com/azalea-rs/azalea/tree/main/azalea-protocol"
version = "0.10.3+mc1.21.1"
version = "0.10.3+mc1.21.4-pre3"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View file

@ -3,7 +3,7 @@ description = "Macros internally used in azalea-protocol."
edition = "2021"
license = "MIT"
name = "azalea-protocol-macros"
version = "0.10.3+mc1.21.1"
version = "0.10.3+mc1.21.4-pre3"
repository = "https://github.com/azalea-rs/azalea/tree/main/azalea-protocol/azalea-protocol-macros"
[lib]

View file

@ -4,7 +4,7 @@ edition = "2021"
license = "MIT"
name = "azalea-registry"
repository = "https://github.com/azalea-rs/azalea/tree/main/azalea-registry"
version = "0.10.3+mc1.21.1"
version = "0.10.3+mc1.21.4-pre3"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View file

@ -4,7 +4,7 @@ edition = "2021"
license = "MIT"
name = "azalea-registry-macros"
repository = "https://github.com/azalea-rs/azalea/tree/main/azalea-registry/azalea-registry-macros"
version = "0.10.3+mc1.21.1"
version = "0.10.3+mc1.21.4-pre3"
[lib]
proc-macro = true

View file

@ -4,7 +4,7 @@ edition = "2021"
license = "MIT"
name = "azalea-world"
repository = "https://github.com/azalea-rs/azalea/tree/main/azalea-world"
version = "0.10.3+mc1.21.1"
version = "0.10.3+mc1.21.4-pre3"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View file

@ -4,7 +4,7 @@ edition = "2021"
license = "MIT"
name = "azalea"
repository = "https://github.com/azalea-rs/azalea/tree/main/azalea"
version = "0.10.3+mc1.21.1"
version = "0.10.3+mc1.21.4-pre3"
[package.metadata.release]
pre-release-replacements = [

View file

@ -7,24 +7,19 @@ import lib.download
import lib.extract
import lib.utils
def generate():
version_id = lib.code.version.get_version_id()
def generate(version_id):
# TODO: pixlyzer is broken so we use old data
shape_datas = lib.extract.get_pixlyzer_data(
'1.20.3-pre4', 'shapes')
pixlyzer_block_datas = lib.extract.get_pixlyzer_data(
'1.20.3-pre4', 'blocks')
mappings = lib.download.get_mappings_for_version(version_id)
block_states_report = lib.extract.get_block_states_report(version_id)
registries = lib.extract.get_registries_report(version_id)
ordered_blocks = get_ordered_blocks(registries)
ordered_blocks = lib.code.blocks.get_ordered_blocks(registries)
lib.code.blocks.generate_blocks(
block_states_report, pixlyzer_block_datas, ordered_blocks, mappings)
block_states_report, pixlyzer_block_datas, ordered_blocks)
lib.code.shapes.generate_block_shapes(
pixlyzer_block_datas, shape_datas['shapes'], shape_datas['aabbs'], block_states_report)
@ -33,23 +28,6 @@ def generate():
print('Done!')
def get_ordered_blocks(registries_report: dict[str, dict]) -> list[str]:
'''
Returns a list of block ids (like ['air', 'stone', ...]) ordered by their protocol id.
'''
blocks_registry = registries_report['minecraft:block']
blocks_to_ids = {}
for block_id, value in blocks_registry['entries'].items():
prefix = 'minecraft:'
assert block_id.startswith(prefix)
block_id = block_id[len(prefix):]
protocol_id = value['protocol_id']
blocks_to_ids[block_id] = protocol_id
ordered_blocks = []
for block_id in sorted(blocks_to_ids, key=blocks_to_ids.get):
ordered_blocks.append(block_id)
return ordered_blocks
generate()
if __name__ == '__main__':
generate(lib.code.version.get_version_id())

View file

@ -12,7 +12,7 @@ BLOCKS_RS_DIR = get_dir_location('../azalea-block/src/generated.rs')
# - Block: Has properties and states.
def generate_blocks(blocks_report: dict, pixlyzer_block_datas: dict, ordered_blocks: list[str], mappings: Mappings):
def generate_blocks(blocks_report: dict, pixlyzer_block_datas: dict, ordered_blocks: list[str]):
with open(BLOCKS_RS_DIR, 'r') as f:
existing_code = f.read().splitlines()
@ -32,7 +32,7 @@ def generate_blocks(blocks_report: dict, pixlyzer_block_datas: dict, ordered_blo
property_variants = block_data_report['properties'][property_id]
property_struct_name = get_property_struct_name(
block_id, property_id, property_variants, mappings)
block_id, property_id, property_variants)
if property_struct_name in properties:
if not properties[property_struct_name] == property_variants:
@ -89,7 +89,7 @@ def generate_blocks(blocks_report: dict, pixlyzer_block_datas: dict, ordered_blo
property_variants = block_data_report['properties'][property_id]
property_struct_name = get_property_struct_name(
block_id, property_id, property_variants, mappings)
block_id, property_id, property_variants)
is_boolean_property = property_variants == ['true', 'false']
@ -156,7 +156,7 @@ def generate_blocks(blocks_report: dict, pixlyzer_block_datas: dict, ordered_blo
with open(BLOCKS_RS_DIR, 'w') as f:
f.write('\n'.join(new_code))
def get_property_struct_name(block_id: str, property_id: str, property_variants: list[str], mappings: Mappings) -> str:
def get_property_struct_name(block_id: str, property_id: str, property_variants: list[str]) -> str:
# these are hardcoded because otherwise they cause conflicts
# some names inspired by https://github.com/feather-rs/feather/blob/main/feather/blocks/src/generated/table.rs
if property_variants == ['north', 'east', 'south', 'west', 'up', 'down']:
@ -195,3 +195,22 @@ def get_property_struct_name(block_id: str, property_id: str, property_variants:
def is_list_of_string_integers(l: list[str]) -> bool:
return all(map(str.isdigit, l))
def get_ordered_blocks(registries_report: dict[str, dict]) -> list[str]:
'''
Returns a list of block ids (like ['air', 'stone', ...]) ordered by their protocol id.
'''
blocks_registry = registries_report['minecraft:block']
blocks_to_ids = {}
for block_id, value in blocks_registry['entries'].items():
prefix = 'minecraft:'
assert block_id.startswith(prefix)
block_id = block_id[len(prefix):]
protocol_id = value['protocol_id']
blocks_to_ids[block_id] = protocol_id
ordered_blocks = []
for block_id in sorted(blocks_to_ids, key=blocks_to_ids.get):
ordered_blocks.append(block_id)
return ordered_blocks

View file

@ -31,7 +31,28 @@ def set_version_id(version_id: str) -> None:
with open(README_DIR, 'wb') as f:
f.write(readme_text.encode())
# update the version in all Cargo.toml files
# version = "0.10.3+mc1.21.1"
for root, _, files in os.walk(get_dir_location('..')):
for file in files:
if file == 'Cargo.toml':
with open(os.path.join(root, file), 'r') as f:
cargo_toml = f.read().splitlines()
for i, line in enumerate(cargo_toml):
if line.strip().startswith('version = '):
replaced = re.sub(r'\+mc[^"]+?"', f'+mc{version_id}"', line)
cargo_toml[i] = replaced
break
else:
# didn't have a version line
continue
if cargo_toml[-1] != '':
# make sure there's always a trailing newline
cargo_toml.append('')
with open(os.path.join(root, file), 'w') as f:
f.write('\n'.join(cargo_toml))
print('Updated version in README.md and Cargo.toml files')
def get_protocol_version() -> str:
# azalea-protocol/src/packets/mod.rs

View file

@ -37,25 +37,19 @@ lib.code.version.set_protocol_version(
print('Updated protocol!')
# old_ordered_blocks = lib.extract.get_ordered_blocks_burger(old_version_id)
# new_ordered_blocks = lib.extract.get_ordered_blocks_burger(new_version_id)
# if old_ordered_blocks != new_ordered_blocks:
# print('Blocks changed, updating...')
# block_states_burger = lib.extract.get_block_states_burger(new_version_id)
# block_states_report = lib.extract.get_block_states_report(new_version_id)
# # TODO: pixlyzer is currently broken so uhhhh
# shape_datas = lib.extract.get_pixlyzer_data(
# '1.20.3-pre4', 'shapes')
# pixlyzer_block_datas = lib.extract.get_pixlyzer_data(
# '1.20.3-pre4', 'blocks')
# lib.code.blocks.generate_blocks(
# block_states_burger, block_states_report, pixlyzer_block_datas, new_ordered_blocks, new_mappings)
# lib.code.shapes.generate_block_shapes(
# pixlyzer_block_datas, shape_datas['shapes'], shape_datas['aabbs'], block_states_report, block_states_burger, new_mappings)
print('Generating blocks and shapes...')
# TODO: pixlyzer is broken so we use old data
new_shape_datas = lib.extract.get_pixlyzer_data(
'1.20.3-pre4', 'shapes')
new_pixlyzer_block_datas = lib.extract.get_pixlyzer_data(
'1.20.3-pre4', 'blocks')
new_block_states_report = lib.extract.get_block_states_report(new_version_id)
new_registries = lib.extract.get_registries_report(new_version_id)
new_ordered_blocks = lib.code.blocks.get_ordered_blocks(new_registries)
lib.code.blocks.generate_blocks(
new_block_states_report, new_pixlyzer_block_datas, new_ordered_blocks)
lib.code.shapes.generate_block_shapes(
new_pixlyzer_block_datas, new_shape_datas['shapes'], new_shape_datas['aabbs'], new_block_states_report)
print('Getting en_us.json...')
language = lib.extract.get_en_us_lang(new_version_id)
@ -66,13 +60,12 @@ import genregistries
genregistries.generate(new_version_id)
# print('Generating entity metadata...')
# burger_entities_data = new_burger_data[0]['entities']
# lib.code.entity.generate_entity_metadata(burger_entities_data, new_mappings)
burger_entities_data = new_burger_data[0]['entities']
lib.code.entity.generate_entity_metadata(burger_entities_data, new_mappings)
print('Finishing touches, setting version in README and formatting code...')
lib.code.version.set_version_id(new_version_id)
lib.code.utils.fmt()
print('Done!')