Search in sources :

Example 1 with VirtualBiomeType

use of org.spongepowered.api.world.biome.VirtualBiomeType in project SpongeCommon by SpongePowered.

the class ObjectArrayImmutableBiomeBuffer 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 2 with VirtualBiomeType

use of org.spongepowered.api.world.biome.VirtualBiomeType in project SpongeCommon by SpongePowered.

the class ObjectArrayMutableBiomeBuffer method fill.

public void fill(byte[] 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()] = (byte) Biome.getIdForBiome((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 3 with VirtualBiomeType

use of org.spongepowered.api.world.biome.VirtualBiomeType 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 4 with VirtualBiomeType

use of org.spongepowered.api.world.biome.VirtualBiomeType 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 5 with VirtualBiomeType

use of org.spongepowered.api.world.biome.VirtualBiomeType 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)5 VirtualBiomeType (org.spongepowered.api.world.biome.VirtualBiomeType)5 Biome (net.minecraft.world.biome.Biome)2