mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-20 15:20:25 +00:00
Begin work on languages, general cleanup, fix minor local sea level issues.
This commit is contained in:
@@ -1,11 +1,22 @@
|
||||
package com.dfsek.terra.biome;
|
||||
|
||||
import com.dfsek.terra.procgen.math.Vector2;
|
||||
import org.polydev.gaea.math.FastNoise;
|
||||
|
||||
/**
|
||||
* Offset a coordinate pair by an amount.
|
||||
*/
|
||||
public class CoordinatePerturb {
|
||||
private final FastNoise perturbX;
|
||||
private final FastNoise perturbZ;
|
||||
private final int amplitude;
|
||||
|
||||
/**
|
||||
* Create a CoordinatePerturb object with a given frequency, amplitude, and seed.
|
||||
* @param frequency Noise frequency
|
||||
* @param amplitude Offset amplitude
|
||||
* @param seed Noise seed
|
||||
*/
|
||||
public CoordinatePerturb(float frequency, int amplitude, long seed) {
|
||||
perturbX = new FastNoise((int) seed);
|
||||
perturbX.setNoiseType(FastNoise.NoiseType.Simplex);
|
||||
@@ -15,7 +26,14 @@ public class CoordinatePerturb {
|
||||
perturbZ.setFrequency(frequency);
|
||||
this.amplitude = amplitude;
|
||||
}
|
||||
public int[] getShiftedCoords(int x, int z) {
|
||||
return new int[] {(int) (perturbX.getNoise(x, z)*amplitude+x), (int) (perturbZ.getNoise(x, z)*amplitude+z)};
|
||||
|
||||
/**
|
||||
* Offset a coordinate pair
|
||||
* @param x X coordinate
|
||||
* @param z Z coordinate
|
||||
* @return Vector2 containing offset coordinates
|
||||
*/
|
||||
public Vector2 getShiftedCoords(int x, int z) {
|
||||
return new Vector2(perturbX.getNoise(x, z)*amplitude+x, perturbZ.getNoise(x, z)*amplitude+z);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.dfsek.terra.biome;
|
||||
|
||||
import com.dfsek.terra.config.base.ConfigPack;
|
||||
import com.dfsek.terra.config.base.ConfigUtil;
|
||||
import com.dfsek.terra.procgen.math.Vector2;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
@@ -19,14 +20,12 @@ public class TerraBiomeGrid extends BiomeGrid {
|
||||
private UserDefinedGrid erosionGrid;
|
||||
|
||||
private final BiomeZone zone;
|
||||
private final boolean perturbPaletteOnly;
|
||||
|
||||
public TerraBiomeGrid(World w, float freq1, float freq2, BiomeZone zone, ConfigPack c, UserDefinedGrid erosion) {
|
||||
super(w, freq1, freq2);
|
||||
if(c.biomeBlend) {
|
||||
perturb = new CoordinatePerturb(c.blendFreq, c.blendAmp, w.getSeed());
|
||||
}
|
||||
perturbPaletteOnly = c.perturbPaletteOnly;
|
||||
this.zone = zone;
|
||||
if(c.erosionEnable) {
|
||||
erode = new ErosionNoise(c.erosionFreq, c.erosionThresh, w.getSeed());
|
||||
@@ -38,10 +37,10 @@ public class TerraBiomeGrid extends BiomeGrid {
|
||||
public Biome getBiome(int x, int z, GenerationPhase phase) {
|
||||
int xp = x;
|
||||
int zp = z;
|
||||
if(perturb != null && (!perturbPaletteOnly || phase.equals(GenerationPhase.PALETTE_APPLY))) {
|
||||
int[] perturbCoords = perturb.getShiftedCoords(x, z);
|
||||
xp = perturbCoords[0];
|
||||
zp = perturbCoords[1];
|
||||
if(perturb != null && phase.equals(GenerationPhase.PALETTE_APPLY)) {
|
||||
Vector2 perturbCoords = perturb.getShiftedCoords(x, z);
|
||||
xp = (int) perturbCoords.getX();
|
||||
zp = (int) perturbCoords.getZ();
|
||||
}
|
||||
|
||||
UserDefinedBiome b;
|
||||
|
||||
@@ -9,6 +9,9 @@ import org.polydev.gaea.structures.features.Feature;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Class representing a config-defined biome
|
||||
*/
|
||||
public class UserDefinedBiome implements Biome {
|
||||
private final UserDefinedGenerator gen;
|
||||
private final UserDefinedDecorator decorator;
|
||||
|
||||
Reference in New Issue
Block a user