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 - Procedural generator:
com.hypixel.hytale.builtin.hytalegenerator - WorldGen modifiers:
com.hypixel.hytale.builtin.worldgen.modifier
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);}Staged Chunk Generator (Engine)
Section titled “Staged Chunk Generator (Engine)”The StagedChunkGenerator at com.hypixel.hytale.builtin.hytalegenerator.engine.chunkgenerator manages chunk generation through a pipeline of Stage implementations:
| Stage | Description |
|---|---|
BiomeStage | Determines biome at each position |
BiomeDistanceStage | Calculates distance to biome edges |
TerrainStage | Generates terrain density and block placement |
PropStage | Places props and decorations |
EnvironmentStage | Applies environment settings |
TintStage | Applies block tinting |
Each stage implements Stage with run(Context), getInputTypesAndBounds_bufferGrid(), getOutputTypes(), and getName().
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.
Prop API (v4)
Section titled “Prop API (v4)”public abstract class Prop { public abstract boolean generate(Prop.Context context); public abstract Bounds3i getReadBounds_voxelGrid(); public abstract Bounds3i getWriteBounds_voxelGrid();
public static class Context { public Vector3i position; public VoxelSpace<Material> materialReadSpace; public VoxelSpace<Material> materialWriteSpace; public EntityFunnel entityWriteBuffer; public double distanceToBiomeEdge; }}New Prop Types
Section titled “New Prop Types”| Prop | Description |
|---|---|
CuboidProp | Cuboid generation |
DensityProp | Density-based block placement (rewritten in v4) |
DensitySelectorProp | Density-based prop selection |
EmptyProp | No-op singleton (EmptyProp.INSTANCE) |
LocatorProp | Locator-based placement |
ManualProp | Manual block placement |
MaskProp | Masking support |
OffsetProp | Position offset applied to child prop |
OrienterProp | Orientation handling |
PrefabProp | Prefab structure placement |
PondFillerProp | Pond filling |
QueueProp | Queued prop execution |
StaticRotatorProp | Static rotation |
UnionProp | Union of multiple props |
WeightedProp | Weight-based random selection |
WeightedProp
Section titled “WeightedProp”Selects a child prop randomly based on weight probability:
public class WeightedProp extends Prop { private final WeightedMap<Prop> props;}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 extends Prop { private final Vector3i offset; private final Prop childProp;}Configuration:
{ "Type": "Offset", "Prop": "Mushroom_Cluster", "Offset": { "X": 0, "Y": -1, "Z": 0 }}| Field | Type | Description |
|---|---|---|
Prop | string | Child prop ID |
Offset | Vector3i | 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}Scanners
Section titled “Scanners”Scanners find valid positions for prop placement within a region.
public abstract class Scanner { @Deprecated public abstract void scan(Scanner.Context context);
public abstract void scan(Vector3i position, Pipe.One<Vector3i> pipe);
public abstract Bounds3i getBounds_voxelGrid();
public Bounds3i getBoundsWithPattern_voxelGrid(Pattern pattern);}| Scanner | Description |
|---|---|
DirectScanner | Direct position scanning (replaces OriginScanner) |
EmptyScanner | No-op singleton |
LinearScanner | Linear scanning pattern |
QueueScanner | Queue-based scanning |
RadialScanner | Radial scanning pattern |
RandomScanner | Random position scanning |
Position Providers
Section titled “Position Providers”Position providers generate candidate positions for prop distribution.
public abstract class PositionProvider { public abstract void generate(PositionProvider.Context context);
public static class Context { public Bounds3d bounds; public Pipe.One<Vector3d> pipe; public Vector3d anchor; }}Pipe System
Section titled “Pipe System”public class Pipe { @FunctionalInterface public interface One<Input> { void accept(Input input, Control control); }
@FunctionalInterface public interface Two<InputA, InputB> { void accept(InputA a, InputB b, Control control); }}
public class Control { public boolean stop = false; public void reset();}Setting control.stop = true within a pipe callback signals the caller to stop iterating, allowing early termination of position or prop generation.
Prop Distribution System
Section titled “Prop Distribution System”Prop distributions manage how props are selected and positioned within biomes.
| Distribution | Description |
|---|---|
AssignedPropDistribution | Distribution with prop assignments |
ConstantPropDistribution | Constant prop distribution |
NoPropDistribution | No-op distribution |
PositionsPropDistribution | Position-based distribution |
UnionPropDistribution | Union of multiple distributions |
VoxelSpace
Section titled “VoxelSpace”public interface VoxelSpace<T> { void set(T value, int x, int y, int z); void set(T value, Vector3i pos); void setAll(T value); T get(int x, int y, int z); T get(Vector3i pos); Bounds3i getBounds();}| Implementation | Description |
|---|---|
ArrayVoxelSpace | Array-backed storage |
MaskVoxelSpace | Boolean mask (replaces BooleanVoxelSpace) |
NullSpace | Null-pattern implementation |
RotationVoxelSpace | Rotation-aware access |
WindowVoxelSpace | Windowed view into another space |
RNG System
Section titled “RNG System”The RNG system at com.hypixel.hytale.builtin.hytalegenerator.rng provides deterministic random number generation for world generation.
| Class | Description |
|---|---|
Rng | Static utility with getRandomInt(seed, key), mix(seed, a, b), splitMixLong(n) |
RngField | Position-seeded RNG field with get(x, y, z) and get(x, y) |
SeedBox | Seed container (relocated from seed/) |
Patterns
Section titled “Patterns”WorldGen Modifier System
Section titled “WorldGen Modifier System”Modifiers target specific world-gen configurations and apply operations (add/remove) to biome and cave content lists. This allows plugins to inject or remove biome covers, layers, prefabs, tints, cave types, and more.
WorldGenModifier Asset
Section titled “WorldGenModifier Asset”public class WorldGenModifier { protected String id; protected EventPriority priority; protected Target target; protected Map<EventType, Op[]> content;}| Field | Type | Description |
|---|---|---|
Priority | EventPriority | Order relative to other modifiers |
Target | Target | Which world-gen configuration to modify |
Content | Map<EventType, Op[]> | Operations to apply per event type |
Target
Section titled “Target”public class Target { private String root = "Default"; private String[] rules;}Root: the world-gen root configuration folder name to targetRules: glob patterns to match asset file paths within the root
Event Types
Section titled “Event Types”| Event Type | Description |
|---|---|
Biome_Covers | Surface cover blocks |
Biome_Environments | Environment settings |
Biome_Fluids | Fluid configurations |
Biome_Dynamic_Layers | Dynamic block layers |
Biome_Static_Layers | Static block layers |
Biome_Prefabs | Structure placement |
Biome_Tints | Block tinting |
Cave_Types | Cave type definitions |
Cave_Covers | Cave surface covers |
Cave_Prefabs | Cave structure placement |
Operations
Section titled “Operations”Two built-in operations are available:
Add: adds content to the target list via aContentreference (file path or inline JSON)Remove: removes entries matching globRules. Supports"*"to clear all entries. Glob matching is implemented for prefab paths and cave type names.
Example Configuration
Section titled “Example Configuration”{ "Priority": "NORMAL", "Target": { "Root": "Default", "Rules": ["Biomes/Plains/*"] }, "Content": { "Biome_Prefabs": [ { "Operation": "Add", "Content": { "Type": "File", "Path": "MyPlugin.Prefabs.CustomTree" } } ] }}Event Handling
Section titled “Event Handling”The EventHandler is scoped per thread and acquired for a root configuration path. It collects all matching modifiers, sorts them by priority and asset pack order, and dispatches operations against ModifyEvent instances during asset loading.
Entity Funnel
Section titled “Entity Funnel”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