Random selector feature
The random_selector
feature can be used to randomly choose from a provided list of features to place.
Configuration
The random_selector
feature has the following configuration options:
Option | Type | Description |
---|---|---|
features | A list of placed features objects (or id's inside the feature option in Json) and their corresponding chance. | The list of features to choose from. |
default | A placed feature | The default feature to place if none of the provided features got picked |
In code, the RandomFeatureConfiguration
class is used to configure the feature.
Example
As an example, here's the random selector used to generate tree in the old growth taiga biome
ConfiguredFeatures.kt
@OptIn(ExperimentalWorldGen::class)
@Init(stage = InitStage.POST_PACK_PRE_WORLD)(stage = InitStage.POST_PACK_PRE_WORLD)
object ConfiguredFeatures : FeatureRegistry by ExampleAddon.registry {
val TREES_OLD_GROWTH_SPRUCE_TAIGA = registerConfiguredFeature(
"trees_old_growth_spruce_taiga",
Feature.RANDOM_SELECTOR,
RandomFeatureConfiguration(
listOf(
WeightedPlacedFeature(
VanillaRegistryAccess.getHolder(TreePlacements.MEGA_SPRUCE_CHECKED),
1f / 3f
),
WeightedPlacedFeature(
VanillaRegistryAccess.getHolder(TreePlacements.PINE_CHECKED),
1f / 3f
)
),
VanillaRegistryAccess.getHolder(TreePlacements.SPRUCE_CHECKED)
)
)
}