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.wrapper.level.noise.NoiseRouter;
import dev.wyck.wrapper.level.noise.function.DensityFunction;
import dev.wyck.wrapper.level.noise.function.DensityFunctions;
import org.bukkit.plugin.java.JavaPlugin;
public class ExamplePlugin extends JavaPlugin {
@Override
public void onEnable() {
// Referencing existing density functions
DensityFunction overworldContinents = DensityFunctions.CONTINENTS;
DensityFunction overworldErosion = DensityFunction.reference(ResourceKey.of("minecraft:overworld/erosion")); // or do it this way!
// Authoring custom density functions
DensityFunction customRidges = DensityFunction.add(
DensityFunction.yClampedGradient(0, 128, 1.0, -1.0),
DensityFunction.constant(0.05)
)
.clamp(-1.0, 1.0);
// Using the values in a noise router
NoiseRouter router = NoiseRouter.builder()
.continents(overworldContinents)
.erosion(overworldErosion)
.ridges(customRidges)
.build();
}
}