Feature System Overview
Features in Substratum are defined using YAML configuration files located in thefeatures/ directory. Each feature controls:
- Distribution: How frequently the feature appears
- Location: Where the feature can be placed
- Structures: What blocks/structures are placed
Features run after cave carving and palette generation, decorating the carved cave surfaces.
Feature Anatomy
A typical feature consists of three main components:1. Distributor
Controls how frequently the feature attempts to spawn:type: Distribution method (SAMPLER, PADDING, etc.)sampler: Noise function for distributionthreshold: Probability threshold (0.1 = 10% of locations)salt: Random seed for this feature
2. Locator
Determines valid placement locations:PATTERN: Match block patterns at specific offsetsAND: All conditions must be trueOR: Any condition can be trueADJACENT_PATTERN: Check adjacent blocksGAUSSIAN_RANDOM: Random height with gaussian distribution
3. Structures
Defines what is actually placed:distribution: How structures are selectedstructures: List of structure IDs with weights
Example: Giant Calcite Stalactites
Here’s a complete feature definition fromgiant_calcite_stalactites.yml:
How This Feature Works
How This Feature Works
- Distributor: Runs at 10% of locations (threshold: 0.1)
- Locator: Finds ceiling positions where:
- Block above (offset: 1) is solid
- Current block (offset: 0) is air
- Adjacent blocks (offset: 1) are solid
- Structures: Places stalactite with 1:5 ratio (16.7% when location is valid)
Feature Categories
Vegetation Features
Plant-based decorations for cave biomes:substratum_meta.yml):
Geological Features
Stone formations and structures:Liquid Features
Water, lava, and other liquids:Deposit Features
Ore generation and mineral deposits:Example: Diamond Ore Feature
Here’s how diamond ore generation is configured:Understanding Gaussian Distribution
Understanding Gaussian Distribution
The
GAUSSIAN_RANDOM locator places ores with a bell curve distribution:- Most diamonds spawn near Y=-50 (center of range)
- Fewer diamonds spawn at Y=-64 and Y=16 (edges)
standard-deviationcontrols the spread (wider = more uniform)
(max - min) / 6 fits ~99.7% of results within the range.Pattern Types
Patterns define block matching conditions:MATCH_SOLID
MATCH_AIR
MATCH_BLOCK
Offset System
Offsets determine which block relative to the spawn position to check:offset: 1- Block above (+Y)offset: 0- Current blockoffset: -1- Block below (-Y)
For ceiling features (stalactites, icicles), you typically want:
offset: 1with MATCH_SOLID (ceiling)offset: 0with MATCH_AIR (spawn location)
offset: -1with MATCH_SOLID (floor)offset: 0with MATCH_AIR (spawn location)
Distribution Methods
SAMPLER Distribution
Uses noise functions for natural-looking distribution:PADDING Distribution
Ensures minimum spacing between features:CONSTANT Distribution
Places feature at every valid location:Creating a Custom Feature
Let’s create a custom glowing mushroom feature:Explanation
Explanation
- 3% spawn rate via threshold: 0.03
- Floor placement via offset: -1 MATCH_SOLID
- Block filter ensures mushrooms only grow on appropriate surfaces
- Weighted structures create variety:
- 5/11 chance: small cluster
- 3/11 chance: medium cluster
- 1/11 chance: large cluster
- 2/11 chance: nothing (adds natural gaps)
Feature Integration
Features are assigned to biomes through the biome configuration:Advanced Techniques
Using Variables and Anchors
YAML anchors allow reusing configuration:Conditional Features
Use multiple locators to create complex conditions:Debugging Features
Common issues and solutions:Feature Not Spawning
- Check
threshold- too high = too rare - Verify
locatorpatterns match your environment - Ensure
rangeincludes your test area - Check that structure IDs are valid
Feature Too Common
- Increase
thresholdvalue - Add more
blankentries to structures - Add PADDING distributor
Feature in Wrong Location
- Review
offsetvalues in patterns - Check block matching in MATCH_BLOCK
- Verify height range is correct
See Also
- Cave Carving System - Understand cave generation
- Palette System - Learn about terrain texturing
- Cave Biomes - Explore cave biome types
