aboutsummaryrefslogtreecommitdiff
path: root/codegen
diff options
context:
space:
mode:
Diffstat (limited to 'codegen')
-rw-r--r--codegen/lib/code/entity.py6
-rwxr-xr-xcodegen/lib/code/packet.py24
-rwxr-xr-xcodegen/lib/code/utils.py9
3 files changed, 29 insertions, 10 deletions
diff --git a/codegen/lib/code/entity.py b/codegen/lib/code/entity.py
index 67e818b7..45210b5e 100644
--- a/codegen/lib/code/entity.py
+++ b/codegen/lib/code/entity.py
@@ -6,10 +6,10 @@ from typing import Optional
import re
METADATA_RS_DIR = get_dir_location(
- '../azalea-world/src/entity/metadata.rs')
+ '../azalea-entity/src/metadata.rs')
DATA_RS_DIR = get_dir_location(
- '../azalea-world/src/entity/data.rs')
+ '../azalea-entity/src/data.rs')
def generate_metadata_names(burger_dataserializers: dict, mappings: Mappings):
serializer_names: list[Optional[str]] = [None] * len(burger_dataserializers)
@@ -105,7 +105,7 @@ use super::{
SnifferState, VillagerData
};
use azalea_chat::FormattedText;
-use azalea_core::{BlockPos, Direction, Particle, Vec3};
+use azalea_core::{particle::Particle, BlockPos, Direction, Vec3};
use azalea_inventory::ItemSlot;
use bevy_ecs::{bundle::Bundle, component::Component};
use derive_more::{Deref, DerefMut};
diff --git a/codegen/lib/code/packet.py b/codegen/lib/code/packet.py
index 58e50136..b34d3455 100755
--- a/codegen/lib/code/packet.py
+++ b/codegen/lib/code/packet.py
@@ -237,12 +237,16 @@ def burger_instruction_to_code(instructions: list[dict], index: int, generated_p
field_type_rs = None
field_comment = None
- print('instruction', instruction)
+ print('instruction', instruction, next_instruction, next_next_instruction)
# iterators
- if instruction['operation'] == 'write' and instruction['field'].endswith('.size()') and next_instruction and next_instruction['type'] == 'Iterator' and next_next_instruction and next_next_instruction['operation'] == 'loop':
- obfuscated_field_name = instruction['field'].split('.')[
- 0]
+ if instruction['operation'] == 'write'\
+ and instruction['field'].endswith('.size()')\
+ and next_instruction\
+ and next_instruction['type'] == 'Iterator'\
+ and next_next_instruction\
+ and next_next_instruction['operation'] == 'loop':
+ obfuscated_field_name = instruction['field'].split('.')[0]
field_name = mappings.get_field(
obfuscated_class_name, obfuscated_field_name)
@@ -303,6 +307,11 @@ def burger_instruction_to_code(instructions: list[dict], index: int, generated_p
condition_types_rs = []
for condition_instruction in condition_instructions:
+ print('condition_instruction', condition_instruction)
+ if 'type' not in condition_instruction:
+ # weird type, maybe it's a loop or something
+ condition_types_rs.append('todo!("weird type, maybe it\'s a loop or something")')
+ continue
condition_type_rs, is_var, this_uses, this_extra_code = burger_type_to_rust_type(
condition_instruction['type'], None, condition_instruction, mappings, obfuscated_class_name)
condition_types_rs.append(condition_type_rs)
@@ -381,8 +390,11 @@ def burger_field_to_type(field, mappings: Mappings, obfuscated_class_name: str,
if obfuscated_first in known_variable_types:
first_type = known_variable_types[obfuscated_first]
else:
- first_type = mappings.get_field_type(
- obfuscated_class_name, obfuscated_first)
+ try:
+ first_type = mappings.get_field_type(
+ obfuscated_class_name, obfuscated_first)
+ except:
+ first_type = 'TODO'
first_obfuscated_class_name: Optional[str] = mappings.get_class_from_deobfuscated_name(
first_type)
if first_obfuscated_class_name:
diff --git a/codegen/lib/code/utils.py b/codegen/lib/code/utils.py
index 3f9b6edb..6dd910dc 100755
--- a/codegen/lib/code/utils.py
+++ b/codegen/lib/code/utils.py
@@ -71,6 +71,11 @@ def burger_type_to_rust_type(burger_type, field_name: Optional[str] = None, inst
field_type_rs = 'todo!("fixed bitset")'
elif burger_type == 'abstract':
field_type_rs = 'todo!()'
+ elif burger_type == 'interface':
+ # depends on context
+ field_type_rs = 'todo!()'
+ elif burger_type == 'Iterator':
+ field_type_rs = 'todo!()'
elif burger_type == 'enum':
if not instruction or not mappings or not obfuscated_class_name:
field_type_rs = 'todo!("enum")'
@@ -152,7 +157,9 @@ def burger_type_to_rust_type(burger_type, field_name: Optional[str] = None, inst
uses.add('azalea_buf::UnsizedByteArray')
else:
- raise Exception(f'Unknown field type: {burger_type}')
+ print('instruction that we errored on:', instruction)
+ deobfuscated_class_name = mappings.get_class(obfuscated_class_name) if obfuscated_class_name else None
+ raise Exception(f'Unknown field type: {burger_type} ({deobfuscated_class_name or obfuscated_class_name})')
return field_type_rs, is_var, uses, extra_code