Density Functions
Density functions are used in Minecraft world generation to define the shape and structure of terrain. They determine how different blocks are placed in the world, influencing features such as hills, valleys, caves, and other geological formations.
In Wyck, you can reference density functions that already exist in the game, are registered from datapacks, or author your own using
the DensityFunction interface.
Example Usage
Section titled “Example Usage”import dev.wyck.keys.ResourceKey;
import dev.wyck.worldgen.noise.NoiseRouter;
import dev.wyck.worldgen.function.DensityFunction;
import dev.wyck.worldgen.function.DensityFunctions;
import org.bukkit.plugin.java.JavaPlugin;
public class ExamplePlugin extends JavaPlugin {
@Override
public void onEnable() {
// Referencing existing density functions
DensityFunction overworldRidges = DensityFunctions.RIDGES;
DensityFunction datapackErosion = DensityFunction.reference(ResourceKey.of("test:my_erosion")); // or do it this way!
// Authoring custom density functions
DensityFunction customContinents = DensityFunction.yClampedGradient(0, 128, 1.0, -1.0)
.add(DensityFunction.constant(0.05))
.clamp(-1.0, 1.0);
// Using the values in a noise router
NoiseRouter router = NoiseRouter.builder()
.continents(customContinents)
.erosion(datapackErosion)
.ridges(overworldRidges)
.build();
}
}