aboutsummaryrefslogtreecommitdiff
path: root/codegen/lib/code
diff options
context:
space:
mode:
Diffstat (limited to 'codegen/lib/code')
-rwxr-xr-xcodegen/lib/code/blocks.py8
-rw-r--r--codegen/lib/code/entity.py28
2 files changed, 22 insertions, 14 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 {')