From 68ab3d65247c02d469d77e5702f57e46f690965b Mon Sep 17 00:00:00 2001 From: mat Date: Fri, 27 May 2022 01:11:42 -0500 Subject: Fix codegen more --- codegen/lib/utils.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'codegen/lib/utils.py') diff --git a/codegen/lib/utils.py b/codegen/lib/utils.py index c185c0e5..77a7b2d4 100644 --- a/codegen/lib/utils.py +++ b/codegen/lib/utils.py @@ -1,4 +1,5 @@ import re +import os # utilities that could be used for things other than codegen @@ -44,3 +45,7 @@ def group_packets(packets: list[PacketIdentifier]): packet_groups[key] = [] packet_groups[key].append(packet.packet_id) return packet_groups + + +def get_dir_location(name: str): + return os.path.join(os.path.dirname(__file__), '..', name) -- cgit v1.2.3 From 9c1c2862361a4863cfd0af36c80705fb6213c3a4 Mon Sep 17 00:00:00 2001 From: mat Date: Sat, 28 May 2022 20:59:22 -0500 Subject: default block properties --- azalea-block/block-macros/src/lib.rs | 73 +++++++++++++++++++++++++++++------- azalea-block/src/blocks.rs | 34 ++++++++--------- codegen/lib/code/blocks.py | 46 ++++++++++++++++++++--- codegen/lib/utils.py | 7 +++- 4 files changed, 123 insertions(+), 37 deletions(-) (limited to 'codegen/lib/utils.py') diff --git a/azalea-block/block-macros/src/lib.rs b/azalea-block/block-macros/src/lib.rs index 63e21e58..c0b5422d 100644 --- a/azalea-block/block-macros/src/lib.rs +++ b/azalea-block/block-macros/src/lib.rs @@ -20,10 +20,14 @@ struct PropertyDefinitions { properties: Vec, } +struct PropertyAndDefault { + name: Ident, + default: Ident, +} struct BlockDefinition { name: Ident, behavior: Expr, - properties: Punctuated, + properties_and_defaults: Vec, } struct BlockDefinitions { blocks: Vec, @@ -39,14 +43,14 @@ impl Parse for PropertyDefinition { // Floor, // Wall, // Ceiling - // }; + // }, let name = input.parse()?; let content; braced!(content in input); let variants = content.parse_terminated(Ident::parse)?; - input.parse::()?; + input.parse::()?; Ok(PropertyDefinition { name, variants }) } } @@ -66,11 +70,11 @@ impl Parse for PropertyDefinitions { impl Parse for BlockDefinition { fn parse(input: ParseStream) -> Result { - // acacia_button => BlockBehavior { has_collision: false }, { + // acacia_button => BlockBehavior::default().no_collision(), { // Face, // Facing, // Powered - // }; + // }, let name = input.parse()?; input.parse::]>()?; let behavior = input.parse()?; @@ -78,12 +82,29 @@ impl Parse for BlockDefinition { input.parse::()?; let content; braced!(content in input); - let properties = content.parse_terminated(Ident::parse)?; - input.parse::()?; + + let mut properties_and_defaults = Vec::new(); + + loop { + let property = match content.parse() { + Ok(property) => property, + Err(_) => break, + }; + content.parse::()?; + let property_default = content.parse()?; + properties_and_defaults.push(PropertyAndDefault { + name: property, + default: property_default, + }); + if content.parse::().is_err() { + break; + } + } + input.parse::()?; Ok(BlockDefinition { name, behavior, - properties, + properties_and_defaults, }) } } @@ -109,6 +130,8 @@ impl Parse for MakeBlockStates { braced!(content in input); let properties = content.parse()?; + input.parse::()?; + let blocks_ident = input.parse::()?; assert_eq!(blocks_ident.to_string(), "Blocks"); input.parse::]>()?; @@ -183,9 +206,9 @@ pub fn make_block_states(input: TokenStream) -> TokenStream { let mut from_state_to_block_match = quote! {}; for block in &input.block_definitions.blocks { let block_property_names = &block - .properties + .properties_and_defaults .iter() - .map(|p| p.to_string()) + .map(|p| p.name.to_string()) .collect::>(); let mut block_properties_vec = Vec::new(); for property_name in block_property_names { @@ -200,7 +223,7 @@ pub fn make_block_states(input: TokenStream) -> TokenStream { // pub facing: properties::Facing, // pub powered: properties::Powered, let mut block_struct_fields = quote! {}; - for property in &block.properties { + for PropertyAndDefault { name: property, .. } in &block.properties_and_defaults { let property_name_snake = Ident::new(&property.to_string(), proc_macro2::Span::call_site()); block_struct_fields.extend(quote! { @@ -268,12 +291,16 @@ pub fn make_block_states(input: TokenStream) -> TokenStream { // } let mut from_state_to_block_inner = quote! {}; let mut division = 1usize; - for i in (0..block.properties.len()).rev() { - let property = &block.properties[i]; + for i in (0..block.properties_and_defaults.len()).rev() { + let PropertyAndDefault { + name: property_name, + .. + } = &block.properties_and_defaults[i]; + let property_variants = &block_properties_vec[i]; let property_variants_count = property_variants.len(); from_state_to_block_inner.extend(quote! { - #property: #property::from((b / #division) % #property_variants_count), + #property_name: #property_name::from((b / #division) % #property_variants_count), }); division *= property_variants_count; @@ -289,6 +316,17 @@ pub fn make_block_states(input: TokenStream) -> TokenStream { }, }); + let mut block_default_fields = quote! {}; + for PropertyAndDefault { + name: property, + default: property_default, + } in &block.properties_and_defaults + { + block_default_fields.extend(quote! { + #property: #property::#property_default, + }) + } + let block_behavior = &block.behavior; let block_id = block.name.to_string(); let block_struct = quote! { @@ -314,6 +352,13 @@ pub fn make_block_states(input: TokenStream) -> TokenStream { } } + impl Default for #block_struct_name { + fn default() -> Self { + Self { + #block_default_fields + } + } + } }; block_structs.extend(block_struct); diff --git a/azalea-block/src/blocks.rs b/azalea-block/src/blocks.rs index 88253e34..8a4a150b 100644 --- a/azalea-block/src/blocks.rs +++ b/azalea-block/src/blocks.rs @@ -12,43 +12,43 @@ make_block_states! { Floor, Wall, Ceiling - }; + }, Facing { North, South, West, East - }; + }, Powered { True, False - }; + }, Half { Upper, Lower - }; + }, Hinge { Left, Right - }; + }, Open { True, False - }; - } + }, + }, Blocks => { acacia_button => BlockBehavior::default().no_collision(), { - Face, - Facing, - Powered - }; + Face=Floor, + Facing=North, + Powered=True + }, acacia_door => BlockBehavior::default(), { - Facing, - Half, - Hinge, - Open, - Powered - }; + Facing=North, + Half=Upper, + Hinge=Left, + Open=True, + Powered=True + }, } } diff --git a/codegen/lib/code/blocks.py b/codegen/lib/code/blocks.py index fd268b98..a8f9afd1 100644 --- a/codegen/lib/code/blocks.py +++ b/codegen/lib/code/blocks.py @@ -1,5 +1,6 @@ +from lib.utils import to_camel_case from lib.utils import get_dir_location - +import json BLOCKS_RS_DIR = get_dir_location('../azalea-block/src/blocks.rs') @@ -11,10 +12,45 @@ def generate_blocks(blocks: dict): new_make_block_states_macro_code = [] new_make_block_states_macro_code.append('make_block_states! {') + # Find properties properties = {} - for block_name, block_data in blocks.items(): - block_properties = block_data['properties'] - + for block_data in blocks.values(): + block_properties = block_data.get('properties', {}) properties.update(block_properties) - print(properties) + # Property codegen + new_make_block_states_macro_code.append(' Properties => {') + for property_name, property_variants in properties.items(): + new_make_block_states_macro_code.append( + f' {to_camel_case(property_name)} => {{') + + for variant in property_variants: + new_make_block_states_macro_code.append( + f' {to_camel_case(variant)},') + + new_make_block_states_macro_code.append( + f' }},') + new_make_block_states_macro_code.append(' },') + + # Block codegen + new_make_block_states_macro_code.append(' Blocks => {') + for block_id, block_data in blocks.items(): + block_id = block_id.split(':')[1] + block_states = block_data['states'] + + default_property_variants = {} + for state in block_states: + if state.get('default'): + default_property_variants = state.get('properties', {}) + + # TODO: use burger to generate the blockbehavior + new_make_block_states_macro_code.append( + f' {block_id} => BlockBehavior::default(), {{') + for property in block_data.get('properties', {}): + property_default = default_property_variants.get(property) + new_make_block_states_macro_code.append( + f' {to_camel_case(property)}={to_camel_case(property_default)},') + new_make_block_states_macro_code.append(' },') + new_make_block_states_macro_code.append(' },') + + print('\n'.join(new_make_block_states_macro_code)) diff --git a/codegen/lib/utils.py b/codegen/lib/utils.py index 77a7b2d4..fb43af21 100644 --- a/codegen/lib/utils.py +++ b/codegen/lib/utils.py @@ -11,7 +11,12 @@ def to_snake_case(name: str): def to_camel_case(name: str): s = re.sub('_([a-z])', lambda m: m.group(1).upper(), name) - return s[0].upper() + s[1:] + s = s[0].upper() + s[1:] + # if the first character is a number, we need to add an underscore + # maybe we could convert it to the number name (like 2 would become "two")? + if s[0].isdigit(): + s = f'_{s}' + return s def padded_hex(n: int): -- cgit v1.2.3 From b852bdc48150c0c01f341f73dfb84084b50eda9c Mon Sep 17 00:00:00 2001 From: mat Date: Sat, 11 Jun 2022 09:50:14 -0500 Subject: Separate int properties --- azalea-block/src/blocks.rs | 1656 +++++++++++++++++++++++++++++++++++++------- codegen/lib/code/blocks.py | 8 +- codegen/lib/utils.py | 4 +- 3 files changed, 1397 insertions(+), 271 deletions(-) (limited to 'codegen/lib/utils.py') diff --git a/azalea-block/src/blocks.rs b/azalea-block/src/blocks.rs index 71d04f99..faaafbb1 100644 --- a/azalea-block/src/blocks.rs +++ b/azalea-block/src/blocks.rs @@ -59,7 +59,7 @@ make_block_states! { True, False, }, - Distance { + AcaciaLeavesDistance { _1, _2, _3, @@ -77,11 +77,11 @@ make_block_states! { Y, Z, }, - Stage { + AcaciaSaplingStage { _0, _1, }, - Rotation { + AcaciaSignRotation { _0, _1, _2, @@ -135,8 +135,7 @@ make_block_states! { Low, Tall, }, - Age { - _0, + AzaleaLeavesDistance { _1, _2, _3, @@ -145,12 +144,28 @@ make_block_states! { _6, _7, }, + BambooAge { + _0, + _1, + }, Leaves { None, Small, Large, }, - HoneyLevel { + BambooStage { + _0, + _1, + }, + BeeNestHoneyLevel { + _0, + _1, + _2, + _3, + _4, + _5, + }, + BeehiveHoneyLevel { _0, _1, _2, @@ -158,6 +173,12 @@ make_block_states! { _4, _5, }, + BeetrootsAge { + _0, + _1, + _2, + _3, + }, Attachment { Floor, Ceiling, @@ -170,37 +191,20 @@ make_block_states! { Partial, Full, }, - Occupied { - True, - False, - }, - Part { - Head, - Foot, - }, - Candles { + BirchLeavesDistance { _1, _2, _3, _4, + _5, + _6, + _7, }, - Lit { - True, - False, - }, - HasBottle { - True, - False, - }, - Down { - True, - False, - }, - DragDown { - True, - False, + BirchSaplingStage { + _0, + _1, }, - Bites { + BirchSignRotation { _0, _1, _2, @@ -208,31 +212,53 @@ make_block_states! { _4, _5, _6, + _7, + _8, + _9, + _10, + _11, + _12, + _13, + _14, + _15, }, - SignalFire { - True, - False, + BlackBannerRotation { + _0, + _1, + _2, + _3, + _4, + _5, + _6, + _7, + _8, + _9, + _10, + _11, + _12, + _13, + _14, + _15, }, - Conditional { + Occupied { True, False, }, - Mode { - Save, - Load, - Corner, - Data, + Part { + Head, + Foot, }, - Level { + BlackCandleCandles { _1, _2, _3, + _4, }, - Inverted { + Lit { True, False, }, - Power { + BlueBannerRotation { _0, _1, _2, @@ -250,15 +276,17 @@ make_block_states! { _14, _15, }, - Triggered { - True, - False, + BlueCandleCandles { + _1, + _2, + _3, + _4, }, - HasEye { + HasBottle { True, False, }, - Moisture { + BrownBannerRotation { _0, _1, _2, @@ -267,60 +295,30 @@ make_block_states! { _5, _6, _7, + _8, + _9, + _10, + _11, + _12, + _13, + _14, + _15, }, - Snowy { - True, - False, - }, - Enabled { - True, - False, - }, - Orientation { - DownEast, - DownNorth, - DownSouth, - DownWest, - UpEast, - UpNorth, - UpSouth, - UpWest, - WestUp, - EastUp, - NorthUp, - SouthUp, - }, - HasRecord { - True, - False, + BrownCandleCandles { + _1, + _2, + _3, + _4, }, - Hanging { + Down { True, False, }, - HasBook { + DragDown { True, False, }, - Instrument { - Harp, - Basedrum, - Snare, - Hat, - Bass, - Flute, - Bell, - Guitar, - Chime, - Xylophone, - IronXylophone, - CowBell, - Didgeridoo, - Bit, - Banjo, - Pling, - }, - Note { + CactusAge { _0, _1, _2, @@ -337,80 +335,61 @@ make_block_states! { _13, _14, _15, - _16, - _17, - _18, - _19, - _20, - _21, - _22, - _23, - _24, }, - Extended { - True, - False, + CakeBites { + _0, + _1, + _2, + _3, + _4, + _5, + _6, }, - Short { + SignalFire { True, False, }, - Thickness { - TipMerge, - Tip, - Frustum, - Middle, - Base, - }, - TipDirection { - Up, - Down, - }, - Delay { + CandleCandles { _1, _2, _3, _4, }, - Locked { - True, - False, - }, - Charge { + CarrotsAge { _0, _1, _2, _3, _4, + _5, + _6, + _7, }, - Bottom { - True, - False, - }, - Pulse { - True, - False, - }, - Phase { - Inactive, - Active, - Cooldown, - }, - CanSummon { - True, - False, - }, - Shrieking { + Conditional { True, False, }, - Pickles { + ChorusFlowerAge { + _0, _1, _2, _3, _4, + _5, + }, + CocoaAge { + _0, + _1, + _2, + }, + Mode { + Save, + Load, + Corner, + Data, }, - Layers { + ComposterLevel { + _0, _1, _2, _3, @@ -420,7 +399,7 @@ make_block_states! { _7, _8, }, - OutputPower { + CreeperHeadRotation { _0, _1, _2, @@ -438,28 +417,1171 @@ make_block_states! { _14, _15, }, - Unstable { - True, - False, - }, - Attached { - True, - False, - }, - Disarmed { - True, - False, - }, - Eggs { + CrimsonSignRotation { + _0, _1, _2, _3, _4, + _5, + _6, + _7, + _8, + _9, + _10, + _11, + _12, + _13, + _14, + _15, }, - Hatch { + CyanBannerRotation { _0, _1, _2, + _3, + _4, + _5, + _6, + _7, + _8, + _9, + _10, + _11, + _12, + _13, + _14, + _15, + }, + CyanCandleCandles { + _1, + _2, + _3, + _4, + }, + DarkOakLeavesDistance { + _1, + _2, + _3, + _4, + _5, + _6, + _7, + }, + DarkOakSaplingStage { + _0, + _1, + }, + DarkOakSignRotation { + _0, + _1, + _2, + _3, + _4, + _5, + _6, + _7, + _8, + _9, + _10, + _11, + _12, + _13, + _14, + _15, + }, + Inverted { + True, + False, + }, + DaylightDetectorPower { + _0, + _1, + _2, + _3, + _4, + _5, + _6, + _7, + _8, + _9, + _10, + _11, + _12, + _13, + _14, + _15, + }, + Triggered { + True, + False, + }, + DragonHeadRotation { + _0, + _1, + _2, + _3, + _4, + _5, + _6, + _7, + _8, + _9, + _10, + _11, + _12, + _13, + _14, + _15, + }, + HasEye { + True, + False, + }, + FarmlandMoisture { + _0, + _1, + _2, + _3, + _4, + _5, + _6, + _7, + }, + FireAge { + _0, + _1, + _2, + _3, + _4, + _5, + _6, + _7, + _8, + _9, + _10, + _11, + _12, + _13, + _14, + _15, + }, + FloweringAzaleaLeavesDistance { + _1, + _2, + _3, + _4, + _5, + _6, + _7, + }, + FrostedIceAge { + _0, + _1, + _2, + _3, + }, + Snowy { + True, + False, + }, + GrayBannerRotation { + _0, + _1, + _2, + _3, + _4, + _5, + _6, + _7, + _8, + _9, + _10, + _11, + _12, + _13, + _14, + _15, + }, + GrayCandleCandles { + _1, + _2, + _3, + _4, + }, + GreenBannerRotation { + _0, + _1, + _2, + _3, + _4, + _5, + _6, + _7, + _8, + _9, + _10, + _11, + _12, + _13, + _14, + _15, + }, + GreenCandleCandles { + _1, + _2, + _3, + _4, + }, + HeavyWeightedPressurePlatePower { + _0, + _1, + _2, + _3, + _4, + _5, + _6, + _7, + _8, + _9, + _10, + _11, + _12, + _13, + _14, + _15, + }, + Enabled { + True, + False, + }, + Orientation { + DownEast, + DownNorth, + DownSouth, + DownWest, + UpEast, + UpNorth, + UpSouth, + UpWest, + WestUp, + EastUp, + NorthUp, + SouthUp, + }, + HasRecord { + True, + False, + }, + JungleLeavesDistance { + _1, + _2, + _3, + _4, + _5, + _6, + _7, + }, + JungleSaplingStage { + _0, + _1, + }, + JungleSignRotation { + _0, + _1, + _2, + _3, + _4, + _5, + _6, + _7, + _8, + _9, + _10, + _11, + _12, + _13, + _14, + _15, + }, + KelpAge { + _0, + _1, + _2, + _3, + _4, + _5, + _6, + _7, + _8, + _9, + _10, + _11, + _12, + _13, + _14, + _15, + _16, + _17, + _18, + _19, + _20, + _21, + _22, + _23, + _24, + _25, + }, + Hanging { + True, + False, + }, + LavaLevel { + _0, + _1, + _2, + _3, + _4, + _5, + _6, + _7, + _8, + _9, + _10, + _11, + _12, + _13, + _14, + _15, + }, + HasBook { + True, + False, + }, + LightLevel { + _0, + _1, + _2, + _3, + _4, + _5, + _6, + _7, + _8, + _9, + _10, + _11, + _12, + _13, + _14, + _15, + }, + LightBlueBannerRotation { + _0, + _1, + _2, + _3, + _4, + _5, + _6, + _7, + _8, + _9, + _10, + _11, + _12, + _13, + _14, + _15, + }, + LightBlueCandleCandles { + _1, + _2, + _3, + _4, + }, + LightGrayBannerRotation { + _0, + _1, + _2, + _3, + _4, + _5, + _6, + _7, + _8, + _9, + _10, + _11, + _12, + _13, + _14, + _15, + }, + LightGrayCandleCandles { + _1, + _2, + _3, + _4, + }, + LightWeightedPressurePlatePower { + _0, + _1, + _2, + _3, + _4, + _5, + _6, + _7, + _8, + _9, + _10, + _11, + _12, + _13, + _14, + _15, + }, + LimeBannerRotation { + _0, + _1, + _2, + _3, + _4, + _5, + _6, + _7, + _8, + _9, + _10, + _11, + _12, + _13, + _14, + _15, + }, + LimeCandleCandles { + _1, + _2, + _3, + _4, + }, + MagentaBannerRotation { + _0, + _1, + _2, + _3, + _4, + _5, + _6, + _7, + _8, + _9, + _10, + _11, + _12, + _13, + _14, + _15, + }, + MagentaCandleCandles { + _1, + _2, + _3, + _4, + }, + MangroveLeavesDistance { + _1, + _2, + _3, + _4, + _5, + _6, + _7, + }, + MangrovePropaguleAge { + _0, + _1, + _2, + _3, + _4, + }, + MangrovePropaguleStage { + _0, + _1, + }, + MangroveSignRotation { + _0, + _1, + _2, + _3, + _4, + _5, + _6, + _7, + _8, + _9, + _10, + _11, + _12, + _13, + _14, + _15, + }, + MelonStemAge { + _0, + _1, + _2, + _3, + _4, + _5, + _6, + _7, + }, + NetherWartAge { + _0, + _1, + _2, + _3, + }, + Instrument { + Harp, + Basedrum, + Snare, + Hat, + Bass, + Flute, + Bell, + Guitar, + Chime, + Xylophone, + IronXylophone, + CowBell, + Didgeridoo, + Bit, + Banjo, + Pling, + }, + NoteBlockNote { + _0, + _1, + _2, + _3, + _4, + _5, + _6, + _7, + _8, + _9, + _10, + _11, + _12, + _13, + _14, + _15, + _16, + _17, + _18, + _19, + _20, + _21, + _22, + _23, + _24, + }, + OakLeavesDistance { + _1, + _2, + _3, + _4, + _5, + _6, + _7, + }, + OakSaplingStage { + _0, + _1, + }, + OakSignRotation { + _0, + _1, + _2, + _3, + _4, + _5, + _6, + _7, + _8, + _9, + _10, + _11, + _12, + _13, + _14, + _15, + }, + OrangeBannerRotation { + _0, + _1, + _2, + _3, + _4, + _5, + _6, + _7, + _8, + _9, + _10, + _11, + _12, + _13, + _14, + _15, + }, + OrangeCandleCandles { + _1, + _2, + _3, + _4, + }, + PinkBannerRotation { + _0, + _1, + _2, + _3, + _4, + _5, + _6, + _7, + _8, + _9, + _10, + _11, + _12, + _13, + _14, + _15, + }, + PinkCandleCandles { + _1, + _2, + _3, + _4, + }, + Extended { + True, + False, + }, + Short { + True, + False, + }, + PlayerHeadRotation { + _0, + _1, + _2, + _3, + _4, + _5, + _6, + _7, + _8, + _9, + _10, + _11, + _12, + _13, + _14, + _15, + }, + Thickness { + TipMerge, + Tip, + Frustum, + Middle, + Base, + }, + TipDirection { + Up, + Down, + }, + PotatoesAge { + _0, + _1, + _2, + _3, + _4, + _5, + _6, + _7, + }, + PowderSnowCauldronLevel { + _1, + _2, + _3, + }, + PumpkinStemAge { + _0, + _1, + _2, + _3, + _4, + _5, + _6, + _7, + }, + PurpleBannerRotation { + _0, + _1, + _2, + _3, + _4, + _5, + _6, + _7, + _8, + _9, + _10, + _11, + _12, + _13, + _14, + _15, + }, + PurpleCandleCandles { + _1, + _2, + _3, + _4, + }, + RedBannerRotation { + _0, + _1, + _2, + _3, + _4, + _5, + _6, + _7, + _8, + _9, + _10, + _11, + _12, + _13, + _14, + _15, + }, + RedCandleCandles { + _1, + _2, + _3, + _4, + }, + RedstoneWirePower { + _0, + _1, + _2, + _3, + _4, + _5, + _6, + _7, + _8, + _9, + _10, + _11, + _12, + _13, + _14, + _15, + }, + RepeaterDelay { + _1, + _2, + _3, + _4, + }, + Locked { + True, + False, + }, + RespawnAnchorCharge { + _0, + _1, + _2, + _3, + _4, + }, + Bottom { + True, + False, + }, + ScaffoldingDistance { + _0, + _1, + _2, + _3, + _4, + _5, + _6, + _7, + }, + Pulse { + True, + False, + }, + SculkSensorPower { + _0, + _1, + _2, + _3, + _4, + _5, + _6, + _7, + _8, + _9, + _10, + _11, + _12, + _13, + _14, + _15, + }, + Phase { + Inactive, + Active, + Cooldown, + }, + CanSummon { + True, + False, + }, + Shrieking { + True, + False, + }, + SeaPicklePickles { + _1, + _2, + _3, + _4, + }, + SkeletonSkullRotation { + _0, + _1, + _2, + _3, + _4, + _5, + _6, + _7, + _8, + _9, + _10, + _11, + _12, + _13, + _14, + _15, + }, + SnowLayers { + _1, + _2, + _3, + _4, + _5, + _6, + _7, + _8, + }, + SpruceLeavesDistance { + _1, + _2, + _3, + _4, + _5, + _6, + _7, + }, + SpruceSaplingStage { + _0, + _1, + }, + SpruceSignRotation { + _0, + _1, + _2, + _3, + _4, + _5, + _6, + _7, + _8, + _9, + _10, + _11, + _12, + _13, + _14, + _15, + }, + SugarCaneAge { + _0, + _1, + _2, + _3, + _4, + _5, + _6, + _7, + _8, + _9, + _10, + _11, + _12, + _13, + _14, + _15, + }, + SweetBerryBushAge { + _0, + _1, + _2, + _3, + }, + TargetOutputPower { + _0, + _1, + _2, + _3, + _4, + _5, + _6, + _7, + _8, + _9, + _10, + _11, + _12, + _13, + _14, + _15, + }, + Unstable { + True, + False, + }, + Attached { + True, + False, + }, + Disarmed { + True, + False, + }, + TurtleEggEggs { + _1, + _2, + _3, + _4, + }, + TurtleEggHatch { + _0, + _1, + _2, + }, + TwistingVinesAge { + _0, + _1, + _2, + _3, + _4, + _5, + _6, + _7, + _8, + _9, + _10, + _11, + _12, + _13, + _14, + _15, + _16, + _17, + _18, + _19, + _20, + _21, + _22, + _23, + _24, + _25, + }, + WarpedSignRotation { + _0, + _1, + _2, + _3, + _4, + _5, + _6, + _7, + _8, + _9, + _10, + _11, + _12, + _13, + _14, + _15, + }, + WaterLevel { + _0, + _1, + _2, + _3, + _4, + _5, + _6, + _7, + _8, + _9, + _10, + _11, + _12, + _13, + _14, + _15, + }, + WaterCauldronLevel { + _1, + _2, + _3, + }, + WeepingVinesAge { + _0, + _1, + _2, + _3, + _4, + _5, + _6, + _7, + _8, + _9, + _10, + _11, + _12, + _13, + _14, + _15, + _16, + _17, + _18, + _19, + _20, + _21, + _22, + _23, + _24, + _25, + }, + WheatAge { + _0, + _1, + _2, + _3, + _4, + _5, + _6, + _7, + }, + WhiteBannerRotation { + _0, + _1, + _2, + _3, + _4, + _5, + _6, + _7, + _8, + _9, + _10, + _11, + _12, + _13, + _14, + _15, + }, + WhiteCandleCandles { + _1, + _2, + _3, + _4, + }, + WitherSkeletonSkullRotation { + _0, + _1, + _2, + _3, + _4, + _5, + _6, + _7, + _8, + _9, + _10, + _11, + _12, + _13, + _14, + _15, + }, + YellowBannerRotation { + _0, + _1, + _2, + _3, + _4, + _5, + _6, + _7, + _8, + _9, + _10, + _11, + _12, + _13, + _14, + _15, + }, + YellowCandleCandles { + _1, + _2, + _3, + _4, + }, + ZombieHeadRotation { + _0, + _1, + _2, + _3, + _4, + _5, + _6, + _7, + _8, + _9, + _10, + _11, + _12, + _13, + _14, + _15, }, }, Blocks => { @@ -489,7 +1611,7 @@ make_block_states! { InWall=False, }, acacia_leaves => BlockBehavior::default(), { - Distance=_7, + AcaciaLeavesDistance=_7, Persistent=False, Waterlogged=False, }, @@ -502,10 +1624,10 @@ make_block_states! { Powered=False, }, acacia_sapling => BlockBehavior::default(), { - Stage=_0, + AcaciaSaplingStage=_0, }, acacia_sign => BlockBehavior::default(), { - Rotation=_0, + AcaciaSignRotation=_0, Waterlogged=False, }, acacia_slab => BlockBehavior::default(), { @@ -581,16 +1703,16 @@ make_block_states! { azalea => BlockBehavior::default(), { }, azalea_leaves => BlockBehavior::default(), { - Distance=_7, + AzaleaLeavesDistance=_7, Persistent=False, Waterlogged=False, }, azure_bluet => BlockBehavior::default(), { }, bamboo => BlockBehavior::default(), { - Age=_0, + BambooAge=_0, Leaves=None, - Stage=_0, + BambooStage=_0, }, bamboo_sapling => BlockBehavior::default(), { }, @@ -608,15 +1730,15 @@ make_block_states! { bedrock => BlockBehavior::default(), { }, bee_nest => BlockBehavior::default(), { - HoneyLevel=_0, + BeeNestHoneyLevel=_0, Facing=North, }, beehive => BlockBehavior::default(), { - HoneyLevel=_0, + BeehiveHoneyLevel=_0, Facing=North, }, beetroots => BlockBehavior::default(), { - Age=_0, + BeetrootsAge=_0, }, bell => BlockBehavior::default(), { Facing=North, @@ -658,7 +1780,7 @@ make_block_states! { InWall=False, }, birch_leaves => BlockBehavior::default(), { - Distance=_7, + BirchLeavesDistance=_7, Persistent=False, Waterlogged=False, }, @@ -671,10 +1793,10 @@ make_block_states! { Powered=False, }, birch_sapling => BlockBehavior::default(), { - Stage=_0, + BirchSaplingStage=_0, }, birch_sign => BlockBehavior::default(), { - Rotation=_0, + BirchSignRotation=_0, Waterlogged=False, }, birch_slab => BlockBehavior::default(), { @@ -702,7 +1824,7 @@ make_block_states! { Axis=Y, }, black_banner => BlockBehavior::default(), { - Rotation=_0, + BlackBannerRotation=_0, }, black_bed => BlockBehavior::default(), { Facing=North, @@ -710,7 +1832,7 @@ make_block_states! { Occupied=False, }, black_candle => BlockBehavior::default(), { - Candles=_1, + BlackCandleCandles=_1, Lit=False, Waterlogged=False, }, @@ -770,7 +1892,7 @@ make_block_states! { Lit=False, }, blue_banner => BlockBehavior::default(), { - Rotation=_0, + BlueBannerRotation=_0, }, blue_bed => BlockBehavior::default(), { Facing=North, @@ -778,7 +1900,7 @@ make_block_states! { Occupied=False, }, blue_candle => BlockBehavior::default(), { - Candles=_1, + BlueCandleCandles=_1, Lit=False, Waterlogged=False, }, @@ -860,7 +1982,7 @@ make_block_states! { bricks => BlockBehavior::default(), { }, brown_banner => BlockBehavior::default(), { - Rotation=_0, + BrownBannerRotation=_0, }, brown_bed => BlockBehavior::default(), { Facing=North, @@ -868,7 +1990,7 @@ make_block_states! { Occupied=False, }, brown_candle => BlockBehavior::default(), { - Candles=_1, + BrownCandleCandles=_1, Lit=False, Waterlogged=False, }, @@ -931,10 +2053,10 @@ make_block_states! { budding_amethyst => BlockBehavior::default(), { }, cactus => BlockBehavior::default(), { - Age=_0, + CactusAge=_0, }, cake => BlockBehavior::default(), { - Bites=_0, + CakeBites=_0, }, calcite => BlockBehavior::default(), { }, @@ -945,7 +2067,7 @@ make_block_states! { Facing=North, }, candle => BlockBehavior::default(), { - Candles=_1, + CandleCandles=_1, Lit=False, Waterlogged=False, }, @@ -953,7 +2075,7 @@ make_block_states! { Lit=False, }, carrots => BlockBehavior::default(), { - Age=_0, + CarrotsAge=_0, }, cartography_table => BlockBehavior::default(), { }, @@ -999,7 +2121,7 @@ make_block_states! { chiseled_stone_bricks => BlockBehavior::default(), { }, chorus_flower => BlockBehavior::default(), { - Age=_0, + ChorusFlowerAge=_0, }, chorus_plant => BlockBehavior::default(), { North=False, @@ -1061,7 +2183,7 @@ make_block_states! { }, cocoa => BlockBehavior::default(), { Facing=North, - Age=_0, + CocoaAge=_0, }, command_block => BlockBehavior::default(), { Facing=North, @@ -1073,7 +2195,7 @@ make_block_states! { Powered=False, }, composter => BlockBehavior::default(), { - Level=_0, + ComposterLevel=_0, }, conduit => BlockBehavior::default(), { Waterlogged=True, @@ -1097,7 +2219,7 @@ make_block_states! { crafting_table => BlockBehavior::default(), { }, creeper_head => BlockBehavior::default(), { - Rotation=_0, + CreeperHeadRotation=_0, }, creeper_wall_head => BlockBehavior::default(), { Facing=North, @@ -1142,7 +2264,7 @@ make_block_states! { crimson_roots => BlockBehavior::default(), { }, crimson_sign => BlockBehavior::default(), { - Rotation=_0, + CrimsonSignRotation=_0, Waterlogged=False, }, crimson_slab => BlockBehavior::default(), { @@ -1196,7 +2318,7 @@ make_block_states! { Waterlogged=False, }, cyan_banner => BlockBehavior::default(), { - Rotation=_0, + CyanBannerRotation=_0, }, cyan_bed => BlockBehavior::default(), { Facing=North, @@ -1204,7 +2326,7 @@ make_block_states! { Occupied=False, }, cyan_candle => BlockBehavior::default(), { - Candles=_1, + CyanCandleCandles=_1, Lit=False, Waterlogged=False, }, @@ -1270,7 +2392,7 @@ make_block_states! { InWall=False, }, dark_oak_leaves => BlockBehavior::default(), { - Distance=_7, + DarkOakLeavesDistance=_7, Persistent=False, Waterlogged=False, }, @@ -1283,10 +2405,10 @@ make_block_states! { Powered=False, }, dark_oak_sapling => BlockBehavior::default(), { - Stage=_0, + DarkOakSaplingStage=_0, }, dark_oak_sign => BlockBehavior::default(), { - Rotation=_0, + DarkOakSignRotation=_0, Waterlogged=False, }, dark_oak_slab => BlockBehavior::default(), { @@ -1326,7 +2448,7 @@ make_block_states! { Waterlogged=False, }, daylight_detector => BlockBehavior::default(), { - Power=_0, + DaylightDetectorPower=_0, Inverted=False, }, dead_brain_coral => BlockBehavior::default(), { @@ -1491,7 +2613,7 @@ make_block_states! { dragon_egg => BlockBehavior::default(), { }, dragon_head => BlockBehavior::default(), { - Rotation=_0, + DragonHeadRotation=_0, }, dragon_wall_head => BlockBehavior::default(), { Facing=North, @@ -1562,12 +2684,12 @@ make_block_states! { Waterlogged=False, }, farmland => BlockBehavior::default(), { - Moisture=_0, + FarmlandMoisture=_0, }, fern => BlockBehavior::default(), { }, fire => BlockBehavior::default(), { - Age=_0, + FireAge=_0, North=False, East=False, South=False, @@ -1593,14 +2715,14 @@ make_block_states! { flowering_azalea => BlockBehavior::default(), { }, flowering_azalea_leaves => BlockBehavior::default(), { - Distance=_7, + FloweringAzaleaLeavesDistance=_7, Persistent=False, Waterlogged=False, }, frogspawn => BlockBehavior::default(), { }, frosted_ice => BlockBehavior::default(), { - Age=_0, + FrostedIceAge=_0, }, furnace => BlockBehavior::default(), { Facing=North, @@ -1653,7 +2775,7 @@ make_block_states! { gravel => BlockBehavior::default(), { }, gray_banner => BlockBehavior::default(), { - Rotation=_0, + GrayBannerRotation=_0, }, gray_bed => BlockBehavior::default(), { Facing=North, @@ -1661,7 +2783,7 @@ make_block_states! { Occupied=False, }, gray_candle => BlockBehavior::default(), { - Candles=_1, + GrayCandleCandles=_1, Lit=False, Waterlogged=False, }, @@ -1697,7 +2819,7 @@ make_block_states! { gray_wool => BlockBehavior::default(), { }, green_banner => BlockBehavior::default(), { - Rotation=_0, + GreenBannerRotation=_0, }, green_bed => BlockBehavior::default(), { Facing=North, @@ -1705,7 +2827,7 @@ make_block_states! { Occupied=False, }, green_candle => BlockBehavior::default(), { - Candles=_1, + GreenCandleCandles=_1, Lit=False, Waterlogged=False, }, @@ -1751,7 +2873,7 @@ make_block_states! { Axis=Y, }, heavy_weighted_pressure_plate => BlockBehavior::default(), { - Power=_0, + HeavyWeightedPressurePlatePower=_0, }, honey_block => BlockBehavior::default(), { }, @@ -1849,7 +2971,7 @@ make_block_states! { InWall=False, }, jungle_leaves => BlockBehavior::default(), { - Distance=_7, + JungleLeavesDistance=_7, Persistent=False, Waterlogged=False, }, @@ -1862,10 +2984,10 @@ make_block_states! { Powered=False, }, jungle_sapling => BlockBehavior::default(), { - Stage=_0, + JungleSaplingStage=_0, }, jungle_sign => BlockBehavior::default(), { - Rotation=_0, + JungleSignRotation=_0, Waterlogged=False, }, jungle_slab => BlockBehavior::default(), { @@ -1893,7 +3015,7 @@ make_block_states! { Axis=Y, }, kelp => BlockBehavior::default(), { - Age=_0, + KelpAge=_0, }, kelp_plant => BlockBehavior::default(), { }, @@ -1917,7 +3039,7 @@ make_block_states! { Half=Lower, }, lava => BlockBehavior::default(), { - Level=_0, + LavaLevel=_0, }, lava_cauldron => BlockBehavior::default(), { }, @@ -1932,11 +3054,11 @@ make_block_states! { Powered=False, }, light => BlockBehavior::default(), { - Level=_15, + LightLevel=_15, Waterlogged=False, }, light_blue_banner => BlockBehavior::default(), { - Rotation=_0, + LightBlueBannerRotation=_0, }, light_blue_bed => BlockBehavior::default(), { Facing=North, @@ -1944,7 +3066,7 @@ make_block_states! { Occupied=False, }, light_blue_candle => BlockBehavior::default(), { - Candles=_1, + LightBlueCandleCandles=_1, Lit=False, Waterlogged=False, }, @@ -1980,7 +3102,7 @@ make_block_states! { light_blue_wool => BlockBehavior::default(), { }, light_gray_banner => BlockBehavior::default(), { - Rotation=_0, + LightGrayBannerRotation=_0, }, light_gray_bed => BlockBehavior::default(), { Facing=North, @@ -1988,7 +3110,7 @@ make_block_states! { Occupied=False, }, light_gray_candle => BlockBehavior::default(), { - Candles=_1, + LightGrayCandleCandles=_1, Lit=False, Waterlogged=False, }, @@ -2024,7 +3146,7 @@ make_block_states! { light_gray_wool => BlockBehavior::default(), { }, light_weighted_pressure_plate => BlockBehavior::default(), { - Power=_0, + LightWeightedPressurePlatePower=_0, }, lightning_rod => BlockBehavior::default(), { Facing=Up, @@ -2039,7 +3161,7 @@ make_block_states! { lily_pad => BlockBehavior::default(), { }, lime_banner => BlockBehavior::default(), { - Rotation=_0, + LimeBannerRotation=_0, }, lime_bed => BlockBehavior::default(), { Facing=North, @@ -2047,7 +3169,7 @@ make_block_states! { Occupied=False, }, lime_candle => BlockBehavior::default(), { - Candles=_1, + LimeCandleCandles=_1, Lit=False, Waterlogged=False, }, @@ -2088,7 +3210,7 @@ make_block_states! { Facing=North, }, magenta_banner => BlockBehavior::default(), { - Rotation=_0, + MagentaBannerRotation=_0, }, magenta_bed => BlockBehavior::default(), { Facing=North, @@ -2096,7 +3218,7 @@ make_block_states! { Occupied=False, }, magenta_candle => BlockBehavior::default(), { - Candles=_1, + MagentaCandleCandles=_1, Lit=False, Waterlogged=False, }, @@ -2159,7 +3281,7 @@ make_block_states! { InWall=False, }, mangrove_leaves => BlockBehavior::default(), { - Distance=_7, + MangroveLeavesDistance=_7, Persistent=False, Waterlogged=False, }, @@ -2172,8 +3294,8 @@ make_block_states! { Powered=False, }, mangrove_propagule => BlockBehavior::default(), { - Stage=_0, - Age=_0, + MangrovePropaguleStage=_0, + MangrovePropaguleAge=_0, Waterlogged=False, Hanging=False, }, @@ -2181,7 +3303,7 @@ make_block_states! { Waterlogged=False, }, mangrove_sign => BlockBehavior::default(), { - Rotation=_0, + MangroveSignRotation=_0, Waterlogged=False, }, mangrove_slab => BlockBehavior::default(), { @@ -2215,7 +3337,7 @@ make_block_states! { melon => BlockBehavior::default(), { }, melon_stem => BlockBehavior::default(), { - Age=_0, + MelonStemAge=_0, }, moss_block => BlockBehavior::default(), { }, @@ -2338,7 +3460,7 @@ make_block_states! { nether_sprouts => BlockBehavior::default(), { }, nether_wart => BlockBehavior::default(), { - Age=_0, + NetherWartAge=_0, }, nether_wart_block => BlockBehavior::default(), { }, @@ -2349,7 +3471,7 @@ make_block_states! { note_block => BlockBehavior::default(), { Instrument=Harp, Powered=False, - Note=_0, + NoteBlockNote=_0, }, oak_button => BlockBehavior::default(), { Facing=North, @@ -2377,7 +3499,7 @@ make_block_states! { InWall=False, }, oak_leaves => BlockBehavior::default(), { - Distance=_7, + OakLeavesDistance=_7, Persistent=False, Waterlogged=False, }, @@ -2390,10 +3512,10 @@ make_block_states! { Powered=False, }, oak_sapling => BlockBehavior::default(), { - Stage=_0, + OakSaplingStage=_0, }, oak_sign => BlockBehavior::default(), { - Rotation=_0, + OakSignRotation=_0, Waterlogged=False, }, oak_slab => BlockBehavior::default(), { @@ -2430,7 +3552,7 @@ make_block_states! { Axis=Y, }, orange_banner => BlockBehavior::default(), { - Rotation=_0, + OrangeBannerRotation=_0, }, orange_bed => BlockBehavior::default(), { Facing=North, @@ -2438,7 +3560,7 @@ make_block_states! { Occupied=False, }, orange_candle => BlockBehavior::default(), { - Candles=_1, + OrangeCandleCandles=_1, Lit=False, Waterlogged=False, }, @@ -2506,7 +3628,7 @@ make_block_states! { Waterlogged=False, }, pink_banner => BlockBehavior::default(), { - Rotation=_0, + PinkBannerRotation=_0, }, pink_bed => BlockBehavior::default(), { Facing=North, @@ -2514,7 +3636,7 @@ make_block_states! { Occupied=False, }, pink_candle => BlockBehavior::default(), { - Candles=_1, + PinkCandleCandles=_1, Lit=False, Waterlogged=False, }, @@ -2561,7 +3683,7 @@ make_block_states! { Short=False, }, player_head => BlockBehavior::default(), { - Rotation=_0, + PlayerHeadRotation=_0, }, player_wall_head => BlockBehavior::default(), { Facing=North, @@ -2684,7 +3806,7 @@ make_block_states! { poppy => BlockBehavior::default(), { }, potatoes => BlockBehavior::default(), { - Age=_0, + PotatoesAge=_0, }, potted_acacia_sapling => BlockBehavior::default(), { }, @@ -2753,7 +3875,7 @@ make_block_states! { powder_snow => BlockBehavior::default(), { }, powder_snow_cauldron => BlockBehavior::default(), { - Level=_1, + PowderSnowCauldronLevel=_1, }, powered_rail => BlockBehavior::default(), { Shape=NorthSouth, @@ -2795,10 +3917,10 @@ make_block_states! { pumpkin => BlockBehavior::default(), { }, pumpkin_stem => BlockBehavior::default(), { - Age=_0, + PumpkinStemAge=_0, }, purple_banner => BlockBehavior::default(), { - Rotation=_0, + PurpleBannerRotation=_0, }, purple_bed => BlockBehavior::default(), { Facing=North, @@ -2806,7 +3928,7 @@ make_block_states! { Occupied=False, }, purple_candle => BlockBehavior::default(), { - Candles=_1, + PurpleCandleCandles=_1, Lit=False, Waterlogged=False, }, @@ -2884,7 +4006,7 @@ make_block_states! { raw_iron_block => BlockBehavior::default(), { }, red_banner => BlockBehavior::default(), { - Rotation=_0, + RedBannerRotation=_0, }, red_bed => BlockBehavior::default(), { Facing=North, @@ -2892,7 +4014,7 @@ make_block_states! { Occupied=False, }, red_candle => BlockBehavior::default(), { - Candles=_1, + RedCandleCandles=_1, Lit=False, Waterlogged=False, }, @@ -3001,13 +4123,13 @@ make_block_states! { East=None, South=None, West=None, - Power=_0, + RedstoneWirePower=_0, }, reinforced_deepslate => BlockBehavior::default(), { }, repeater => BlockBehavior::default(), { Facing=North, - Delay=_1, + RepeaterDelay=_1, Locked=False, Powered=False, }, @@ -3016,7 +4138,7 @@ make_block_states! { Conditional=False, }, respawn_anchor => BlockBehavior::default(), { - Charge=_0, + RespawnAnchorCharge=_0, }, rooted_dirt => BlockBehavior::default(), { }, @@ -3046,7 +4168,7 @@ make_block_states! { Waterlogged=False, }, scaffolding => BlockBehavior::default(), { - Distance=_7, + ScaffoldingDistance=_7, Waterlogged=False, Bottom=False, }, @@ -3057,7 +4179,7 @@ make_block_states! { }, sculk_sensor => BlockBehavior::default(), { Phase=Inactive, - Power=_0, + SculkSensorPower=_0, Waterlogged=False, }, sculk_shrieker => BlockBehavior::default(), { @@ -3070,7 +4192,7 @@ make_block_states! { sea_lantern => BlockBehavior::default(), { }, sea_pickle => BlockBehavior::default(), { - Pickles=_1, + SeaPicklePickles=_1, Waterlogged=True, }, seagrass => BlockBehavior::default(), { @@ -3081,7 +4203,7 @@ make_block_states! { Facing=Up, }, skeleton_skull => BlockBehavior::default(), { - Rotation=_0, + SkeletonSkullRotation=_0, }, skeleton_wall_skull => BlockBehavior::default(), { Facing=North, @@ -3148,7 +4270,7 @@ make_block_states! { Waterlogged=False, }, snow => BlockBehavior::default(), { - Layers=_1, + SnowLayers=_1, }, snow_block => BlockBehavior::default(), { }, @@ -3205,7 +4327,7 @@ make_block_states! { InWall=False, }, spruce_leaves => BlockBehavior::default(), { - Distance=_7, + SpruceLeavesDistance=_7, Persistent=False, Waterlogged=False, }, @@ -3218,10 +4340,10 @@ make_block_states! { Powered=False, }, spruce_sapling => BlockBehavior::default(), { - Stage=_0, + SpruceSaplingStage=_0, }, spruce_sign => BlockBehavior::default(), { - Rotation=_0, + SpruceSignRotation=_0, Waterlogged=False, }, spruce_slab => BlockBehavior::default(), { @@ -3355,13 +4477,13 @@ make_block_states! { structure_void => BlockBehavior::default(), { }, sugar_cane => BlockBehavior::default(), { - Age=_0, + SugarCaneAge=_0, }, sunflower => BlockBehavior::default(), { Half=Lower, }, sweet_berry_bush => BlockBehavior::default(), { - Age=_0, + SweetBerryBushAge=_0, }, tall_grass => BlockBehavior::default(), { Half=Lower, @@ -3370,7 +4492,7 @@ make_block_states! { Half=Lower, }, target => BlockBehavior::default(), { - OutputPower=_0, + TargetOutputPower=_0, }, terracotta => BlockBehavior::default(), { }, @@ -3415,11 +4537,11 @@ make_block_states! { tuff => BlockBehavior::default(), { }, turtle_egg => BlockBehavior::default(), { - Hatch=_0, - Eggs=_1, + TurtleEggHatch=_0, + TurtleEggEggs=_1, }, twisting_vines => BlockBehavior::default(), { - Age=_0, + TwistingVinesAge=_0, }, twisting_vines_plant => BlockBehavior::default(), { }, @@ -3478,7 +4600,7 @@ make_block_states! { warped_roots => BlockBehavior::default(), { }, warped_sign => BlockBehavior::default(), { - Rotation=_0, + WarpedSignRotation=_0, Waterlogged=False, }, warped_slab => BlockBehavior::default(), { @@ -3508,10 +4630,10 @@ make_block_states! { warped_wart_block => BlockBehavior::default(), { }, water => BlockBehavior::default(), { - Level=_0, + WaterLevel=_0, }, water_cauldron => BlockBehavior::default(), { - Level=_1, + WaterCauldronLevel=_1, }, waxed_copper_block => BlockBehavior::default(), { }, @@ -3584,17 +4706,17 @@ make_block_states! { Waterlogged=False, }, weeping_vines => BlockBehavior::default(), { - Age=_0, + WeepingVinesAge=_0, }, weeping_vines_plant => BlockBehavior::default(), { }, wet_sponge => BlockBehavior::default(), { }, wheat => BlockBehavior::default(), { - Age=_0, + WheatAge=_0, }, white_banner => BlockBehavior::default(), { - Rotation=_0, + WhiteBannerRotation=_0, }, white_bed => BlockBehavior::default(), { Facing=North, @@ -3602,7 +4724,7 @@ make_block_states! { Occupied=False, }, white_candle => BlockBehavior::default(), { - Candles=_1, + WhiteCandleCandles=_1, Lit=False, Waterlogged=False, }, @@ -3642,13 +4764,13 @@ make_block_states! { wither_rose => BlockBehavior::default(), { }, wither_skeleton_skull => BlockBehavior::default(), { - Rotation=_0, + WitherSkeletonSkullRotation=_0, }, wither_skeleton_wall_skull => BlockBehavior::default(), { Facing=North, }, yellow_banner => BlockBehavior::default(), { - Rotation=_0, + YellowBannerRotation=_0, }, yellow_bed => BlockBehavior::default(), { Facing=North, @@ -3656,7 +4778,7 @@ make_block_states! { Occupied=False, }, yellow_candle => BlockBehavior::default(), { - Candles=_1, + YellowCandleCandles=_1, Lit=False, Waterlogged=False, }, @@ -3692,7 +4814,7 @@ make_block_states! { yellow_wool => BlockBehavior::default(), { }, zombie_head => BlockBehavior::default(), { - Rotation=_0, + ZombieHeadRotation=_0, }, zombie_wall_head => BlockBehavior::default(), { Facing=North, diff --git a/codegen/lib/code/blocks.py b/codegen/lib/code/blocks.py index a5c9e2c6..d2fe6da2 100644 --- a/codegen/lib/code/blocks.py +++ b/codegen/lib/code/blocks.py @@ -1,7 +1,7 @@ +from lib.utils import upper_first_letter from lib.utils import get_dir_location from lib.utils import to_camel_case from ..mappings import Mappings -import json BLOCKS_RS_DIR = get_dir_location('../azalea-block/src/blocks.rs') @@ -25,7 +25,9 @@ def generate_blocks(blocks_burger: dict, blocks_report: dict, mappings: Mappings if property_name: break assert property_name - property_name = property_name.lower() + property_name = to_camel_case(property_name.lower()) + if property['type'] == 'int': + property_name = to_camel_case(block_data_burger['text_id']) + property_name return property_name # Find properties @@ -84,7 +86,7 @@ def generate_blocks(blocks_burger: dict, blocks_report: dict, mappings: Mappings 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)},') + f' {property_struct_name}={to_camel_case(property_default)},') # new_make_block_states_macro_code.append( # f' {to_camel_case(state)}=TODO,') new_make_block_states_macro_code.append(' },') diff --git a/codegen/lib/utils.py b/codegen/lib/utils.py index fb43af21..3887bb35 100644 --- a/codegen/lib/utils.py +++ b/codegen/lib/utils.py @@ -11,13 +11,15 @@ def to_snake_case(name: str): def to_camel_case(name: str): s = re.sub('_([a-z])', lambda m: m.group(1).upper(), name) - s = s[0].upper() + s[1:] + s = upper_first_letter(s) # if the first character is a number, we need to add an underscore # maybe we could convert it to the number name (like 2 would become "two")? if s[0].isdigit(): s = f'_{s}' return s +def upper_first_letter(name: str): + return name[0].upper() + name[1:] def padded_hex(n: int): return f'0x{n:02x}' -- cgit v1.2.3