mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 18:23:06 +00:00
Caves fixed
This commit is contained in:
parent
d42be730c3
commit
e1824ffda1
@ -4,73 +4,67 @@ import org.bukkit.Material;
|
||||
import org.bukkit.generator.ChunkGenerator.ChunkData;
|
||||
|
||||
import ninja.bytecode.iris.generator.DimensionChunkGenerator;
|
||||
import ninja.bytecode.iris.util.Borders;
|
||||
import ninja.bytecode.iris.util.CNG;
|
||||
import ninja.bytecode.iris.util.FastNoise;
|
||||
import ninja.bytecode.iris.util.FastNoise.CellularDistanceFunction;
|
||||
import ninja.bytecode.iris.util.FastNoise.CellularReturnType;
|
||||
import ninja.bytecode.iris.util.FastNoise.NoiseType;
|
||||
import ninja.bytecode.iris.util.GenLayer;
|
||||
import ninja.bytecode.iris.util.HeightMap;
|
||||
import ninja.bytecode.iris.util.PolygonGenerator;
|
||||
import ninja.bytecode.iris.util.RNG;
|
||||
|
||||
public class GenLayerCave extends GenLayer
|
||||
{
|
||||
private PolygonGenerator g;
|
||||
private CNG gincline;
|
||||
private CNG shuffle;
|
||||
private FastNoise gg;
|
||||
|
||||
public GenLayerCave(DimensionChunkGenerator iris, RNG rng)
|
||||
{
|
||||
//@builder
|
||||
super(iris, rng);
|
||||
g = new PolygonGenerator(rng.nextParallelRNG(1111), 3, 0.024, 8, (c) -> c);
|
||||
gincline = new CNG(rng.nextParallelRNG(1112), 1D, 3).scale(0.00652);
|
||||
shuffle = CNG.signature(rng.nextParallelRNG(2348566));
|
||||
gincline = new CNG(rng.nextParallelRNG(1112), 1D, 3).scale(0.00452);
|
||||
gg = new FastNoise(324895 * rng.nextParallelRNG(45678).imax());
|
||||
//@done
|
||||
}
|
||||
|
||||
public void genCaves(double wxxf, double wzxf, int x, int z, ChunkData data, HeightMap height)
|
||||
public void genCaves(double wxx, double wzz, int x, int z, ChunkData data, HeightMap height)
|
||||
{
|
||||
if(!iris.getDimension().isCaves())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
double itr = 2;
|
||||
double level = 8;
|
||||
double incline = 157;
|
||||
double baseWidth = 16 * iris.getDimension().getCaveScale();
|
||||
double drop = 44 + iris.getDimension().getCaveShift();
|
||||
shuffle.scale(0.01);
|
||||
double shuffleDistance = 72;
|
||||
gg.SetNoiseType(NoiseType.Cellular);
|
||||
gg.SetCellularReturnType(CellularReturnType.Distance2Sub);
|
||||
gg.SetCellularDistanceFunction(CellularDistanceFunction.Natural);
|
||||
|
||||
for(double m = 1; m <= itr; m += 0.45)
|
||||
for(int i = 0; i < 3; i++)
|
||||
{
|
||||
double w = baseWidth / m;
|
||||
|
||||
if(w < 5)
|
||||
double wx = wxx + (shuffle.noise(wxx, wzz) * shuffleDistance);
|
||||
double wz = wzz + (shuffle.noise(wzz, wxx) * shuffleDistance);
|
||||
double incline = 157;
|
||||
double baseWidth = (9 * iris.getDimension().getCaveScale());
|
||||
double distanceCheck = 0.0132 * baseWidth;
|
||||
double distanceTake = 0.0032 * baseWidth;
|
||||
double drop = 44 + iris.getDimension().getCaveShift();
|
||||
double caveHeightNoise = incline * gincline.noise((wx + (10000 * i)), (wz - (10000 * i)));
|
||||
caveHeightNoise += shuffle.fitDoubleD(-1, 1, wxx - caveHeightNoise, wzz + caveHeightNoise) * 3;
|
||||
for(double tunnelHeight = 1; tunnelHeight <= baseWidth; tunnelHeight++)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
int lowest = 325;
|
||||
|
||||
double n = incline * gincline.noise((wxxf + (m * 10000)), (wzxf - (m * 10000)));
|
||||
for(double i = 1; i <= w / 3D; i++)
|
||||
{
|
||||
if(Borders.isBorderWithin((wxxf + (m * 10000)), (wzxf - (m * 10000)), 32, w / 2D / i, (wxxf / 3D) + (wzxf / 3D), (xx, zz) -> g.getIndex(xx, zz)))
|
||||
double distance = (gg.GetCellular((float) wx + (10000 * i), (float) wz - (10000 * i)) + 1D) / 2D;
|
||||
if(distance < distanceCheck - (tunnelHeight * distanceTake))
|
||||
{
|
||||
int h = (int) ((level + n) - drop);
|
||||
if(dig(x, (int) (h + i), z, data) && h + i < lowest)
|
||||
{
|
||||
lowest = (int) (h + i);
|
||||
}
|
||||
int caveHeight = (int) Math.round(caveHeightNoise - drop);
|
||||
dig(x, (int) (caveHeight + tunnelHeight), z, data);
|
||||
dig(x, (int) (caveHeight - tunnelHeight), z, data);
|
||||
|
||||
if(dig(x, (int) (h - i), z, data) && h - i < lowest)
|
||||
if(tunnelHeight == 1)
|
||||
{
|
||||
lowest = (int) (h - i);
|
||||
}
|
||||
|
||||
if(i == 1)
|
||||
{
|
||||
if(dig(x, (int) (h), z, data) && h < lowest)
|
||||
{
|
||||
lowest = (int) (h);
|
||||
}
|
||||
dig(x, (int) (caveHeight), z, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user