aboutsummaryrefslogtreecommitdiff
path: root/codegen/lib
diff options
context:
space:
mode:
authormat <27899617+mat-1@users.noreply.github.com>2024-04-23 10:34:50 -0500
committerGitHub <noreply@github.com>2024-04-23 10:34:50 -0500
commit1d80f531b74bc3b31023753acb81b35efcdadd73 (patch)
tree675635c7c41fbb456e3e0dd7b9f09c7211d356f0 /codegen/lib
parent0ddad8bd9c7c0e8846aec8bc90c95416418c9a63 (diff)
downloadazalea-drasl-1d80f531b74bc3b31023753acb81b35efcdadd73.tar.xz
1.20.5 (#127)
* 23w51b * make recalculate_near_end_of_path public so other plugins can do .after(recalculate_near_end_of_path) * update to 24w03a i think * start implementing 24w13a * registries work (but a lot of packets are still broken) * fix recipes and commands packets * i love codecs :D i am not going insane :D mojang's java is very readable :D * item components are "implemented" meowmeowmeowmeowmeowmeowmeowmeowmeowmeowmeowmeowmeowmeowmeowmeowmeowmeow * update to 1.20.5-pre3 * fix all the broken packets and clippy (mojang please don't do an update like this again or i will murder someone) * 1.20.5-rc1 * fix failing tests * 1.20.5
Diffstat (limited to 'codegen/lib')
-rwxr-xr-xcodegen/lib/code/blocks.py8
-rw-r--r--codegen/lib/code/entity.py28
-rwxr-xr-xcodegen/lib/download.py2
-rwxr-xr-xcodegen/lib/extract.py17
4 files changed, 40 insertions, 15 deletions
diff --git a/codegen/lib/code/blocks.py b/codegen/lib/code/blocks.py
index f96b1116..64347849 100755
--- a/codegen/lib/code/blocks.py
+++ b/codegen/lib/code/blocks.py
@@ -41,7 +41,7 @@ def generate_blocks(blocks_burger: dict, blocks_report: dict, pixlyzer_block_dat
if property_burger is None:
print(
- 'Warning: The reports have states for a block, but Burger doesn\'t!', block_data_burger)
+ f'Warning: The reports have states for a block, but Burger doesn\'t! (missing "{property_name}")', block_data_burger)
property_struct_name = get_property_struct_name(
property_burger, block_data_burger, property_variants, mappings)
@@ -90,7 +90,7 @@ def generate_blocks(blocks_burger: dict, blocks_report: dict, pixlyzer_block_dat
for block_id in ordered_blocks:
block_data_burger = blocks_burger[block_id]
block_data_report = blocks_report['minecraft:' + block_id]
- block_data_pixlyzer = pixlyzer_block_datas[f'minecraft:{block_id}']
+ block_data_pixlyzer = pixlyzer_block_datas.get(f'minecraft:{block_id}', {})
block_properties = block_data_burger.get('states', [])
block_properties_burger = block_data_burger.get('states', [])
@@ -202,6 +202,10 @@ def get_property_struct_name(property: Optional[dict], block_data_burger: dict,
return 'ChestType'
if property_variants == ['compare', 'subtract']:
return 'ComparatorType'
+ if property_variants == ['inactive', 'waiting_for_players', 'active', 'waiting_for_reward_ejection', 'ejecting_reward', 'cooldown']:
+ return 'TrialSpawnerState'
+ if property_variants == ['inactive', 'active', 'unlocking', 'ejecting']:
+ return 'VaultState'
if 'harp' in property_variants and 'didgeridoo' in property_variants:
return 'Sound'
diff --git a/codegen/lib/code/entity.py b/codegen/lib/code/entity.py
index 8fa11430..5f0bc3d9 100644
--- a/codegen/lib/code/entity.py
+++ b/codegen/lib/code/entity.py
@@ -89,7 +89,7 @@ def generate_entity_metadata(burger_entities_data: dict, mappings: Mappings):
with open(DATA_RS_DIR, 'w') as f:
f.write('\n'.join(lines))
print('Expected metadata types:\n' + '\n'.join(new_metadata_names))
- print('Updated metadata types in azalea-world/src/entity/data.rs, go make sure they\'re correct and then press enter')
+ print('Updated metadata types in azalea-entity/src/data.rs, go make sure they\'re correct (check EntityDataSerializers.java) and then press enter')
input()
metadata_types = parse_metadata_types_from_code()
@@ -100,12 +100,17 @@ def generate_entity_metadata(burger_entities_data: dict, mappings: Mappings):
// This file is generated from codegen/lib/code/entity.py.
// Don't change it manually!
+use crate::particle::Particle;
+
use super::{
- EntityDataItem, EntityDataValue, OptionalUnsignedInt, Pose, Quaternion, Rotations,
- SnifferState, VillagerData
+ ArmadilloStateKind, EntityDataItem, EntityDataValue, OptionalUnsignedInt, Pose, Quaternion,
+ Rotations, SnifferState, VillagerData,
};
use azalea_chat::FormattedText;
-use azalea_core::{particle::Particle, position::{BlockPos, Vec3}, direction::Direction};
+use azalea_core::{
+ direction::Direction,
+ position::{BlockPos, Vec3},
+};
use azalea_inventory::ItemSlot;
use bevy_ecs::{bundle::Bundle, component::Component};
use derive_more::{Deref, DerefMut};
@@ -218,8 +223,7 @@ impl From<EntityDataValue> for UpdateMetadataError {
struct_name = upper_first_letter(
to_camel_case(name_or_bitfield))
- type_id = next(filter(lambda i: i['index'] == index, entity_metadatas))[
- 'type_id']
+ type_id = next(filter(lambda i: i['index'] == index, entity_metadatas))['type_id']
metadata_type_data = metadata_types[type_id]
rust_type = metadata_type_data['type']
@@ -281,8 +285,7 @@ impl From<EntityDataValue> for UpdateMetadataError {
if name_or_bitfield in single_use_imported_types:
field_struct_name = ''
- type_id = next(filter(lambda i: i['index'] == index, entity_metadatas))[
- 'type_id']
+ type_id = next(filter(lambda i: i['index'] == index, entity_metadatas))['type_id']
metadata_type_data = metadata_types[type_id]
rust_type = metadata_type_data['type']
type_name = metadata_type_data['name']
@@ -384,8 +387,7 @@ impl From<EntityDataValue> for UpdateMetadataError {
' },')
for index, name_or_bitfield in get_entity_metadata_names(this_entity_id, burger_entity_metadata, mappings).items():
- default = next(filter(lambda i: i['index'] == index, entity_metadatas)).get(
- 'default', 'Default::default()')
+ default = next(filter(lambda i: i['index'] == index, entity_metadatas)).get('default', 'Default::default()')
if isinstance(name_or_bitfield, str):
type_id = next(filter(lambda i: i['index'] == index, entity_metadatas))[
'type_id']
@@ -454,8 +456,10 @@ impl From<EntityDataValue> for UpdateMetadataError {
for mask, name in name_or_bitfield.items():
name = maybe_rename_field(name, index)
mask = int(mask, 0)
- bit_default = 'true' if (
- default & mask != 0) else 'false'
+ if default is None:
+ bit_default = 'false'
+ else:
+ bit_default = 'true' if (default & mask != 0) else 'false'
code.append(
f' {name}: {upper_first_letter(to_camel_case(name))}({bit_default}),')
code.append(' Self {')
diff --git a/codegen/lib/download.py b/codegen/lib/download.py
index 319c6080..41576594 100755
--- a/codegen/lib/download.py
+++ b/codegen/lib/download.py
@@ -16,7 +16,7 @@ def get_burger():
if not os.path.exists(get_dir_location('__cache__/Burger')):
print('\033[92mDownloading Burger...\033[m')
os.system(
- f'cd {get_dir_location("__cache__")} && git clone https://github.com/pokechu22/Burger && cd Burger && git pull')
+ f'cd {get_dir_location("__cache__")} && git clone https://github.com/mat-1/Burger && cd Burger && git pull')
print('\033[92mInstalling dependencies...\033[m')
os.system(f'cd {get_dir_location("__cache__")}/Burger && pip install six jawa')
diff --git a/codegen/lib/extract.py b/codegen/lib/extract.py
index 608673fa..fa75c49e 100755
--- a/codegen/lib/extract.py
+++ b/codegen/lib/extract.py
@@ -1,5 +1,6 @@
# 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 zipfile import ZipFile
@@ -275,3 +276,19 @@ def get_en_us_lang(version_id: str):
return json.loads(
get_file_from_jar(version_id, 'assets/minecraft/lang/en_us.json')
)
+
+# burger packet id extraction is broken since 1.20.5 (always returns -1, so we have to determine packet id ourselves from the mappings).
+# 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