World Generation Overview
World Generation Overview
Section titled “World Generation Overview”The World Generation system creates terrain, structures, and biomes for Hytale worlds. It uses a procedural generation pipeline with zones, biomes, caves, and prefabs.
Package Location
Section titled “Package Location”- Providers:
com.hypixel.hytale.server.core.universe.world.worldgen.provider - Hytale generator:
com.hypixel.hytale.server.worldgen - Generated chunks:
com.hypixel.hytale.server.core.universe.world.worldgen
Architecture
Section titled “Architecture”flowchart TB
subgraph WorldGen["World Generation"]
subgraph Provider["HytaleWorldGenProvider"]
subgraph ChunkGen["ChunkGenerator"]
ZonePattern["ZonePattern<br/>Generator"]
BiomePattern["BiomePattern<br/>Generator"]
CaveGen["CaveGenerator"]
Heightmap["Heightmap<br/>Generator"]
Prefab["Prefab<br/>Generator"]
Populator
end
end
end
World Gen Providers
Section titled “World Gen Providers”IWorldGenProvider Interface
Section titled “IWorldGenProvider Interface”public interface IWorldGenProvider { IWorldGen getGenerator() throws WorldGenLoadException;}HytaleWorldGenProvider
Section titled “HytaleWorldGenProvider”The default world generation provider for Hytale:
public class HytaleWorldGenProvider implements IWorldGenProvider { public static final String ID = "Hytale";
// Configuration String name = "Default"; // Generator name String path; // Custom path (optional)}World Config Usage
Section titled “World Config Usage”{ "WorldGen": { "Type": "Hytale", "Name": "MyWorldGen", "Path": "path/to/worldgen/config" }}Built-in Providers
Section titled “Built-in Providers”| Provider | Description |
|---|---|
HytaleWorldGenProvider | Full procedural terrain (in server.worldgen package) |
FlatWorldGenProvider | Flat terrain |
VoidWorldGenProvider | Empty void world |
DummyWorldGenProvider | No generation |
HandleProvider | Custom handle-based generator (in builtin.hytalegenerator) |
ChunkGenerator
Section titled “ChunkGenerator”The core class that generates chunks:
public class ChunkGenerator implements IBenchmarkableWorldGen, IWorldMapProvider { // Pool size based on CPU cores public static final int POOL_SIZE = Math.max(2, (int) Math.ceil(Runtime.getRuntime().availableProcessors() * 0.75));
// Get zone data at coordinates public ZoneBiomeResult getZoneBiomeResultAt(int seed, int x, int z);
// Get height at coordinates public int getHeight(int seed, int x, int z);
// Get cave data public Cave getCave(CaveType caveType, int seed, int x, int z);
// Get spawn points public Transform[] getSpawnPoints(int seed);}Generation Pipeline
Section titled “Generation Pipeline”- Zone Generation: Determine zone at position
- Biome Generation: Determine biome within zone
- Heightmap: Generate terrain height
- Block Placement: Place blocks based on layers
- Cave Carving: Carve caves and caverns
- Prefab Placement: Place structures
- Population: Add details (ores, plants, etc.)
Zones are large-scale regions of the world with distinct generation rules.
Zone Record
Section titled “Zone Record”public record Zone( int id, String name, ZoneDiscoveryConfig discoveryConfig, CaveGenerator caveGenerator, BiomePatternGenerator biomePatternGenerator, UniquePrefabContainer uniquePrefabContainer) {}Zone Configuration
Section titled “Zone Configuration”{ "Id": 1, "Name": "Plains", "DiscoveryConfig": { "DiscoverKey": "zone_plains", "DiscoverRadius": 100 }, "CaveGenerator": "DefaultCaves", "BiomePattern": "plains_biomes.png"}Zone Pattern Provider
Section titled “Zone Pattern Provider”Generates zone layout based on patterns:
public class ZonePatternProvider { // Zone pattern generation}
public class ZonePatternGenerator { // Generate zone at coordinates}Biomes
Section titled “Biomes”Biomes define terrain characteristics within zones.
Biome Class
Section titled “Biome Class”public abstract class Biome { int id; String name; BiomeInterpolation interpolation; IHeightThresholdInterpreter heightmapInterpreter;
// Containers CoverContainer coverContainer; // Surface cover (grass, etc.) LayerContainer layerContainer; // Block layers PrefabContainer prefabContainer; // Structures TintContainer tintContainer; // Color tinting EnvironmentContainer environmentContainer; // Environment settings WaterContainer waterContainer; // Water features FadeContainer fadeContainer; // Biome transitions
// Noise NoiseProperty heightmapNoise;
// Visual int mapColor;}Biome Containers
Section titled “Biome Containers”| Container | Description |
|---|---|
CoverContainer | Surface blocks (grass, snow) |
LayerContainer | Block layer definitions |
PrefabContainer | Structure placement |
TintContainer | Block tinting rules |
EnvironmentContainer | Environment settings |
WaterContainer | Water/fluid settings |
FadeContainer | Transition rules |
Layer Container
Section titled “Layer Container”Defines block layers from surface to bedrock:
{ "Layers": [ { "Block": "Grass", "Depth": 1 }, { "Block": "Dirt", "Depth": 3 }, { "Block": "Stone", "Depth": -1 } ]}Cave Generation
Section titled “Cave Generation”CaveGenerator
Section titled “CaveGenerator”public class CaveGenerator { // Generate caves for a region}
public enum CaveType { // Cave type definitions}
public class Cave { // Cave data}Cave Configuration
Section titled “Cave Configuration”{ "CaveType": "Standard", "Frequency": 0.5, "MinHeight": 10, "MaxHeight": 64, "Radius": { "Min": 2, "Max": 5 }}Prefabs
Section titled “Prefabs”Prefabs are pre-built structures placed during generation.
PrefabContainer
Section titled “PrefabContainer”public class PrefabContainer { // Prefab placement rules}
public class PrefabLoadingCache { // Cache for loaded prefabs}Prefab Configuration
Section titled “Prefab Configuration”{ "Prefabs": [ { "Id": "Village_House", "Chance": 0.1, "MinDistance": 100, "GroundLevel": "Surface" } ]}Unique Prefabs
Section titled “Unique Prefabs”Special one-per-world prefabs:
public class UniquePrefabContainer { // Unique prefab management
public static class UniquePrefabEntry { boolean isSpawnLocation(); Vector3i getPosition(); Vector3d getSpawnOffset(); Rotation getRotation(); }}Props are decorative elements placed during world generation. Server v2 introduces new prop types for enhanced placement control.
WeightedProp
Section titled “WeightedProp”Selects a child prop randomly based on weight probability:
public class WeightedProp implements Prop { // Weight-based random selection from child props private final List<WeightedEntry> entries;
public record WeightedEntry(Prop prop, float weight) {}}Configuration:
{ "Type": "Weighted", "Entries": [ { "Prop": "Tree_Oak_Large", "Weight": 0.1 }, { "Prop": "Tree_Oak_Medium", "Weight": 0.3 }, { "Prop": "Tree_Oak_Small", "Weight": 0.6 } ]}| Field | Type | Description |
|---|---|---|
Entries | array | List of weighted prop entries |
Entries[].Prop | string | Prop ID to place |
Entries[].Weight | float | Relative weight (higher = more likely) |
Use Cases:
- Varied tree sizes (mostly small, occasionally large)
- Rock formations with random sizes
- Flower variety in meadows
OffsetProp
Section titled “OffsetProp”Applies a position offset to a child prop:
public class OffsetProp implements Prop { // Offset applied to child prop position private final Prop childProp; private final Vector3d offset;}Configuration:
{ "Type": "Offset", "Prop": "Mushroom_Cluster", "Offset": { "X": 0, "Y": -0.5, "Z": 0 }}| Field | Type | Description |
|---|---|---|
Prop | string | Child prop ID |
Offset | Vector3d | Position offset to apply |
Use Cases:
- Partially buried objects
- Floating elements (vines, hanging plants)
- Stacked prop combinations
SimpleHorizontalPositionProvider
Section titled “SimpleHorizontalPositionProvider”Provides horizontal positions for prop placement:
public class SimpleHorizontalPositionProvider implements PositionProvider { // Generates horizontal positions within a region}Configuration:
{ "Type": "SimpleHorizontal", "Density": 0.1, "MinSpacing": 2.0, "MaxSpacing": 8.0}Populators
Section titled “Populators”Populators add details after basic terrain is generated.
Built-in Populators
Section titled “Built-in Populators”| Populator | Description |
|---|---|
BlockPopulator | Place additional blocks |
CavePopulator | Carve caves |
WaterPopulator | Add water features |
PrefabPopulator | Place structures |
Populator Interface
Section titled “Populator Interface”public interface IPopulator { void populate(GeneratedChunk chunk, Random random);}Generated Chunk
Section titled “Generated Chunk”The output of chunk generation:
public class GeneratedChunk { // Block data GeneratedBlockChunk blockChunk;
// Block states GeneratedBlockStateChunk blockStateChunk;
// Entities GeneratedEntityChunk entityChunk;}Noise Functions
Section titled “Noise Functions”World generation uses noise for natural variation.
NoiseProperty
Section titled “NoiseProperty”public class NoiseProperty { // Noise configuration}Height Threshold Interpreter
Section titled “Height Threshold Interpreter”public interface IHeightThresholdInterpreter { // Interpret height thresholds for biome-specific terrain}Procedural Library
Section titled “Procedural Library”The procedural library provides tools for generation:
Conditions
Section titled “Conditions”// Height-based conditionsIHeightThresholdInterpreter
// Block-based conditionsHashSetBlockFluidConditionFilteredBlockFluidConditionBlockMaskConditionProperty Suppliers
Section titled “Property Suppliers”ICoordinateDoubleSupplierConstantCoordinateDoubleSupplierRandomCoordinateDoubleSupplierWorld Bounds
Section titled “World Bounds”public interface IWorldBounds { int getMinX(); int getMaxX(); int getMinZ(); int getMaxZ();}
public interface IChunkBounds { int getMinChunkX(); int getMaxChunkX(); int getMinChunkZ(); int getMaxChunkZ();}Caching
Section titled “Caching”World generation uses extensive caching:
public class ChunkGeneratorCache { // Cache zone/biome results // Cache heights // Cache interpolated values}
public class CaveGeneratorCache { // Cache cave data}
public class PrefabLoadingCache { // Cache loaded prefabs}Configuration Files
Section titled “Configuration Files”World.json
Section titled “World.json”Main world generation configuration:
{ "Zones": "zones/", "DefaultZone": "Plains", "SeaLevel": 64, "WorldHeight": 256, "Caves": { "Enabled": true, "Types": ["Standard", "Cavern"] }}Zone Configuration
Section titled “Zone Configuration”Each zone has its own configuration:
Directoryworldgen/
- World.json
Directoryzones/
DirectoryPlains/
- zone.json
Directorybiomes/
- Grassland.json
- Forest.json
DirectoryMountains/
- zone.json
Directorybiomes/
- Alpine.json
Directoryprefabs/
Directoryvillage/
- …
Directorydungeons/
- …
Custom World Generation
Section titled “Custom World Generation”Implementing IWorldGenProvider
Section titled “Implementing IWorldGenProvider”public class MyWorldGenProvider implements IWorldGenProvider { public static final BuilderCodec<MyWorldGenProvider> CODEC = BuilderCodec.builder(MyWorldGenProvider.class, MyWorldGenProvider::new) // Add configuration fields .build();
@Override public IWorldGen getGenerator() throws WorldGenLoadException { return new MyChunkGenerator(); }}Registering Provider
Section titled “Registering Provider”@Overrideprotected void setup() { IWorldGenProvider.CODEC.register( Priority.DEFAULT, "MyPlugin_WorldGen", MyWorldGenProvider.class, MyWorldGenProvider.CODEC );}Timings and Metrics
Section titled “Timings and Metrics”public class WorldGenTimingsCollector { // Collect generation timings}
// ChunkGenerator implements MetricProviderpublic interface MetricProvider { MetricResults getMetrics();}Best Practices
Section titled “Best Practices”- Use caching: Leverage built-in caches for performance
- Async generation: Use thread pool for heavy operations
- Seed consistency: Ensure deterministic generation from seed
- Validate output: Use
ValidatableWorldGeninterface - Profile performance: Use benchmarking tools
- Modular design: Separate zones, biomes, and populators
Related
Section titled “Related”- World System - World management
- Block System - Block types
- Asset System - Prefab assets