Only use RandomPalette if palette contains multiple materials.

This commit is contained in:
dfsek
2020-10-01 00:39:18 -07:00
parent 0f29a506d0
commit d239358afe
16 changed files with 40 additions and 149 deletions

View File

@@ -1,6 +1,7 @@
package com.dfsek.terra.population;
import com.dfsek.terra.TerraProfiler;
import com.dfsek.terra.config.ConfigUtil;
import com.dfsek.terra.config.genconfig.CarverConfig;
import org.bukkit.Chunk;
import org.bukkit.Location;
@@ -26,6 +27,7 @@ public class CavePopulator extends BlockPopulator {
private static final BlockData AIR = Material.AIR.createBlockData();
@Override
public void populate(@NotNull World world, @NotNull Random random, @NotNull Chunk chunk) {
if(ConfigUtil.masterDisableCaves) return;
try(ProfileFuture ignored = TerraProfiler.fromWorld(world).measure("CaveTime")) {
for(CarverConfig c : CarverConfig.getCarvers()) {
Map<Location, Material> shiftCandidate = new HashMap<>();

View File

@@ -23,12 +23,9 @@ import java.util.Random;
import java.util.Set;
public class FloraPopulator extends GaeaBlockPopulator {
Set<Chunk> pop = new HashSet<>();
@Override
public void populate(@NotNull World world, @NotNull Random random, @NotNull Chunk chunk) {
try (ProfileFuture ignored = TerraProfiler.fromWorld(world).measure("FloraTime")) {
if(pop.contains(chunk)) Bukkit.getLogger().warning("Already populated flora in chunk: " + chunk);
pop.add(chunk);
for(int x = 0; x < 16; x++) {
for(int z = 0; z < 16; z++) {
UserDefinedBiome biome = (UserDefinedBiome) TerraBiomeGrid.fromWorld(world).getBiome((chunk.getX() << 4) + x, (chunk.getZ() << 4) + z, GenerationPhase.POPULATE);
@@ -39,8 +36,8 @@ public class FloraPopulator extends GaeaBlockPopulator {
Flora item;
if(c.isFloraSimplex()) item = biome.getDecorator().getFlora().get(c.getFloraNoise(), (chunk.getX() << 4) + x, (chunk.getZ() << 4) + z);
else item = biome.getDecorator().getFlora().get(random);
for(Block highest : item.getValidSpawnsAt(chunk, x, z)) {
if(c.getFloraHeights(item).isInRange(highest.getY()) && random.nextInt(100) < biome.getDecorator().getFloraChance())
for(Block highest : item.getValidSpawnsAt(chunk, x, z, c.getFloraHeights(item))) {
if(random.nextInt(100) < biome.getDecorator().getFloraChance())
item.plant(highest.getLocation());
}
}

View File

@@ -1,6 +1,6 @@
package com.dfsek.terra.population;
import com.dfsek.terra.Range;
import org.polydev.gaea.math.Range;
import com.dfsek.terra.TerraProfiler;
import com.dfsek.terra.biome.TerraBiomeGrid;
import com.dfsek.terra.biome.UserDefinedBiome;