|
| 1 | +--- |
| 2 | +title: "Overview" |
| 3 | +description: "Learn how to create custom world generation features for your Hytale mod." |
| 4 | +authors: |
| 5 | + - name: "Neil Revin" |
| 6 | + link: "https://itsneil.dev" |
| 7 | +--- |
| 8 | + |
| 9 | +# Overview |
| 10 | + |
| 11 | +This section covers Hytale's procedural world generation systems that creates environments, biomes, and structures dynamically as players explore the world. |
| 12 | + |
| 13 | +Hytale’s world generation is organized into three interconnected systems: |
| 14 | + |
| 15 | +- **Zones** - Large-scale regions that define overall world structure |
| 16 | +- **Biomes** - Terrain characteristics and environmental properties within zones |
| 17 | +- **Caves** - Underground structures and networks generated within zones |
| 18 | + |
| 19 | +These systems work together to create a rich, varied world with smooth transitions and coherent regional themes. |
| 20 | + |
| 21 | +## Getting Started |
| 22 | + |
| 23 | +1. Zone System - Large regions |
| 24 | +2. Biome System - Terrain and environment within zones |
| 25 | +3. Cave System - Underground structures and networks within zones |
| 26 | + |
| 27 | +## Implementation Details |
| 28 | + |
| 29 | +### Zone Lookup and Generation |
| 30 | + |
| 31 | +```java |
| 32 | + |
| 33 | +// Get zone at position |
| 34 | +ZonePatternGenerator zoneGen = /* world generator */; |
| 35 | +ZoneGeneratorResult zoneResult = zoneGen.generate(seed, x, z); |
| 36 | +Zone zone = zoneResult.getZone(); |
| 37 | + |
| 38 | +// Get biome within zone |
| 39 | +BiomePatternGenerator biomeGen = zone.biomePatternGenerator(); |
| 40 | +Biome biome = biomeGen.generateBiomeAt(zoneResult, seed, x, z); |
| 41 | + |
| 42 | +// Check for caves in zone |
| 43 | +CaveGenerator caveGen = zone.caveGenerator(); |
| 44 | +if (caveGen != null) { |
| 45 | + CaveType[] caveTypes = caveGen.getCaveTypes(); |
| 46 | + // Generate caves as needed |
| 47 | +} |
| 48 | +``` |
| 49 | + |
| 50 | +### Creating a Custom Zone |
| 51 | + |
| 52 | +```java |
| 53 | +// Configure zone discovery |
| 54 | +ZoneDiscoveryConfig discovery = new ZoneDiscoveryConfig( |
| 55 | + true, // Show notification |
| 56 | + "Custom Zone", // Display name |
| 57 | + "zone.forest.discover", // Sound event |
| 58 | + "icons/forest.png", // Icon |
| 59 | + true, // Major zone |
| 60 | + 5.0f, 2.0f, 1.5f // Duration, fade in, fade out |
| 61 | +); |
| 62 | + |
| 63 | +// Create biome pattern |
| 64 | +IPointGenerator biomePoints; |
| 65 | +IWeightedMap<TileBiome> tileBiomes; |
| 66 | +CustomBiome[] customBiomes; |
| 67 | + |
| 68 | +BiomePatternGenerator biomeGen = new BiomePatternGenerator( |
| 69 | + biomePoints, |
| 70 | + tileBiomes, |
| 71 | + customBiomes |
| 72 | +); |
| 73 | + |
| 74 | +// Create cave configuration |
| 75 | +CaveType[] caveTypes; // cave definitions |
| 76 | +CaveGenerator caveGen = new CaveGenerator(caveTypes); |
| 77 | + |
| 78 | +// Assemble the zone |
| 79 | +Zone customZone = new Zone( |
| 80 | + 100, // Unique ID |
| 81 | + "new_custom_zone", // Internal name |
| 82 | + discovery, // Discovery config |
| 83 | + caveGen, // Cave generator |
| 84 | + biomeGen, // Biome pattern |
| 85 | + uniquePrefabs // Unique structures |
| 86 | +); |
| 87 | +``` |
| 88 | + |
| 89 | +## System Integration |
| 90 | + |
| 91 | +### Zone & Biome Integration |
| 92 | + |
| 93 | +Each zone defines its own biome pattern: |
| 94 | + |
| 95 | +```java |
| 96 | +Zone zone = zoneGen.generate(seed, x, z).getZone(); |
| 97 | +BiomePatternGenerator biomeGen = zone.biomePatternGenerator(); |
| 98 | +Biome biome = biomeGen.generateBiomeAt(zoneResult, seed, x, z); |
| 99 | +``` |
| 100 | + |
| 101 | +### Zone & Cave Integration |
| 102 | + |
| 103 | +Eacdh zone defines it's own cave patterns: |
| 104 | + |
| 105 | +```java |
| 106 | +Zone zone = /* ... */; |
| 107 | +CaveGenerator caveGen = zone.caveGenerator(); |
| 108 | +if (caveGen != null) { |
| 109 | + // This zone has caves |
| 110 | + CaveType[] types = caveGen.getCaveTypes(); |
| 111 | +} |
| 112 | +``` |
| 113 | + |
| 114 | +### Biome & Cave Integration |
| 115 | + |
| 116 | +Caves use biome masks for placement control: |
| 117 | + |
| 118 | +```java |
| 119 | +// Cave type with biome restrictions |
| 120 | +Int2FlagsCondition biomeMask = caveType.getBiomeMask(); |
| 121 | +int biomeId = biome.getId(); |
| 122 | +int flags = biomeMask.eval(biomeId); |
| 123 | + |
| 124 | +// Check if cave can generate in this biome |
| 125 | +if (CaveBiomeMaskFlags.canGenerate(flags)) { |
| 126 | + // Generate cave |
| 127 | +} |
| 128 | +``` |
| 129 | + |
| 130 | +### Border Transitions |
| 131 | + |
| 132 | +All systems respect zone boundaries: |
| 133 | + |
| 134 | +```java |
| 135 | +ZoneGeneratorResult result = zoneGen.generate(seed, x, z); |
| 136 | +double borderDistance = result.getBorderDistance(); |
| 137 | + |
| 138 | +// Fade custom biomes near borders |
| 139 | +if (borderDistance < customBiome.getFadeContainer().getMaskFadeSum()) { |
| 140 | + double factor = customBiome.getFadeContainer().getMaskFactor(result); |
| 141 | + // Apply fading |
| 142 | +} |
| 143 | +``` |
| 144 | + |
0 commit comments