mirror of
https://github.com/mat-1/azalea.git
synced 2025-08-02 14:26:04 +00:00
Fix all the errors
This commit is contained in:
parent
e79e58da36
commit
e36095c2b1
5 changed files with 136 additions and 4976 deletions
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
|
@ -1,3 +1,3 @@
|
||||||
{
|
{
|
||||||
"editor.formatOnSave": false
|
"editor.formatOnSave": true
|
||||||
}
|
}
|
40
Cargo.lock
generated
40
Cargo.lock
generated
|
@ -45,9 +45,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "async-trait"
|
name = "async-trait"
|
||||||
version = "0.1.53"
|
version = "0.1.56"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ed6aa3524a2dfcf9fe180c51eae2b58738348d819517ceadf95789c51fff7600"
|
checksum = "96cf8829f67d2eab0b2dfa42c5d0ef737e0724e4a82b01b3e292456202b19716"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
|
@ -236,9 +236,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bumpalo"
|
name = "bumpalo"
|
||||||
version = "3.9.1"
|
version = "3.10.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a4a45a46ab1f2412e53d3a0ade76ffad2025804294569aae387231a0cd6e0899"
|
checksum = "37ccbd214614c6783386c1af30caf03192f17891059cecc394b4fb119e363de3"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "byteorder"
|
name = "byteorder"
|
||||||
|
@ -474,13 +474,11 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "flate2"
|
name = "flate2"
|
||||||
version = "1.0.23"
|
version = "1.0.24"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b39522e96686d38f4bc984b9198e3a0613264abaebaff2c5c918bfa6b6da09af"
|
checksum = "f82b0f4c27ad9f8bfd1f3208d882da2b09c301bc1c828fd3a00d0216d2fbbff6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
|
||||||
"crc32fast",
|
"crc32fast",
|
||||||
"libc",
|
|
||||||
"miniz_oxide",
|
"miniz_oxide",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -745,9 +743,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "miniz_oxide"
|
name = "miniz_oxide"
|
||||||
version = "0.5.1"
|
version = "0.5.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d2b29bd4bc3f33391105ebee3589c19197c4271e3e5a9ec9bfe8127eeff8f082"
|
checksum = "6f5c75688da582b8ffc1f1799e9db273f32133c49e048f614d22ec3256773ccc"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"adler",
|
"adler",
|
||||||
]
|
]
|
||||||
|
@ -1120,9 +1118,9 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "semver"
|
name = "semver"
|
||||||
version = "1.0.9"
|
version = "1.0.10"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8cb243bdfdb5936c8dc3c45762a19d12ab4550cdc753bc247637d4ec35a040fd"
|
checksum = "a41d061efea015927ac527063765e73601444cdc344ba855bc7bd44578b25e1c"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde"
|
name = "serde"
|
||||||
|
@ -1223,9 +1221,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
version = "1.0.95"
|
version = "1.0.96"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "fbaf6116ab8924f39d52792136fb74fd60a80194cf1b1c6ffa6453eef1c3f942"
|
checksum = "0748dd251e24453cb8717f0354206b91557e4ec8703673a4b30208f2abaf1ebf"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
|
@ -1288,9 +1286,9 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tokio"
|
name = "tokio"
|
||||||
version = "1.18.2"
|
version = "1.19.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4903bf0427cf68dddd5aa6a93220756f8be0c34fcfa9f5e6191e103e15a31395"
|
checksum = "c51a52ed6686dd62c320f9b89299e9dfb46f730c7a48e635c19f21d116cb1439"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytes",
|
"bytes",
|
||||||
"libc",
|
"libc",
|
||||||
|
@ -1306,9 +1304,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tokio-macros"
|
name = "tokio-macros"
|
||||||
version = "1.7.0"
|
version = "1.8.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b557f72f448c511a979e2564e55d74e6c4432fc96ff4f6241bc6bded342643b7"
|
checksum = "9724f9a975fb987ef7a3cd9be0350edcbe130698af5b8f7a631e23d42d052484"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
|
@ -1392,12 +1390,6 @@ version = "1.0.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d22af068fba1eb5edcb4aea19d382b2a3deb4c8f9d475c589b6ada9e0fd493ee"
|
checksum = "d22af068fba1eb5edcb4aea19d382b2a3deb4c8f9d475c589b6ada9e0fd493ee"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "unicode-ident"
|
|
||||||
version = "1.0.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "d22af068fba1eb5edcb4aea19d382b2a3deb4c8f9d475c589b6ada9e0fd493ee"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-normalization"
|
name = "unicode-normalization"
|
||||||
version = "0.1.19"
|
version = "0.1.19"
|
||||||
|
|
|
@ -8,12 +8,13 @@ use syn::{
|
||||||
parse::{Parse, ParseStream, Result},
|
parse::{Parse, ParseStream, Result},
|
||||||
parse_macro_input,
|
parse_macro_input,
|
||||||
punctuated::Punctuated,
|
punctuated::Punctuated,
|
||||||
Expr, Ident, Token,
|
Expr, Ident, LitStr, Token,
|
||||||
};
|
};
|
||||||
use utils::{combinations_of, to_pascal_case};
|
use utils::{combinations_of, to_pascal_case};
|
||||||
|
|
||||||
struct PropertyDefinition {
|
struct PropertyDefinition {
|
||||||
name: Ident,
|
name: LitStr,
|
||||||
|
struct_name: Ident,
|
||||||
variants: Punctuated<Ident, Token![,]>,
|
variants: Punctuated<Ident, Token![,]>,
|
||||||
}
|
}
|
||||||
struct PropertyDefinitions {
|
struct PropertyDefinitions {
|
||||||
|
@ -21,7 +22,12 @@ struct PropertyDefinitions {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct PropertyAndDefault {
|
struct PropertyAndDefault {
|
||||||
name: Ident,
|
struct_name: Ident,
|
||||||
|
default: Ident,
|
||||||
|
}
|
||||||
|
struct PropertyWithNameAndDefault {
|
||||||
|
name: String,
|
||||||
|
struct_name: Ident,
|
||||||
default: Ident,
|
default: Ident,
|
||||||
}
|
}
|
||||||
struct BlockDefinition {
|
struct BlockDefinition {
|
||||||
|
@ -29,6 +35,15 @@ struct BlockDefinition {
|
||||||
behavior: Expr,
|
behavior: Expr,
|
||||||
properties_and_defaults: Vec<PropertyAndDefault>,
|
properties_and_defaults: Vec<PropertyAndDefault>,
|
||||||
}
|
}
|
||||||
|
impl PropertyAndDefault {
|
||||||
|
fn into_property_with_name_and_default(&self, name: String) -> PropertyWithNameAndDefault {
|
||||||
|
PropertyWithNameAndDefault {
|
||||||
|
name,
|
||||||
|
struct_name: self.struct_name.clone(),
|
||||||
|
default: self.default.clone(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
struct BlockDefinitions {
|
struct BlockDefinitions {
|
||||||
blocks: Vec<BlockDefinition>,
|
blocks: Vec<BlockDefinition>,
|
||||||
}
|
}
|
||||||
|
@ -39,19 +54,29 @@ struct MakeBlockStates {
|
||||||
|
|
||||||
impl Parse for PropertyDefinition {
|
impl Parse for PropertyDefinition {
|
||||||
fn parse(input: ParseStream) -> Result<Self> {
|
fn parse(input: ParseStream) -> Result<Self> {
|
||||||
// Face {
|
// "face" => Face {
|
||||||
// Floor,
|
// Floor,
|
||||||
// Wall,
|
// Wall,
|
||||||
// Ceiling
|
// Ceiling
|
||||||
// },
|
// },
|
||||||
|
|
||||||
|
// if you're wondering, the reason it's in quotes is because `type` is
|
||||||
|
// a keyword in rust so if we don't put it in quotes it results in a
|
||||||
|
// syntax error
|
||||||
let name = input.parse()?;
|
let name = input.parse()?;
|
||||||
|
input.parse::<Token![=>]>()?;
|
||||||
|
let struct_name = input.parse()?;
|
||||||
|
|
||||||
let content;
|
let content;
|
||||||
braced!(content in input);
|
braced!(content in input);
|
||||||
let variants = content.parse_terminated(Ident::parse)?;
|
let variants = content.parse_terminated(Ident::parse)?;
|
||||||
|
|
||||||
input.parse::<Token![,]>()?;
|
input.parse::<Token![,]>()?;
|
||||||
Ok(PropertyDefinition { name, variants })
|
Ok(PropertyDefinition {
|
||||||
|
name,
|
||||||
|
struct_name,
|
||||||
|
variants,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,11 +95,11 @@ impl Parse for PropertyDefinitions {
|
||||||
|
|
||||||
impl Parse for BlockDefinition {
|
impl Parse for BlockDefinition {
|
||||||
fn parse(input: ParseStream) -> Result<Self> {
|
fn parse(input: ParseStream) -> Result<Self> {
|
||||||
// acacia_button => BlockBehavior::default().no_collision(), {
|
// acacia_button => BlockBehavior::default(), {
|
||||||
// Face,
|
// Facing=North,
|
||||||
// Facing,
|
// Powered=False,
|
||||||
// Powered
|
// Face=Wall,
|
||||||
// },
|
// },
|
||||||
let name = input.parse()?;
|
let name = input.parse()?;
|
||||||
input.parse::<Token![=>]>()?;
|
input.parse::<Token![=>]>()?;
|
||||||
let behavior = input.parse()?;
|
let behavior = input.parse()?;
|
||||||
|
@ -93,7 +118,7 @@ impl Parse for BlockDefinition {
|
||||||
content.parse::<Token![=]>()?;
|
content.parse::<Token![=]>()?;
|
||||||
let property_default = content.parse()?;
|
let property_default = content.parse()?;
|
||||||
properties_and_defaults.push(PropertyAndDefault {
|
properties_and_defaults.push(PropertyAndDefault {
|
||||||
name: property,
|
struct_name: property,
|
||||||
default: property_default,
|
default: property_default,
|
||||||
});
|
});
|
||||||
if content.parse::<Token![,]>().is_err() {
|
if content.parse::<Token![,]>().is_err() {
|
||||||
|
@ -152,15 +177,21 @@ pub fn make_block_states(input: TokenStream) -> TokenStream {
|
||||||
|
|
||||||
let mut property_enums = quote! {};
|
let mut property_enums = quote! {};
|
||||||
let mut properties_map = HashMap::new();
|
let mut properties_map = HashMap::new();
|
||||||
|
let mut property_struct_names_to_names = HashMap::new();
|
||||||
|
|
||||||
let mut state_id = 0usize;
|
let mut state_id: usize = 0;
|
||||||
|
|
||||||
for property in &input.property_definitions.properties {
|
for property in &input.property_definitions.properties {
|
||||||
let mut property_enum_variants = quote! {};
|
let mut property_enum_variants = quote! {};
|
||||||
let mut property_from_number_variants = quote! {};
|
let mut property_from_number_variants = quote! {};
|
||||||
let mut property_enum_variant_names = Vec::new();
|
let mut property_enum_variant_names = Vec::new();
|
||||||
|
|
||||||
let property_name = &property.name;
|
let property_struct_name = &property.struct_name;
|
||||||
|
|
||||||
|
property_struct_names_to_names.insert(
|
||||||
|
property_struct_name.to_string(),
|
||||||
|
property.name.clone().value(),
|
||||||
|
);
|
||||||
|
|
||||||
for i in 0..property.variants.len() {
|
for i in 0..property.variants.len() {
|
||||||
let variant = &property.variants[i];
|
let variant = &property.variants[i];
|
||||||
|
@ -177,7 +208,7 @@ pub fn make_block_states(input: TokenStream) -> TokenStream {
|
||||||
// i_lit is used here instead of i because otherwise it says 0size
|
// i_lit is used here instead of i because otherwise it says 0size
|
||||||
// in the expansion and that looks uglier
|
// in the expansion and that looks uglier
|
||||||
property_from_number_variants.extend(quote! {
|
property_from_number_variants.extend(quote! {
|
||||||
#i_lit => #property_name::#variant,
|
#i_lit => #property_struct_name::#variant,
|
||||||
});
|
});
|
||||||
|
|
||||||
property_enum_variant_names.push(variant.to_string());
|
property_enum_variant_names.push(variant.to_string());
|
||||||
|
@ -185,11 +216,11 @@ pub fn make_block_states(input: TokenStream) -> TokenStream {
|
||||||
|
|
||||||
property_enums.extend(quote! {
|
property_enums.extend(quote! {
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
pub enum #property_name {
|
pub enum #property_struct_name {
|
||||||
#property_enum_variants
|
#property_enum_variants
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<usize> for #property_name {
|
impl From<usize> for #property_struct_name {
|
||||||
fn from(value: usize) -> Self {
|
fn from(value: usize) -> Self {
|
||||||
match value {
|
match value {
|
||||||
#property_from_number_variants
|
#property_from_number_variants
|
||||||
|
@ -198,7 +229,10 @@ pub fn make_block_states(input: TokenStream) -> TokenStream {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
properties_map.insert(property_name.to_string(), property_enum_variant_names);
|
properties_map.insert(
|
||||||
|
property_struct_name.to_string(),
|
||||||
|
property_enum_variant_names,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut block_state_enum_variants = quote! {};
|
let mut block_state_enum_variants = quote! {};
|
||||||
|
@ -208,7 +242,7 @@ pub fn make_block_states(input: TokenStream) -> TokenStream {
|
||||||
let block_property_names = &block
|
let block_property_names = &block
|
||||||
.properties_and_defaults
|
.properties_and_defaults
|
||||||
.iter()
|
.iter()
|
||||||
.map(|p| p.name.to_string())
|
.map(|p| p.struct_name.to_string())
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
let mut block_properties_vec = Vec::new();
|
let mut block_properties_vec = Vec::new();
|
||||||
for property_name in block_property_names {
|
for property_name in block_property_names {
|
||||||
|
@ -219,17 +253,56 @@ pub fn make_block_states(input: TokenStream) -> TokenStream {
|
||||||
block_properties_vec.push(property_variants);
|
block_properties_vec.push(property_variants);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let mut properties_with_name: Vec<PropertyWithNameAndDefault> =
|
||||||
|
Vec::with_capacity(block.properties_and_defaults.len());
|
||||||
|
for property in &block.properties_and_defaults {
|
||||||
|
let index: Option<usize> = if block
|
||||||
|
.properties_and_defaults
|
||||||
|
.iter()
|
||||||
|
.filter(|p| p.struct_name == property.struct_name)
|
||||||
|
.count()
|
||||||
|
> 1
|
||||||
|
{
|
||||||
|
Some(
|
||||||
|
properties_with_name
|
||||||
|
.iter()
|
||||||
|
.filter(|p| p.struct_name == property.struct_name)
|
||||||
|
.count(),
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
|
let mut property_name = property_struct_names_to_names
|
||||||
|
.get(&property.struct_name.to_string())
|
||||||
|
.expect(format!("Property '{}' is bad", property.struct_name).as_str())
|
||||||
|
.clone();
|
||||||
|
if let Some(index) = index {
|
||||||
|
property_name.push_str(&format!("_{}", &index.to_string()));
|
||||||
|
}
|
||||||
|
properties_with_name
|
||||||
|
.push(property.into_property_with_name_and_default(property_name.clone()));
|
||||||
|
}
|
||||||
|
|
||||||
// pub face: properties::Face,
|
// pub face: properties::Face,
|
||||||
// pub facing: properties::Facing,
|
// pub facing: properties::Facing,
|
||||||
// pub powered: properties::Powered,
|
// pub powered: properties::Powered,
|
||||||
|
// or
|
||||||
|
// pub has_bottle_0: HasBottle,
|
||||||
|
// pub has_bottle_1: HasBottle,
|
||||||
|
// pub has_bottle_2: HasBottle,
|
||||||
let mut block_struct_fields = quote! {};
|
let mut block_struct_fields = quote! {};
|
||||||
for PropertyAndDefault { name: property, .. } in &block.properties_and_defaults {
|
for PropertyWithNameAndDefault {
|
||||||
let property_name_snake =
|
struct_name, name, ..
|
||||||
Ident::new(&property.to_string(), proc_macro2::Span::call_site());
|
} in &properties_with_name
|
||||||
|
{
|
||||||
|
// let property_name_snake =
|
||||||
|
// Ident::new(&property.to_string(), proc_macro2::Span::call_site());
|
||||||
|
let name_ident = Ident::new(&name, proc_macro2::Span::call_site());
|
||||||
block_struct_fields.extend(quote! {
|
block_struct_fields.extend(quote! {
|
||||||
pub #property_name_snake: #property,
|
pub #name_ident: #struct_name,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
let block_name_pascal_case = Ident::new(
|
let block_name_pascal_case = Ident::new(
|
||||||
&to_pascal_case(&block.name.to_string()),
|
&to_pascal_case(&block.name.to_string()),
|
||||||
proc_macro2::Span::call_site(),
|
proc_macro2::Span::call_site(),
|
||||||
|
@ -272,16 +345,16 @@ pub fn make_block_states(input: TokenStream) -> TokenStream {
|
||||||
// facing: properties::Facing::North,
|
// facing: properties::Facing::North,
|
||||||
// powered: properties::Powered::True,
|
// powered: properties::Powered::True,
|
||||||
let mut from_block_to_state_combination_match_inner = quote! {};
|
let mut from_block_to_state_combination_match_inner = quote! {};
|
||||||
for i in 0..block_property_names.len() {
|
for i in 0..properties_with_name.len() {
|
||||||
let property_name = &block_property_names[i];
|
let property = &properties_with_name[i];
|
||||||
|
let property_name = &property.name;
|
||||||
let property_name_ident = Ident::new(property_name, proc_macro2::Span::call_site());
|
let property_name_ident = Ident::new(property_name, proc_macro2::Span::call_site());
|
||||||
let property_name_snake =
|
let property_struct_name_ident = &property.struct_name;
|
||||||
Ident::new(&property_name.to_string(), proc_macro2::Span::call_site());
|
|
||||||
let variant =
|
let variant =
|
||||||
Ident::new(&combination[i].to_string(), proc_macro2::Span::call_site());
|
Ident::new(&combination[i].to_string(), proc_macro2::Span::call_site());
|
||||||
|
|
||||||
from_block_to_state_combination_match_inner.extend(quote! {
|
from_block_to_state_combination_match_inner.extend(quote! {
|
||||||
#property_name_ident: #property_name_snake::#variant,
|
#property_name_ident: #property_struct_name_ident::#variant,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -295,23 +368,25 @@ pub fn make_block_states(input: TokenStream) -> TokenStream {
|
||||||
// 7035..=7058 => {
|
// 7035..=7058 => {
|
||||||
// let b = b - 7035;
|
// let b = b - 7035;
|
||||||
// &AcaciaButtonBlock {
|
// &AcaciaButtonBlock {
|
||||||
// Powered: Powered::from((b / 1) % 2),
|
// powered: Powered::from((b / 1) % 2),
|
||||||
// Facing: Facing::from((b / 2) % 4),
|
// facing: Facing::from((b / 2) % 4),
|
||||||
// Face: Face::from((b / 8) % 3),
|
// face: Face::from((b / 8) % 3),
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
let mut from_state_to_block_inner = quote! {};
|
let mut from_state_to_block_inner = quote! {};
|
||||||
let mut division = 1usize;
|
let mut division = 1usize;
|
||||||
for i in (0..block.properties_and_defaults.len()).rev() {
|
for i in (0..properties_with_name.len()).rev() {
|
||||||
let PropertyAndDefault {
|
let PropertyWithNameAndDefault {
|
||||||
|
struct_name: property_struct_name_ident,
|
||||||
name: property_name,
|
name: property_name,
|
||||||
..
|
..
|
||||||
} = &block.properties_and_defaults[i];
|
} = &properties_with_name[i];
|
||||||
|
|
||||||
let property_variants = &block_properties_vec[i];
|
let property_variants = &block_properties_vec[i];
|
||||||
let property_variants_count = property_variants.len();
|
let property_variants_count = property_variants.len();
|
||||||
|
let property_name_ident = Ident::new(property_name, proc_macro2::Span::call_site());
|
||||||
from_state_to_block_inner.extend(quote! {
|
from_state_to_block_inner.extend(quote! {
|
||||||
#property_name: #property_name::from((b / #division) % #property_variants_count),
|
#property_name_ident: #property_struct_name_ident::from((b / #division) % #property_variants_count),
|
||||||
});
|
});
|
||||||
|
|
||||||
division *= property_variants_count;
|
division *= property_variants_count;
|
||||||
|
@ -328,13 +403,15 @@ pub fn make_block_states(input: TokenStream) -> TokenStream {
|
||||||
});
|
});
|
||||||
|
|
||||||
let mut block_default_fields = quote! {};
|
let mut block_default_fields = quote! {};
|
||||||
for PropertyAndDefault {
|
for PropertyWithNameAndDefault {
|
||||||
name: property,
|
struct_name: struct_name_ident,
|
||||||
|
name,
|
||||||
default: property_default,
|
default: property_default,
|
||||||
} in &block.properties_and_defaults
|
} in properties_with_name
|
||||||
{
|
{
|
||||||
|
let name_ident = Ident::new(&name, proc_macro2::Span::call_site());
|
||||||
block_default_fields.extend(quote! {
|
block_default_fields.extend(quote! {
|
||||||
#property: #property::#property_default,
|
#name_ident: #struct_name_ident::#property_default,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -65,14 +65,14 @@ def generate_blocks(blocks_burger: dict, blocks_report: dict, mappings: Mappings
|
||||||
# Property codegen
|
# Property codegen
|
||||||
new_make_block_states_macro_code.append(' Properties => {')
|
new_make_block_states_macro_code.append(' Properties => {')
|
||||||
for property_struct_name, property_variants in properties.items():
|
for property_struct_name, property_variants in properties.items():
|
||||||
# face => Face {
|
# "face" => Face {
|
||||||
# Floor,
|
# Floor,
|
||||||
# Wall,
|
# Wall,
|
||||||
# Ceiling,
|
# Ceiling,
|
||||||
# },
|
# },
|
||||||
property_name = property_struct_names_to_names[property_struct_name]
|
property_name = property_struct_names_to_names[property_struct_name]
|
||||||
new_make_block_states_macro_code.append(
|
new_make_block_states_macro_code.append(
|
||||||
f' {property_name} => {property_struct_name} {{')
|
f' "{property_name}" => {property_struct_name} {{')
|
||||||
|
|
||||||
for variant in property_variants:
|
for variant in property_variants:
|
||||||
new_make_block_states_macro_code.append(
|
new_make_block_states_macro_code.append(
|
||||||
|
|
Loading…
Add table
Reference in a new issue