mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 18:23:06 +00:00
F
This commit is contained in:
parent
30dc6e865f
commit
066fb7fba0
@ -3,24 +3,49 @@ package ninja.bytecode.iris.generator;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.generator.ChunkGenerator.BiomeGrid;
|
||||
import org.bukkit.generator.ChunkGenerator.ChunkData;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import ninja.bytecode.iris.Iris;
|
||||
import ninja.bytecode.iris.IrisContext;
|
||||
import ninja.bytecode.iris.layer.GenLayerCave;
|
||||
import ninja.bytecode.iris.object.IrisRegion;
|
||||
import ninja.bytecode.iris.util.BiomeResult;
|
||||
import ninja.bytecode.iris.util.RNG;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class IrisChunkGenerator extends CeilingChunkGenerator implements IrisContext
|
||||
{
|
||||
private Method initLighting;
|
||||
private GenLayerCave caves;
|
||||
|
||||
public IrisChunkGenerator(String dimensionName, int threads)
|
||||
{
|
||||
super(dimensionName, threads);
|
||||
caves = new GenLayerCave(this, new RNG(23456));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onGenerate(RNG random, int x, int z, ChunkData data, BiomeGrid grid)
|
||||
{
|
||||
for(int i = 0; i < 16; i++)
|
||||
{
|
||||
for(int j = 0; j < 64; j++)
|
||||
{
|
||||
for(int k = 0; k < 16; k++)
|
||||
{
|
||||
if(caves.isCave((x * 16) + i, j, (z * 16) + k))
|
||||
{
|
||||
data.setBlock(i, j, k, Material.GREEN_STAINED_GLASS.createBlockData());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -258,13 +258,13 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator
|
||||
|
||||
protected void onPostParallaxPostGenerate(RNG random, int x, int z, ChunkData data, BiomeGrid grid, HeightMap height, BiomeMap biomeMap)
|
||||
{
|
||||
for(int i = 0; i < 16; i++)
|
||||
{
|
||||
for(int j = 0; j < 16; j++)
|
||||
{
|
||||
glCave.genCaves((x << 4) + i, (z << 4) + j, i, j, data, height);
|
||||
}
|
||||
}
|
||||
// for(int i = 0; i < 16; i++)
|
||||
// {
|
||||
// for(int j = 0; j < 16; j++)
|
||||
// {
|
||||
// glCave.genCaves((x << 4) + i, (z << 4) + j, i, j, data, height);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
protected double getNoiseHeight(int rx, int rz)
|
||||
|
@ -1,111 +1,45 @@
|
||||
package ninja.bytecode.iris.layer;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.generator.ChunkGenerator.ChunkData;
|
||||
|
||||
import ninja.bytecode.iris.Iris;
|
||||
import ninja.bytecode.iris.generator.DimensionChunkGenerator;
|
||||
import ninja.bytecode.iris.util.Borders;
|
||||
import ninja.bytecode.iris.util.CNG;
|
||||
import ninja.bytecode.iris.util.CellGenerator;
|
||||
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 CellGenerator g;
|
||||
private double max = -10000;
|
||||
|
||||
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);
|
||||
//@done
|
||||
g = new CellGenerator(rng.nextParallelRNG(2345));
|
||||
g.setShuffle(0);
|
||||
}
|
||||
|
||||
public void genCaves(double wxxf, double wzxf, int x, int z, ChunkData data, HeightMap height)
|
||||
public boolean isCave(int i, int j, int k)
|
||||
{
|
||||
if(!iris.getDimension().isCaves())
|
||||
double v = g.getDistance(i, j, k);
|
||||
|
||||
if(v > max)
|
||||
{
|
||||
return;
|
||||
max = v;
|
||||
Iris.info("MAX: " + max);
|
||||
}
|
||||
|
||||
double itr = 2;
|
||||
double level = 8;
|
||||
double incline = 157;
|
||||
double baseWidth = 16 * iris.getDimension().getCaveScale();
|
||||
double drop = 44 + iris.getDimension().getCaveShift();
|
||||
|
||||
for(double m = 1; m <= itr; m += 0.45)
|
||||
if(v < 0.08)
|
||||
{
|
||||
double w = baseWidth / m;
|
||||
|
||||
if(w < 5)
|
||||
{
|
||||
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)))
|
||||
{
|
||||
int h = (int) ((level + n) - drop);
|
||||
if(dig(x, (int) (h + i), z, data) && h + i < lowest)
|
||||
{
|
||||
lowest = (int) (h + i);
|
||||
}
|
||||
|
||||
if(dig(x, (int) (h - i), z, data) && h - i < lowest)
|
||||
{
|
||||
lowest = (int) (h - i);
|
||||
}
|
||||
|
||||
if(i == 1)
|
||||
{
|
||||
if(dig(x, (int) (h), z, data) && h < lowest)
|
||||
{
|
||||
lowest = (int) (h);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean dig(int x, int y, int z, ChunkData data)
|
||||
{
|
||||
Material a = data.getType(x, y, z);
|
||||
Material b = data.getType(x, y, z + 1);
|
||||
Material c = data.getType(x, y + 1, z);
|
||||
Material d = data.getType(x + 1, y, z);
|
||||
Material e = data.getType(x, y, z - 1);
|
||||
Material f = data.getType(x, y - 1, z);
|
||||
Material g = data.getType(x - 1, y, z);
|
||||
|
||||
if(can(a) && cann(b) && cann(c) && cann(d) && cann(e) && cann(f) && cann(g))
|
||||
{
|
||||
data.setBlock(x, y, z, Material.AIR);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean cann(Material m)
|
||||
{
|
||||
return m.isSolid() || m.equals(Material.AIR) && !m.equals(Material.BEDROCK);
|
||||
}
|
||||
|
||||
public boolean can(Material m)
|
||||
{
|
||||
return m.isSolid() && !m.equals(Material.BEDROCK);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double generate(double x, double z)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user