From 330a68054f71c903a1a73272ab92b7087be547c5 Mon Sep 17 00:00:00 2001 From: Alexander Medvedev Date: Tue, 19 May 2026 20:19:46 +0200 Subject: [PATCH] chore: replace String with ConfiguredFeatures enum --- pumpkin-codegen/src/configured_feature.rs | 64 +- pumpkin-codegen/src/main.rs | 1 + pumpkin-codegen/src/placed_feature.rs | 3 +- pumpkin-data/Cargo.toml | 2 + .../src/generated/configured_feature.rs | 679 ++++++++++++++ .../configured_features_generated.rs | 514 ++++++----- .../generated/placed_features_generated.rs | 860 ++++++++++++------ pumpkin-data/src/lib.rs | 4 + .../generation/feature/configured_features.rs | 5 +- .../src/generation/feature/placed_features.rs | 6 +- 10 files changed, 1630 insertions(+), 508 deletions(-) create mode 100644 pumpkin-data/src/generated/configured_feature.rs diff --git a/pumpkin-codegen/src/configured_feature.rs b/pumpkin-codegen/src/configured_feature.rs index 2831af010..137565ce5 100644 --- a/pumpkin-codegen/src/configured_feature.rs +++ b/pumpkin-codegen/src/configured_feature.rs @@ -9,6 +9,58 @@ use crate::placed_feature::{ value_to_block_state_codec, value_to_height_provider, value_to_int_provider, }; +/// Reads `configured_features.json` and emits the complete `ConfiguredFeature` enum `TokenStream`. +pub fn build_enum() -> TokenStream { + let json_content = fs::read_to_string("../assets/configured_features.json") + .expect("Failed to read configured_features.json"); + let json: Value = + serde_json::from_str(&json_content).expect("Failed to parse configured_features.json"); + + let mut from_name_arms = Vec::new(); + let mut to_name_arms = Vec::new(); + + let variants: Vec = json + .as_object() + .unwrap() + .iter() + .map(|(name, _)| { + let variant_name = format_ident!("{}", name.to_pascal_case()); + from_name_arms.push(quote! { + #name => Some(Self::#variant_name), + }); + to_name_arms.push(quote! { + Self::#variant_name => #name, + }); + quote! { + #variant_name, + } + }) + .collect(); + + quote! { + #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] + pub enum ConfiguredFeature { + #(#variants)* + } + + impl ConfiguredFeature { + pub fn from_name(name: &str) -> Option { + let name = name.strip_prefix("minecraft:").unwrap_or(name); + match name { + #(#from_name_arms)* + _ => None, + } + } + + pub const fn to_name(&self) -> &'static str { + match self { + #(#to_name_arms)* + } + } + } + } +} + /// Reads `configured_features.json` and emits a `build_configured_features()` function `TokenStream`. pub fn build() -> TokenStream { let json_content = fs::read_to_string("../assets/configured_features.json") @@ -22,15 +74,16 @@ pub fn build() -> TokenStream { .iter() .map(|(name, value)| { let cf = value_to_configured_feature(value); + let variant_name = format_ident!("{}", name.to_pascal_case()); quote! { - map.insert(#name.to_string(), #cf); + map.insert(pumpkin_data::configured_feature::ConfiguredFeature::#variant_name, #cf); } }) .collect(); quote! { #[allow(clippy::all, unused_imports, dead_code)] - fn build_configured_features() -> std::collections::HashMap { + fn build_configured_features() -> std::collections::HashMap { use crate::generation::block_predicate::{ AllOfBlockPredicate, AnyOfBlockPredicate, BlockPredicate, HasSturdyFacePredicate, InsideWorldBoundsBlockPredicate, @@ -1473,18 +1526,19 @@ fn value_to_placed_feature_wrapper(v: &Value) -> TokenStream { /// – `v` – a JSON string (named reference) or object (inline configured feature). /// /// # Returns -/// `Feature::Named` for a string value or `Feature::Inlined` for an object; defaults to `Feature::Named("")` for other types. +/// `Feature::Named` for a string value or `Feature::Inlined` for an object; defaults to `Feature::Named(pumpkin_data::configured_feature::ConfiguredFeature::NoOp)` for other types. fn value_to_feature_ref(v: &Value) -> TokenStream { match v { Value::String(s) => { let name = s.strip_prefix("minecraft:").unwrap_or(s); - quote! { Feature::Named(#name.to_string()) } + let variant_name = format_ident!("{}", name.to_pascal_case()); + quote! { Feature::Named(pumpkin_data::configured_feature::ConfiguredFeature::#variant_name) } } Value::Object(_) => { let cf = value_to_configured_feature(v); quote! { Feature::Inlined(Box::new(#cf)) } } - _ => quote! { Feature::Named(String::new()) }, + _ => quote! { Feature::Named(pumpkin_data::configured_feature::ConfiguredFeature::NoOp) }, } } diff --git a/pumpkin-codegen/src/main.rs b/pumpkin-codegen/src/main.rs index dfec4efdd..8308be89e 100644 --- a/pumpkin-codegen/src/main.rs +++ b/pumpkin-codegen/src/main.rs @@ -126,6 +126,7 @@ pub fn main() { (recipe_remainder::build, "recipe_remainder.rs"), (placed_feature::build_enum, "placed_feature.rs"), (placed_feature::build, "placed_features_generated.rs"), + (configured_feature::build_enum, "configured_feature.rs"), ( configured_feature::build, "configured_features_generated.rs", diff --git a/pumpkin-codegen/src/placed_feature.rs b/pumpkin-codegen/src/placed_feature.rs index 492bd3254..2537557f8 100644 --- a/pumpkin-codegen/src/placed_feature.rs +++ b/pumpkin-codegen/src/placed_feature.rs @@ -140,7 +140,8 @@ fn value_to_feature(v: &Value) -> TokenStream { match v { Value::String(s) => { let name = s.strip_prefix("minecraft:").unwrap_or(s); - quote! { Feature::Named(#name.to_string()) } + let variant_name = format_ident!("{}", name.to_pascal_case()); + quote! { Feature::Named(pumpkin_data::configured_feature::ConfiguredFeature::#variant_name) } } Value::Object(_) => { let cf = value_to_inline_configured_feature(v); diff --git a/pumpkin-data/Cargo.toml b/pumpkin-data/Cargo.toml index be06526e2..c196dbbe6 100644 --- a/pumpkin-data/Cargo.toml +++ b/pumpkin-data/Cargo.toml @@ -44,6 +44,7 @@ default = [ "carver", "villager", "placed_feature", + "configured_feature", ] item = [] @@ -92,6 +93,7 @@ spawn_egg = [] world_event = [] message_type = [] placed_feature = [] +configured_feature = [] block = [] item_id_remap = [] entity_id_remap = [] diff --git a/pumpkin-data/src/generated/configured_feature.rs b/pumpkin-data/src/generated/configured_feature.rs new file mode 100644 index 000000000..0e4fc1cf7 --- /dev/null +++ b/pumpkin-data/src/generated/configured_feature.rs @@ -0,0 +1,679 @@ +/* This file is generated. Do not edit manually. */ +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +pub enum ConfiguredFeature { + Acacia, + AmethystGeode, + AzaleaTree, + BambooNoPodzol, + BambooSomePodzol, + BambooVegetation, + BasaltBlobs, + BasaltPillar, + BerryBush, + Birch, + BirchBees0002, + BirchBees0002LeafLitter, + BirchBees002, + BirchBees005, + BirchLeafLitter, + BirchTall, + BlackstoneBlobs, + BlueIce, + BonusChest, + BrownMushroom, + Bush, + Cactus, + CaveVine, + CaveVineInMoss, + Cherry, + CherryBees005, + ChorusPlant, + ClayPoolWithDripleaves, + ClayWithDripleaves, + CrimsonForestVegetation, + CrimsonForestVegetationBonemeal, + CrimsonFungus, + CrimsonFungusPlanted, + CrimsonRoots, + DarkForestVegetation, + DarkOak, + DarkOakLeafLitter, + DeadBush, + Delta, + DesertWell, + DiskClay, + DiskGrass, + DiskGravel, + DiskSand, + Dripleaf, + DripstoneCluster, + DryGrass, + EndGatewayDelayed, + EndGatewayReturn, + EndIsland, + EndPlatform, + EndSpike, + FallenBirchTree, + FallenJungleTree, + FallenOakTree, + FallenSpruceTree, + FallenSuperBirchTree, + FancyOak, + FancyOakBees, + FancyOakBees0002LeafLitter, + FancyOakBees002, + FancyOakBees005, + FancyOakLeafLitter, + FireflyBush, + FlowerCherry, + FlowerDefault, + FlowerFlowerForest, + FlowerMeadow, + FlowerPaleGarden, + FlowerPlain, + FlowerSwamp, + ForestFlowers, + ForestRock, + FossilCoal, + FossilDiamonds, + FreezeTopLayer, + GlowLichen, + GlowstoneExtra, + Grass, + GrassJungle, + HugeBrownMushroom, + HugeRedMushroom, + IcePatch, + IceSpike, + IcebergBlue, + IcebergPacked, + JungleBush, + JungleTree, + JungleTreeNoVine, + Kelp, + LakeLava, + LargeBasaltColumns, + LargeDripstone, + LargeFern, + LeafLitter, + LushCavesClay, + Mangrove, + MangroveVegetation, + MeadowTrees, + MegaJungleTree, + MegaPine, + MegaSpruce, + Melon, + MonsterRoom, + MossPatch, + MossPatchBonemeal, + MossPatchCeiling, + MossVegetation, + MushroomIslandVegetation, + NetherSprouts, + NetherSproutsBonemeal, + Oak, + OakBees0002LeafLitter, + OakBees002, + OakBees005, + OakLeafLitter, + OreAncientDebrisLarge, + OreAncientDebrisSmall, + OreAndesite, + OreBlackstone, + OreClay, + OreCoal, + OreCoalBuried, + OreCopperLarge, + OreCopperSmall, + OreDiamondBuried, + OreDiamondLarge, + OreDiamondMedium, + OreDiamondSmall, + OreDiorite, + OreDirt, + OreEmerald, + OreGold, + OreGoldBuried, + OreGranite, + OreGravel, + OreGravelNether, + OreInfested, + OreIron, + OreIronSmall, + OreLapis, + OreLapisBuried, + OreMagma, + OreNetherGold, + OreQuartz, + OreRedstone, + OreSoulSand, + OreTuff, + PaleForestFlower, + PaleGardenVegetation, + PaleMossPatch, + PaleMossPatchBonemeal, + PaleMossVegetation, + PaleOak, + PaleOakBonemeal, + PaleOakCreaking, + PatchFire, + PatchSoulFire, + PileHay, + PileIce, + PileMelon, + PilePumpkin, + PileSnow, + Pine, + PointedDripstone, + Pumpkin, + RedMushroom, + RootedAzaleaTree, + SculkPatchAncientCity, + SculkPatchDeepDark, + SculkVein, + SeaPickle, + SeagrassMid, + SeagrassShort, + SeagrassSlightlyLessShort, + SeagrassTall, + SmallBasaltColumns, + SporeBlossom, + SpringLavaFrozen, + SpringLavaNether, + SpringLavaOverworld, + SpringNetherClosed, + SpringNetherOpen, + SpringWater, + Spruce, + SugarCane, + Sunflower, + SuperBirchBees, + SuperBirchBees0002, + SwampOak, + TaigaGrass, + TallGrass, + TallMangrove, + TreesBadlands, + TreesBirch, + TreesBirchAndOakLeafLitter, + TreesFlowerForest, + TreesGrove, + TreesJungle, + TreesOldGrowthPineTaiga, + TreesOldGrowthSpruceTaiga, + TreesPlains, + TreesSavanna, + TreesSnowy, + TreesSparseJungle, + TreesTaiga, + TreesWater, + TreesWindsweptHills, + TwistingVines, + TwistingVinesBonemeal, + UnderwaterMagma, + Vines, + VoidStartPlatform, + WarmOceanVegetation, + WarpedForestVegetation, + WarpedForestVegetationBonemeal, + WarpedFungus, + WarpedFungusPlanted, + Waterlily, + WeepingVines, + Wildflower, +} +impl ConfiguredFeature { + pub fn from_name(name: &str) -> Option { + let name = name.strip_prefix("minecraft:").unwrap_or(name); + match name { + "acacia" => Some(Self::Acacia), + "amethyst_geode" => Some(Self::AmethystGeode), + "azalea_tree" => Some(Self::AzaleaTree), + "bamboo_no_podzol" => Some(Self::BambooNoPodzol), + "bamboo_some_podzol" => Some(Self::BambooSomePodzol), + "bamboo_vegetation" => Some(Self::BambooVegetation), + "basalt_blobs" => Some(Self::BasaltBlobs), + "basalt_pillar" => Some(Self::BasaltPillar), + "berry_bush" => Some(Self::BerryBush), + "birch" => Some(Self::Birch), + "birch_bees_0002" => Some(Self::BirchBees0002), + "birch_bees_0002_leaf_litter" => Some(Self::BirchBees0002LeafLitter), + "birch_bees_002" => Some(Self::BirchBees002), + "birch_bees_005" => Some(Self::BirchBees005), + "birch_leaf_litter" => Some(Self::BirchLeafLitter), + "birch_tall" => Some(Self::BirchTall), + "blackstone_blobs" => Some(Self::BlackstoneBlobs), + "blue_ice" => Some(Self::BlueIce), + "bonus_chest" => Some(Self::BonusChest), + "brown_mushroom" => Some(Self::BrownMushroom), + "bush" => Some(Self::Bush), + "cactus" => Some(Self::Cactus), + "cave_vine" => Some(Self::CaveVine), + "cave_vine_in_moss" => Some(Self::CaveVineInMoss), + "cherry" => Some(Self::Cherry), + "cherry_bees_005" => Some(Self::CherryBees005), + "chorus_plant" => Some(Self::ChorusPlant), + "clay_pool_with_dripleaves" => Some(Self::ClayPoolWithDripleaves), + "clay_with_dripleaves" => Some(Self::ClayWithDripleaves), + "crimson_forest_vegetation" => Some(Self::CrimsonForestVegetation), + "crimson_forest_vegetation_bonemeal" => Some(Self::CrimsonForestVegetationBonemeal), + "crimson_fungus" => Some(Self::CrimsonFungus), + "crimson_fungus_planted" => Some(Self::CrimsonFungusPlanted), + "crimson_roots" => Some(Self::CrimsonRoots), + "dark_forest_vegetation" => Some(Self::DarkForestVegetation), + "dark_oak" => Some(Self::DarkOak), + "dark_oak_leaf_litter" => Some(Self::DarkOakLeafLitter), + "dead_bush" => Some(Self::DeadBush), + "delta" => Some(Self::Delta), + "desert_well" => Some(Self::DesertWell), + "disk_clay" => Some(Self::DiskClay), + "disk_grass" => Some(Self::DiskGrass), + "disk_gravel" => Some(Self::DiskGravel), + "disk_sand" => Some(Self::DiskSand), + "dripleaf" => Some(Self::Dripleaf), + "dripstone_cluster" => Some(Self::DripstoneCluster), + "dry_grass" => Some(Self::DryGrass), + "end_gateway_delayed" => Some(Self::EndGatewayDelayed), + "end_gateway_return" => Some(Self::EndGatewayReturn), + "end_island" => Some(Self::EndIsland), + "end_platform" => Some(Self::EndPlatform), + "end_spike" => Some(Self::EndSpike), + "fallen_birch_tree" => Some(Self::FallenBirchTree), + "fallen_jungle_tree" => Some(Self::FallenJungleTree), + "fallen_oak_tree" => Some(Self::FallenOakTree), + "fallen_spruce_tree" => Some(Self::FallenSpruceTree), + "fallen_super_birch_tree" => Some(Self::FallenSuperBirchTree), + "fancy_oak" => Some(Self::FancyOak), + "fancy_oak_bees" => Some(Self::FancyOakBees), + "fancy_oak_bees_0002_leaf_litter" => Some(Self::FancyOakBees0002LeafLitter), + "fancy_oak_bees_002" => Some(Self::FancyOakBees002), + "fancy_oak_bees_005" => Some(Self::FancyOakBees005), + "fancy_oak_leaf_litter" => Some(Self::FancyOakLeafLitter), + "firefly_bush" => Some(Self::FireflyBush), + "flower_cherry" => Some(Self::FlowerCherry), + "flower_default" => Some(Self::FlowerDefault), + "flower_flower_forest" => Some(Self::FlowerFlowerForest), + "flower_meadow" => Some(Self::FlowerMeadow), + "flower_pale_garden" => Some(Self::FlowerPaleGarden), + "flower_plain" => Some(Self::FlowerPlain), + "flower_swamp" => Some(Self::FlowerSwamp), + "forest_flowers" => Some(Self::ForestFlowers), + "forest_rock" => Some(Self::ForestRock), + "fossil_coal" => Some(Self::FossilCoal), + "fossil_diamonds" => Some(Self::FossilDiamonds), + "freeze_top_layer" => Some(Self::FreezeTopLayer), + "glow_lichen" => Some(Self::GlowLichen), + "glowstone_extra" => Some(Self::GlowstoneExtra), + "grass" => Some(Self::Grass), + "grass_jungle" => Some(Self::GrassJungle), + "huge_brown_mushroom" => Some(Self::HugeBrownMushroom), + "huge_red_mushroom" => Some(Self::HugeRedMushroom), + "ice_patch" => Some(Self::IcePatch), + "ice_spike" => Some(Self::IceSpike), + "iceberg_blue" => Some(Self::IcebergBlue), + "iceberg_packed" => Some(Self::IcebergPacked), + "jungle_bush" => Some(Self::JungleBush), + "jungle_tree" => Some(Self::JungleTree), + "jungle_tree_no_vine" => Some(Self::JungleTreeNoVine), + "kelp" => Some(Self::Kelp), + "lake_lava" => Some(Self::LakeLava), + "large_basalt_columns" => Some(Self::LargeBasaltColumns), + "large_dripstone" => Some(Self::LargeDripstone), + "large_fern" => Some(Self::LargeFern), + "leaf_litter" => Some(Self::LeafLitter), + "lush_caves_clay" => Some(Self::LushCavesClay), + "mangrove" => Some(Self::Mangrove), + "mangrove_vegetation" => Some(Self::MangroveVegetation), + "meadow_trees" => Some(Self::MeadowTrees), + "mega_jungle_tree" => Some(Self::MegaJungleTree), + "mega_pine" => Some(Self::MegaPine), + "mega_spruce" => Some(Self::MegaSpruce), + "melon" => Some(Self::Melon), + "monster_room" => Some(Self::MonsterRoom), + "moss_patch" => Some(Self::MossPatch), + "moss_patch_bonemeal" => Some(Self::MossPatchBonemeal), + "moss_patch_ceiling" => Some(Self::MossPatchCeiling), + "moss_vegetation" => Some(Self::MossVegetation), + "mushroom_island_vegetation" => Some(Self::MushroomIslandVegetation), + "nether_sprouts" => Some(Self::NetherSprouts), + "nether_sprouts_bonemeal" => Some(Self::NetherSproutsBonemeal), + "oak" => Some(Self::Oak), + "oak_bees_0002_leaf_litter" => Some(Self::OakBees0002LeafLitter), + "oak_bees_002" => Some(Self::OakBees002), + "oak_bees_005" => Some(Self::OakBees005), + "oak_leaf_litter" => Some(Self::OakLeafLitter), + "ore_ancient_debris_large" => Some(Self::OreAncientDebrisLarge), + "ore_ancient_debris_small" => Some(Self::OreAncientDebrisSmall), + "ore_andesite" => Some(Self::OreAndesite), + "ore_blackstone" => Some(Self::OreBlackstone), + "ore_clay" => Some(Self::OreClay), + "ore_coal" => Some(Self::OreCoal), + "ore_coal_buried" => Some(Self::OreCoalBuried), + "ore_copper_large" => Some(Self::OreCopperLarge), + "ore_copper_small" => Some(Self::OreCopperSmall), + "ore_diamond_buried" => Some(Self::OreDiamondBuried), + "ore_diamond_large" => Some(Self::OreDiamondLarge), + "ore_diamond_medium" => Some(Self::OreDiamondMedium), + "ore_diamond_small" => Some(Self::OreDiamondSmall), + "ore_diorite" => Some(Self::OreDiorite), + "ore_dirt" => Some(Self::OreDirt), + "ore_emerald" => Some(Self::OreEmerald), + "ore_gold" => Some(Self::OreGold), + "ore_gold_buried" => Some(Self::OreGoldBuried), + "ore_granite" => Some(Self::OreGranite), + "ore_gravel" => Some(Self::OreGravel), + "ore_gravel_nether" => Some(Self::OreGravelNether), + "ore_infested" => Some(Self::OreInfested), + "ore_iron" => Some(Self::OreIron), + "ore_iron_small" => Some(Self::OreIronSmall), + "ore_lapis" => Some(Self::OreLapis), + "ore_lapis_buried" => Some(Self::OreLapisBuried), + "ore_magma" => Some(Self::OreMagma), + "ore_nether_gold" => Some(Self::OreNetherGold), + "ore_quartz" => Some(Self::OreQuartz), + "ore_redstone" => Some(Self::OreRedstone), + "ore_soul_sand" => Some(Self::OreSoulSand), + "ore_tuff" => Some(Self::OreTuff), + "pale_forest_flower" => Some(Self::PaleForestFlower), + "pale_garden_vegetation" => Some(Self::PaleGardenVegetation), + "pale_moss_patch" => Some(Self::PaleMossPatch), + "pale_moss_patch_bonemeal" => Some(Self::PaleMossPatchBonemeal), + "pale_moss_vegetation" => Some(Self::PaleMossVegetation), + "pale_oak" => Some(Self::PaleOak), + "pale_oak_bonemeal" => Some(Self::PaleOakBonemeal), + "pale_oak_creaking" => Some(Self::PaleOakCreaking), + "patch_fire" => Some(Self::PatchFire), + "patch_soul_fire" => Some(Self::PatchSoulFire), + "pile_hay" => Some(Self::PileHay), + "pile_ice" => Some(Self::PileIce), + "pile_melon" => Some(Self::PileMelon), + "pile_pumpkin" => Some(Self::PilePumpkin), + "pile_snow" => Some(Self::PileSnow), + "pine" => Some(Self::Pine), + "pointed_dripstone" => Some(Self::PointedDripstone), + "pumpkin" => Some(Self::Pumpkin), + "red_mushroom" => Some(Self::RedMushroom), + "rooted_azalea_tree" => Some(Self::RootedAzaleaTree), + "sculk_patch_ancient_city" => Some(Self::SculkPatchAncientCity), + "sculk_patch_deep_dark" => Some(Self::SculkPatchDeepDark), + "sculk_vein" => Some(Self::SculkVein), + "sea_pickle" => Some(Self::SeaPickle), + "seagrass_mid" => Some(Self::SeagrassMid), + "seagrass_short" => Some(Self::SeagrassShort), + "seagrass_slightly_less_short" => Some(Self::SeagrassSlightlyLessShort), + "seagrass_tall" => Some(Self::SeagrassTall), + "small_basalt_columns" => Some(Self::SmallBasaltColumns), + "spore_blossom" => Some(Self::SporeBlossom), + "spring_lava_frozen" => Some(Self::SpringLavaFrozen), + "spring_lava_nether" => Some(Self::SpringLavaNether), + "spring_lava_overworld" => Some(Self::SpringLavaOverworld), + "spring_nether_closed" => Some(Self::SpringNetherClosed), + "spring_nether_open" => Some(Self::SpringNetherOpen), + "spring_water" => Some(Self::SpringWater), + "spruce" => Some(Self::Spruce), + "sugar_cane" => Some(Self::SugarCane), + "sunflower" => Some(Self::Sunflower), + "super_birch_bees" => Some(Self::SuperBirchBees), + "super_birch_bees_0002" => Some(Self::SuperBirchBees0002), + "swamp_oak" => Some(Self::SwampOak), + "taiga_grass" => Some(Self::TaigaGrass), + "tall_grass" => Some(Self::TallGrass), + "tall_mangrove" => Some(Self::TallMangrove), + "trees_badlands" => Some(Self::TreesBadlands), + "trees_birch" => Some(Self::TreesBirch), + "trees_birch_and_oak_leaf_litter" => Some(Self::TreesBirchAndOakLeafLitter), + "trees_flower_forest" => Some(Self::TreesFlowerForest), + "trees_grove" => Some(Self::TreesGrove), + "trees_jungle" => Some(Self::TreesJungle), + "trees_old_growth_pine_taiga" => Some(Self::TreesOldGrowthPineTaiga), + "trees_old_growth_spruce_taiga" => Some(Self::TreesOldGrowthSpruceTaiga), + "trees_plains" => Some(Self::TreesPlains), + "trees_savanna" => Some(Self::TreesSavanna), + "trees_snowy" => Some(Self::TreesSnowy), + "trees_sparse_jungle" => Some(Self::TreesSparseJungle), + "trees_taiga" => Some(Self::TreesTaiga), + "trees_water" => Some(Self::TreesWater), + "trees_windswept_hills" => Some(Self::TreesWindsweptHills), + "twisting_vines" => Some(Self::TwistingVines), + "twisting_vines_bonemeal" => Some(Self::TwistingVinesBonemeal), + "underwater_magma" => Some(Self::UnderwaterMagma), + "vines" => Some(Self::Vines), + "void_start_platform" => Some(Self::VoidStartPlatform), + "warm_ocean_vegetation" => Some(Self::WarmOceanVegetation), + "warped_forest_vegetation" => Some(Self::WarpedForestVegetation), + "warped_forest_vegetation_bonemeal" => Some(Self::WarpedForestVegetationBonemeal), + "warped_fungus" => Some(Self::WarpedFungus), + "warped_fungus_planted" => Some(Self::WarpedFungusPlanted), + "waterlily" => Some(Self::Waterlily), + "weeping_vines" => Some(Self::WeepingVines), + "wildflower" => Some(Self::Wildflower), + _ => None, + } + } + pub const fn to_name(&self) -> &'static str { + match self { + Self::Acacia => "acacia", + Self::AmethystGeode => "amethyst_geode", + Self::AzaleaTree => "azalea_tree", + Self::BambooNoPodzol => "bamboo_no_podzol", + Self::BambooSomePodzol => "bamboo_some_podzol", + Self::BambooVegetation => "bamboo_vegetation", + Self::BasaltBlobs => "basalt_blobs", + Self::BasaltPillar => "basalt_pillar", + Self::BerryBush => "berry_bush", + Self::Birch => "birch", + Self::BirchBees0002 => "birch_bees_0002", + Self::BirchBees0002LeafLitter => "birch_bees_0002_leaf_litter", + Self::BirchBees002 => "birch_bees_002", + Self::BirchBees005 => "birch_bees_005", + Self::BirchLeafLitter => "birch_leaf_litter", + Self::BirchTall => "birch_tall", + Self::BlackstoneBlobs => "blackstone_blobs", + Self::BlueIce => "blue_ice", + Self::BonusChest => "bonus_chest", + Self::BrownMushroom => "brown_mushroom", + Self::Bush => "bush", + Self::Cactus => "cactus", + Self::CaveVine => "cave_vine", + Self::CaveVineInMoss => "cave_vine_in_moss", + Self::Cherry => "cherry", + Self::CherryBees005 => "cherry_bees_005", + Self::ChorusPlant => "chorus_plant", + Self::ClayPoolWithDripleaves => "clay_pool_with_dripleaves", + Self::ClayWithDripleaves => "clay_with_dripleaves", + Self::CrimsonForestVegetation => "crimson_forest_vegetation", + Self::CrimsonForestVegetationBonemeal => "crimson_forest_vegetation_bonemeal", + Self::CrimsonFungus => "crimson_fungus", + Self::CrimsonFungusPlanted => "crimson_fungus_planted", + Self::CrimsonRoots => "crimson_roots", + Self::DarkForestVegetation => "dark_forest_vegetation", + Self::DarkOak => "dark_oak", + Self::DarkOakLeafLitter => "dark_oak_leaf_litter", + Self::DeadBush => "dead_bush", + Self::Delta => "delta", + Self::DesertWell => "desert_well", + Self::DiskClay => "disk_clay", + Self::DiskGrass => "disk_grass", + Self::DiskGravel => "disk_gravel", + Self::DiskSand => "disk_sand", + Self::Dripleaf => "dripleaf", + Self::DripstoneCluster => "dripstone_cluster", + Self::DryGrass => "dry_grass", + Self::EndGatewayDelayed => "end_gateway_delayed", + Self::EndGatewayReturn => "end_gateway_return", + Self::EndIsland => "end_island", + Self::EndPlatform => "end_platform", + Self::EndSpike => "end_spike", + Self::FallenBirchTree => "fallen_birch_tree", + Self::FallenJungleTree => "fallen_jungle_tree", + Self::FallenOakTree => "fallen_oak_tree", + Self::FallenSpruceTree => "fallen_spruce_tree", + Self::FallenSuperBirchTree => "fallen_super_birch_tree", + Self::FancyOak => "fancy_oak", + Self::FancyOakBees => "fancy_oak_bees", + Self::FancyOakBees0002LeafLitter => "fancy_oak_bees_0002_leaf_litter", + Self::FancyOakBees002 => "fancy_oak_bees_002", + Self::FancyOakBees005 => "fancy_oak_bees_005", + Self::FancyOakLeafLitter => "fancy_oak_leaf_litter", + Self::FireflyBush => "firefly_bush", + Self::FlowerCherry => "flower_cherry", + Self::FlowerDefault => "flower_default", + Self::FlowerFlowerForest => "flower_flower_forest", + Self::FlowerMeadow => "flower_meadow", + Self::FlowerPaleGarden => "flower_pale_garden", + Self::FlowerPlain => "flower_plain", + Self::FlowerSwamp => "flower_swamp", + Self::ForestFlowers => "forest_flowers", + Self::ForestRock => "forest_rock", + Self::FossilCoal => "fossil_coal", + Self::FossilDiamonds => "fossil_diamonds", + Self::FreezeTopLayer => "freeze_top_layer", + Self::GlowLichen => "glow_lichen", + Self::GlowstoneExtra => "glowstone_extra", + Self::Grass => "grass", + Self::GrassJungle => "grass_jungle", + Self::HugeBrownMushroom => "huge_brown_mushroom", + Self::HugeRedMushroom => "huge_red_mushroom", + Self::IcePatch => "ice_patch", + Self::IceSpike => "ice_spike", + Self::IcebergBlue => "iceberg_blue", + Self::IcebergPacked => "iceberg_packed", + Self::JungleBush => "jungle_bush", + Self::JungleTree => "jungle_tree", + Self::JungleTreeNoVine => "jungle_tree_no_vine", + Self::Kelp => "kelp", + Self::LakeLava => "lake_lava", + Self::LargeBasaltColumns => "large_basalt_columns", + Self::LargeDripstone => "large_dripstone", + Self::LargeFern => "large_fern", + Self::LeafLitter => "leaf_litter", + Self::LushCavesClay => "lush_caves_clay", + Self::Mangrove => "mangrove", + Self::MangroveVegetation => "mangrove_vegetation", + Self::MeadowTrees => "meadow_trees", + Self::MegaJungleTree => "mega_jungle_tree", + Self::MegaPine => "mega_pine", + Self::MegaSpruce => "mega_spruce", + Self::Melon => "melon", + Self::MonsterRoom => "monster_room", + Self::MossPatch => "moss_patch", + Self::MossPatchBonemeal => "moss_patch_bonemeal", + Self::MossPatchCeiling => "moss_patch_ceiling", + Self::MossVegetation => "moss_vegetation", + Self::MushroomIslandVegetation => "mushroom_island_vegetation", + Self::NetherSprouts => "nether_sprouts", + Self::NetherSproutsBonemeal => "nether_sprouts_bonemeal", + Self::Oak => "oak", + Self::OakBees0002LeafLitter => "oak_bees_0002_leaf_litter", + Self::OakBees002 => "oak_bees_002", + Self::OakBees005 => "oak_bees_005", + Self::OakLeafLitter => "oak_leaf_litter", + Self::OreAncientDebrisLarge => "ore_ancient_debris_large", + Self::OreAncientDebrisSmall => "ore_ancient_debris_small", + Self::OreAndesite => "ore_andesite", + Self::OreBlackstone => "ore_blackstone", + Self::OreClay => "ore_clay", + Self::OreCoal => "ore_coal", + Self::OreCoalBuried => "ore_coal_buried", + Self::OreCopperLarge => "ore_copper_large", + Self::OreCopperSmall => "ore_copper_small", + Self::OreDiamondBuried => "ore_diamond_buried", + Self::OreDiamondLarge => "ore_diamond_large", + Self::OreDiamondMedium => "ore_diamond_medium", + Self::OreDiamondSmall => "ore_diamond_small", + Self::OreDiorite => "ore_diorite", + Self::OreDirt => "ore_dirt", + Self::OreEmerald => "ore_emerald", + Self::OreGold => "ore_gold", + Self::OreGoldBuried => "ore_gold_buried", + Self::OreGranite => "ore_granite", + Self::OreGravel => "ore_gravel", + Self::OreGravelNether => "ore_gravel_nether", + Self::OreInfested => "ore_infested", + Self::OreIron => "ore_iron", + Self::OreIronSmall => "ore_iron_small", + Self::OreLapis => "ore_lapis", + Self::OreLapisBuried => "ore_lapis_buried", + Self::OreMagma => "ore_magma", + Self::OreNetherGold => "ore_nether_gold", + Self::OreQuartz => "ore_quartz", + Self::OreRedstone => "ore_redstone", + Self::OreSoulSand => "ore_soul_sand", + Self::OreTuff => "ore_tuff", + Self::PaleForestFlower => "pale_forest_flower", + Self::PaleGardenVegetation => "pale_garden_vegetation", + Self::PaleMossPatch => "pale_moss_patch", + Self::PaleMossPatchBonemeal => "pale_moss_patch_bonemeal", + Self::PaleMossVegetation => "pale_moss_vegetation", + Self::PaleOak => "pale_oak", + Self::PaleOakBonemeal => "pale_oak_bonemeal", + Self::PaleOakCreaking => "pale_oak_creaking", + Self::PatchFire => "patch_fire", + Self::PatchSoulFire => "patch_soul_fire", + Self::PileHay => "pile_hay", + Self::PileIce => "pile_ice", + Self::PileMelon => "pile_melon", + Self::PilePumpkin => "pile_pumpkin", + Self::PileSnow => "pile_snow", + Self::Pine => "pine", + Self::PointedDripstone => "pointed_dripstone", + Self::Pumpkin => "pumpkin", + Self::RedMushroom => "red_mushroom", + Self::RootedAzaleaTree => "rooted_azalea_tree", + Self::SculkPatchAncientCity => "sculk_patch_ancient_city", + Self::SculkPatchDeepDark => "sculk_patch_deep_dark", + Self::SculkVein => "sculk_vein", + Self::SeaPickle => "sea_pickle", + Self::SeagrassMid => "seagrass_mid", + Self::SeagrassShort => "seagrass_short", + Self::SeagrassSlightlyLessShort => "seagrass_slightly_less_short", + Self::SeagrassTall => "seagrass_tall", + Self::SmallBasaltColumns => "small_basalt_columns", + Self::SporeBlossom => "spore_blossom", + Self::SpringLavaFrozen => "spring_lava_frozen", + Self::SpringLavaNether => "spring_lava_nether", + Self::SpringLavaOverworld => "spring_lava_overworld", + Self::SpringNetherClosed => "spring_nether_closed", + Self::SpringNetherOpen => "spring_nether_open", + Self::SpringWater => "spring_water", + Self::Spruce => "spruce", + Self::SugarCane => "sugar_cane", + Self::Sunflower => "sunflower", + Self::SuperBirchBees => "super_birch_bees", + Self::SuperBirchBees0002 => "super_birch_bees_0002", + Self::SwampOak => "swamp_oak", + Self::TaigaGrass => "taiga_grass", + Self::TallGrass => "tall_grass", + Self::TallMangrove => "tall_mangrove", + Self::TreesBadlands => "trees_badlands", + Self::TreesBirch => "trees_birch", + Self::TreesBirchAndOakLeafLitter => "trees_birch_and_oak_leaf_litter", + Self::TreesFlowerForest => "trees_flower_forest", + Self::TreesGrove => "trees_grove", + Self::TreesJungle => "trees_jungle", + Self::TreesOldGrowthPineTaiga => "trees_old_growth_pine_taiga", + Self::TreesOldGrowthSpruceTaiga => "trees_old_growth_spruce_taiga", + Self::TreesPlains => "trees_plains", + Self::TreesSavanna => "trees_savanna", + Self::TreesSnowy => "trees_snowy", + Self::TreesSparseJungle => "trees_sparse_jungle", + Self::TreesTaiga => "trees_taiga", + Self::TreesWater => "trees_water", + Self::TreesWindsweptHills => "trees_windswept_hills", + Self::TwistingVines => "twisting_vines", + Self::TwistingVinesBonemeal => "twisting_vines_bonemeal", + Self::UnderwaterMagma => "underwater_magma", + Self::Vines => "vines", + Self::VoidStartPlatform => "void_start_platform", + Self::WarmOceanVegetation => "warm_ocean_vegetation", + Self::WarpedForestVegetation => "warped_forest_vegetation", + Self::WarpedForestVegetationBonemeal => "warped_forest_vegetation_bonemeal", + Self::WarpedFungus => "warped_fungus", + Self::WarpedFungusPlanted => "warped_fungus_planted", + Self::Waterlily => "waterlily", + Self::WeepingVines => "weeping_vines", + Self::Wildflower => "wildflower", + } + } +} diff --git a/pumpkin-data/src/generated/configured_features_generated.rs b/pumpkin-data/src/generated/configured_features_generated.rs index 0557458aa..86ee47b6d 100644 --- a/pumpkin-data/src/generated/configured_features_generated.rs +++ b/pumpkin-data/src/generated/configured_features_generated.rs @@ -1,6 +1,8 @@ /* This file is generated. Do not edit manually. */ #[allow(clippy::all, unused_imports, dead_code)] -fn build_configured_features() -> std::collections::HashMap { +fn build_configured_features() +-> std::collections::HashMap +{ use crate::block::BlockStateCodec; use crate::generation::block_predicate::{ AllOfBlockPredicate, AnyOfBlockPredicate, BlockPredicate, HasSturdyFacePredicate, @@ -95,9 +97,9 @@ fn build_configured_features() -> std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap std::collections::HashMap> = - LazyLock::new(build_configured_features); +pub static CONFIGURED_FEATURES: LazyLock< + HashMap, +> = LazyLock::new(build_configured_features); pub enum ConfiguredFeature { NoOp, diff --git a/pumpkin-world/src/generation/feature/placed_features.rs b/pumpkin-world/src/generation/feature/placed_features.rs index af4ef9263..30f07b327 100644 --- a/pumpkin-world/src/generation/feature/placed_features.rs +++ b/pumpkin-world/src/generation/feature/placed_features.rs @@ -44,7 +44,7 @@ pub struct PlacedFeature { } pub enum Feature { - Named(String), + Named(pumpkin_data::configured_feature::ConfiguredFeature), Inlined(Box), } @@ -82,8 +82,8 @@ impl PlacedFeature { let feature = match &self.feature { Feature::Named(name) => CONFIGURED_FEATURES - .get(name.strip_prefix("minecraft:").unwrap_or(name)) - .expect("Name: {name} not found"), + .get(name) + .expect("Name: {name:?} not found"), Feature::Inlined(feature) => feature, };