use of org.spongepowered.api.world.biome.Biomes in project SpongeCommon by SpongePowered.
the class ByteArrayMutableBiomeBuffer method biomeStream.
@Override
public VolumeStream<BiomeVolume.Mutable, Biome> biomeStream(final Vector3i min, final Vector3i max, final StreamOptions options) {
final Vector3i blockMin = this.min();
final Vector3i blockMax = this.max();
VolumeStreamUtils.validateStreamArgs(min, max, blockMin, blockMax, options);
final byte[] biomes;
if (options.carbonCopy()) {
biomes = Arrays.copyOf(this.biomes, this.biomes.length);
} else {
biomes = this.biomes;
}
final Stream<VolumeElement<BiomeVolume.Mutable, Biome>> stateStream = IntStream.range(min.x(), max.x() + 1).mapToObj(x -> IntStream.range(min.z(), max.z() + 1).mapToObj(z -> IntStream.range(min.y(), max.y() + 1).mapToObj(y -> VolumeElement.of((BiomeVolume.Mutable) this, () -> {
final byte biomeId = biomes[this.getIndex(x, y, z)];
return this.palette.get(biomeId & 255, Sponge.server()).orElseGet(() -> Sponge.server().registry(RegistryTypes.BIOME).value(Biomes.OCEAN));
}, new Vector3d(x, y, z)))).flatMap(Function.identity())).flatMap(Function.identity());
return new SpongeVolumeStream<>(stateStream, () -> this);
}
Aggregations