Skip to main content

steel_registry/
structure_set.rs

1//! Structure set data types for generated registry data.
2//!
3//! These are simple data containers populated by the build script from
4//! the vanilla datapack JSONs. `steel-core` converts these into its
5//! placement types for actual worldgen logic.
6
7pub use crate::structure::{DimensionPadding, JigsawConfig, PoolAlias, StartHeight};
8use steel_utils::Identifier;
9
10/// A structure set entry from the vanilla datapack.
11#[derive(Debug, Clone)]
12pub struct StructureSetData {
13    /// Registry key (e.g., `minecraft:villages`).
14    pub key: Identifier,
15    /// Weighted structure entries.
16    pub structures: Vec<StructureEntryData>,
17    /// Placement configuration.
18    pub placement: PlacementData,
19}
20
21/// A weighted structure entry within a structure set.
22#[derive(Debug, Clone)]
23pub struct StructureEntryData {
24    /// Structure identifier (e.g., `minecraft:village_plains`).
25    pub structure: Identifier,
26    /// Selection weight.
27    pub weight: i32,
28}
29
30/// Placement configuration from the vanilla datapack.
31#[derive(Debug, Clone)]
32pub enum PlacementData {
33    /// Grid-based spread placement (`minecraft:random_spread`).
34    RandomSpread {
35        /// Chunk spacing between grid cell centers.
36        spacing: i32,
37        /// Minimum chunk separation.
38        separation: i32,
39        /// Spread type: `"linear"` or `"triangular"`.
40        spread_type: SpreadTypeData,
41        /// Unique seed modifier.
42        salt: i32,
43        /// Generation probability (0.0–1.0). Default: 1.0.
44        frequency: f32,
45        /// Frequency reduction method name. Default: `"default"`.
46        frequency_reduction_method: FrequencyMethodData,
47        /// Exclusion zone: (other_set key, chunk_count).
48        exclusion_zone: Option<ExclusionZoneData>,
49        /// Block offset from the placement chunk used by `/locate`.
50        locate_offset: [i32; 3],
51    },
52    /// Ring-based placement (`minecraft:concentric_rings`).
53    ConcentricRings {
54        /// Base distance between rings (in chunks).
55        distance: i32,
56        /// Positions spread per ring.
57        spread: i32,
58        /// Total positions.
59        count: i32,
60        /// Biomes that ring positions prefer to snap to.
61        preferred_biomes: Vec<Identifier>,
62        /// Unique seed modifier.
63        salt: i32,
64        /// Generation probability. Default: 1.0.
65        frequency: f32,
66        /// Frequency reduction method name.
67        frequency_reduction_method: FrequencyMethodData,
68        /// Block offset from the placement chunk used by `/locate`.
69        locate_offset: [i32; 3],
70    },
71}
72
73/// Spread type for random spread placement.
74#[derive(Debug, Clone, Copy)]
75pub enum SpreadTypeData {
76    /// Uniform random.
77    Linear,
78    /// Biased toward center.
79    Triangular,
80}
81
82/// Frequency reduction method identifier.
83#[derive(Debug, Clone, Copy)]
84pub enum FrequencyMethodData {
85    /// Standard method.
86    Default,
87    /// Pillager outpost legacy.
88    LegacyType1,
89    /// Hardcoded salt legacy.
90    LegacyType2,
91    /// Double-precision legacy.
92    LegacyType3,
93}
94
95/// Exclusion zone preventing overlap with another structure set.
96#[derive(Debug, Clone)]
97pub struct ExclusionZoneData {
98    /// Registry key of the other structure set.
99    pub other_set: Identifier,
100    /// Radius in chunks.
101    pub chunk_count: i32,
102}