Search in sources :

Example 1 with BiomeChange

use of org.terasology.world.propagation.BiomeChange in project Terasology by MovingBlocks.

the class WorldProviderCoreImpl method setBiome.

@Override
public Biome setBiome(Vector3i worldPos, Biome biome) {
    Vector3i chunkPos = ChunkMath.calcChunkPos(worldPos);
    CoreChunk chunk = chunkProvider.getChunk(chunkPos);
    if (chunk != null) {
        Vector3i blockPos = ChunkMath.calcBlockPos(worldPos);
        Biome oldBiomeType = chunk.setBiome(blockPos.x, blockPos.y, blockPos.z, biome);
        if (oldBiomeType != biome) {
            BiomeChange oldChange = biomeChanges.get(worldPos);
            if (oldChange == null) {
                biomeChanges.put(worldPos, new BiomeChange(worldPos, oldBiomeType, biome));
            } else {
                oldChange.setTo(biome);
            }
            for (Vector3i pos : ChunkMath.getChunkRegionAroundWorldPos(worldPos, 1)) {
                RenderableChunk dirtiedChunk = chunkProvider.getChunk(pos);
                if (dirtiedChunk != null) {
                    dirtiedChunk.setDirty(true);
                }
            }
            notifyBiomeChanged(worldPos, biome, oldBiomeType);
        }
        return oldBiomeType;
    }
    return null;
}
Also used : CoreChunk(org.terasology.world.chunks.CoreChunk) Biome(org.terasology.world.biomes.Biome) BiomeChange(org.terasology.world.propagation.BiomeChange) Vector3i(org.terasology.math.geom.Vector3i) RenderableChunk(org.terasology.world.chunks.RenderableChunk)

Aggregations

Vector3i (org.terasology.math.geom.Vector3i)1 Biome (org.terasology.world.biomes.Biome)1 CoreChunk (org.terasology.world.chunks.CoreChunk)1 RenderableChunk (org.terasology.world.chunks.RenderableChunk)1 BiomeChange (org.terasology.world.propagation.BiomeChange)1