Value Providers
World generation rarely uses plain numbers. Rather, we use value providers, small objects that produce a number,
sometimes constant and sometimes sampled from a distribution. Carvers, features, and placement modifiers all take value
providers instead of raw ints or floats so the same configuration can vary naturally across the world.
For providers that produce a Y position, see Height Providers.
IntProvider
Section titled “IntProvider”An IntProvider produces an integer,
either constant or sampled from a distribution.
import dev.wyck.worldgen.valueproviders.IntProvider;
IntProvider.constant(4); // always 4
IntProvider.uniform(2, 8); // evenly between 2 and 8 (inclusive)
IntProvider.triangle(6); // triangular distribution with spread 6
IntProvider.trapezoid(0, 16, 4); // trapezoidal distribution with a flat plateau
IntProvider.biasedToBottom(2, 8); // skewed toward the lower end
IntProvider.clampedNormal(2, 8, 5.0f, 1.5f); // normal distribution clamped to [2, 8] FloatProvider
Section titled “FloatProvider”A FloatProvider is the floating-point
equivalent, used for radii, scales, and probabilities inside carvers and features.
import dev.wyck.worldgen.valueproviders.FloatProvider;
FloatProvider.constant(3.0f); // always 3.0
FloatProvider.uniform(0.1f, 0.9f); // evenly between 0.1 and 0.9
FloatProvider.trapezoid(0.0f, 6.0f, 2.0f); // trapezoidal distribution
FloatProvider.clampedNormal(0.5f, 0.1f, 0.0f, 1.0f); // normal distribution clamped to [0.0, 1.0] WeightedList
Section titled “WeightedList”A WeightedList is a generic pool of entries, each with an
integer weight, that samples one entry at random. Several providers accept one to pick between whole sub-providers —
for example IntProvider.weightedList(...) and
HeightProvider.weightedList(...) — and it also shows up in tree decorators and
foliage configuration.
import dev.wyck.util.WeightedList;
import dev.wyck.worldgen.valueproviders.IntProvider;
// Higher weight = chosen more often. Here 8 is picked roughly twice as often as 24.
WeightedList<IntProvider> counts = WeightedList.<IntProvider>builder()
.add(IntProvider.constant(8), 2)
.add(IntProvider.uniform(16, 24), 1)
.build();
IntProvider count = IntProvider.weightedList(counts);