--- title: Hytale Generator type: docs weight: 7 --- The Hytale Generator is the default procedural world generator that creates Hytale's terrain, structures, and features. **Package:** `com.hypixel.hytale.builtin.hytalegenerator` ## Overview The Hytale Generator combines multiple systems: ``` Hytale Generator ├── Density Functions (terrain shape) ├── Material Providers (block selection) ├── Prop Placement (vegetation/objects) ├── Cave Generation ├── Structure Placement └── Biome-specific features ``` ## Generator Structure ```java public class HytaleGenerator implements WorldGenerator { private DensityFunctionRegistry densityFunctions; private MaterialProviderRegistry materialProviders; private PropPlacementRegistry propPlacement; private CaveGenerator caveGenerator; private StructureGenerator structureGenerator; @Override public void generate(GenerationContainer container, int chunkX, int chunkZ) { // 1. Generate base terrain generateTerrain(container, chunkX, chunkZ); // 2. Carve caves caveGenerator.generate(container, chunkX, chunkZ); // 3. Place structures structureGenerator.generate(container, chunkX, chunkZ); // 4. Place props propPlacement.generate(container, chunkX, chunkZ); // 5. Finalize finalize(container); } } ``` ## Asset Configuration Generator assets define generation parameters: ```yaml # hytalegenerator/world_generator.yaml Type: HytaleGenerator Id: default_generator Seed: 0 # 0 = random TerrainDensity: Function: terrain_combined Scale: 1.0 Materials: Provider: biome_materials Caves: Enabled: true Frequency: 0.5 Structures: Enabled: true Spacing: 32 Props: Density: 1.0 ``` ## Framework Components The generator framework provides core utilities: ```java // Generation context public class GenerationContext { private long seed; private int chunkX, chunkZ; private Biome biome; private Random random; public float noise2D(float x, float z, float scale); public float noise3D(float x, float y, float z, float scale); } // Generation phase public enum GenerationPhase { TERRAIN, CARVING, STRUCTURES, DECORATION, FINALIZATION } ``` ## Data Structures Specialized data structures for generation: ```java // Height map storage public class HeightMap2D { private float[] data; private int width, height; public float get(int x, int z); public void set(int x, int z, float value); } // 3D density storage public class DensityField3D { private float[] data; private int sizeX, sizeY, sizeZ; public float get(int x, int y, int z); public float sample(float x, float y, float z); // Interpolated } ``` ## New System Integration The generator integrates newer systems: ```java public class NewSystemIntegration { // Register custom density function public void registerDensityFunction(String id, DensityFunction function); // Register custom material provider public void registerMaterialProvider(String id, MaterialProvider provider); // Register custom prop placer public void registerPropPlacer(String id, PropPlacer placer); } ``` ## Subpackages | Package | Files | Description | |---------|-------|-------------| | `assets/` | 232 | Asset definitions for generation | | `density/` | 76 | Density function implementations | | `newsystem/` | 29 | New generation system | | `materialproviders/` | 29 | Material selection | | `framework/` | 29 | Core framework | | `props/` | 24 | Prop placement | | `datastructures/` | 16 | Data structures | | `positionproviders/` | 14 | Position calculation | | `patterns/` | 13 | Generation patterns | | `fields/` | 8 | Field generation | ## Custom Generator Create a custom generator: ```java public class MyGenerator extends HytaleGenerator { @Override protected void generateTerrain(GenerationContainer container, int chunkX, int chunkZ) { // Custom terrain generation for (int x = 0; x < 16; x++) { for (int z = 0; z < 16; z++) { int worldX = chunkX * 16 + x; int worldZ = chunkZ * 16 + z; float density = getCustomDensity(worldX, worldZ); int height = (int) (density * 64) + 64; fillColumn(container, x, z, height); } } } } ``` ## Configuration ```yaml # hytalegenerator/config.yaml HytaleGenerator: WorldType: normal SeaLevel: 64 TerrainAmplitude: 1.0 CaveFrequency: 0.5 StructureSpacing: 32 BiomeScale: 256 Features: Caves: true Structures: true Props: true Ores: true ``` ## Best Practices {{< callout type="info" >}} **Generator Guidelines:** - Extend HytaleGenerator for custom worlds - Use the asset system for configuration - Register custom components in setup phase - Test generation across different seeds - Profile performance for custom functions {{< /callout >}}