mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-16 13:23:07 +00:00
Add more Flora config options
This commit is contained in:
@@ -2,6 +2,8 @@ package com.dfsek.terra.population;
|
||||
|
||||
import com.dfsek.terra.TerraProfiler;
|
||||
import com.dfsek.terra.biome.TerraBiomeGrid;
|
||||
import com.dfsek.terra.biome.UserDefinedBiome;
|
||||
import com.dfsek.terra.config.genconfig.BiomeConfig;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
@@ -19,13 +21,16 @@ public class FloraPopulator extends GaeaBlockPopulator {
|
||||
ProfileFuture flora = TerraProfiler.fromWorld(world).measure("FloraTime");
|
||||
for(int x = 0; x < 16; x++) {
|
||||
for(int z = 0; z < 16; z++) {
|
||||
Biome biome = TerraBiomeGrid.fromWorld(world).getBiome((chunk.getX() << 4) + x, (chunk.getZ() << 4) + z);
|
||||
UserDefinedBiome biome = (UserDefinedBiome) TerraBiomeGrid.fromWorld(world).getBiome((chunk.getX() << 4) + x, (chunk.getZ() << 4) + z);
|
||||
if(biome.getDecorator().getFloraChance() <= 0 || random.nextInt(100) > biome.getDecorator().getFloraChance())
|
||||
continue;
|
||||
try {
|
||||
Flora item = biome.getDecorator().getFlora().get(random);
|
||||
Block highest = item.getHighestValidSpawnAt(chunk, x, z);
|
||||
if(highest != null) item.plant(highest.getLocation());
|
||||
BiomeConfig c = BiomeConfig.fromBiome(biome);
|
||||
for(int i = 0; i < c.getFloraAttempts(); i++) {
|
||||
Flora item = biome.getDecorator().getFlora().get(random);
|
||||
Block highest = item.getHighestValidSpawnAt(chunk, x, z);
|
||||
if(highest != null && c.getFloraHeights(item).isInRange(highest.getY())) item.plant(highest.getLocation());
|
||||
}
|
||||
} catch(NullPointerException ignored) {}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user