Lets not update chunks 458,752 times on island create and biome change.

This commit is contained in:
Brianna 2020-04-10 13:20:18 -04:00
parent e49b7da845
commit 0490425cde

View File

@ -23,20 +23,21 @@ public class BiomeManager {
}
public void setBiome(Island island, Biome biome) {
Set<Chunk> chunks = new HashSet<>();
Location location = island.getLocation(IslandWorld.Normal, IslandEnvironment.Island);
int radius = (int) Math.ceil(island.getRadius());
for (int x = location.getBlockX() - radius; x < location.getBlockX() + radius; x++) {
for (int z = location.getBlockZ() - radius; z < location.getBlockZ() + radius; z++) {
location.getWorld().setBiome(x, z, biome);
Chunk chunk = location.getWorld().getChunkAt(x >> 4, z >> 4);
chunks.add(chunk);
}
}
for (Chunk chunk : chunks)
updateBiome(island, chunk);
for (int x = location.getBlockX() - radius; x < location.getBlockX() + radius; x += 16) {
for (int z = location.getBlockZ() - radius; z < location.getBlockZ() + radius; z += 16) {
Chunk chunk = location.getWorld().getChunkAt(x >> 4, z >> 4);
updateBiome(island, chunk);
}
}
}
private void updateBiome(Island island, Chunk chunk) {