Search in sources :

Example 16 with BiomeType

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();
        }
    }
}
Also used : BiomeType(org.spongepowered.api.world.biome.BiomeType) FilteredPopulator(org.spongepowered.common.world.gen.populators.FilteredPopulator) MapGenStructure(net.minecraft.world.gen.structure.MapGenStructure) Dungeon(org.spongepowered.api.world.gen.populator.Dungeon) BiomeGenerationSettings(org.spongepowered.api.world.biome.BiomeGenerationSettings) Lake(org.spongepowered.api.world.gen.populator.Lake) MapGenBase(net.minecraft.world.gen.MapGenBase)

Example 17 with BiomeType

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;
}
Also used : BiomeType(org.spongepowered.api.world.biome.BiomeType)

Example 18 with 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;
        }
    }
}
Also used : BiomeType(org.spongepowered.api.world.biome.BiomeType) VirtualBiomeType(org.spongepowered.api.world.biome.VirtualBiomeType) VirtualBiomeType(org.spongepowered.api.world.biome.VirtualBiomeType)

Example 19 with BiomeType

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;
}
Also used : BiomeType(org.spongepowered.api.world.biome.BiomeType) VirtualBiomeType(org.spongepowered.api.world.biome.VirtualBiomeType) Biome(net.minecraft.world.biome.Biome) VirtualBiomeType(org.spongepowered.api.world.biome.VirtualBiomeType)

Example 20 with BiomeType

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;
}
Also used : BiomeType(org.spongepowered.api.world.biome.BiomeType) VirtualBiomeType(org.spongepowered.api.world.biome.VirtualBiomeType) VirtualBiomeType(org.spongepowered.api.world.biome.VirtualBiomeType)

Aggregations

BiomeType (org.spongepowered.api.world.biome.BiomeType)25 Vector3i (com.flowpowered.math.vector.Vector3i)10 VirtualBiomeType (org.spongepowered.api.world.biome.VirtualBiomeType)9 BiomeGenerationSettings (org.spongepowered.api.world.biome.BiomeGenerationSettings)8 ImmutableBiomeVolume (org.spongepowered.api.world.extent.ImmutableBiomeVolume)5 GenerationPopulator (org.spongepowered.api.world.gen.GenerationPopulator)5 Biome (net.minecraft.world.biome.Biome)4 UnmodifiableBiomeVolume (org.spongepowered.api.world.extent.UnmodifiableBiomeVolume)4 ArrayList (java.util.ArrayList)3 Extent (org.spongepowered.api.world.extent.Extent)3 Populator (org.spongepowered.api.world.gen.Populator)3 Timing (co.aikar.timings.Timing)2 ResourceLocation (net.minecraft.util.ResourceLocation)2 BlockPos (net.minecraft.util.math.BlockPos)2 World (net.minecraft.world.World)2 Chunk (net.minecraft.world.chunk.Chunk)2 ChunkGeneratorOverworld (net.minecraft.world.gen.ChunkGeneratorOverworld)2 DataContainer (org.spongepowered.api.data.DataContainer)2 EventManager (org.spongepowered.api.event.EventManager)2 BiomeGenerator (org.spongepowered.api.world.gen.BiomeGenerator)2