mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2025-07-18 18:42:30 +00:00
Cleanup
This commit is contained in:
parent
cb537d0514
commit
9a403805c9
@ -2,7 +2,6 @@ package com.dfsek.terra.generation;
|
|||||||
|
|
||||||
import com.dfsek.terra.biome.grid.TerraBiomeGrid;
|
import com.dfsek.terra.biome.grid.TerraBiomeGrid;
|
||||||
import com.dfsek.terra.generation.config.WorldGenerator;
|
import com.dfsek.terra.generation.config.WorldGenerator;
|
||||||
import org.bukkit.World;
|
|
||||||
import org.polydev.gaea.generation.GenerationPhase;
|
import org.polydev.gaea.generation.GenerationPhase;
|
||||||
import org.polydev.gaea.math.Interpolator;
|
import org.polydev.gaea.math.Interpolator;
|
||||||
|
|
||||||
@ -13,7 +12,7 @@ public class ElevationInterpolator {
|
|||||||
private final int zOrigin;
|
private final int zOrigin;
|
||||||
private final TerraBiomeGrid grid;
|
private final TerraBiomeGrid grid;
|
||||||
|
|
||||||
public ElevationInterpolator(World w, int chunkX, int chunkZ, TerraBiomeGrid grid) {
|
public ElevationInterpolator(int chunkX, int chunkZ, TerraBiomeGrid grid) {
|
||||||
this.xOrigin = chunkX << 4;
|
this.xOrigin = chunkX << 4;
|
||||||
this.zOrigin = chunkZ << 4;
|
this.zOrigin = chunkZ << 4;
|
||||||
this.grid = grid;
|
this.grid = grid;
|
||||||
@ -28,13 +27,13 @@ public class ElevationInterpolator {
|
|||||||
for(byte z = -1; z <= 16; z++) {
|
for(byte z = -1; z <= 16; z++) {
|
||||||
WorldGenerator generator = getGenerator(x, z);
|
WorldGenerator generator = getGenerator(x, z);
|
||||||
if(compareGens((x / 4), (z / 4)) && generator.interpolateElevation()) {
|
if(compareGens((x / 4), (z / 4)) && generator.interpolateElevation()) {
|
||||||
Interpolator interpolator = new Interpolator(biomeAvg(x / 4, z / 4, w),
|
Interpolator interpolator = new Interpolator(biomeAvg(x / 4, z / 4),
|
||||||
biomeAvg((x / 4) + 1, z / 4, w),
|
biomeAvg((x / 4) + 1, z / 4),
|
||||||
biomeAvg(x / 4, (z / 4) + 1, w),
|
biomeAvg(x / 4, (z / 4) + 1),
|
||||||
biomeAvg((x / 4) + 1, (z / 4) + 1, w),
|
biomeAvg((x / 4) + 1, (z / 4) + 1),
|
||||||
Interpolator.Type.LINEAR);
|
Interpolator.Type.LINEAR);
|
||||||
values[x + 1][z + 1] = interpolator.bilerp((double) (x % 4) / 4, (double) (z % 4) / 4);
|
values[x + 1][z + 1] = interpolator.bilerp((double) (x % 4) / 4, (double) (z % 4) / 4);
|
||||||
} else values[x + 1][z + 1] = elevate(generator, xOrigin + x, zOrigin + z, w);
|
} else values[x + 1][z + 1] = elevate(generator, xOrigin + x, zOrigin + z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -58,20 +57,20 @@ public class ElevationInterpolator {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private double biomeAvg(int x, int z, World w) {
|
private double biomeAvg(int x, int z) {
|
||||||
return (elevate(getStoredGen(x + 1, z), x * 4 + 4 + xOrigin, z * 4 + zOrigin, w)
|
return (elevate(getStoredGen(x + 1, z), x * 4 + 4 + xOrigin, z * 4 + zOrigin)
|
||||||
+ elevate(getStoredGen(x - 1, z), x * 4 - 4 + xOrigin, z * 4 + zOrigin, w)
|
+ elevate(getStoredGen(x - 1, z), x * 4 - 4 + xOrigin, z * 4 + zOrigin)
|
||||||
+ elevate(getStoredGen(x, z + 1), x * 4 + xOrigin, z * 4 + 4 + zOrigin, w)
|
+ elevate(getStoredGen(x, z + 1), x * 4 + xOrigin, z * 4 + 4 + zOrigin)
|
||||||
+ elevate(getStoredGen(x, z - 1), x * 4 + xOrigin, z * 4 - 4 + zOrigin, w)
|
+ elevate(getStoredGen(x, z - 1), x * 4 + xOrigin, z * 4 - 4 + zOrigin)
|
||||||
+ elevate(getStoredGen(x, z), x * 4 + xOrigin, z * 4 + zOrigin, w)
|
+ elevate(getStoredGen(x, z), x * 4 + xOrigin, z * 4 + zOrigin)
|
||||||
+ elevate(getStoredGen(x - 1, z - 1), x * 4 + xOrigin, z * 4 + zOrigin, w)
|
+ elevate(getStoredGen(x - 1, z - 1), x * 4 + xOrigin, z * 4 + zOrigin)
|
||||||
+ elevate(getStoredGen(x - 1, z + 1), x * 4 + xOrigin, z * 4 + zOrigin, w)
|
+ elevate(getStoredGen(x - 1, z + 1), x * 4 + xOrigin, z * 4 + zOrigin)
|
||||||
+ elevate(getStoredGen(x + 1, z - 1), x * 4 + xOrigin, z * 4 + zOrigin, w)
|
+ elevate(getStoredGen(x + 1, z - 1), x * 4 + xOrigin, z * 4 + zOrigin)
|
||||||
+ elevate(getStoredGen(x + 1, z + 1), x * 4 + xOrigin, z * 4 + zOrigin, w)) / 9D;
|
+ elevate(getStoredGen(x + 1, z + 1), x * 4 + xOrigin, z * 4 + zOrigin)) / 9D;
|
||||||
}
|
}
|
||||||
|
|
||||||
private double elevate(WorldGenerator g, int x, int z, World w) {
|
private double elevate(WorldGenerator g, int x, int z) {
|
||||||
if(g.getElevationEquation(w) != null) return g.getElevationEquation(w).getNoise(x, z);
|
if(g.getElevationEquation() != null) return g.getElevationEquation().getNoise(x, z);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ public class TerraChunkGenerator extends GaeaChunkGenerator {
|
|||||||
|
|
||||||
ElevationInterpolator elevationInterpolator;
|
ElevationInterpolator elevationInterpolator;
|
||||||
try(ProfileFuture ignore = TerraProfiler.fromWorld(world).measure("ElevationTime")) {
|
try(ProfileFuture ignore = TerraProfiler.fromWorld(world).measure("ElevationTime")) {
|
||||||
elevationInterpolator = new ElevationInterpolator(world, chunkX, chunkZ, tw.getGrid());
|
elevationInterpolator = new ElevationInterpolator(chunkX, chunkZ, tw.getGrid());
|
||||||
}
|
}
|
||||||
|
|
||||||
for(byte x = 0; x < 16; x++) {
|
for(byte x = 0; x < 16; x++) {
|
||||||
|
@ -117,10 +117,6 @@ public class WorldGenerator extends Generator {
|
|||||||
return Interpolator.Type.LINEAR;
|
return Interpolator.Type.LINEAR;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ElevationEquation getElevationEquation(World w) {
|
|
||||||
return elevationEquation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean interpolateElevation() {
|
public boolean interpolateElevation() {
|
||||||
return elevationInterpolation;
|
return elevationInterpolation;
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ public class AirSpawn extends Requirement {
|
|||||||
UserDefinedBiome b = (UserDefinedBiome) tw.getGrid().getBiome(x, z, GenerationPhase.POPULATE);
|
UserDefinedBiome b = (UserDefinedBiome) tw.getGrid().getBiome(x, z, GenerationPhase.POPULATE);
|
||||||
BiomeConfig c = wc.getBiome(b);
|
BiomeConfig c = wc.getBiome(b);
|
||||||
if(y <= c.getOcean().getSeaLevel()) return false;
|
if(y <= c.getOcean().getSeaLevel()) return false;
|
||||||
ElevationEquation elevationEquation = ((WorldGenerator) b.getGenerator()).getElevationEquation(getWorld());
|
ElevationEquation elevationEquation = ((WorldGenerator) b.getGenerator()).getElevationEquation();
|
||||||
int yf = y - ((elevationEquation == null) ? 0 : (int) elevationEquation.getNoise(x, z));
|
int yf = y - ((elevationEquation == null) ? 0 : (int) elevationEquation.getNoise(x, z));
|
||||||
return b.getGenerator().getNoise(getNoise(), getWorld(), x, yf, z) <= 0;
|
return b.getGenerator().getNoise(getNoise(), getWorld(), x, yf, z) <= 0;
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ public class LandSpawn extends Requirement {
|
|||||||
public boolean matches(int x, int y, int z) {
|
public boolean matches(int x, int y, int z) {
|
||||||
TerraWorld tw = TerraWorld.getWorld(getWorld());
|
TerraWorld tw = TerraWorld.getWorld(getWorld());
|
||||||
UserDefinedBiome b = (UserDefinedBiome) tw.getGrid().getBiome(x, z, GenerationPhase.POPULATE);
|
UserDefinedBiome b = (UserDefinedBiome) tw.getGrid().getBiome(x, z, GenerationPhase.POPULATE);
|
||||||
ElevationEquation elevationEquation = ((WorldGenerator) b.getGenerator()).getElevationEquation(getWorld());
|
ElevationEquation elevationEquation = ((WorldGenerator) b.getGenerator()).getElevationEquation();
|
||||||
int yf = y - ((elevationEquation == null) ? 0 : (int) elevationEquation.getNoise(x, z));
|
int yf = y - ((elevationEquation == null) ? 0 : (int) elevationEquation.getNoise(x, z));
|
||||||
return b.getGenerator().getNoise(getNoise(), getWorld(), x, yf, z) > 0;
|
return b.getGenerator().getNoise(getNoise(), getWorld(), x, yf, z) > 0;
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ public class OceanSpawn extends Requirement {
|
|||||||
UserDefinedBiome b = (UserDefinedBiome) tw.getGrid().getBiome(x, z, GenerationPhase.POPULATE);
|
UserDefinedBiome b = (UserDefinedBiome) tw.getGrid().getBiome(x, z, GenerationPhase.POPULATE);
|
||||||
BiomeConfig c = tw.getConfig().getBiome(b);
|
BiomeConfig c = tw.getConfig().getBiome(b);
|
||||||
if(y > c.getOcean().getSeaLevel()) return false;
|
if(y > c.getOcean().getSeaLevel()) return false;
|
||||||
ElevationEquation elevationEquation = ((WorldGenerator) b.getGenerator()).getElevationEquation(getWorld());
|
ElevationEquation elevationEquation = ((WorldGenerator) b.getGenerator()).getElevationEquation();
|
||||||
int yf = y - ((elevationEquation == null) ? 0 : (int) elevationEquation.getNoise(x, z));
|
int yf = y - ((elevationEquation == null) ? 0 : (int) elevationEquation.getNoise(x, z));
|
||||||
return b.getGenerator().getNoise(getNoise(), getWorld(), x, yf, z) <= 0;
|
return b.getGenerator().getNoise(getNoise(), getWorld(), x, yf, z) <= 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user