mirror of
https://github.com/italicsjenga/valence.git
synced 2024-12-23 14:31:30 +11:00
Temp fix for heck with unicode enabled (#326)
## Description This should _temporarily_ fix the heck issue described in #324 until https://github.com/withoutboats/heck/issues/42 is fixed downstream. When it is fixed downstream, this commit should get reverted. Fixes #324
This commit is contained in:
parent
abf9064901
commit
d3ed3123ca
|
@ -86,7 +86,7 @@ fn build() -> anyhow::Result<TokenStream> {
|
||||||
let kind_to_translation_key_arms = blocks
|
let kind_to_translation_key_arms = blocks
|
||||||
.iter()
|
.iter()
|
||||||
.map(|b| {
|
.map(|b| {
|
||||||
let kind = ident(b.name.to_pascal_case());
|
let kind = ident(b.name.replace('.', "_").to_pascal_case());
|
||||||
let translation_key = &b.translation_key;
|
let translation_key = &b.translation_key;
|
||||||
quote! {
|
quote! {
|
||||||
Self::#kind => #translation_key,
|
Self::#kind => #translation_key,
|
||||||
|
@ -97,7 +97,7 @@ fn build() -> anyhow::Result<TokenStream> {
|
||||||
let state_to_kind_arms = blocks
|
let state_to_kind_arms = blocks
|
||||||
.iter()
|
.iter()
|
||||||
.map(|b| {
|
.map(|b| {
|
||||||
let name = ident(b.name.to_pascal_case());
|
let name = ident(b.name.replace('.', "_").to_pascal_case());
|
||||||
let mut token_stream = TokenStream::new();
|
let mut token_stream = TokenStream::new();
|
||||||
|
|
||||||
let min_id = b.min_state_id();
|
let min_id = b.min_state_id();
|
||||||
|
@ -191,13 +191,13 @@ fn build() -> anyhow::Result<TokenStream> {
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|&b| !b.properties.is_empty())
|
.filter(|&b| !b.properties.is_empty())
|
||||||
.map(|b| {
|
.map(|b| {
|
||||||
let block_kind_name = ident(b.name.to_pascal_case());
|
let block_kind_name = ident(b.name.replace('.', "_").to_pascal_case());
|
||||||
|
|
||||||
let arms = b
|
let arms = b
|
||||||
.properties
|
.properties
|
||||||
.iter()
|
.iter()
|
||||||
.map(|p| {
|
.map(|p| {
|
||||||
let prop_name = ident(p.name.to_pascal_case());
|
let prop_name = ident(p.name.replace('.', "_").to_pascal_case());
|
||||||
let min_state_id = b.min_state_id();
|
let min_state_id = b.min_state_id();
|
||||||
let product: u16 = b
|
let product: u16 = b
|
||||||
.properties
|
.properties
|
||||||
|
@ -211,7 +211,7 @@ fn build() -> anyhow::Result<TokenStream> {
|
||||||
|
|
||||||
let arms = p.values.iter().enumerate().map(|(i, v)| {
|
let arms = p.values.iter().enumerate().map(|(i, v)| {
|
||||||
let value_idx = i as u16;
|
let value_idx = i as u16;
|
||||||
let value_name = ident(v.to_pascal_case());
|
let value_name = ident(v.replace('.', "_").to_pascal_case());
|
||||||
quote! {
|
quote! {
|
||||||
#value_idx => Some(PropValue::#value_name),
|
#value_idx => Some(PropValue::#value_name),
|
||||||
}
|
}
|
||||||
|
@ -239,13 +239,13 @@ fn build() -> anyhow::Result<TokenStream> {
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|&b| !b.properties.is_empty())
|
.filter(|&b| !b.properties.is_empty())
|
||||||
.map(|b| {
|
.map(|b| {
|
||||||
let block_kind_name = ident(b.name.to_pascal_case());
|
let block_kind_name = ident(b.name.replace('.', "_").to_pascal_case());
|
||||||
|
|
||||||
let arms = b
|
let arms = b
|
||||||
.properties
|
.properties
|
||||||
.iter()
|
.iter()
|
||||||
.map(|p| {
|
.map(|p| {
|
||||||
let prop_name = ident(p.name.to_pascal_case());
|
let prop_name = ident(p.name.replace('.', "_").to_pascal_case());
|
||||||
let min_state_id = b.min_state_id();
|
let min_state_id = b.min_state_id();
|
||||||
let product: u16 = b
|
let product: u16 = b
|
||||||
.properties
|
.properties
|
||||||
|
@ -263,7 +263,7 @@ fn build() -> anyhow::Result<TokenStream> {
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.map(|(i, v)| {
|
.map(|(i, v)| {
|
||||||
let val_idx = i as u16;
|
let val_idx = i as u16;
|
||||||
let val_name = ident(v.to_pascal_case());
|
let val_name = ident(v.replace('.', "_").to_pascal_case());
|
||||||
quote! {
|
quote! {
|
||||||
PropValue::#val_name =>
|
PropValue::#val_name =>
|
||||||
Self(self.0 - (self.0 - #min_state_id) / #product % #values_count * #product
|
Self(self.0 - (self.0 - #min_state_id) / #product % #values_count * #product
|
||||||
|
@ -293,7 +293,7 @@ fn build() -> anyhow::Result<TokenStream> {
|
||||||
let default_block_states = blocks
|
let default_block_states = blocks
|
||||||
.iter()
|
.iter()
|
||||||
.map(|b| {
|
.map(|b| {
|
||||||
let name = ident(b.name.to_shouty_snake_case());
|
let name = ident(b.name.replace('.', "_").to_shouty_snake_case());
|
||||||
let state = b.default_state_id;
|
let state = b.default_state_id;
|
||||||
let doc = format!("The default block state for `{}`.", b.name);
|
let doc = format!("The default block state for `{}`.", b.name);
|
||||||
quote! {
|
quote! {
|
||||||
|
@ -307,10 +307,11 @@ fn build() -> anyhow::Result<TokenStream> {
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|b| b.wall_variant_id.is_some())
|
.filter(|b| b.wall_variant_id.is_some())
|
||||||
.map(|b| {
|
.map(|b| {
|
||||||
let block_name = ident(b.name.to_shouty_snake_case());
|
let block_name = ident(b.name.replace('.', "_").to_shouty_snake_case());
|
||||||
let wall_block_name = ident(
|
let wall_block_name = ident(
|
||||||
blocks[b.wall_variant_id.unwrap() as usize]
|
blocks[b.wall_variant_id.unwrap() as usize]
|
||||||
.name
|
.name
|
||||||
|
.replace('.', "_")
|
||||||
.to_shouty_snake_case(),
|
.to_shouty_snake_case(),
|
||||||
);
|
);
|
||||||
quote! {
|
quote! {
|
||||||
|
@ -335,8 +336,8 @@ fn build() -> anyhow::Result<TokenStream> {
|
||||||
let kind_to_state_arms = blocks
|
let kind_to_state_arms = blocks
|
||||||
.iter()
|
.iter()
|
||||||
.map(|b| {
|
.map(|b| {
|
||||||
let kind = ident(b.name.to_pascal_case());
|
let kind = ident(b.name.replace('.', "_").to_pascal_case());
|
||||||
let state = ident(b.name.to_shouty_snake_case());
|
let state = ident(b.name.replace('.', "_").to_shouty_snake_case());
|
||||||
quote! {
|
quote! {
|
||||||
BlockKind::#kind => BlockState::#state,
|
BlockKind::#kind => BlockState::#state,
|
||||||
}
|
}
|
||||||
|
@ -345,14 +346,14 @@ fn build() -> anyhow::Result<TokenStream> {
|
||||||
|
|
||||||
let block_kind_variants = blocks
|
let block_kind_variants = blocks
|
||||||
.iter()
|
.iter()
|
||||||
.map(|b| ident(b.name.to_pascal_case()))
|
.map(|b| ident(b.name.replace('.', "_").to_pascal_case()))
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
let block_kind_from_str_arms = blocks
|
let block_kind_from_str_arms = blocks
|
||||||
.iter()
|
.iter()
|
||||||
.map(|b| {
|
.map(|b| {
|
||||||
let name = &b.name;
|
let name = &b.name;
|
||||||
let name_ident = ident(name.to_pascal_case());
|
let name_ident = ident(name.replace('.', "_").to_pascal_case());
|
||||||
quote! {
|
quote! {
|
||||||
#name => Some(BlockKind::#name_ident),
|
#name => Some(BlockKind::#name_ident),
|
||||||
}
|
}
|
||||||
|
@ -363,7 +364,7 @@ fn build() -> anyhow::Result<TokenStream> {
|
||||||
.iter()
|
.iter()
|
||||||
.map(|b| {
|
.map(|b| {
|
||||||
let name = &b.name;
|
let name = &b.name;
|
||||||
let name_ident = ident(name.to_pascal_case());
|
let name_ident = ident(name.replace('.', "_").to_pascal_case());
|
||||||
quote! {
|
quote! {
|
||||||
BlockKind::#name_ident => #name,
|
BlockKind::#name_ident => #name,
|
||||||
}
|
}
|
||||||
|
@ -374,8 +375,11 @@ fn build() -> anyhow::Result<TokenStream> {
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|&b| !b.properties.is_empty())
|
.filter(|&b| !b.properties.is_empty())
|
||||||
.map(|b| {
|
.map(|b| {
|
||||||
let name = ident(b.name.to_pascal_case());
|
let name = ident(b.name.replace('.', "_").to_pascal_case());
|
||||||
let prop_names = b.properties.iter().map(|p| ident(p.name.to_pascal_case()));
|
let prop_names = b
|
||||||
|
.properties
|
||||||
|
.iter()
|
||||||
|
.map(|p| ident(p.name.replace('.', "_").to_pascal_case()));
|
||||||
|
|
||||||
quote! {
|
quote! {
|
||||||
Self::#name => &[#(PropName::#prop_names,)*],
|
Self::#name => &[#(PropName::#prop_names,)*],
|
||||||
|
@ -386,7 +390,7 @@ fn build() -> anyhow::Result<TokenStream> {
|
||||||
let block_kind_to_item_kind_arms = blocks
|
let block_kind_to_item_kind_arms = blocks
|
||||||
.iter()
|
.iter()
|
||||||
.map(|block| {
|
.map(|block| {
|
||||||
let name = ident(block.name.to_pascal_case());
|
let name = ident(block.name.replace('.', "_").to_pascal_case());
|
||||||
let item_id = block.item_id;
|
let item_id = block.item_id;
|
||||||
|
|
||||||
quote! {
|
quote! {
|
||||||
|
@ -399,7 +403,7 @@ fn build() -> anyhow::Result<TokenStream> {
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|block| block.item_id != 0)
|
.filter(|block| block.item_id != 0)
|
||||||
.map(|block| {
|
.map(|block| {
|
||||||
let name = ident(block.name.to_pascal_case());
|
let name = ident(block.name.replace('.', "_").to_pascal_case());
|
||||||
let item_id = block.item_id;
|
let item_id = block.item_id;
|
||||||
|
|
||||||
quote! {
|
quote! {
|
||||||
|
@ -411,7 +415,7 @@ fn build() -> anyhow::Result<TokenStream> {
|
||||||
let block_kind_from_raw_arms = blocks
|
let block_kind_from_raw_arms = blocks
|
||||||
.iter()
|
.iter()
|
||||||
.map(|block| {
|
.map(|block| {
|
||||||
let name = ident(block.name.to_pascal_case());
|
let name = ident(block.name.replace('.', "_").to_pascal_case());
|
||||||
let id = block.id;
|
let id = block.id;
|
||||||
|
|
||||||
quote! {
|
quote! {
|
||||||
|
@ -423,7 +427,7 @@ fn build() -> anyhow::Result<TokenStream> {
|
||||||
let block_entity_kind_variants = block_entity_types
|
let block_entity_kind_variants = block_entity_types
|
||||||
.iter()
|
.iter()
|
||||||
.map(|block_entity| {
|
.map(|block_entity| {
|
||||||
let name = ident(block_entity.name.to_pascal_case());
|
let name = ident(block_entity.name.replace('.', "_").to_pascal_case());
|
||||||
let doc = format!(
|
let doc = format!(
|
||||||
"The block entity type `{}` (ID {}).",
|
"The block entity type `{}` (ID {}).",
|
||||||
block_entity.name, block_entity.id
|
block_entity.name, block_entity.id
|
||||||
|
@ -439,7 +443,7 @@ fn build() -> anyhow::Result<TokenStream> {
|
||||||
.iter()
|
.iter()
|
||||||
.map(|block_entity| {
|
.map(|block_entity| {
|
||||||
let id = block_entity.id;
|
let id = block_entity.id;
|
||||||
let name = ident(block_entity.name.to_pascal_case());
|
let name = ident(block_entity.name.replace('.', "_").to_pascal_case());
|
||||||
|
|
||||||
quote! {
|
quote! {
|
||||||
#id => Some(Self::#name),
|
#id => Some(Self::#name),
|
||||||
|
@ -451,7 +455,7 @@ fn build() -> anyhow::Result<TokenStream> {
|
||||||
.iter()
|
.iter()
|
||||||
.map(|block_entity| {
|
.map(|block_entity| {
|
||||||
let id = block_entity.id;
|
let id = block_entity.id;
|
||||||
let name = ident(block_entity.name.to_pascal_case());
|
let name = ident(block_entity.name.replace('.', "_").to_pascal_case());
|
||||||
|
|
||||||
quote! {
|
quote! {
|
||||||
Self::#name => #id,
|
Self::#name => #id,
|
||||||
|
@ -462,7 +466,7 @@ fn build() -> anyhow::Result<TokenStream> {
|
||||||
let block_entity_kind_from_ident_arms = block_entity_types
|
let block_entity_kind_from_ident_arms = block_entity_types
|
||||||
.iter()
|
.iter()
|
||||||
.map(|block_entity| {
|
.map(|block_entity| {
|
||||||
let name = ident(block_entity.name.to_pascal_case());
|
let name = ident(block_entity.name.replace('.', "_").to_pascal_case());
|
||||||
let ident = &block_entity.ident;
|
let ident = &block_entity.ident;
|
||||||
|
|
||||||
quote! {
|
quote! {
|
||||||
|
@ -474,7 +478,7 @@ fn build() -> anyhow::Result<TokenStream> {
|
||||||
let block_entity_kind_to_ident_arms = block_entity_types
|
let block_entity_kind_to_ident_arms = block_entity_types
|
||||||
.iter()
|
.iter()
|
||||||
.map(|block_entity| {
|
.map(|block_entity| {
|
||||||
let name = ident(block_entity.name.to_pascal_case());
|
let name = ident(block_entity.name.replace('.', "_").to_pascal_case());
|
||||||
let ident = &block_entity.ident;
|
let ident = &block_entity.ident;
|
||||||
|
|
||||||
quote! {
|
quote! {
|
||||||
|
@ -492,13 +496,13 @@ fn build() -> anyhow::Result<TokenStream> {
|
||||||
|
|
||||||
let prop_name_variants = prop_names
|
let prop_name_variants = prop_names
|
||||||
.iter()
|
.iter()
|
||||||
.map(|&name| ident(name.to_pascal_case()))
|
.map(|&name| ident(name.replace('.', "_").to_pascal_case()))
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
let prop_name_from_str_arms = prop_names
|
let prop_name_from_str_arms = prop_names
|
||||||
.iter()
|
.iter()
|
||||||
.map(|&name| {
|
.map(|&name| {
|
||||||
let ident = ident(name.to_pascal_case());
|
let ident = ident(name.replace('.', "_").to_pascal_case());
|
||||||
quote! {
|
quote! {
|
||||||
#name => Some(PropName::#ident),
|
#name => Some(PropName::#ident),
|
||||||
}
|
}
|
||||||
|
@ -508,7 +512,7 @@ fn build() -> anyhow::Result<TokenStream> {
|
||||||
let prop_name_to_str_arms = prop_names
|
let prop_name_to_str_arms = prop_names
|
||||||
.iter()
|
.iter()
|
||||||
.map(|&name| {
|
.map(|&name| {
|
||||||
let ident = ident(name.to_pascal_case());
|
let ident = ident(name.replace('.', "_").to_pascal_case());
|
||||||
quote! {
|
quote! {
|
||||||
PropName::#ident => #name,
|
PropName::#ident => #name,
|
||||||
}
|
}
|
||||||
|
@ -525,13 +529,13 @@ fn build() -> anyhow::Result<TokenStream> {
|
||||||
|
|
||||||
let prop_value_variants = prop_values
|
let prop_value_variants = prop_values
|
||||||
.iter()
|
.iter()
|
||||||
.map(|val| ident(val.to_pascal_case()))
|
.map(|val| ident(val.replace('.', "_").to_pascal_case()))
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
let prop_value_from_str_arms = prop_values
|
let prop_value_from_str_arms = prop_values
|
||||||
.iter()
|
.iter()
|
||||||
.map(|val| {
|
.map(|val| {
|
||||||
let ident = ident(val.to_pascal_case());
|
let ident = ident(val.replace('.', "_").to_pascal_case());
|
||||||
quote! {
|
quote! {
|
||||||
#val => Some(PropValue::#ident),
|
#val => Some(PropValue::#ident),
|
||||||
}
|
}
|
||||||
|
@ -541,7 +545,7 @@ fn build() -> anyhow::Result<TokenStream> {
|
||||||
let prop_value_to_str_arms = prop_values
|
let prop_value_to_str_arms = prop_values
|
||||||
.iter()
|
.iter()
|
||||||
.map(|val| {
|
.map(|val| {
|
||||||
let ident = ident(val.to_pascal_case());
|
let ident = ident(val.replace('.', "_").to_pascal_case());
|
||||||
quote! {
|
quote! {
|
||||||
PropValue::#ident => #val,
|
PropValue::#ident => #val,
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ pub fn build() -> anyhow::Result<TokenStream> {
|
||||||
.iter()
|
.iter()
|
||||||
.map(|item| {
|
.map(|item| {
|
||||||
let id = &item.id;
|
let id = &item.id;
|
||||||
let name = ident(item.name.to_pascal_case());
|
let name = ident(item.name.replace('.', "_").to_pascal_case());
|
||||||
|
|
||||||
quote! {
|
quote! {
|
||||||
#id => Some(Self::#name),
|
#id => Some(Self::#name),
|
||||||
|
@ -48,7 +48,7 @@ pub fn build() -> anyhow::Result<TokenStream> {
|
||||||
.iter()
|
.iter()
|
||||||
.map(|item| {
|
.map(|item| {
|
||||||
let id = &item.id;
|
let id = &item.id;
|
||||||
let name = ident(item.name.to_pascal_case());
|
let name = ident(item.name.replace('.', "_").to_pascal_case());
|
||||||
|
|
||||||
quote! {
|
quote! {
|
||||||
Self::#name => #id,
|
Self::#name => #id,
|
||||||
|
@ -60,7 +60,7 @@ pub fn build() -> anyhow::Result<TokenStream> {
|
||||||
.iter()
|
.iter()
|
||||||
.map(|item| {
|
.map(|item| {
|
||||||
let str_name = &item.name;
|
let str_name = &item.name;
|
||||||
let name = ident(str_name.to_pascal_case());
|
let name = ident(str_name.replace('.', "_").to_pascal_case());
|
||||||
quote! {
|
quote! {
|
||||||
#str_name => Some(Self::#name),
|
#str_name => Some(Self::#name),
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ pub fn build() -> anyhow::Result<TokenStream> {
|
||||||
.iter()
|
.iter()
|
||||||
.map(|item| {
|
.map(|item| {
|
||||||
let str_name = &item.name;
|
let str_name = &item.name;
|
||||||
let name = ident(str_name.to_pascal_case());
|
let name = ident(str_name.replace('.', "_").to_pascal_case());
|
||||||
quote! {
|
quote! {
|
||||||
Self::#name => #str_name,
|
Self::#name => #str_name,
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,7 @@ pub fn build() -> anyhow::Result<TokenStream> {
|
||||||
let item_kind_to_translation_key_arms = items
|
let item_kind_to_translation_key_arms = items
|
||||||
.iter()
|
.iter()
|
||||||
.map(|item| {
|
.map(|item| {
|
||||||
let name = ident(item.name.to_pascal_case());
|
let name = ident(item.name.replace('.', "_").to_pascal_case());
|
||||||
let translation_key = &item.translation_key;
|
let translation_key = &item.translation_key;
|
||||||
quote! {
|
quote! {
|
||||||
Self::#name => #translation_key,
|
Self::#name => #translation_key,
|
||||||
|
@ -91,13 +91,13 @@ pub fn build() -> anyhow::Result<TokenStream> {
|
||||||
|
|
||||||
let item_kind_variants = items
|
let item_kind_variants = items
|
||||||
.iter()
|
.iter()
|
||||||
.map(|item| ident(item.name.to_pascal_case()))
|
.map(|item| ident(item.name.replace('.', "_").to_pascal_case()))
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
let item_kind_to_max_stack_arms = items
|
let item_kind_to_max_stack_arms = items
|
||||||
.iter()
|
.iter()
|
||||||
.map(|item| {
|
.map(|item| {
|
||||||
let name = ident(item.name.to_pascal_case());
|
let name = ident(item.name.replace('.', "_").to_pascal_case());
|
||||||
let max_stack = item.max_stack;
|
let max_stack = item.max_stack;
|
||||||
|
|
||||||
quote! {
|
quote! {
|
||||||
|
@ -110,7 +110,7 @@ pub fn build() -> anyhow::Result<TokenStream> {
|
||||||
.iter()
|
.iter()
|
||||||
.map(|item| match &item.food {
|
.map(|item| match &item.food {
|
||||||
Some(food_component) => {
|
Some(food_component) => {
|
||||||
let name = ident(item.name.to_pascal_case());
|
let name = ident(item.name.replace('.', "_").to_pascal_case());
|
||||||
let hunger = food_component.hunger;
|
let hunger = food_component.hunger;
|
||||||
let saturation = food_component.saturation;
|
let saturation = food_component.saturation;
|
||||||
let always_edible = food_component.always_edible;
|
let always_edible = food_component.always_edible;
|
||||||
|
@ -136,7 +136,7 @@ pub fn build() -> anyhow::Result<TokenStream> {
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|item| item.max_durability != 0)
|
.filter(|item| item.max_durability != 0)
|
||||||
.map(|item| {
|
.map(|item| {
|
||||||
let name = ident(item.name.to_pascal_case());
|
let name = ident(item.name.replace('.', "_").to_pascal_case());
|
||||||
let max_durability = item.max_durability;
|
let max_durability = item.max_durability;
|
||||||
|
|
||||||
quote! {
|
quote! {
|
||||||
|
@ -149,7 +149,7 @@ pub fn build() -> anyhow::Result<TokenStream> {
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|item| item.enchantability != 0)
|
.filter(|item| item.enchantability != 0)
|
||||||
.map(|item| {
|
.map(|item| {
|
||||||
let name = ident(item.name.to_pascal_case());
|
let name = ident(item.name.replace('.', "_").to_pascal_case());
|
||||||
let ench = item.enchantability;
|
let ench = item.enchantability;
|
||||||
|
|
||||||
quote! {
|
quote! {
|
||||||
|
@ -162,7 +162,7 @@ pub fn build() -> anyhow::Result<TokenStream> {
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|item| item.fireproof)
|
.filter(|item| item.fireproof)
|
||||||
.map(|item| {
|
.map(|item| {
|
||||||
let name = ident(item.name.to_pascal_case());
|
let name = ident(item.name.replace('.', "_").to_pascal_case());
|
||||||
|
|
||||||
quote! {
|
quote! {
|
||||||
Self::#name => true,
|
Self::#name => true,
|
||||||
|
|
|
@ -21,7 +21,7 @@ pub fn build() -> anyhow::Result<TokenStream> {
|
||||||
for packet in packets {
|
for packet in packets {
|
||||||
let stripped_name = packet.name.strip_suffix("Packet").unwrap_or(&packet.name);
|
let stripped_name = packet.name.strip_suffix("Packet").unwrap_or(&packet.name);
|
||||||
|
|
||||||
let name_ident = ident(stripped_name.to_pascal_case());
|
let name_ident = ident(stripped_name.replace('.', "_").to_pascal_case());
|
||||||
let id = packet.id;
|
let id = packet.id;
|
||||||
|
|
||||||
let doc = format!("Side: {}\nState: {}", packet.side, packet.state);
|
let doc = format!("Side: {}\nState: {}", packet.side, packet.state);
|
||||||
|
|
|
@ -20,7 +20,7 @@ pub fn build() -> anyhow::Result<TokenStream> {
|
||||||
.iter()
|
.iter()
|
||||||
.map(|sound| {
|
.map(|sound| {
|
||||||
let id = &sound.id;
|
let id = &sound.id;
|
||||||
let name = ident(sound.name.to_pascal_case());
|
let name = ident(sound.name.replace('.', "_").to_pascal_case());
|
||||||
|
|
||||||
quote! {
|
quote! {
|
||||||
#id => Some(Self::#name),
|
#id => Some(Self::#name),
|
||||||
|
@ -32,7 +32,7 @@ pub fn build() -> anyhow::Result<TokenStream> {
|
||||||
.iter()
|
.iter()
|
||||||
.map(|sound| {
|
.map(|sound| {
|
||||||
let id = &sound.id;
|
let id = &sound.id;
|
||||||
let name = ident(sound.name.to_pascal_case());
|
let name = ident(sound.name.replace('.', "_").to_pascal_case());
|
||||||
|
|
||||||
quote! {
|
quote! {
|
||||||
Self::#name => #id,
|
Self::#name => #id,
|
||||||
|
@ -44,7 +44,7 @@ pub fn build() -> anyhow::Result<TokenStream> {
|
||||||
.iter()
|
.iter()
|
||||||
.map(|sound| {
|
.map(|sound| {
|
||||||
let str_name = &sound.name;
|
let str_name = &sound.name;
|
||||||
let name = ident(str_name.to_pascal_case());
|
let name = ident(str_name.replace('.', "_").to_pascal_case());
|
||||||
quote! {
|
quote! {
|
||||||
#str_name => Some(Self::#name),
|
#str_name => Some(Self::#name),
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ pub fn build() -> anyhow::Result<TokenStream> {
|
||||||
.iter()
|
.iter()
|
||||||
.map(|sound| {
|
.map(|sound| {
|
||||||
let str_name = &sound.name;
|
let str_name = &sound.name;
|
||||||
let name = ident(str_name.to_pascal_case());
|
let name = ident(str_name.replace('.', "_").to_pascal_case());
|
||||||
quote! {
|
quote! {
|
||||||
Self::#name => ident!(#str_name),
|
Self::#name => ident!(#str_name),
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ pub fn build() -> anyhow::Result<TokenStream> {
|
||||||
|
|
||||||
let sound_variants = sounds
|
let sound_variants = sounds
|
||||||
.iter()
|
.iter()
|
||||||
.map(|sound| ident(sound.name.to_pascal_case()))
|
.map(|sound| ident(sound.name.replace('.', "_").to_pascal_case()))
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
Ok(quote! {
|
Ok(quote! {
|
||||||
|
|
|
@ -24,7 +24,7 @@ pub fn build() -> anyhow::Result<TokenStream> {
|
||||||
let translation_key_consts = translations
|
let translation_key_consts = translations
|
||||||
.iter()
|
.iter()
|
||||||
.map(|translation| {
|
.map(|translation| {
|
||||||
let const_id = ident(translation.key.to_shouty_snake_case());
|
let const_id = ident(translation.key.replace('.', "_").to_shouty_snake_case());
|
||||||
let key = &translation.key;
|
let key = &translation.key;
|
||||||
let english_translation = &translation.english_translation;
|
let english_translation = &translation.english_translation;
|
||||||
let doc = format!("\"{}\"", escape(english_translation));
|
let doc = format!("\"{}\"", escape(english_translation));
|
||||||
|
|
|
@ -189,7 +189,7 @@ impl Value {
|
||||||
quote!(None)
|
quote!(None)
|
||||||
}
|
}
|
||||||
Value::Facing(f) => {
|
Value::Facing(f) => {
|
||||||
let variant = ident(f.to_pascal_case());
|
let variant = ident(f.replace('.', "_").to_pascal_case());
|
||||||
quote!(valence_core::direction::Direction::#variant)
|
quote!(valence_core::direction::Direction::#variant)
|
||||||
}
|
}
|
||||||
Value::OptionalUuid(uuid) => {
|
Value::OptionalUuid(uuid) => {
|
||||||
|
@ -208,7 +208,7 @@ impl Value {
|
||||||
quote!(valence_nbt::Compound::default())
|
quote!(valence_nbt::Compound::default())
|
||||||
}
|
}
|
||||||
Value::Particle(p) => {
|
Value::Particle(p) => {
|
||||||
let variant = ident(p.to_pascal_case());
|
let variant = ident(p.replace('.', "_").to_pascal_case());
|
||||||
quote!(valence_core::packet::s2c::play::particle::Particle::#variant)
|
quote!(valence_core::packet::s2c::play::particle::Particle::#variant)
|
||||||
}
|
}
|
||||||
Value::VillagerData {
|
Value::VillagerData {
|
||||||
|
@ -216,8 +216,8 @@ impl Value {
|
||||||
profession,
|
profession,
|
||||||
level,
|
level,
|
||||||
} => {
|
} => {
|
||||||
let typ = ident(typ.to_pascal_case());
|
let typ = ident(typ.replace('.', "_").to_pascal_case());
|
||||||
let profession = ident(profession.to_pascal_case());
|
let profession = ident(profession.replace('.', "_").to_pascal_case());
|
||||||
quote! {
|
quote! {
|
||||||
crate::VillagerData {
|
crate::VillagerData {
|
||||||
kind: crate::VillagerKind::#typ,
|
kind: crate::VillagerKind::#typ,
|
||||||
|
@ -231,24 +231,24 @@ impl Value {
|
||||||
quote!(None)
|
quote!(None)
|
||||||
}
|
}
|
||||||
Value::EntityPose(p) => {
|
Value::EntityPose(p) => {
|
||||||
let variant = ident(p.to_pascal_case());
|
let variant = ident(p.replace('.', "_").to_pascal_case());
|
||||||
quote!(crate::Pose::#variant)
|
quote!(crate::Pose::#variant)
|
||||||
}
|
}
|
||||||
Value::CatVariant(c) => {
|
Value::CatVariant(c) => {
|
||||||
let variant = ident(c.to_pascal_case());
|
let variant = ident(c.replace('.', "_").to_pascal_case());
|
||||||
quote!(crate::CatKind::#variant)
|
quote!(crate::CatKind::#variant)
|
||||||
}
|
}
|
||||||
Value::FrogVariant(f) => {
|
Value::FrogVariant(f) => {
|
||||||
let variant = ident(f.to_pascal_case());
|
let variant = ident(f.replace('.', "_").to_pascal_case());
|
||||||
quote!(crate::FrogKind::#variant)
|
quote!(crate::FrogKind::#variant)
|
||||||
}
|
}
|
||||||
Value::OptionalGlobalPos(_) => quote!(()),
|
Value::OptionalGlobalPos(_) => quote!(()),
|
||||||
Value::PaintingVariant(p) => {
|
Value::PaintingVariant(p) => {
|
||||||
let variant = ident(p.to_pascal_case());
|
let variant = ident(p.replace('.', "_").to_pascal_case());
|
||||||
quote!(crate::PaintingKind::#variant)
|
quote!(crate::PaintingKind::#variant)
|
||||||
}
|
}
|
||||||
Value::SnifferState(s) => {
|
Value::SnifferState(s) => {
|
||||||
let state = ident(s.to_pascal_case());
|
let state = ident(s.replace('.', "_").to_pascal_case());
|
||||||
quote!(crate::SnifferState::#state)
|
quote!(crate::SnifferState::#state)
|
||||||
}
|
}
|
||||||
Value::Vector3f { x, y, z } => quote!(glam::f32::Vec3::new(#x, #y, #z)),
|
Value::Vector3f { x, y, z } => quote!(glam::f32::Vec3::new(#x, #y, #z)),
|
||||||
|
@ -297,7 +297,9 @@ fn build() -> anyhow::Result<TokenStream> {
|
||||||
|
|
||||||
for (entity_name, entity) in entities.clone() {
|
for (entity_name, entity) in entities.clone() {
|
||||||
let entity_name_ident = ident(&entity_name);
|
let entity_name_ident = ident(&entity_name);
|
||||||
let stripped_shouty_entity_name = strip_entity_suffix(&entity_name).to_shouty_snake_case();
|
let stripped_shouty_entity_name = strip_entity_suffix(&entity_name)
|
||||||
|
.replace('.', "_")
|
||||||
|
.to_shouty_snake_case();
|
||||||
let stripped_shouty_entity_name_ident = ident(&stripped_shouty_entity_name);
|
let stripped_shouty_entity_name_ident = ident(&stripped_shouty_entity_name);
|
||||||
let stripped_snake_entity_name = strip_entity_suffix(&entity_name).to_snake_case();
|
let stripped_snake_entity_name = strip_entity_suffix(&entity_name).to_snake_case();
|
||||||
let stripped_snake_entity_name_ident = ident(&stripped_snake_entity_name);
|
let stripped_snake_entity_name_ident = ident(&stripped_snake_entity_name);
|
||||||
|
@ -351,7 +353,8 @@ fn build() -> anyhow::Result<TokenStream> {
|
||||||
let snake_entity_name_ident = ident(entity_name.to_snake_case());
|
let snake_entity_name_ident = ident(entity_name.to_snake_case());
|
||||||
let stripped_snake_entity_name_ident =
|
let stripped_snake_entity_name_ident =
|
||||||
ident(stripped_entity_name.to_snake_case());
|
ident(stripped_entity_name.to_snake_case());
|
||||||
let pascal_entity_name_ident = ident(entity_name.to_pascal_case());
|
let pascal_entity_name_ident =
|
||||||
|
ident(entity_name.replace('.', "_").to_pascal_case());
|
||||||
|
|
||||||
bundle_fields.extend([quote! {
|
bundle_fields.extend([quote! {
|
||||||
pub #snake_entity_name_ident: super::#stripped_snake_entity_name_ident::#pascal_entity_name_ident,
|
pub #snake_entity_name_ident: super::#stripped_snake_entity_name_ident::#pascal_entity_name_ident,
|
||||||
|
@ -363,7 +366,7 @@ fn build() -> anyhow::Result<TokenStream> {
|
||||||
}
|
}
|
||||||
MarkerOrField::Field { entity_name, field } => {
|
MarkerOrField::Field { entity_name, field } => {
|
||||||
let snake_field_name = field.name.to_snake_case();
|
let snake_field_name = field.name.to_snake_case();
|
||||||
let pascal_field_name = field.name.to_pascal_case();
|
let pascal_field_name = field.name.replace('.', "_").to_pascal_case();
|
||||||
let pascal_field_name_ident = ident(&pascal_field_name);
|
let pascal_field_name_ident = ident(&pascal_field_name);
|
||||||
let stripped_entity_name = strip_entity_suffix(entity_name);
|
let stripped_entity_name = strip_entity_suffix(entity_name);
|
||||||
let stripped_snake_entity_name = stripped_entity_name.to_snake_case();
|
let stripped_snake_entity_name = stripped_entity_name.to_snake_case();
|
||||||
|
@ -444,7 +447,7 @@ fn build() -> anyhow::Result<TokenStream> {
|
||||||
}
|
}
|
||||||
|
|
||||||
for field in &entity.fields {
|
for field in &entity.fields {
|
||||||
let pascal_field_name_ident = ident(field.name.to_pascal_case());
|
let pascal_field_name_ident = ident(field.name.replace('.', "_").to_pascal_case());
|
||||||
let snake_field_name = field.name.to_snake_case();
|
let snake_field_name = field.name.to_snake_case();
|
||||||
let inner_type = field.default_value.field_type();
|
let inner_type = field.default_value.field_type();
|
||||||
let default_expr = field.default_value.default_expr();
|
let default_expr = field.default_value.default_expr();
|
||||||
|
@ -522,7 +525,7 @@ fn build() -> anyhow::Result<TokenStream> {
|
||||||
.entity_status
|
.entity_status
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|(name, code)| {
|
.map(|(name, code)| {
|
||||||
let name = ident(name.to_pascal_case());
|
let name = ident(name.replace('.', "_").to_pascal_case());
|
||||||
let code = code as isize;
|
let code = code as isize;
|
||||||
|
|
||||||
quote! {
|
quote! {
|
||||||
|
@ -535,7 +538,7 @@ fn build() -> anyhow::Result<TokenStream> {
|
||||||
.entity_animation
|
.entity_animation
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|(name, code)| {
|
.map(|(name, code)| {
|
||||||
let name = ident(name.to_pascal_case());
|
let name = ident(name.replace('.', "_").to_pascal_case());
|
||||||
let code = code as isize;
|
let code = code as isize;
|
||||||
|
|
||||||
quote! {
|
quote! {
|
||||||
|
|
Loading…
Reference in a new issue