diff --git a/azalea-block/src/blocks.rs b/azalea-block/src/blocks.rs index ea58c062..71d04f99 100644 --- a/azalea-block/src/blocks.rs +++ b/azalea-block/src/blocks.rs @@ -8,6 +8,11 @@ pub trait Block { make_block_states! { Properties => { + Face { + Floor, + Wall, + Ceiling, + }, Facing { North, South, @@ -18,24 +23,15 @@ make_block_states! { True, False, }, - Face { - Floor, - Wall, - Ceiling, - }, Half { Top, Bottom, }, - Open { - True, - False, - }, Hinge { Left, Right, }, - North { + Open { True, False, }, @@ -43,7 +39,7 @@ make_block_states! { True, False, }, - West { + North { True, False, }, @@ -55,6 +51,10 @@ make_block_states! { True, False, }, + West { + True, + False, + }, InWall { True, False, @@ -111,30 +111,30 @@ make_block_states! { OuterLeft, OuterRight, }, - Up { - True, - False, + EastWall { + None, + Low, + Tall, }, NorthWall { None, Low, Tall, }, - EastWall { + SouthWall { None, Low, Tall, }, + Up { + True, + False, + }, WestWall { None, Low, Tall, }, - SouthWall { - None, - Low, - Tall, - }, Age { _0, _1, @@ -170,14 +170,14 @@ make_block_states! { Partial, Full, }, - Part { - Head, - Foot, - }, Occupied { True, False, }, + Part { + Head, + Foot, + }, Candles { _1, _2, @@ -228,6 +228,10 @@ make_block_states! { _2, _3, }, + Inverted { + True, + False, + }, Power { _0, _1, @@ -246,10 +250,6 @@ make_block_states! { _14, _15, }, - Inverted { - True, - False, - }, Triggered { True, False, @@ -355,10 +355,6 @@ make_block_states! { True, False, }, - TipDirection { - Up, - Down, - }, Thickness { TipMerge, Tip, @@ -366,6 +362,10 @@ make_block_states! { Middle, Base, }, + TipDirection { + Up, + Down, + }, Delay { _1, _2, @@ -396,11 +396,11 @@ make_block_states! { Active, Cooldown, }, - Shrieking { + CanSummon { True, False, }, - CanSummon { + Shrieking { True, False, }, @@ -450,17 +450,17 @@ make_block_states! { True, False, }, - Hatch { - _0, - _1, - _2, - }, Eggs { _1, _2, _3, _4, }, + Hatch { + _0, + _1, + _2, + }, }, Blocks => { acacia_button => BlockBehavior::default(), { diff --git a/codegen/lib/code/blocks.py b/codegen/lib/code/blocks.py index 0737270b..a5c9e2c6 100644 --- a/codegen/lib/code/blocks.py +++ b/codegen/lib/code/blocks.py @@ -18,7 +18,7 @@ def generate_blocks(blocks_burger: dict, blocks_report: dict, mappings: Mappings new_make_block_states_macro_code = [] new_make_block_states_macro_code.append('make_block_states! {') - def get_property_name(property: dict, block_data_burger: dict) -> str: + def get_property_struct_name(property: dict, block_data_burger: dict) -> str: property_name = None for class_name in [block_data_burger['class']] + block_data_burger['super']: property_name = mappings.get_field(class_name, property['field_name']) @@ -34,11 +34,20 @@ def generate_blocks(blocks_burger: dict, blocks_report: dict, mappings: Mappings block_data_report = blocks_report[f'minecraft:{block_id}'] block_properties = {} - for property in block_data_burger.get('states', []): - property_variants = block_data_report['properties'][property['name']] - property_name = get_property_name(property, block_data_burger) + for property_name in list(block_data_report.get('properties', {}).keys()): + property_burger = None + for property in block_data_burger['states']: + if property['name'] == property_name: + property_burger = property + break + if property_burger is None: + print('Error: The reports have states for a block, but Burger doesn\'t!', block_data_burger) + continue + # assert property_burger is not None + property_variants = block_data_report['properties'][property_name] + property_struct_name = get_property_struct_name(property_burger, block_data_burger) - block_properties[property_name] = property_variants + block_properties[property_struct_name] = property_variants properties.update(block_properties) # Property codegen @@ -70,10 +79,9 @@ def generate_blocks(blocks_burger: dict, blocks_report: dict, mappings: Mappings # TODO: use burger to generate the blockbehavior new_make_block_states_macro_code.append( f' {block_id} => BlockBehavior::default(), {{') - print('block data', block_data_burger) for property in block_properties_burger: property_default = default_property_variants.get(property['name']) - property_struct_name = get_property_name(property, block_data_burger) + property_struct_name = get_property_struct_name(property, block_data_burger) assert property_default is not None new_make_block_states_macro_code.append( f' {to_camel_case(property_struct_name)}={to_camel_case(property_default)},')