use of org.spongepowered.api.world.biome.BiomeType in project SpongeCommon by SpongePowered.
the class MixinChunkGeneratorFlat method addPopulators.
@Override
public void addPopulators(WorldGenerator generator) {
for (Object o : this.structureGenerators.values()) {
if (o instanceof MapGenBase) {
generator.getGenerationPopulators().add((GenerationPopulator) o);
if (o instanceof MapGenStructure) {
generator.getPopulators().add((Populator) o);
}
}
}
if (this.flatWorldGenInfo.getWorldFeatures().containsKey("lake")) {
Lake lake = Lake.builder().chance(1 / 4d).liquidType((BlockState) Blocks.WATER.getDefaultState()).height(VariableAmount.baseWithRandomAddition(0, 256)).build();
FilteredPopulator filtered = new FilteredPopulator(lake);
filtered.setRequiredFlags(WorldGenConstants.VILLAGE_FLAG);
generator.getPopulators().add(lake);
}
if (this.flatWorldGenInfo.getWorldFeatures().containsKey("lava_lake")) {
Lake lake = Lake.builder().chance(1 / 8d).liquidType((BlockState) Blocks.WATER.getDefaultState()).height(VariableAmount.baseWithVariance(0, VariableAmount.baseWithRandomAddition(8, VariableAmount.baseWithOptionalAddition(55, 193, 0.1)))).build();
FilteredPopulator filtered = new FilteredPopulator(lake);
filtered.setRequiredFlags(WorldGenConstants.VILLAGE_FLAG);
generator.getPopulators().add(filtered);
}
if (this.hasDungeons) {
Dungeon dungeon = Dungeon.builder().attempts(8).build();
generator.getPopulators().add(dungeon);
}
for (BiomeType type : Sponge.getRegistry().getAllOf(BiomeType.class)) {
BiomeGenerationSettings settings = generator.getBiomeSettings(type);
settings.getGroundCoverLayers().clear();
if (!this.hasDecoration) {
settings.getPopulators().clear();
settings.getGenerationPopulators().clear();
}
}
}
use of org.spongepowered.api.world.biome.BiomeType in project SpongeCommon by SpongePowered.
the class ByteArrayImmutableBiomeBuffer method getBiome.
@Override
public BiomeType getBiome(int x, int y, int z) {
checkRange(x, y, z);
BiomeType biomeType = (BiomeType) Biome.getBiomeForId(this.biomes[getIndex(x, z)] & 255);
return biomeType == null ? BiomeTypes.OCEAN : biomeType;
}
use of org.spongepowered.api.world.biome.BiomeType in project SpongeCommon by SpongePowered.
the class ObjectArrayMutableBiomeBuffer method fill.
public void fill(Biome[] biomes) {
for (int x = 0; x < this.size.getX(); x++) {
for (int z = 0; z < this.size.getZ(); z++) {
BiomeType type = this.biomes[x + z * this.size.getX()];
if (type instanceof VirtualBiomeType) {
type = ((VirtualBiomeType) type).getPersistedType();
}
biomes[x + z * this.size.getX()] = (Biome) type;
}
}
}
use of org.spongepowered.api.world.biome.BiomeType in project SpongeCommon by SpongePowered.
the class ObjectArrayMutableBiomeBuffer method getNativeBiome.
/**
* Gets the native biome for the position, resolving virtual biomes to
* persisted types if needed.
*
* @param x The X position
* @param y The Y position
* @param z The X position
* @return The native biome
*/
public Biome getNativeBiome(int x, int y, int z) {
checkRange(x, y, z);
BiomeType type = this.biomes[getIndex(x, z)];
if (type instanceof VirtualBiomeType) {
type = ((VirtualBiomeType) type).getPersistedType();
}
return (Biome) type;
}
use of org.spongepowered.api.world.biome.BiomeType in project SpongeCommon by SpongePowered.
the class ExtentBufferUtil method copyToArray.
public static byte[] copyToArray(BiomeVolume volume, Vector3i min, Vector3i max, Vector3i size) {
// Check if the volume has more biomes than can be stored in an array
final long memory = (long) size.getX() * (long) size.getZ();
// Leave 8 bytes for a header used in some JVMs
if (memory > Integer.MAX_VALUE - 8) {
throw new OutOfMemoryError("Cannot copy the biomes to an array because the size limit was reached");
}
final byte[] copy = new byte[(int) memory];
int i = 0;
for (int z = min.getZ(); z <= max.getZ(); z++) {
for (int x = min.getX(); x <= max.getX(); x++) {
BiomeType type = volume.getBiome(x, 0, z);
if (type instanceof VirtualBiomeType) {
type = ((VirtualBiomeType) type).getPersistedType();
}
copy[i++] = (byte) Biome.getIdForBiome((Biome) type);
}
}
return copy;
}
Aggregations