use 3d biomes in FeatureGenerationStage

This commit is contained in:
dfsek committed 2022-06-08 19:17:00 -07:00
1 parent 53df9a47fc
commit 245acde336
1 file changed
+23 -23
@@ -7,9 +7,6 @@
package com.dfsek.terra.addons.generation.feature; package com.dfsek.terra.addons.generation.feature;
import java.util.Collections;
import java.util.Random;
import com.dfsek.terra.addons.generation.feature.config.BiomeFeatures; import com.dfsek.terra.addons.generation.feature.config.BiomeFeatures;
import com.dfsek.terra.api.Platform; import com.dfsek.terra.api.Platform;
import com.dfsek.terra.api.registry.key.StringIdentifiable; import com.dfsek.terra.api.registry.key.StringIdentifiable;
@@ -20,6 +17,9 @@ import com.dfsek.terra.api.world.chunk.generation.ProtoWorld;
import com.dfsek.terra.api.world.chunk.generation.stage.GenerationStage; import com.dfsek.terra.api.world.chunk.generation.stage.GenerationStage;
import com.dfsek.terra.api.world.chunk.generation.util.Column; import com.dfsek.terra.api.world.chunk.generation.util.Column;
import java.util.Collections;
import java.util.Random;
public class FeatureGenerationStage implements GenerationStage, StringIdentifiable { public class FeatureGenerationStage implements GenerationStage, StringIdentifiable {
private final Platform platform; private final Platform platform;
@@ -49,26 +49,26 @@ public class FeatureGenerationStage implements GenerationStage, StringIdentifiab
long coordinateSeed = (seed * 31 + tx) * 31 + tz; long coordinateSeed = (seed * 31 + tx) * 31 + tz;
world.getBiomeProvider() world.getBiomeProvider()
.getBiome(tx, 0, tz, seed) .getColumn(tx, tz, world)
.getContext() .forRanges((min, max, biome) ->
.get(BiomeFeatures.class) biome.getContext()
.getFeatures() .get(BiomeFeatures.class)
.getOrDefault(this, Collections.emptyList()) .getFeatures()
.forEach(feature -> { .getOrDefault(this, Collections.emptyList())
platform.getProfiler().push(feature.getID()); .forEach(feature -> {
if(feature.getDistributor().matches(tx, tz, seed)) { platform.getProfiler().push(feature.getID());
feature.getLocator() if(feature.getDistributor().matches(tx, tz, seed)) {
.getSuitableCoordinates(column) feature.getLocator()
.forEach(y -> .getSuitableCoordinates(column.clamp(min, max))
feature.getStructure(world, tx, y, tz) .forEach(y -> feature.getStructure(world, tx, y, tz)
.generate(Vector3Int.of(tx, y, tz), .generate(Vector3Int.of(tx, y, tz),
world, world,
new Random(coordinateSeed * 31 + y), new Random(coordinateSeed * 31 + y),
Rotation.NONE) Rotation.NONE)
); );
} }
platform.getProfiler().pop(feature.getID()); platform.getProfiler().pop(feature.getID());
}); }));
} }
} }
platform.getProfiler().pop(profile); platform.getProfiler().pop(profile);