fix: disable cave carver for now

fixes some issues
This commit is contained in:
Alexander Medvedev
2026-05-23 16:36:08 +02:00
parent f19d84efef
commit 3629f43dcc
53 changed files with 403 additions and 212 deletions

View File

@@ -1435,7 +1435,7 @@ fn get_be_data_from_nbt<R: Read + Seek>(
let raw_name = nbt.get_string("name").unwrap();
raw_name
.strip_prefix("minecraft:")
.unwrap_or(&raw_name)
.unwrap_or(raw_name)
.to_string()
};

View File

@@ -91,7 +91,6 @@ impl ToTokens for LootPoolStruct {
}
}
/// Deserialized single-item loot entry holding the item's registry key.
#[derive(Deserialize, Clone, Debug)]
pub struct ItemEntryStruct {
@@ -428,9 +427,7 @@ pub enum LootConditionStruct {
},
/// References an external predicate by ID.
#[serde(rename = "minecraft:reference")]
Reference {
name: String,
},
Reference { name: String },
/// Passes based on the current in-game time.
#[serde(rename = "minecraft:time_check")]
TimeCheck {
@@ -446,9 +443,7 @@ pub enum LootConditionStruct {
},
/// Passes if an enchantment is currently active.
#[serde(rename = "minecraft:enchantment_active_check")]
EnchantmentActiveCheck {
active: bool,
},
EnchantmentActiveCheck { active: bool },
}
impl ToTokens for LootConditionStruct {
@@ -461,7 +456,10 @@ impl ToTokens for LootConditionStruct {
Self::RandomChance { chance } => {
quote! { LootCondition::RandomChance { chance: #chance } }
}
Self::RandomChanceWithEnchantedBonus { enchantment, chances } => {
Self::RandomChanceWithEnchantedBonus {
enchantment,
chances,
} => {
let e = LitStr::new(enchantment, Span::call_site());
if let Some(chances) = chances {
quote! { LootCondition::RandomChanceWithEnchantedBonus { enchantment: #e, chances: Some(&[#(#chances),*]) } }
@@ -472,15 +470,17 @@ impl ToTokens for LootConditionStruct {
Self::EntityProperties { entity, predicate } => {
let entity = entity.as_deref().unwrap_or("this");
let e = LitStr::new(entity, Span::call_site());
let expected_type = predicate.as_ref().and_then(|p| p.entity_type.as_ref()).map(|t| {
match t {
let expected_type = predicate
.as_ref()
.and_then(|p| p.entity_type.as_ref())
.map(|t| match t {
StringOrVec::String(s) => quote! { Some(#s) },
StringOrVec::Vec(v) => {
let s = &v[0];
quote! { Some(#s) }
}
}
}).unwrap_or(quote! { None });
})
.unwrap_or(quote! { None });
quote! { LootCondition::EntityProperties { entity: #e, expected_type: #expected_type } }
}
Self::KilledByPlayer => quote! { LootCondition::KilledByPlayer },
@@ -516,7 +516,10 @@ impl ToTokens for LootConditionStruct {
quote! { LootCondition::MatchTool { items: None } }
}
}
Self::TableBonus { enchantment, chances } => {
Self::TableBonus {
enchantment,
chances,
} => {
let e = LitStr::new(enchantment, Span::call_site());
quote! { LootCondition::TableBonus { enchantment: #e, chances: &[#(#chances),*] } }
}
@@ -559,20 +562,29 @@ impl ToTokens for LootConditionStruct {
let ox = offset_x.unwrap_or(0);
let oy = offset_y.unwrap_or(0);
let oz = offset_z.unwrap_or(0);
let expected_biome = predicate.as_ref().and_then(|p| p.biome.as_ref()).map(|b| {
match b {
let expected_biome = predicate
.as_ref()
.and_then(|p| p.biome.as_ref())
.map(|b| match b {
StringOrVec::String(s) => quote! { Some(#s) },
StringOrVec::Vec(v) => {
let s = &v[0];
quote! { Some(#s) }
}
}
}).unwrap_or(quote! { None });
})
.unwrap_or(quote! { None });
quote! { LootCondition::LocationCheck { offset_x: #ox, offset_y: #oy, offset_z: #oz, expected_biome: #expected_biome } }
}
Self::WeatherCheck { raining, thundering } => {
let r = raining.map(|b| quote! { Some(#b) }).unwrap_or(quote! { None });
let t = thundering.map(|b| quote! { Some(#b) }).unwrap_or(quote! { None });
Self::WeatherCheck {
raining,
thundering,
} => {
let r = raining
.map(|b| quote! { Some(#b) })
.unwrap_or(quote! { None });
let t = thundering
.map(|b| quote! { Some(#b) })
.unwrap_or(quote! { None });
quote! { LootCondition::WeatherCheck { raining: #r, thundering: #t } }
}
Self::Reference { name } => {
@@ -581,7 +593,9 @@ impl ToTokens for LootConditionStruct {
}
Self::TimeCheck { range, period } => {
let r = range.to_token_stream();
let p = period.map(|val| quote! { Some(#val) }).unwrap_or(quote! { None });
let p = period
.map(|val| quote! { Some(#val) })
.unwrap_or(quote! { None });
quote! { LootCondition::TimeCheck { range: #r, period: #p } }
}
Self::ValueCheck { value, range } => {
@@ -824,8 +838,14 @@ pub struct LootFunctionLimitCountStruct {
impl ToTokens for LootFunctionLimitCountStruct {
fn to_tokens(&self, tokens: &mut TokenStream) {
let min = self.min.map(|val| quote! { Some(#val) }).unwrap_or(quote! { None });
let max = self.max.map(|val| quote! { Some(#val) }).unwrap_or(quote! { None });
let min = self
.min
.map(|val| quote! { Some(#val) })
.unwrap_or(quote! { None });
let max = self
.max
.map(|val| quote! { Some(#val) })
.unwrap_or(quote! { None });
tokens.extend(quote! { (#min, #max) });
}
}
@@ -918,7 +938,6 @@ impl ToTokens for LootPoolEntryStruct {
}
}
/// Deserialized loot table category, tagged by its `"type"` field.
#[derive(Deserialize, Clone, Debug)]
#[serde(rename = "snake_case")]

View File

@@ -15,7 +15,10 @@ pub fn build() -> TokenStream {
(JavaMinecraftVersion::V_1_21_6, "1_21_6_meta_data_type.json"),
(JavaMinecraftVersion::V_1_21_7, "1_21_7_meta_data_type.json"),
(JavaMinecraftVersion::V_1_21_9, "1_21_9_meta_data_type.json"),
(JavaMinecraftVersion::V_1_21_11, "1_21_11_meta_data_type.json"),
(
JavaMinecraftVersion::V_1_21_11,
"1_21_11_meta_data_type.json",
),
(JavaMinecraftVersion::V_26_1, "26_1_meta_data_type.json"),
];

View File

@@ -13,14 +13,35 @@ const LATEST_VERSION: JavaMinecraftVersion = JavaMinecraftVersion::V_26_1;
/// static registry data, and the `Registry::get_synced` method.
pub(crate) fn build() -> TokenStream {
let assets = [
(JavaMinecraftVersion::V_1_20_5, "1_21_synced_registries.json"),
(
JavaMinecraftVersion::V_1_20_5,
"1_21_synced_registries.json",
),
(JavaMinecraftVersion::V_1_21, "1_21_synced_registries.json"),
(JavaMinecraftVersion::V_1_21_2, "1_21_2_synced_registries.json"),
(JavaMinecraftVersion::V_1_21_4, "1_21_4_synced_registries.json"),
(JavaMinecraftVersion::V_1_21_5, "1_21_5_synced_registries.json"),
(JavaMinecraftVersion::V_1_21_6, "1_21_6_synced_registries.json"),
(JavaMinecraftVersion::V_1_21_7, "1_21_7_synced_registries.json"),
(JavaMinecraftVersion::V_1_21_9, "1_21_9_synced_registries.json"),
(
JavaMinecraftVersion::V_1_21_2,
"1_21_2_synced_registries.json",
),
(
JavaMinecraftVersion::V_1_21_4,
"1_21_4_synced_registries.json",
),
(
JavaMinecraftVersion::V_1_21_5,
"1_21_5_synced_registries.json",
),
(
JavaMinecraftVersion::V_1_21_6,
"1_21_6_synced_registries.json",
),
(
JavaMinecraftVersion::V_1_21_7,
"1_21_7_synced_registries.json",
),
(
JavaMinecraftVersion::V_1_21_9,
"1_21_9_synced_registries.json",
),
(
JavaMinecraftVersion::V_1_21_11,
"1_21_11_synced_registries.json",

View File

@@ -27,10 +27,7 @@ pub fn build() -> String {
biome_enum.case(name);
}
interface.type_def(TypeDef::new(
"biome",
TypeDefKind::Enum(biome_enum),
));
interface.type_def(TypeDef::new("biome", TypeDefKind::Enum(biome_enum)));
package.interface(interface);
package.to_string()

View File

@@ -23,8 +23,7 @@ pub fn build() -> String {
let name = raw_name
.strip_prefix("minecraft:")
.unwrap_or(raw_name)
.replace('_', "-")
.replace('/', "-");
.replace(['_', '/'], "-");
component_enum.case(name);
}

View File

@@ -88,7 +88,9 @@ fn parse_packet_file(path: &Path, interface: &mut Interface, variant: &mut Varia
syn::Type::Path(p) => p.path.segments.last().unwrap().ident.to_string(),
syn::Type::Reference(r) => match &*r.elem {
syn::Type::Slice(s) => match &*s.elem {
syn::Type::Path(p) => p.path.segments.last().unwrap().ident.to_string(),
syn::Type::Path(p) => {
p.path.segments.last().unwrap().ident.to_string()
}
_ => String::new(),
},
syn::Type::Path(p) => p.path.segments.last().unwrap().ident.to_string(),

View File

@@ -235,7 +235,11 @@ fn parse_packet_file(
fn get_type_info(ty: &syn::Type) -> (String, bool, bool) {
match ty {
syn::Type::Path(tp) => (tp.path.segments.last().unwrap().ident.to_string(), false, false),
syn::Type::Path(tp) => (
tp.path.segments.last().unwrap().ident.to_string(),
false,
false,
),
syn::Type::Reference(tr) => {
let (name, _, is_slice) = get_type_info(&tr.elem);
(name, true, is_slice)

View File

@@ -17,16 +17,15 @@ pub fn map_type(ty: &Type) -> WitType {
"u8" | "i8" => WitType::U8,
"u16" | "i16" => WitType::S32,
"Option" => {
if let syn::PathArguments::AngleBracketed(args) = &last_segment.arguments {
if let Some(syn::GenericArgument::Type(inner_ty)) = args.args.first() {
if let syn::PathArguments::AngleBracketed(args) = &last_segment.arguments
&& let Some(syn::GenericArgument::Type(inner_ty)) = args.args.first() {
return WitType::option(map_type(inner_ty));
}
}
WitType::String
}
"Vec" | "Box" => {
if let syn::PathArguments::AngleBracketed(args) = &last_segment.arguments {
if let Some(syn::GenericArgument::Type(inner_ty)) = args.args.first() {
if let syn::PathArguments::AngleBracketed(args) = &last_segment.arguments
&& let Some(syn::GenericArgument::Type(inner_ty)) = args.args.first() {
// Check if the inner type is u8
if let Type::Path(tp) = inner_ty
&& tp.path.segments.last().unwrap().ident == "u8"
@@ -35,7 +34,6 @@ pub fn map_type(ty: &Type) -> WitType {
}
return WitType::list(map_type(inner_ty));
}
}
WitType::String
}
"Vector3" | "BlockPos" => {