| 1 | package net.minecraft.world.level.biome;
|
| 2 |
|
| 3 | import com.mojang.datafixers.util.Pair;
|
| 4 | import it.unimi.dsi.fastutil.floats.Float2FloatFunction;
|
| 5 | import java.util.List;
|
| 6 | import java.util.Map;
|
| 7 | import java.util.function.Consumer;
|
| 8 | import net.minecraft.SharedConstants;
|
| 9 | import net.minecraft.core.Holder;
|
| 10 | import net.minecraft.core.HolderGetter;
|
| 11 | import net.minecraft.core.HolderLookup;
|
| 12 | import net.minecraft.core.RegistryAccess;
|
| 13 | import net.minecraft.core.RegistrySetBuilder;
|
| 14 | import net.minecraft.core.registries.BuiltInRegistries;
|
| 15 | import net.minecraft.core.registries.Registries;
|
| 16 | import net.minecraft.data.worldgen.NoiseData;
|
| 17 | import net.minecraft.data.worldgen.TerrainProvider;
|
| 18 | import net.minecraft.resources.ResourceKey;
|
| 19 | import net.minecraft.util.CubicSpline;
|
| 20 | import net.minecraft.util.VisibleForDebug;
|
| 21 | import net.minecraft.world.level.levelgen.NoiseRouterData;
|
| 22 | import net.minecraft.world.level.levelgen.OverworldFunctionSet;
|
| 23 | import net.minecraft.world.level.levelgen.SpawnTargetPoint;
|
| 24 | import net.minecraft.world.level.levelgen.densityfunction.DensityFunction;
|
| 25 | import net.minecraft.world.level.levelgen.densityfunction.DensityFunctions;
|
| 26 | import net.minecraft.world.level.levelgen.densityfunction.op.SplineFunction;
|
| 27 |
|
| 28 | public final class OverworldBiomeBuilder {
|
| 29 | private static final float VALLEY_SIZE = 0.05F;
|
| 30 | private static final float LOW_START = 0.26666668F;
|
| 31 | public static final float HIGH_START = 0.4F;
|
| 32 | private static final float HIGH_END = 0.93333334F;
|
| 33 | private static final float PEAK_SIZE = 0.1F;
|
| 34 | public static final float PEAK_START = 0.56666666F;
|
| 35 | private static final float PEAK_END = 0.7666667F;
|
| 36 | public static final float NEAR_INLAND_START = -0.11F;
|
| 37 | public static final float MID_INLAND_START = 0.03F;
|
| 38 | public static final float FAR_INLAND_START = 0.3F;
|
| 39 | public static final float EROSION_INDEX_1_START = -0.78F;
|
| 40 | public static final float EROSION_INDEX_2_START = -0.375F;
|
| 41 | private static final float EROSION_DEEP_DARK_DRYNESS_THRESHOLD = -0.225F;
|
| 42 | private static final float DEPTH_DEEP_DARK_DRYNESS_THRESHOLD = 0.9F;
|
| 43 | private final Climate.Parameter FULL_RANGE = Climate.Parameter.span(-1.0F, 1.0F);
|
| 44 | private final Climate.Parameter[] temperatures = new Climate.Parameter[]{
|
| 45 | Climate.Parameter.span(-1.0F, -0.45F),
|
| 46 | Climate.Parameter.span(-0.45F, -0.15F),
|
| 47 | Climate.Parameter.span(-0.15F, 0.2F),
|
| 48 | Climate.Parameter.span(0.2F, 0.55F),
|
| 49 | Climate.Parameter.span(0.55F, 1.0F)
|
| 50 | };
|
| 51 | private final Climate.Parameter[] humidities = new Climate.Parameter[]{
|
| 52 | Climate.Parameter.span(-1.0F, -0.35F),
|
| 53 | Climate.Parameter.span(-0.35F, -0.1F),
|
| 54 | Climate.Parameter.span(-0.1F, 0.1F),
|
| 55 | Climate.Parameter.span(0.1F, 0.3F),
|
| 56 | Climate.Parameter.span(0.3F, 1.0F)
|
| 57 | };
|
| 58 | private final Climate.Parameter[] erosions = new Climate.Parameter[]{
|
| 59 | Climate.Parameter.span(-1.0F, -0.78F),
|
| 60 | Climate.Parameter.span(-0.78F, -0.375F),
|
| 61 | Climate.Parameter.span(-0.375F, -0.2225F),
|
| 62 | Climate.Parameter.span(-0.2225F, 0.05F),
|
| 63 | Climate.Parameter.span(0.05F, 0.45F),
|
| 64 | Climate.Parameter.span(0.45F, 0.55F),
|
| 65 | Climate.Parameter.span(0.55F, 1.0F)
|
| 66 | };
|
| 67 | private final Climate.Parameter FROZEN_RANGE = this.temperatures[0];
|
| 68 | private final Climate.Parameter UNFROZEN_RANGE = Climate.Parameter.span(this.temperatures[1], this.temperatures[4]);
|
| 69 | private final Climate.Parameter mushroomFieldsContinentalness = Climate.Parameter.span(-1.2F, -1.05F);
|
| 70 | private final Climate.Parameter deepOceanContinentalness = Climate.Parameter.span(-1.05F, -0.455F);
|
| 71 | private final Climate.Parameter oceanContinentalness = Climate.Parameter.span(-0.455F, -0.19F);
|
| 72 | private final Climate.Parameter coastContinentalness = Climate.Parameter.span(-0.19F, -0.11F);
|
| 73 | private final Climate.Parameter inlandContinentalness = Climate.Parameter.span(-0.11F, 0.55F);
|
| 74 | private final Climate.Parameter nearInlandContinentalness = Climate.Parameter.span(-0.11F, 0.03F);
|
| 75 | private final Climate.Parameter midInlandContinentalness = Climate.Parameter.span(0.03F, 0.3F);
|
| 76 | private final Climate.Parameter farInlandContinentalness = Climate.Parameter.span(0.3F, 1.0F);
|
| 77 | private final ResourceKey<Biome>[][] OCEANS = new ResourceKey[][]{
|
| 78 | {Biomes.DEEP_FROZEN_OCEAN, Biomes.DEEP_COLD_OCEAN, Biomes.DEEP_OCEAN, Biomes.DEEP_LUKEWARM_OCEAN, Biomes.WARM_OCEAN},
|
| 79 | {Biomes.FROZEN_OCEAN, Biomes.COLD_OCEAN, Biomes.OCEAN, Biomes.LUKEWARM_OCEAN, Biomes.WARM_OCEAN}
|
| 80 | };
|
| 81 | private final ResourceKey<Biome>[][] MIDDLE_BIOMES = new ResourceKey[][]{
|
| 82 | {Biomes.SNOWY_PLAINS, Biomes.SNOWY_PLAINS, Biomes.SNOWY_PLAINS, Biomes.SNOWY_TAIGA, Biomes.TAIGA},
|
| 83 | {Biomes.PLAINS, Biomes.PLAINS, Biomes.FOREST, Biomes.TAIGA, Biomes.OLD_GROWTH_SPRUCE_TAIGA},
|
| 84 | {Biomes.FLOWER_FOREST, Biomes.PLAINS, Biomes.FOREST, Biomes.BIRCH_FOREST, Biomes.DARK_FOREST},
|
| 85 | {Biomes.SAVANNA, Biomes.SAVANNA, Biomes.FOREST, Biomes.JUNGLE, Biomes.JUNGLE},
|
| 86 | {Biomes.DESERT, Biomes.DESERT, Biomes.DESERT, Biomes.DESERT, Biomes.DESERT}
|
| 87 | };
|
| 88 | private final ResourceKey<Biome>[][] MIDDLE_BIOMES_VARIANT = new ResourceKey[][]{
|
| 89 | {Biomes.ICE_SPIKES, null, Biomes.SNOWY_TAIGA, null, null},
|
| 90 | {Biomes.DAPPLED_FOREST, null, null, null, Biomes.OLD_GROWTH_PINE_TAIGA},
|
| 91 | {Biomes.SUNFLOWER_PLAINS, null, null, Biomes.OLD_GROWTH_BIRCH_FOREST, null},
|
| 92 | {null, null, Biomes.PLAINS, Biomes.SPARSE_JUNGLE, Biomes.BAMBOO_JUNGLE},
|
| 93 | {null, null, null, null, null}
|
| 94 | };
|
| 95 | private final ResourceKey<Biome>[][] PLATEAU_BIOMES = new ResourceKey[][]{
|
| 96 | {Biomes.SNOWY_PLAINS, Biomes.SNOWY_PLAINS, Biomes.SNOWY_PLAINS, Biomes.SNOWY_TAIGA, Biomes.SNOWY_TAIGA},
|
| 97 | {Biomes.MEADOW, Biomes.MEADOW, Biomes.FOREST, Biomes.TAIGA, Biomes.OLD_GROWTH_SPRUCE_TAIGA},
|
| 98 | {Biomes.MEADOW, Biomes.MEADOW, Biomes.MEADOW, Biomes.MEADOW, Biomes.PALE_GARDEN},
|
| 99 | {Biomes.SAVANNA_PLATEAU, Biomes.SAVANNA_PLATEAU, Biomes.FOREST, Biomes.FOREST, Biomes.JUNGLE},
|
| 100 | {Biomes.BADLANDS, Biomes.BADLANDS, Biomes.BADLANDS, Biomes.WOODED_BADLANDS, Biomes.WOODED_BADLANDS}
|
| 101 | };
|
| 102 | private final ResourceKey<Biome>[][] PLATEAU_BIOMES_VARIANT = new ResourceKey[][]{
|
| 103 | {Biomes.ICE_SPIKES, null, null, null, null},
|
| 104 | {Biomes.CHERRY_GROVE, null, Biomes.MEADOW, Biomes.MEADOW, Biomes.OLD_GROWTH_PINE_TAIGA},
|
| 105 | {Biomes.CHERRY_GROVE, Biomes.CHERRY_GROVE, Biomes.FOREST, Biomes.BIRCH_FOREST, null},
|
| 106 | {null, null, null, null, null},
|
| 107 | {Biomes.ERODED_BADLANDS, Biomes.ERODED_BADLANDS, null, null, null}
|
| 108 | };
|
| 109 | private final ResourceKey<Biome>[][] SHATTERED_BIOMES = new ResourceKey[][]{
|
| 110 | {Biomes.WINDSWEPT_GRAVELLY_HILLS, Biomes.WINDSWEPT_GRAVELLY_HILLS, Biomes.WINDSWEPT_HILLS, Biomes.WINDSWEPT_FOREST, Biomes.WINDSWEPT_FOREST},
|
| 111 | {Biomes.WINDSWEPT_GRAVELLY_HILLS, Biomes.WINDSWEPT_GRAVELLY_HILLS, Biomes.WINDSWEPT_HILLS, Biomes.WINDSWEPT_FOREST, Biomes.WINDSWEPT_FOREST},
|
| 112 | {Biomes.WINDSWEPT_HILLS, Biomes.WINDSWEPT_HILLS, Biomes.WINDSWEPT_HILLS, Biomes.WINDSWEPT_FOREST, Biomes.WINDSWEPT_FOREST},
|
| 113 | {null, null, null, null, null},
|
| 114 | {null, null, null, null, null}
|
| 115 | };
|
| 116 |
|
| 117 | public List<SpawnTargetPoint> spawnTarget(final OverworldFunctionSet<Holder<DensityFunction>> functions, final Holder<DensityFunction> weirdness) {
|
| 118 | Climate.Parameter inland = Climate.Parameter.span(this.inlandContinentalness, this.FULL_RANGE);
|
| 119 | float riverClearance = 0.16F;
|
| 120 | return List.of(
|
| 121 | new SpawnTargetPoint(
|
| 122 | Map.of(
|
| 123 | functions.temperature(),
|
| 124 | this.FULL_RANGE,
|
| 125 | functions.vegetation(),
|
| 126 | this.FULL_RANGE,
|
| 127 | functions.continents(),
|
| 128 | inland,
|
| 129 | functions.erosion(),
|
| 130 | this.FULL_RANGE,
|
| 131 | weirdness,
|
| 132 | Climate.Parameter.span(-1.0F, -0.16F)
|
| 133 | )
|
| 134 | ),
|
| 135 | new SpawnTargetPoint(
|
| 136 | Map.of(
|
| 137 | functions.temperature(),
|
| 138 | this.FULL_RANGE,
|
| 139 | functions.vegetation(),
|
| 140 | this.FULL_RANGE,
|
| 141 | functions.continents(),
|
| 142 | inland,
|
| 143 | functions.erosion(),
|
| 144 | this.FULL_RANGE,
|
| 145 | weirdness,
|
| 146 | Climate.Parameter.span(0.16F, 1.0F)
|
| 147 | )
|
| 148 | )
|
| 149 | );
|
| 150 | }
|
| 151 |
|
| 152 | void addBiomes(final Consumer<Pair<Climate.ParameterPoint, ResourceKey<Biome>>> biomes) {
|
| 153 | if (SharedConstants.debugGenerateSquareTerrainWithoutNoise) {
|
| 154 | this.addDebugBiomes(biomes);
|
| 155 | } else {
|
| 156 | this.addOffCoastBiomes(biomes);
|
| 157 | this.addInlandBiomes(biomes);
|
| 158 | this.addUndergroundBiomes(biomes);
|
| 159 | }
|
| 160 | }
|
| 161 |
|
| 162 | private void addDebugBiomes(final Consumer<Pair<Climate.ParameterPoint, ResourceKey<Biome>>> biomes) {
|
| 163 | HolderLookup.Provider builtIns = new RegistrySetBuilder()
|
| 164 | .add(Registries.DENSITY_FUNCTION, NoiseRouterData::bootstrap)
|
| 165 | .add(Registries.NOISE, NoiseData::bootstrap)
|
| 166 | .build(RegistryAccess.fromRegistryOfRegistries(BuiltInRegistries.REGISTRY));
|
| 167 | HolderGetter<DensityFunction> densityFunctions = builtIns.lookupOrThrow(Registries.DENSITY_FUNCTION);
|
| 168 | SplineFunction.Coordinate continents = new SplineFunction.Coordinate(
|
| 169 | new DensityFunctions.HolderHolder(densityFunctions.getOrThrow(NoiseRouterData.OVERWORLD_FUNCTIONS.continents()))
|
| 170 | );
|
| 171 | SplineFunction.Coordinate erosion = new SplineFunction.Coordinate(
|
| 172 | new DensityFunctions.HolderHolder(densityFunctions.getOrThrow(NoiseRouterData.OVERWORLD_FUNCTIONS.erosion()))
|
| 173 | );
|
| 174 | SplineFunction.Coordinate ridges = new SplineFunction.Coordinate(
|
| 175 | new DensityFunctions.HolderHolder(densityFunctions.getOrThrow(NoiseRouterData.RIDGES_FOLDED))
|
| 176 | );
|
| 177 | biomes.accept(
|
| 178 | Pair.of(
|
| 179 | Climate.parameters(this.FULL_RANGE, this.FULL_RANGE, this.FULL_RANGE, this.FULL_RANGE, Climate.Parameter.point(0.0F), this.FULL_RANGE, 0.01F),
|
| 180 | Biomes.PLAINS
|
| 181 | )
|
| 182 | );
|
| 183 | if (TerrainProvider.buildErosionOffsetSpline(erosion, ridges, -0.15F, 0.0F, 0.0F, 0.1F, 0.0F, -0.03F, false, false, Float2FloatFunction.identity()) instanceof CubicSpline.Multipoint<?> multipoint
|
| 184 | )
|
| 185 | {
|
| 186 | ResourceKey<Biome> biome = Biomes.DESERT;
|
| 187 |
|
| 188 | for (float location : multipoint.locations()) {
|
| 189 | biomes.accept(
|
| 190 | Pair.of(
|
| 191 | Climate.parameters(
|
| 192 | this.FULL_RANGE, this.FULL_RANGE, this.FULL_RANGE, Climate.Parameter.point(location), Climate.Parameter.point(0.0F), this.FULL_RANGE, 0.0F
|
| 193 | ),
|
| 194 | biome
|
| 195 | )
|
| 196 | );
|
| 197 | biome = biome == Biomes.DESERT ? Biomes.BADLANDS : Biomes.DESERT;
|
| 198 | }
|
| 199 | }
|
| 200 |
|
| 201 | if (TerrainProvider.overworldOffset(continents, erosion, ridges, false) instanceof CubicSpline.Multipoint<?> multipoint) {
|
| 202 | for (float location : multipoint.locations()) {
|
| 203 | biomes.accept(
|
| 204 | Pair.of(
|
| 205 | Climate.parameters(
|
| 206 | this.FULL_RANGE, this.FULL_RANGE, Climate.Parameter.point(location), this.FULL_RANGE, Climate.Parameter.point(0.0F), this.FULL_RANGE, 0.0F
|
| 207 | ),
|
| 208 | Biomes.SNOWY_TAIGA
|
| 209 | )
|
| 210 | );
|
| 211 | }
|
| 212 | }
|
| 213 | }
|
| 214 |
|
| 215 | private void addOffCoastBiomes(final Consumer<Pair<Climate.ParameterPoint, ResourceKey<Biome>>> biomes) {
|
| 216 | this.addSurfaceBiome(
|
| 217 | biomes, this.FULL_RANGE, this.FULL_RANGE, this.mushroomFieldsContinentalness, this.FULL_RANGE, this.FULL_RANGE, 0.0F, Biomes.MUSHROOM_FIELDS
|
| 218 | );
|
| 219 |
|
| 220 | for (int temperatureIndex = 0; temperatureIndex < this.temperatures.length; temperatureIndex++) {
|
| 221 | Climate.Parameter temperature = this.temperatures[temperatureIndex];
|
| 222 | this.addSurfaceBiome(
|
| 223 | biomes, temperature, this.FULL_RANGE, this.deepOceanContinentalness, this.FULL_RANGE, this.FULL_RANGE, 0.0F, this.OCEANS[0][temperatureIndex]
|
| 224 | );
|
| 225 | this.addSurfaceBiome(
|
| 226 | biomes, temperature, this.FULL_RANGE, this.oceanContinentalness, this.FULL_RANGE, this.FULL_RANGE, 0.0F, this.OCEANS[1][temperatureIndex]
|
| 227 | );
|
| 228 | }
|
| 229 | }
|
| 230 |
|
| 231 | private void addInlandBiomes(final Consumer<Pair<Climate.ParameterPoint, ResourceKey<Biome>>> biomes) {
|
| 232 | this.addMidSlice(biomes, Climate.Parameter.span(-1.0F, -0.93333334F));
|
| 233 | this.addHighSlice(biomes, Climate.Parameter.span(-0.93333334F, -0.7666667F));
|
| 234 | this.addPeaks(biomes, Climate.Parameter.span(-0.7666667F, -0.56666666F));
|
| 235 | this.addHighSlice(biomes, Climate.Parameter.span(-0.56666666F, -0.4F));
|
| 236 | this.addMidSlice(biomes, Climate.Parameter.span(-0.4F, -0.26666668F));
|
| 237 | this.addLowSlice(biomes, Climate.Parameter.span(-0.26666668F, -0.05F));
|
| 238 | this.addValleys(biomes, Climate.Parameter.span(-0.05F, 0.05F));
|
| 239 | this.addLowSlice(biomes, Climate.Parameter.span(0.05F, 0.26666668F));
|
| 240 | this.addMidSlice(biomes, Climate.Parameter.span(0.26666668F, 0.4F));
|
| 241 | this.addHighSlice(biomes, Climate.Parameter.span(0.4F, 0.56666666F));
|
| 242 | this.addPeaks(biomes, Climate.Parameter.span(0.56666666F, 0.7666667F));
|
| 243 | this.addHighSlice(biomes, Climate.Parameter.span(0.7666667F, 0.93333334F));
|
| 244 | this.addMidSlice(biomes, Climate.Parameter.span(0.93333334F, 1.0F));
|
| 245 | }
|
| 246 |
|
| 247 | private void addPeaks(final Consumer<Pair<Climate.ParameterPoint, ResourceKey<Biome>>> biomes, final Climate.Parameter weirdness) {
|
| 248 | for (int temperatureIndex = 0; temperatureIndex < this.temperatures.length; temperatureIndex++) {
|
| 249 | Climate.Parameter temperature = this.temperatures[temperatureIndex];
|
| 250 |
|
| 251 | for (int humidityIndex = 0; humidityIndex < this.humidities.length; humidityIndex++) {
|
| 252 | Climate.Parameter humidity = this.humidities[humidityIndex];
|
| 253 | ResourceKey<Biome> middleBiome = this.pickMiddleBiome(temperatureIndex, humidityIndex, weirdness);
|
| 254 | ResourceKey<Biome> middleBiomeOrBadlandsIfHot = this.pickMiddleBiomeOrBadlandsIfHot(temperatureIndex, humidityIndex, weirdness);
|
| 255 | ResourceKey<Biome> middleBiomeOrBadlandsIfHotOrSlopeIfCold = this.pickMiddleBiomeOrBadlandsIfHotOrSlopeIfCold(temperatureIndex, humidityIndex, weirdness);
|
| 256 | ResourceKey<Biome> plateauBiome = this.pickPlateauBiome(temperatureIndex, humidityIndex, weirdness);
|
| 257 | ResourceKey<Biome> shatteredBiome = this.pickShatteredBiome(temperatureIndex, humidityIndex, weirdness);
|
| 258 | ResourceKey<Biome> shatteredBiomeOrWindsweptSavanna = this.maybePickWindsweptSavannaBiome(temperatureIndex, humidityIndex, weirdness, shatteredBiome);
|
| 259 | ResourceKey<Biome> peakBiome = this.pickPeakBiome(temperatureIndex, humidityIndex, weirdness);
|
| 260 | this.addSurfaceBiome(
|
| 261 | biomes,
|
| 262 | temperature,
|
| 263 | humidity,
|
| 264 | Climate.Parameter.span(this.coastContinentalness, this.farInlandContinentalness),
|
| 265 | this.erosions[0],
|
| 266 | weirdness,
|
| 267 | 0.0F,
|
| 268 | peakBiome
|
| 269 | );
|
| 270 | this.addSurfaceBiome(
|
| 271 | biomes,
|
| 272 | temperature,
|
| 273 | humidity,
|
| 274 | Climate.Parameter.span(this.coastContinentalness, this.nearInlandContinentalness),
|
| 275 | this.erosions[1],
|
| 276 | weirdness,
|
| 277 | 0.0F,
|
| 278 | middleBiomeOrBadlandsIfHotOrSlopeIfCold
|
| 279 | );
|
| 280 | this.addSurfaceBiome(
|
| 281 | biomes,
|
| 282 | temperature,
|
| 283 | humidity,
|
| 284 | Climate.Parameter.span(this.midInlandContinentalness, this.farInlandContinentalness),
|
| 285 | this.erosions[1],
|
| 286 | weirdness,
|
| 287 | 0.0F,
|
| 288 | peakBiome
|
| 289 | );
|
| 290 | this.addSurfaceBiome(
|
| 291 | biomes,
|
| 292 | temperature,
|
| 293 | humidity,
|
| 294 | Climate.Parameter.span(this.coastContinentalness, this.nearInlandContinentalness),
|
| 295 | Climate.Parameter.span(this.erosions[2], this.erosions[3]),
|
| 296 | weirdness,
|
| 297 | 0.0F,
|
| 298 | middleBiome
|
| 299 | );
|
| 300 | this.addSurfaceBiome(
|
| 301 | biomes,
|
| 302 | temperature,
|
| 303 | humidity,
|
| 304 | Climate.Parameter.span(this.midInlandContinentalness, this.farInlandContinentalness),
|
| 305 | this.erosions[2],
|
| 306 | weirdness,
|
| 307 | 0.0F,
|
| 308 | plateauBiome
|
| 309 | );
|
| 310 | this.addSurfaceBiome(biomes, temperature, humidity, this.midInlandContinentalness, this.erosions[3], weirdness, 0.0F, middleBiomeOrBadlandsIfHot);
|
| 311 | this.addSurfaceBiome(biomes, temperature, humidity, this.farInlandContinentalness, this.erosions[3], weirdness, 0.0F, plateauBiome);
|
| 312 | this.addSurfaceBiome(
|
| 313 | biomes,
|
| 314 | temperature,
|
| 315 | humidity,
|
| 316 | Climate.Parameter.span(this.coastContinentalness, this.farInlandContinentalness),
|
| 317 | this.erosions[4],
|
| 318 | weirdness,
|
| 319 | 0.0F,
|
| 320 | middleBiome
|
| 321 | );
|
| 322 | this.addSurfaceBiome(
|
| 323 | biomes,
|
| 324 | temperature,
|
| 325 | humidity,
|
| 326 | Climate.Parameter.span(this.coastContinentalness, this.nearInlandContinentalness),
|
| 327 | this.erosions[5],
|
| 328 | weirdness,
|
| 329 | 0.0F,
|
| 330 | shatteredBiomeOrWindsweptSavanna
|
| 331 | );
|
| 332 | this.addSurfaceBiome(
|
| 333 | biomes,
|
| 334 | temperature,
|
| 335 | humidity,
|
| 336 | Climate.Parameter.span(this.midInlandContinentalness, this.farInlandContinentalness),
|
| 337 | this.erosions[5],
|
| 338 | weirdness,
|
| 339 | 0.0F,
|
| 340 | shatteredBiome
|
| 341 | );
|
| 342 | this.addSurfaceBiome(
|
| 343 | biomes,
|
| 344 | temperature,
|
| 345 | humidity,
|
| 346 | Climate.Parameter.span(this.coastContinentalness, this.farInlandContinentalness),
|
| 347 | this.erosions[6],
|
| 348 | weirdness,
|
| 349 | 0.0F,
|
| 350 | middleBiome
|
| 351 | );
|
| 352 | }
|
| 353 | }
|
| 354 | }
|
| 355 |
|
| 356 | private void addHighSlice(final Consumer<Pair<Climate.ParameterPoint, ResourceKey<Biome>>> biomes, final Climate.Parameter weirdness) {
|
| 357 | for (int temperatureIndex = 0; temperatureIndex < this.temperatures.length; temperatureIndex++) {
|
| 358 | Climate.Parameter temperature = this.temperatures[temperatureIndex];
|
| 359 |
|
| 360 | for (int humidityIndex = 0; humidityIndex < this.humidities.length; humidityIndex++) {
|
| 361 | Climate.Parameter humidity = this.humidities[humidityIndex];
|
| 362 | ResourceKey<Biome> middleBiome = this.pickMiddleBiome(temperatureIndex, humidityIndex, weirdness);
|
| 363 | ResourceKey<Biome> middleBiomeOrBadlandsIfHot = this.pickMiddleBiomeOrBadlandsIfHot(temperatureIndex, humidityIndex, weirdness);
|
| 364 | ResourceKey<Biome> middleBiomeOrBadlandsIfHotOrSlopeIfCold = this.pickMiddleBiomeOrBadlandsIfHotOrSlopeIfCold(temperatureIndex, humidityIndex, weirdness);
|
| 365 | ResourceKey<Biome> plateauBiome = this.pickPlateauBiome(temperatureIndex, humidityIndex, weirdness);
|
| 366 | ResourceKey<Biome> shatteredBiome = this.pickShatteredBiome(temperatureIndex, humidityIndex, weirdness);
|
| 367 | ResourceKey<Biome> middleBiomeOrWindsweptSavanna = this.maybePickWindsweptSavannaBiome(temperatureIndex, humidityIndex, weirdness, middleBiome);
|
| 368 | ResourceKey<Biome> slopeBiome = this.pickSlopeBiome(temperatureIndex, humidityIndex, weirdness);
|
| 369 | ResourceKey<Biome> peakBiome = this.pickPeakBiome(temperatureIndex, humidityIndex, weirdness);
|
| 370 | this.addSurfaceBiome(
|
| 371 | biomes, temperature, humidity, this.coastContinentalness, Climate.Parameter.span(this.erosions[0], this.erosions[1]), weirdness, 0.0F, middleBiome
|
| 372 | );
|
| 373 | this.addSurfaceBiome(biomes, temperature, humidity, this.nearInlandContinentalness, this.erosions[0], weirdness, 0.0F, slopeBiome);
|
| 374 | this.addSurfaceBiome(
|
| 375 | biomes,
|
| 376 | temperature,
|
| 377 | humidity,
|
| 378 | Climate.Parameter.span(this.midInlandContinentalness, this.farInlandContinentalness),
|
| 379 | this.erosions[0],
|
| 380 | weirdness,
|
| 381 | 0.0F,
|
| 382 | peakBiome
|
| 383 | );
|
| 384 | this.addSurfaceBiome(
|
| 385 | biomes, temperature, humidity, this.nearInlandContinentalness, this.erosions[1], weirdness, 0.0F, middleBiomeOrBadlandsIfHotOrSlopeIfCold
|
| 386 | );
|
| 387 | this.addSurfaceBiome(
|
| 388 | biomes,
|
| 389 | temperature,
|
| 390 | humidity,
|
| 391 | Climate.Parameter.span(this.midInlandContinentalness, this.farInlandContinentalness),
|
| 392 | this.erosions[1],
|
| 393 | weirdness,
|
| 394 | 0.0F,
|
| 395 | slopeBiome
|
| 396 | );
|
| 397 | this.addSurfaceBiome(
|
| 398 | biomes,
|
| 399 | temperature,
|
| 400 | humidity,
|
| 401 | Climate.Parameter.span(this.coastContinentalness, this.nearInlandContinentalness),
|
| 402 | Climate.Parameter.span(this.erosions[2], this.erosions[3]),
|
| 403 | weirdness,
|
| 404 | 0.0F,
|
| 405 | middleBiome
|
| 406 | );
|
| 407 | this.addSurfaceBiome(
|
| 408 | biomes,
|
| 409 | temperature,
|
| 410 | humidity,
|
| 411 | Climate.Parameter.span(this.midInlandContinentalness, this.farInlandContinentalness),
|
| 412 | this.erosions[2],
|
| 413 | weirdness,
|
| 414 | 0.0F,
|
| 415 | plateauBiome
|
| 416 | );
|
| 417 | this.addSurfaceBiome(biomes, temperature, humidity, this.midInlandContinentalness, this.erosions[3], weirdness, 0.0F, middleBiomeOrBadlandsIfHot);
|
| 418 | this.addSurfaceBiome(biomes, temperature, humidity, this.farInlandContinentalness, this.erosions[3], weirdness, 0.0F, plateauBiome);
|
| 419 | this.addSurfaceBiome(
|
| 420 | biomes,
|
| 421 | temperature,
|
| 422 | humidity,
|
| 423 | Climate.Parameter.span(this.coastContinentalness, this.farInlandContinentalness),
|
| 424 | this.erosions[4],
|
| 425 | weirdness,
|
| 426 | 0.0F,
|
| 427 | middleBiome
|
| 428 | );
|
| 429 | this.addSurfaceBiome(
|
| 430 | biomes,
|
| 431 | temperature,
|
| 432 | humidity,
|
| 433 | Climate.Parameter.span(this.coastContinentalness, this.nearInlandContinentalness),
|
| 434 | this.erosions[5],
|
| 435 | weirdness,
|
| 436 | 0.0F,
|
| 437 | middleBiomeOrWindsweptSavanna
|
| 438 | );
|
| 439 | this.addSurfaceBiome(
|
| 440 | biomes,
|
| 441 | temperature,
|
| 442 | humidity,
|
| 443 | Climate.Parameter.span(this.midInlandContinentalness, this.farInlandContinentalness),
|
| 444 | this.erosions[5],
|
| 445 | weirdness,
|
| 446 | 0.0F,
|
| 447 | shatteredBiome
|
| 448 | );
|
| 449 | this.addSurfaceBiome(
|
| 450 | biomes,
|
| 451 | temperature,
|
| 452 | humidity,
|
| 453 | Climate.Parameter.span(this.coastContinentalness, this.farInlandContinentalness),
|
| 454 | this.erosions[6],
|
| 455 | weirdness,
|
| 456 | 0.0F,
|
| 457 | middleBiome
|
| 458 | );
|
| 459 | }
|
| 460 | }
|
| 461 | }
|
| 462 |
|
| 463 | private void addMidSlice(final Consumer<Pair<Climate.ParameterPoint, ResourceKey<Biome>>> biomes, final Climate.Parameter weirdness) {
|
| 464 | this.addSurfaceBiome(
|
| 465 | biomes,
|
| 466 | this.FULL_RANGE,
|
| 467 | this.FULL_RANGE,
|
| 468 | this.coastContinentalness,
|
| 469 | Climate.Parameter.span(this.erosions[0], this.erosions[2]),
|
| 470 | weirdness,
|
| 471 | 0.0F,
|
| 472 | Biomes.STONY_SHORE
|
| 473 | );
|
| 474 | this.addSurfaceBiome(
|
| 475 | biomes,
|
| 476 | Climate.Parameter.span(this.temperatures[1], this.temperatures[2]),
|
| 477 | this.FULL_RANGE,
|
| 478 | Climate.Parameter.span(this.nearInlandContinentalness, this.farInlandContinentalness),
|
| 479 | this.erosions[6],
|
| 480 | weirdness,
|
| 481 | 0.0F,
|
| 482 | Biomes.SWAMP
|
| 483 | );
|
| 484 | this.addSurfaceBiome(
|
| 485 | biomes,
|
| 486 | Climate.Parameter.span(this.temperatures[3], this.temperatures[4]),
|
| 487 | this.FULL_RANGE,
|
| 488 | Climate.Parameter.span(this.nearInlandContinentalness, this.farInlandContinentalness),
|
| 489 | this.erosions[6],
|
| 490 | weirdness,
|
| 491 | 0.0F,
|
| 492 | Biomes.MANGROVE_SWAMP
|
| 493 | );
|
| 494 |
|
| 495 | for (int temperatureIndex = 0; temperatureIndex < this.temperatures.length; temperatureIndex++) {
|
| 496 | Climate.Parameter temperature = this.temperatures[temperatureIndex];
|
| 497 |
|
| 498 | for (int humidityIndex = 0; humidityIndex < this.humidities.length; humidityIndex++) {
|
| 499 | Climate.Parameter humidity = this.humidities[humidityIndex];
|
| 500 | ResourceKey<Biome> middleBiome = this.pickMiddleBiome(temperatureIndex, humidityIndex, weirdness);
|
| 501 | ResourceKey<Biome> middleBiomeOrBadlandsIfHot = this.pickMiddleBiomeOrBadlandsIfHot(temperatureIndex, humidityIndex, weirdness);
|
| 502 | ResourceKey<Biome> middleBiomeOrBadlandsIfHotOrSlopeIfCold = this.pickMiddleBiomeOrBadlandsIfHotOrSlopeIfCold(temperatureIndex, humidityIndex, weirdness);
|
| 503 | ResourceKey<Biome> shatteredBiome = this.pickShatteredBiome(temperatureIndex, humidityIndex, weirdness);
|
| 504 | ResourceKey<Biome> plateauBiome = this.pickPlateauBiome(temperatureIndex, humidityIndex, weirdness);
|
| 505 | ResourceKey<Biome> beachBiome = this.pickBeachBiome(temperatureIndex, humidityIndex);
|
| 506 | ResourceKey<Biome> middleBiomeOrWindsweptSavanna = this.maybePickWindsweptSavannaBiome(temperatureIndex, humidityIndex, weirdness, middleBiome);
|
| 507 | ResourceKey<Biome> shatteredCoastBiome = this.pickShatteredCoastBiome(temperatureIndex, humidityIndex, weirdness);
|
| 508 | ResourceKey<Biome> slopeBiome = this.pickSlopeBiome(temperatureIndex, humidityIndex, weirdness);
|
| 509 | this.addSurfaceBiome(
|
| 510 | biomes,
|
| 511 | temperature,
|
| 512 | humidity,
|
| 513 | Climate.Parameter.span(this.nearInlandContinentalness, this.farInlandContinentalness),
|
| 514 | this.erosions[0],
|
| 515 | weirdness,
|
| 516 | 0.0F,
|
| 517 | slopeBiome
|
| 518 | );
|
| 519 | this.addSurfaceBiome(
|
| 520 | biomes,
|
| 521 | temperature,
|
| 522 | humidity,
|
| 523 | Climate.Parameter.span(this.nearInlandContinentalness, this.midInlandContinentalness),
|
| 524 | this.erosions[1],
|
| 525 | weirdness,
|
| 526 | 0.0F,
|
| 527 | middleBiomeOrBadlandsIfHotOrSlopeIfCold
|
| 528 | );
|
| 529 | this.addSurfaceBiome(
|
| 530 | biomes, temperature, humidity, this.farInlandContinentalness, this.erosions[1], weirdness, 0.0F, temperatureIndex == 0 ? slopeBiome : plateauBiome
|
| 531 | );
|
| 532 | this.addSurfaceBiome(biomes, temperature, humidity, this.nearInlandContinentalness, this.erosions[2], weirdness, 0.0F, middleBiome);
|
| 533 | this.addSurfaceBiome(biomes, temperature, humidity, this.midInlandContinentalness, this.erosions[2], weirdness, 0.0F, middleBiomeOrBadlandsIfHot);
|
| 534 | this.addSurfaceBiome(biomes, temperature, humidity, this.farInlandContinentalness, this.erosions[2], weirdness, 0.0F, plateauBiome);
|
| 535 | this.addSurfaceBiome(
|
| 536 | biomes,
|
| 537 | temperature,
|
| 538 | humidity,
|
| 539 | Climate.Parameter.span(this.coastContinentalness, this.nearInlandContinentalness),
|
| 540 | this.erosions[3],
|
| 541 | weirdness,
|
| 542 | 0.0F,
|
| 543 | middleBiome
|
| 544 | );
|
| 545 | this.addSurfaceBiome(
|
| 546 | biomes,
|
| 547 | temperature,
|
| 548 | humidity,
|
| 549 | Climate.Parameter.span(this.midInlandContinentalness, this.farInlandContinentalness),
|
| 550 | this.erosions[3],
|
| 551 | weirdness,
|
| 552 | 0.0F,
|
| 553 | middleBiomeOrBadlandsIfHot
|
| 554 | );
|
| 555 | if (weirdness.max() < 0L) {
|
| 556 | this.addSurfaceBiome(biomes, temperature, humidity, this.coastContinentalness, this.erosions[4], weirdness, 0.0F, beachBiome);
|
| 557 | this.addSurfaceBiome(
|
| 558 | biomes,
|
| 559 | temperature,
|
| 560 | humidity,
|
| 561 | Climate.Parameter.span(this.nearInlandContinentalness, this.farInlandContinentalness),
|
| 562 | this.erosions[4],
|
| 563 | weirdness,
|
| 564 | 0.0F,
|
| 565 | middleBiome
|
| 566 | );
|
| 567 | } else {
|
| 568 | this.addSurfaceBiome(
|
| 569 | biomes,
|
| 570 | temperature,
|
| 571 | humidity,
|
| 572 | Climate.Parameter.span(this.coastContinentalness, this.farInlandContinentalness),
|
| 573 | this.erosions[4],
|
| 574 | weirdness,
|
| 575 | 0.0F,
|
| 576 | middleBiome
|
| 577 | );
|
| 578 | }
|
| 579 |
|
| 580 | this.addSurfaceBiome(biomes, temperature, humidity, this.coastContinentalness, this.erosions[5], weirdness, 0.0F, shatteredCoastBiome);
|
| 581 | this.addSurfaceBiome(biomes, temperature, humidity, this.nearInlandContinentalness, this.erosions[5], weirdness, 0.0F, middleBiomeOrWindsweptSavanna);
|
| 582 | this.addSurfaceBiome(
|
| 583 | biomes,
|
| 584 | temperature,
|
| 585 | humidity,
|
| 586 | Climate.Parameter.span(this.midInlandContinentalness, this.farInlandContinentalness),
|
| 587 | this.erosions[5],
|
| 588 | weirdness,
|
| 589 | 0.0F,
|
| 590 | shatteredBiome
|
| 591 | );
|
| 592 | if (weirdness.max() < 0L) {
|
| 593 | this.addSurfaceBiome(biomes, temperature, humidity, this.coastContinentalness, this.erosions[6], weirdness, 0.0F, beachBiome);
|
| 594 | } else {
|
| 595 | this.addSurfaceBiome(biomes, temperature, humidity, this.coastContinentalness, this.erosions[6], weirdness, 0.0F, middleBiome);
|
| 596 | }
|
| 597 |
|
| 598 | if (temperatureIndex == 0) {
|
| 599 | this.addSurfaceBiome(
|
| 600 | biomes,
|
| 601 | temperature,
|
| 602 | humidity,
|
| 603 | Climate.Parameter.span(this.nearInlandContinentalness, this.farInlandContinentalness),
|
| 604 | this.erosions[6],
|
| 605 | weirdness,
|
| 606 | 0.0F,
|
| 607 | middleBiome
|
| 608 | );
|
| 609 | }
|
| 610 | }
|
| 611 | }
|
| 612 | }
|
| 613 |
|
| 614 | private void addLowSlice(final Consumer<Pair<Climate.ParameterPoint, ResourceKey<Biome>>> biomes, final Climate.Parameter weirdness) {
|
| 615 | this.addSurfaceBiome(
|
| 616 | biomes,
|
| 617 | this.FULL_RANGE,
|
| 618 | this.FULL_RANGE,
|
| 619 | this.coastContinentalness,
|
| 620 | Climate.Parameter.span(this.erosions[0], this.erosions[2]),
|
| 621 | weirdness,
|
| 622 | 0.0F,
|
| 623 | Biomes.STONY_SHORE
|
| 624 | );
|
| 625 | this.addSurfaceBiome(
|
| 626 | biomes,
|
| 627 | Climate.Parameter.span(this.temperatures[1], this.temperatures[2]),
|
| 628 | this.FULL_RANGE,
|
| 629 | Climate.Parameter.span(this.nearInlandContinentalness, this.farInlandContinentalness),
|
| 630 | this.erosions[6],
|
| 631 | weirdness,
|
| 632 | 0.0F,
|
| 633 | Biomes.SWAMP
|
| 634 | );
|
| 635 | this.addSurfaceBiome(
|
| 636 | biomes,
|
| 637 | Climate.Parameter.span(this.temperatures[3], this.temperatures[4]),
|
| 638 | this.FULL_RANGE,
|
| 639 | Climate.Parameter.span(this.nearInlandContinentalness, this.farInlandContinentalness),
|
| 640 | this.erosions[6],
|
| 641 | weirdness,
|
| 642 | 0.0F,
|
| 643 | Biomes.MANGROVE_SWAMP
|
| 644 | );
|
| 645 |
|
| 646 | for (int temperatureIndex = 0; temperatureIndex < this.temperatures.length; temperatureIndex++) {
|
| 647 | Climate.Parameter temperature = this.temperatures[temperatureIndex];
|
| 648 |
|
| 649 | for (int humidityIndex = 0; humidityIndex < this.humidities.length; humidityIndex++) {
|
| 650 | Climate.Parameter humidity = this.humidities[humidityIndex];
|
| 651 | ResourceKey<Biome> middleBiome = this.pickMiddleBiome(temperatureIndex, humidityIndex, weirdness);
|
| 652 | ResourceKey<Biome> middleBiomeOrBadlandsIfHot = this.pickMiddleBiomeOrBadlandsIfHot(temperatureIndex, humidityIndex, weirdness);
|
| 653 | ResourceKey<Biome> middleBiomeOrBadlandsIfHotOrSlopeIfCold = this.pickMiddleBiomeOrBadlandsIfHotOrSlopeIfCold(temperatureIndex, humidityIndex, weirdness);
|
| 654 | ResourceKey<Biome> beachBiome = this.pickBeachBiome(temperatureIndex, humidityIndex);
|
| 655 | ResourceKey<Biome> middleBiomeOrWindsweptSavanna = this.maybePickWindsweptSavannaBiome(temperatureIndex, humidityIndex, weirdness, middleBiome);
|
| 656 | ResourceKey<Biome> shatteredCoastBiome = this.pickShatteredCoastBiome(temperatureIndex, humidityIndex, weirdness);
|
| 657 | this.addSurfaceBiome(
|
| 658 | biomes,
|
| 659 | temperature,
|
| 660 | humidity,
|
| 661 | this.nearInlandContinentalness,
|
| 662 | Climate.Parameter.span(this.erosions[0], this.erosions[1]),
|
| 663 | weirdness,
|
| 664 | 0.0F,
|
| 665 | middleBiomeOrBadlandsIfHot
|
| 666 | );
|
| 667 | this.addSurfaceBiome(
|
| 668 | biomes,
|
| 669 | temperature,
|
| 670 | humidity,
|
| 671 | Climate.Parameter.span(this.midInlandContinentalness, this.farInlandContinentalness),
|
| 672 | Climate.Parameter.span(this.erosions[0], this.erosions[1]),
|
| 673 | weirdness,
|
| 674 | 0.0F,
|
| 675 | middleBiomeOrBadlandsIfHotOrSlopeIfCold
|
| 676 | );
|
| 677 | this.addSurfaceBiome(
|
| 678 | biomes, temperature, humidity, this.nearInlandContinentalness, Climate.Parameter.span(this.erosions[2], this.erosions[3]), weirdness, 0.0F, middleBiome
|
| 679 | );
|
| 680 | this.addSurfaceBiome(
|
| 681 | biomes,
|
| 682 | temperature,
|
| 683 | humidity,
|
| 684 | Climate.Parameter.span(this.midInlandContinentalness, this.farInlandContinentalness),
|
| 685 | Climate.Parameter.span(this.erosions[2], this.erosions[3]),
|
| 686 | weirdness,
|
| 687 | 0.0F,
|
| 688 | middleBiomeOrBadlandsIfHot
|
| 689 | );
|
| 690 | this.addSurfaceBiome(
|
| 691 | biomes, temperature, humidity, this.coastContinentalness, Climate.Parameter.span(this.erosions[3], this.erosions[4]), weirdness, 0.0F, beachBiome
|
| 692 | );
|
| 693 | this.addSurfaceBiome(
|
| 694 | biomes,
|
| 695 | temperature,
|
| 696 | humidity,
|
| 697 | Climate.Parameter.span(this.nearInlandContinentalness, this.farInlandContinentalness),
|
| 698 | this.erosions[4],
|
| 699 | weirdness,
|
| 700 | 0.0F,
|
| 701 | middleBiome
|
| 702 | );
|
| 703 | this.addSurfaceBiome(biomes, temperature, humidity, this.coastContinentalness, this.erosions[5], weirdness, 0.0F, shatteredCoastBiome);
|
| 704 | this.addSurfaceBiome(biomes, temperature, humidity, this.nearInlandContinentalness, this.erosions[5], weirdness, 0.0F, middleBiomeOrWindsweptSavanna);
|
| 705 | this.addSurfaceBiome(
|
| 706 | biomes,
|
| 707 | temperature,
|
| 708 | humidity,
|
| 709 | Climate.Parameter.span(this.midInlandContinentalness, this.farInlandContinentalness),
|
| 710 | this.erosions[5],
|
| 711 | weirdness,
|
| 712 | 0.0F,
|
| 713 | middleBiome
|
| 714 | );
|
| 715 | this.addSurfaceBiome(biomes, temperature, humidity, this.coastContinentalness, this.erosions[6], weirdness, 0.0F, beachBiome);
|
| 716 | if (temperatureIndex == 0) {
|
| 717 | this.addSurfaceBiome(
|
| 718 | biomes,
|
| 719 | temperature,
|
| 720 | humidity,
|
| 721 | Climate.Parameter.span(this.nearInlandContinentalness, this.farInlandContinentalness),
|
| 722 | this.erosions[6],
|
| 723 | weirdness,
|
| 724 | 0.0F,
|
| 725 | middleBiome
|
| 726 | );
|
| 727 | }
|
| 728 | }
|
| 729 | }
|
| 730 | }
|
| 731 |
|
| 732 | private void addValleys(final Consumer<Pair<Climate.ParameterPoint, ResourceKey<Biome>>> biomes, final Climate.Parameter weirdness) {
|
| 733 | this.addSurfaceBiome(
|
| 734 | biomes,
|
| 735 | this.FROZEN_RANGE,
|
| 736 | this.FULL_RANGE,
|
| 737 | this.coastContinentalness,
|
| 738 | Climate.Parameter.span(this.erosions[0], this.erosions[1]),
|
| 739 | weirdness,
|
| 740 | 0.0F,
|
| 741 | weirdness.max() < 0L ? Biomes.STONY_SHORE : Biomes.FROZEN_RIVER
|
| 742 | );
|
| 743 | this.addSurfaceBiome(
|
| 744 | biomes,
|
| 745 | this.UNFROZEN_RANGE,
|
| 746 | this.FULL_RANGE,
|
| 747 | this.coastContinentalness,
|
| 748 | Climate.Parameter.span(this.erosions[0], this.erosions[1]),
|
| 749 | weirdness,
|
| 750 | 0.0F,
|
| 751 | weirdness.max() < 0L ? Biomes.STONY_SHORE : Biomes.RIVER
|
| 752 | );
|
| 753 | this.addSurfaceBiome(
|
| 754 | biomes,
|
| 755 | this.FROZEN_RANGE,
|
| 756 | this.FULL_RANGE,
|
| 757 | this.nearInlandContinentalness,
|
| 758 | Climate.Parameter.span(this.erosions[0], this.erosions[1]),
|
| 759 | weirdness,
|
| 760 | 0.0F,
|
| 761 | Biomes.FROZEN_RIVER
|
| 762 | );
|
| 763 | this.addSurfaceBiome(
|
| 764 | biomes,
|
| 765 | this.UNFROZEN_RANGE,
|
| 766 | this.FULL_RANGE,
|
| 767 | this.nearInlandContinentalness,
|
| 768 | Climate.Parameter.span(this.erosions[0], this.erosions[1]),
|
| 769 | weirdness,
|
| 770 | 0.0F,
|
| 771 | Biomes.RIVER
|
| 772 | );
|
| 773 | this.addSurfaceBiome(
|
| 774 | biomes,
|
| 775 | this.FROZEN_RANGE,
|
| 776 | this.FULL_RANGE,
|
| 777 | Climate.Parameter.span(this.coastContinentalness, this.farInlandContinentalness),
|
| 778 | Climate.Parameter.span(this.erosions[2], this.erosions[5]),
|
| 779 | weirdness,
|
| 780 | 0.0F,
|
| 781 | Biomes.FROZEN_RIVER
|
| 782 | );
|
| 783 | this.addSurfaceBiome(
|
| 784 | biomes,
|
| 785 | this.UNFROZEN_RANGE,
|
| 786 | this.FULL_RANGE,
|
| 787 | Climate.Parameter.span(this.coastContinentalness, this.farInlandContinentalness),
|
| 788 | Climate.Parameter.span(this.erosions[2], this.erosions[5]),
|
| 789 | weirdness,
|
| 790 | 0.0F,
|
| 791 | Biomes.RIVER
|
| 792 | );
|
| 793 | this.addSurfaceBiome(biomes, this.FROZEN_RANGE, this.FULL_RANGE, this.coastContinentalness, this.erosions[6], weirdness, 0.0F, Biomes.FROZEN_RIVER);
|
| 794 | this.addSurfaceBiome(biomes, this.UNFROZEN_RANGE, this.FULL_RANGE, this.coastContinentalness, this.erosions[6], weirdness, 0.0F, Biomes.RIVER);
|
| 795 | this.addSurfaceBiome(
|
| 796 | biomes,
|
| 797 | Climate.Parameter.span(this.temperatures[1], this.temperatures[2]),
|
| 798 | this.FULL_RANGE,
|
| 799 | Climate.Parameter.span(this.inlandContinentalness, this.farInlandContinentalness),
|
| 800 | this.erosions[6],
|
| 801 | weirdness,
|
| 802 | 0.0F,
|
| 803 | Biomes.SWAMP
|
| 804 | );
|
| 805 | this.addSurfaceBiome(
|
| 806 | biomes,
|
| 807 | Climate.Parameter.span(this.temperatures[3], this.temperatures[4]),
|
| 808 | this.FULL_RANGE,
|
| 809 | Climate.Parameter.span(this.inlandContinentalness, this.farInlandContinentalness),
|
| 810 | this.erosions[6],
|
| 811 | weirdness,
|
| 812 | 0.0F,
|
| 813 | Biomes.MANGROVE_SWAMP
|
| 814 | );
|
| 815 | this.addSurfaceBiome(
|
| 816 | biomes,
|
| 817 | this.FROZEN_RANGE,
|
| 818 | this.FULL_RANGE,
|
| 819 | Climate.Parameter.span(this.inlandContinentalness, this.farInlandContinentalness),
|
| 820 | this.erosions[6],
|
| 821 | weirdness,
|
| 822 | 0.0F,
|
| 823 | Biomes.FROZEN_RIVER
|
| 824 | );
|
| 825 |
|
| 826 | for (int temperatureIndex = 0; temperatureIndex < this.temperatures.length; temperatureIndex++) {
|
| 827 | Climate.Parameter temperature = this.temperatures[temperatureIndex];
|
| 828 |
|
| 829 | for (int humidityIndex = 0; humidityIndex < this.humidities.length; humidityIndex++) {
|
| 830 | Climate.Parameter humidity = this.humidities[humidityIndex];
|
| 831 | ResourceKey<Biome> middleBiomeOrBadlandsIfHot = this.pickMiddleBiomeOrBadlandsIfHot(temperatureIndex, humidityIndex, weirdness);
|
| 832 | this.addSurfaceBiome(
|
| 833 | biomes,
|
| 834 | temperature,
|
| 835 | humidity,
|
| 836 | Climate.Parameter.span(this.midInlandContinentalness, this.farInlandContinentalness),
|
| 837 | Climate.Parameter.span(this.erosions[0], this.erosions[1]),
|
| 838 | weirdness,
|
| 839 | 0.0F,
|
| 840 | middleBiomeOrBadlandsIfHot
|
| 841 | );
|
| 842 | }
|
| 843 | }
|
| 844 | }
|
| 845 |
|
| 846 | private void addUndergroundBiomes(final Consumer<Pair<Climate.ParameterPoint, ResourceKey<Biome>>> biomes) {
|
| 847 | this.addUndergroundBiome(
|
| 848 | biomes, this.FULL_RANGE, this.FULL_RANGE, Climate.Parameter.span(0.8F, 1.0F), this.FULL_RANGE, this.FULL_RANGE, 0.0F, Biomes.DRIPSTONE_CAVES
|
| 849 | );
|
| 850 | this.addUndergroundBiome(
|
| 851 | biomes, this.FULL_RANGE, Climate.Parameter.span(0.7F, 1.0F), this.FULL_RANGE, this.FULL_RANGE, this.FULL_RANGE, 0.0F, Biomes.LUSH_CAVES
|
| 852 | );
|
| 853 | this.addUndergroundBiome(
|
| 854 | biomes,
|
| 855 | this.FULL_RANGE,
|
| 856 | this.FULL_RANGE,
|
| 857 | Climate.Parameter.span(this.coastContinentalness, this.inlandContinentalness),
|
| 858 | Climate.Parameter.span(this.erosions[5], this.erosions[6]),
|
| 859 | Climate.Parameter.span(-1.1F, -0.85F),
|
| 860 | 0.0F,
|
| 861 | Biomes.SULFUR_CAVES
|
| 862 | );
|
| 863 | this.addBottomBiome(
|
| 864 | biomes,
|
| 865 | this.FULL_RANGE,
|
| 866 | this.FULL_RANGE,
|
| 867 | this.FULL_RANGE,
|
| 868 | Climate.Parameter.span(this.erosions[0], this.erosions[1]),
|
| 869 | this.FULL_RANGE,
|
| 870 | 0.0F,
|
| 871 | Biomes.DEEP_DARK
|
| 872 | );
|
| 873 | }
|
| 874 |
|
| 875 | private ResourceKey<Biome> pickMiddleBiome(final int temperatureIndex, final int humidityIndex, final Climate.Parameter weirdness) {
|
| 876 | if (weirdness.max() < 0L) {
|
| 877 | return this.MIDDLE_BIOMES[temperatureIndex][humidityIndex];
|
| 878 | }
|
| 879 |
|
| 880 | ResourceKey<Biome> variant = this.MIDDLE_BIOMES_VARIANT[temperatureIndex][humidityIndex];
|
| 881 | return variant == null ? this.MIDDLE_BIOMES[temperatureIndex][humidityIndex] : variant;
|
| 882 | }
|
| 883 |
|
| 884 | private ResourceKey<Biome> pickMiddleBiomeOrBadlandsIfHot(final int temperatureIndex, final int humidityIndex, final Climate.Parameter weirdness) {
|
| 885 | return temperatureIndex == 4 ? this.pickBadlandsBiome(humidityIndex, weirdness) : this.pickMiddleBiome(temperatureIndex, humidityIndex, weirdness);
|
| 886 | }
|
| 887 |
|
| 888 | private ResourceKey<Biome> pickMiddleBiomeOrBadlandsIfHotOrSlopeIfCold(final int temperatureIndex, final int humidityIndex, final Climate.Parameter weirdness) {
|
| 889 | return temperatureIndex == 0
|
| 890 | ? this.pickSlopeBiome(temperatureIndex, humidityIndex, weirdness)
|
| 891 | : this.pickMiddleBiomeOrBadlandsIfHot(temperatureIndex, humidityIndex, weirdness);
|
| 892 | }
|
| 893 |
|
| 894 | private ResourceKey<Biome> maybePickWindsweptSavannaBiome(
|
| 895 | final int temperatureIndex, final int humidityIndex, final Climate.Parameter weirdness, final ResourceKey<Biome> underlyingBiome
|
| 896 | ) {
|
| 897 | return temperatureIndex > 1 && humidityIndex < 4 && weirdness.max() >= 0L ? Biomes.WINDSWEPT_SAVANNA : underlyingBiome;
|
| 898 | }
|
| 899 |
|
| 900 | private ResourceKey<Biome> pickShatteredCoastBiome(final int temperatureIndex, final int humidityIndex, final Climate.Parameter weirdness) {
|
| 901 | ResourceKey<Biome> beachOrMiddleBiome = weirdness.max() >= 0L
|
| 902 | ? this.pickMiddleBiome(temperatureIndex, humidityIndex, weirdness)
|
| 903 | : this.pickBeachBiome(temperatureIndex, humidityIndex);
|
| 904 | return this.maybePickWindsweptSavannaBiome(temperatureIndex, humidityIndex, weirdness, beachOrMiddleBiome);
|
| 905 | }
|
| 906 |
|
| 907 | private ResourceKey<Biome> pickBeachBiome(final int temperatureIndex, final int humidityIndex) {
|
| 908 | if (temperatureIndex == 0) {
|
| 909 | return Biomes.SNOWY_BEACH;
|
| 910 | } else {
|
| 911 | return temperatureIndex == 4 ? Biomes.DESERT : Biomes.BEACH;
|
| 912 | }
|
| 913 | }
|
| 914 |
|
| 915 | private ResourceKey<Biome> pickBadlandsBiome(final int humidityIndex, final Climate.Parameter weirdness) {
|
| 916 | if (humidityIndex < 2) {
|
| 917 | return weirdness.max() < 0L ? Biomes.BADLANDS : Biomes.ERODED_BADLANDS;
|
| 918 | } else {
|
| 919 | return humidityIndex < 3 ? Biomes.BADLANDS : Biomes.WOODED_BADLANDS;
|
| 920 | }
|
| 921 | }
|
| 922 |
|
| 923 | private ResourceKey<Biome> pickPlateauBiome(final int temperatureIndex, final int humidityIndex, final Climate.Parameter weirdness) {
|
| 924 | if (weirdness.max() >= 0L) {
|
| 925 | ResourceKey<Biome> variant = this.PLATEAU_BIOMES_VARIANT[temperatureIndex][humidityIndex];
|
| 926 | if (variant != null) {
|
| 927 | return variant;
|
| 928 | }
|
| 929 | }
|
| 930 |
|
| 931 | return this.PLATEAU_BIOMES[temperatureIndex][humidityIndex];
|
| 932 | }
|
| 933 |
|
| 934 | private ResourceKey<Biome> pickPeakBiome(final int temperatureIndex, final int humidityIndex, final Climate.Parameter weirdness) {
|
| 935 | if (temperatureIndex <= 2) {
|
| 936 | return weirdness.max() < 0L ? Biomes.JAGGED_PEAKS : Biomes.FROZEN_PEAKS;
|
| 937 | } else {
|
| 938 | return temperatureIndex == 3 ? Biomes.STONY_PEAKS : this.pickBadlandsBiome(humidityIndex, weirdness);
|
| 939 | }
|
| 940 | }
|
| 941 |
|
| 942 | private ResourceKey<Biome> pickSlopeBiome(final int temperatureIndex, final int humidityIndex, final Climate.Parameter weirdness) {
|
| 943 | if (temperatureIndex >= 3) {
|
| 944 | return this.pickPlateauBiome(temperatureIndex, humidityIndex, weirdness);
|
| 945 | } else {
|
| 946 | return humidityIndex <= 1 ? Biomes.SNOWY_SLOPES : Biomes.GROVE;
|
| 947 | }
|
| 948 | }
|
| 949 |
|
| 950 | private ResourceKey<Biome> pickShatteredBiome(final int temperatureIndex, final int humidityIndex, final Climate.Parameter weirdness) {
|
| 951 | ResourceKey<Biome> biome = this.SHATTERED_BIOMES[temperatureIndex][humidityIndex];
|
| 952 | return biome == null ? this.pickMiddleBiome(temperatureIndex, humidityIndex, weirdness) : biome;
|
| 953 | }
|
| 954 |
|
| 955 | private void addSurfaceBiome(
|
| 956 | final Consumer<Pair<Climate.ParameterPoint, ResourceKey<Biome>>> biomes,
|
| 957 | final Climate.Parameter temperature,
|
| 958 | final Climate.Parameter humidity,
|
| 959 | final Climate.Parameter continentalness,
|
| 960 | final Climate.Parameter erosion,
|
| 961 | final Climate.Parameter weirdness,
|
| 962 | final float offset,
|
| 963 | final ResourceKey<Biome> second
|
| 964 | ) {
|
| 965 | biomes.accept(Pair.of(Climate.parameters(temperature, humidity, continentalness, erosion, Climate.Parameter.point(0.0F), weirdness, offset), second));
|
| 966 | biomes.accept(Pair.of(Climate.parameters(temperature, humidity, continentalness, erosion, Climate.Parameter.point(1.0F), weirdness, offset), second));
|
| 967 | }
|
| 968 |
|
| 969 | private void addUndergroundBiome(
|
| 970 | final Consumer<Pair<Climate.ParameterPoint, ResourceKey<Biome>>> biomes,
|
| 971 | final Climate.Parameter temperature,
|
| 972 | final Climate.Parameter humidity,
|
| 973 | final Climate.Parameter continentalness,
|
| 974 | final Climate.Parameter erosion,
|
| 975 | final Climate.Parameter weirdness,
|
| 976 | final float offset,
|
| 977 | final ResourceKey<Biome> biome
|
| 978 | ) {
|
| 979 | biomes.accept(Pair.of(Climate.parameters(temperature, humidity, continentalness, erosion, Climate.Parameter.span(0.2F, 0.9F), weirdness, offset), biome));
|
| 980 | }
|
| 981 |
|
| 982 | private void addBottomBiome(
|
| 983 | final Consumer<Pair<Climate.ParameterPoint, ResourceKey<Biome>>> biomes,
|
| 984 | final Climate.Parameter temperature,
|
| 985 | final Climate.Parameter humidity,
|
| 986 | final Climate.Parameter continentalness,
|
| 987 | final Climate.Parameter erosion,
|
| 988 | final Climate.Parameter weirdness,
|
| 989 | final float offset,
|
| 990 | final ResourceKey<Biome> biome
|
| 991 | ) {
|
| 992 | biomes.accept(Pair.of(Climate.parameters(temperature, humidity, continentalness, erosion, Climate.Parameter.point(1.1F), weirdness, offset), biome));
|
| 993 | }
|
| 994 |
|
| 995 | public static DensityFunction deepDarkRegion(final DensityFunction erosion, final DensityFunction depth) {
|
| 996 | return DensityFunctions.min(
|
| 997 | DensityFunctions.sub(DensityFunctions.constant(-0.225F), erosion), DensityFunctions.max(depth.sub(0.9F), DensityFunctions.constant(0.0F))
|
| 998 | );
|
| 999 | }
|
| 1000 |
|
| 1001 | public static String getDebugStringForPeaksAndValleys(final double peaksAndValleys) {
|
| 1002 | if (peaksAndValleys < NoiseRouterData.peaksAndValleys(0.05F)) {
|
| 1003 | return "Valley";
|
| 1004 | } else if (peaksAndValleys < NoiseRouterData.peaksAndValleys(0.26666668F)) {
|
| 1005 | return "Low";
|
| 1006 | } else if (peaksAndValleys < NoiseRouterData.peaksAndValleys(0.4F)) {
|
| 1007 | return "Mid";
|
| 1008 | } else {
|
| 1009 | return peaksAndValleys < NoiseRouterData.peaksAndValleys(0.56666666F) ? "High" : "Peak";
|
| 1010 | }
|
| 1011 | }
|
| 1012 |
|
| 1013 | public String getDebugStringForContinentalness(final double continentalness) {
|
| 1014 | double continentalnessQuantized = Climate.quantizeCoord((float)continentalness);
|
| 1015 | if (continentalnessQuantized < this.mushroomFieldsContinentalness.max()) {
|
| 1016 | return "Mushroom fields";
|
| 1017 | } else if (continentalnessQuantized < this.deepOceanContinentalness.max()) {
|
| 1018 | return "Deep ocean";
|
| 1019 | } else if (continentalnessQuantized < this.oceanContinentalness.max()) {
|
| 1020 | return "Ocean";
|
| 1021 | } else if (continentalnessQuantized < this.coastContinentalness.max()) {
|
| 1022 | return "Coast";
|
| 1023 | } else if (continentalnessQuantized < this.nearInlandContinentalness.max()) {
|
| 1024 | return "Near inland";
|
| 1025 | } else {
|
| 1026 | return continentalnessQuantized < this.midInlandContinentalness.max() ? "Mid inland" : "Far inland";
|
| 1027 | }
|
| 1028 | }
|
| 1029 |
|
| 1030 | public String getDebugStringForErosion(final double erosion) {
|
| 1031 | return getDebugStringForNoiseValue(erosion, this.erosions);
|
| 1032 | }
|
| 1033 |
|
| 1034 | public String getDebugStringForTemperature(final double temperature) {
|
| 1035 | return getDebugStringForNoiseValue(temperature, this.temperatures);
|
| 1036 | }
|
| 1037 |
|
| 1038 | public String getDebugStringForHumidity(final double humidity) {
|
| 1039 | return getDebugStringForNoiseValue(humidity, this.humidities);
|
| 1040 | }
|
| 1041 |
|
| 1042 | private static String getDebugStringForNoiseValue(final double noiseValue, final Climate.Parameter[] array) {
|
| 1043 | double noiseValueQuantized = Climate.quantizeCoord((float)noiseValue);
|
| 1044 |
|
| 1045 | for (int i = 0; i < array.length; i++) {
|
| 1046 | if (noiseValueQuantized < array[i].max()) {
|
| 1047 | return i + "";
|
| 1048 | }
|
| 1049 | }
|
| 1050 |
|
| 1051 | return "?";
|
| 1052 | }
|
| 1053 |
|
| 1054 | @VisibleForDebug
|
| 1055 | public Climate.Parameter[] getTemperatureThresholds() {
|
| 1056 | return this.temperatures;
|
| 1057 | }
|
| 1058 |
|
| 1059 | @VisibleForDebug
|
| 1060 | public Climate.Parameter[] getHumidityThresholds() {
|
| 1061 | return this.humidities;
|
| 1062 | }
|
| 1063 |
|
| 1064 | @VisibleForDebug
|
| 1065 | public Climate.Parameter[] getErosionThresholds() {
|
| 1066 | return this.erosions;
|
| 1067 | }
|
| 1068 |
|
| 1069 | @VisibleForDebug
|
| 1070 | public Climate.Parameter[] getContinentalnessThresholds() {
|
| 1071 | return new Climate.Parameter[]{
|
| 1072 | this.mushroomFieldsContinentalness,
|
| 1073 | this.deepOceanContinentalness,
|
| 1074 | this.oceanContinentalness,
|
| 1075 | this.coastContinentalness,
|
| 1076 | this.nearInlandContinentalness,
|
| 1077 | this.midInlandContinentalness,
|
| 1078 | this.farInlandContinentalness
|
| 1079 | };
|
| 1080 | }
|
| 1081 |
|
| 1082 | @VisibleForDebug
|
| 1083 | public Climate.Parameter[] getPeaksAndValleysThresholds() {
|
| 1084 | return new Climate.Parameter[]{
|
| 1085 | Climate.Parameter.span(-2.0F, NoiseRouterData.peaksAndValleys(0.05F)),
|
| 1086 | Climate.Parameter.span(NoiseRouterData.peaksAndValleys(0.05F), NoiseRouterData.peaksAndValleys(0.26666668F)),
|
| 1087 | Climate.Parameter.span(NoiseRouterData.peaksAndValleys(0.26666668F), NoiseRouterData.peaksAndValleys(0.4F)),
|
| 1088 | Climate.Parameter.span(NoiseRouterData.peaksAndValleys(0.4F), NoiseRouterData.peaksAndValleys(0.56666666F)),
|
| 1089 | Climate.Parameter.span(NoiseRouterData.peaksAndValleys(0.56666666F), 2.0F)
|
| 1090 | };
|
| 1091 | }
|
| 1092 |
|
| 1093 | @VisibleForDebug
|
| 1094 | public Climate.Parameter[] getWeirdnessThresholds() {
|
| 1095 | return new Climate.Parameter[]{Climate.Parameter.span(-2.0F, 0.0F), Climate.Parameter.span(0.0F, 2.0F)};
|
| 1096 | }
|
| 1097 | }
|
| 1098 |
|