Update to latest Gaea, allow configuration of terrain octaves/frequency

This commit is contained in:
dfsek
2020-10-17 16:49:43 -07:00
parent 2c49160731
commit 2741a761a0
32 changed files with 136 additions and 111 deletions

View File

@@ -30,7 +30,7 @@ import org.polydev.gaea.generation.GaeaChunkGenerator;
import org.polydev.gaea.generation.GenerationPhase;
import org.polydev.gaea.generation.GenerationPopulator;
import org.polydev.gaea.math.ChunkInterpolator;
import org.polydev.gaea.math.FastNoise;
import org.polydev.gaea.math.FastNoiseLite;
import org.polydev.gaea.population.PopulationManager;
import org.polydev.gaea.world.palette.Palette;
@@ -47,19 +47,23 @@ import java.util.logging.Level;
public class TerraChunkGenerator extends GaeaChunkGenerator {
private final PopulationManager popMan = new PopulationManager(Terra.getInstance());
private boolean needsLoad = true;
private int octaves;
private float frequency;
private static final Map<World, PopulationManager> popMap = new HashMap<>();
public TerraChunkGenerator() {
public TerraChunkGenerator(ConfigPack c) {
super(ChunkInterpolator.InterpolationType.TRILINEAR);
this.frequency = c.frequency;
this.octaves = c.octaves;
popMan.attach(new FloraPopulator());
popMan.attach(new OrePopulator());
popMan.attach(new SnowPopulator());
}
@Override
public ChunkData generateBase(@NotNull World world, @NotNull Random random, int chunkX, int chunkZ, FastNoise fastNoise) {
public ChunkData generateBase(@NotNull World world, @NotNull Random random, int chunkX, int chunkZ, FastNoiseLite fastNoise) {
if(needsLoad) load(world); // Load population data for world.
StructureSpawnRequirement.putNoise(world, fastNoise); // Assign noise to world to be used for structures.
ChunkData chunk = createChunkData(world);
@@ -161,11 +165,11 @@ public class TerraChunkGenerator extends GaeaChunkGenerator {
@Override
public int getNoiseOctaves(World world) {
return 4;
return octaves;
}
@Override
public float getNoiseFrequency(World world) {
return 1f/96;
return frequency;
}
@Override
@@ -186,7 +190,7 @@ public class TerraChunkGenerator extends GaeaChunkGenerator {
@Override
public boolean shouldGenerateStructures() {
return true;
return false;
}

View File

@@ -6,7 +6,7 @@ import com.dfsek.terra.util.DataUtil;
import org.bukkit.World;
import org.bukkit.block.data.BlockData;
import org.polydev.gaea.biome.Generator;
import org.polydev.gaea.math.FastNoise;
import org.polydev.gaea.math.FastNoiseLite;
import org.polydev.gaea.world.palette.Palette;
import parsii.eval.Expression;
import parsii.eval.Parser;
@@ -49,15 +49,15 @@ public class UserDefinedGenerator extends Generator {
this.noiseExp = p.parse(equation, s);
}
/**
* Gets the 2D noise at a pair of coordinates using the provided FastNoise instance.
* Gets the 2D noise at a pair of coordinates using the provided FastNoiseLite instance.
*
* @param gen - The FastNoise instance to use.
* @param gen - The FastNoiseLite instance to use.
* @param x - The x coordinate.
* @param z - The z coordinate.
* @return double - Noise value at the specified coordinates.
*/
@Override
public double getNoise(FastNoise gen, World w, int x, int z) {
public double getNoise(FastNoiseLite gen, World w, int x, int z) {
synchronized(noiseLock) {
xVar.setValue(x);
yVar.setValue(0);
@@ -69,16 +69,16 @@ public class UserDefinedGenerator extends Generator {
}
/**
* Gets the 3D noise at a pair of coordinates using the provided FastNoise instance.
* Gets the 3D noise at a pair of coordinates using the provided FastNoiseLite instance.
*
* @param gen - The FastNoise instance to use.
* @param gen - The FastNoiseLite instance to use.
* @param x - The x coordinate.
* @param y - The y coordinate.
* @param z - The z coordinate.
* @return double - Noise value at the specified coordinates.
*/
@Override
public double getNoise(FastNoise gen, World w, int x, int y, int z) {
public double getNoise(FastNoiseLite gen, World w, int x, int y, int z) {
synchronized(noiseLock) {
xVar.setValue(x);
yVar.setValue(y);