Carvers
Carvers are responsible for ‘carving’ out areas of a world to create caves, canyons, ravines, and other underground features.
A WorldCarver is either a
reference to a carver already in the game, or a custom carver you may author from a
carver type and a configuration. Both are added to a biome through its generation settings.
Referencing Built-in Carvers
Section titled “Referencing Built-in Carvers”The Carvers catalog holds typed references to every
vanilla carver.
import dev.wyck.biome.BiomeGenerationSettings;
import dev.wyck.worldgen.carver.Carvers;
BiomeGenerationSettings generation = BiomeGenerationSettings.builder()
.carver(Carvers.CAVE)
.carver(Carvers.CANYON)
.build(); Authoring a Custom Carver
Section titled “Authoring a Custom Carver”To author your own, pair a carver type with a configuration.
import dev.wyck.worldgen.carver.CaveWorldCarver;
import dev.wyck.worldgen.carver.WorldCarver;
import dev.wyck.worldgen.valueproviders.FloatProvider;
import dev.wyck.worldgen.heightproviders.HeightProvider;
import dev.wyck.worldgen.heightproviders.VerticalAnchor;
WorldCarver cave = WorldCarver.cave().config(
CaveWorldCarver.builder()
.probability(0.15f)
.y(HeightProvider.uniform(VerticalAnchor.aboveBottom(8), VerticalAnchor.absolute(180)))
.horizontalRadiusMultiplier(FloatProvider.uniform(0.7f, 1.4f))
.verticalRadiusMultiplier(FloatProvider.uniform(0.8f, 1.3f))
.floorLevel(FloatProvider.uniform(-1.0f, -0.4f))
.build()
).build(); import dev.wyck.worldgen.carver.CanyonWorldCarver;
import dev.wyck.worldgen.carver.CanyonWorldCarver.Shape;
import dev.wyck.worldgen.carver.WorldCarver;
import dev.wyck.worldgen.valueproviders.FloatProvider;
import dev.wyck.worldgen.heightproviders.HeightProvider;
import dev.wyck.worldgen.heightproviders.VerticalAnchor;
WorldCarver canyon = WorldCarver.canyon().config(
CanyonWorldCarver.builder()
.probability(0.02f)
.y(HeightProvider.uniform(VerticalAnchor.absolute(10), VerticalAnchor.absolute(67)))
.verticalRotation(FloatProvider.uniform(-0.125f, 0.125f))
.shape(Shape.builder()
.distanceFactor(FloatProvider.uniform(0.75f, 1.0f))
.thickness(FloatProvider.trapezoid(0.0f, 6.0f, 2.0f))
.widthSmoothness(3)
.horizontalRadiusFactor(FloatProvider.uniform(0.75f, 1.0f))
.verticalRadiusDefaultFactor(1.0f)
.verticalRadiusCenterFactor(0.0f)
.yScale(FloatProvider.constant(3.0f))
.build())
.build()
).build();