mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-16 21:30:08 +00:00
Refactor & update to Gaea 1.10
This commit is contained in:
@@ -9,26 +9,26 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.polydev.gaea.biome.Biome;
|
||||
import org.polydev.gaea.population.GaeaBlockPopulator;
|
||||
import org.polydev.gaea.profiler.ProfileFuture;
|
||||
import org.polydev.gaea.world.Fauna;
|
||||
import org.polydev.gaea.world.Flora;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class FaunaPopulator extends GaeaBlockPopulator {
|
||||
public class FloraPopulator extends GaeaBlockPopulator {
|
||||
@Override
|
||||
public void populate(@NotNull World world, @NotNull Random random, @NotNull Chunk chunk) {
|
||||
ProfileFuture fauna = TerraProfiler.fromWorld(world).measure("FaunaTime");
|
||||
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);
|
||||
if(biome.getDecorator().getFaunaChance() <= 0 || random.nextInt(100) > biome.getDecorator().getFaunaChance())
|
||||
if(biome.getDecorator().getFloraChance() <= 0 || random.nextInt(100) > biome.getDecorator().getFloraChance())
|
||||
continue;
|
||||
try {
|
||||
Fauna item = biome.getDecorator().getFauna().get(random);
|
||||
Flora item = biome.getDecorator().getFlora().get(random);
|
||||
Block highest = item.getHighestValidSpawnAt(chunk, x, z);
|
||||
if(highest != null) item.plant(highest.getLocation());
|
||||
} catch(NullPointerException ignored) {}
|
||||
}
|
||||
}
|
||||
if(fauna!=null) fauna.complete();
|
||||
if(flora!=null) flora.complete();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user