mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-04-05 15:26:28 +00:00
Surfaces and subsurfaces
This commit is contained in:
@@ -2,6 +2,7 @@ package ninja.bytecode.iris.generator;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
@@ -18,6 +19,7 @@ import ninja.bytecode.iris.generator.layer.GenLayerBiome;
|
||||
import ninja.bytecode.iris.generator.layer.GenLayerCarving;
|
||||
import ninja.bytecode.iris.generator.layer.GenLayerCaverns;
|
||||
import ninja.bytecode.iris.generator.layer.GenLayerCaves;
|
||||
import ninja.bytecode.iris.generator.layer.GenLayerCliffs;
|
||||
import ninja.bytecode.iris.generator.layer.GenLayerLayeredNoise;
|
||||
import ninja.bytecode.iris.generator.layer.GenLayerSnow;
|
||||
import ninja.bytecode.iris.pack.CompiledDimension;
|
||||
@@ -69,6 +71,7 @@ public class IrisGenerator extends ParallelChunkGenerator
|
||||
private GenLayerCaverns glCaverns;
|
||||
private GenLayerSnow glSnow;
|
||||
private GenLayerBase glBase;
|
||||
private GenLayerCliffs glCliffs;
|
||||
private RNG rTerrain;
|
||||
private CompiledDimension dim;
|
||||
private World world;
|
||||
@@ -137,6 +140,7 @@ public class IrisGenerator extends ParallelChunkGenerator
|
||||
glCarving = new GenLayerCarving(this, world, random, rTerrain.nextParallelRNG(-2));
|
||||
glCaverns = new GenLayerCaverns(this, world, random, rTerrain.nextParallelRNG(-3));
|
||||
glSnow = new GenLayerSnow(this, world, random, rTerrain.nextParallelRNG(5));
|
||||
glCliffs = new GenLayerCliffs(this, world, random, rTerrain.nextParallelRNG(9));
|
||||
scatterCache = new double[16][][];
|
||||
scatter = new CNG(rTerrain.nextParallelRNG(52), 1, 1).scale(10);
|
||||
|
||||
@@ -183,76 +187,83 @@ public class IrisGenerator extends ParallelChunkGenerator
|
||||
{
|
||||
return Math.round((double) z * (Iris.settings.gen.horizontalZoom / 1.90476190476));
|
||||
}
|
||||
|
||||
|
||||
public IrisBiome getOcean(IrisBiome biome, int height)
|
||||
{
|
||||
if(height < 36)
|
||||
{
|
||||
return biome("Deep Ocean");
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
return biome("Ocean");
|
||||
}
|
||||
}
|
||||
|
||||
public IrisBiome getBeach(IrisBiome biome)
|
||||
{
|
||||
IrisBiome beach = null;
|
||||
IrisRegion region = glBiome.getRegion(biome.getRegion());
|
||||
|
||||
if(region != null)
|
||||
{
|
||||
beach = region.getBeach();
|
||||
}
|
||||
|
||||
if(beach == null)
|
||||
{
|
||||
beach = biome("Beach");
|
||||
}
|
||||
|
||||
return beach;
|
||||
}
|
||||
|
||||
public int computeHeight(int x, int z, ChunkPlan plan, IrisBiome biome)
|
||||
{
|
||||
return (int) Math.round(M.clip(getANoise((int) x, (int) z, plan, biome), 0D, 1D) * 253);
|
||||
}
|
||||
|
||||
public double getANoise(int x, int z, ChunkPlan plan, IrisBiome biome)
|
||||
{
|
||||
double hv = IrisInterpolation.getNoise(x, z, Iris.settings.gen.hermiteSampleRadius, (xf, zf) -> getBiomedHeight((int) Math.round(xf), (int) Math.round(zf), plan));
|
||||
hv += glLNoise.generateLayer(hv * Iris.settings.gen.roughness * 215, (double) x * Iris.settings.gen.roughness * 0.82, (double) z * Iris.settings.gen.roughness * 0.82) * (1.6918 * (hv * 2.35));
|
||||
|
||||
if(biome.hasCliffs())
|
||||
{
|
||||
hv = glCliffs.generateLayer(hv, x, z, biome.getCliffScale(), biome.getCliffChance());
|
||||
}
|
||||
|
||||
return hv;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Biome genColumn(int wxx, int wzx, int x, int z, ChunkPlan plan)
|
||||
{
|
||||
//@builder
|
||||
int highest = 0;
|
||||
int seaLevel = Iris.settings.gen.seaLevel;
|
||||
double wx = getOffsetX(wxx);
|
||||
double wz = getOffsetZ(wzx);
|
||||
IrisBiome biome = getBiome(wxx, wzx);
|
||||
double hv = IrisInterpolation.getNoise(wxx, wzx,
|
||||
Iris.settings.gen.hermiteSampleRadius,
|
||||
(xf, zf) -> getBiomedHeight((int) Math.round(xf), (int) Math.round(zf), plan));
|
||||
hv += glLNoise.generateLayer(hv * Iris.settings.gen.roughness * 215, wxx * Iris.settings.gen.roughness * 0.82, wzx * Iris.settings.gen.roughness * 0.82) * (1.6918 * (hv * 2.35));
|
||||
int height = (int) Math.round(M.clip(hv, 0D, 1D) * 253);
|
||||
int height = computeHeight(wxx, wzx, plan, biome);
|
||||
int max = Math.max(height, seaLevel);
|
||||
IrisBiome override = null;
|
||||
//@done
|
||||
|
||||
if(height > 61 && height < 65 + (glLNoise.getHeight(wz, wx) * Iris.settings.gen.beachScale))
|
||||
{
|
||||
IrisBiome beach = null;
|
||||
IrisRegion region = glBiome.getRegion(biome.getRegion());
|
||||
|
||||
if(region != null)
|
||||
{
|
||||
beach = region.getBeach();
|
||||
}
|
||||
|
||||
if(beach == null)
|
||||
{
|
||||
beach = biome("Beach");
|
||||
}
|
||||
|
||||
override = beach;
|
||||
}
|
||||
|
||||
else if(height < 63)
|
||||
{
|
||||
if(height < 36)
|
||||
{
|
||||
override = biome("Deep Ocean");
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
override = biome("Ocean");
|
||||
}
|
||||
}
|
||||
|
||||
if(override != null)
|
||||
{
|
||||
biome = override;
|
||||
}
|
||||
biome = height > 61 && height < 65 ? getBeach(biome) : biome;
|
||||
biome = height < 63 ? getOcean(biome, height) : biome;
|
||||
|
||||
for(int i = 0; i < max; i++)
|
||||
{
|
||||
MB mb = ROCK.get(scatterInt(wzx, i, wxx, ROCK.size()));
|
||||
boolean underwater = i >= height && i < seaLevel;
|
||||
boolean underground = i < height;
|
||||
|
||||
if(underwater)
|
||||
{
|
||||
mb = WATER;
|
||||
}
|
||||
|
||||
if(underground && (height - 1) - i < scatterInt(x, i, z, 4) + 2)
|
||||
{
|
||||
mb = biome.getDirtRNG();
|
||||
}
|
||||
int dheight = biome.getDirtDepth();
|
||||
int rheight = biome.getRockDepth();
|
||||
boolean dirt = (height - 1) - i < (dheight > 0 ? scatterInt(x, i, z, 4) : 0) + dheight;
|
||||
boolean rocky = i > height - rheight && !dirt;
|
||||
boolean bedrock = i == 0 || !Iris.settings.gen.flatBedrock ? i <= 2 : i < scatterInt(x, i, z, 3);
|
||||
mb = underwater ? WATER : mb;
|
||||
mb = underground && dirt ? biome.getSubSurface(wxx, i, wzx, rTerrain) : mb;
|
||||
mb = underground && rocky ? biome.getRock(wxx, i, wzx, rTerrain) : mb;
|
||||
mb = bedrock ? BEDROCK : mb;
|
||||
|
||||
if(i == height - 1)
|
||||
{
|
||||
@@ -268,17 +279,8 @@ public class IrisGenerator extends ParallelChunkGenerator
|
||||
|
||||
for(int j = 0; j < snowHeight; j++)
|
||||
{
|
||||
if(j == snowHeight - 1)
|
||||
{
|
||||
highest = highest < j ? j : highest;
|
||||
setBlock(x, i + j + 1, z, Material.SNOW, (byte) layers);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
highest = highest < j + 1 ? j + 1 : highest;
|
||||
setBlock(x, i + j + 1, z, Material.SNOW_BLOCK);
|
||||
}
|
||||
highest = j == snowHeight - 1 ? highest < j ? j : highest : highest < j + 1 ? j + 1 : highest;
|
||||
setBlock(x, i + j + 1, z, j == snowHeight - 1 ? Material.SNOW : Material.SNOW_BLOCK, j == snowHeight - 1 ? (byte) layers : (byte) 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -288,24 +290,14 @@ public class IrisGenerator extends ParallelChunkGenerator
|
||||
|
||||
if(!mbx.material.equals(Material.AIR))
|
||||
{
|
||||
setBlock(x, i + 1, z, mbx.material, mbx.data);
|
||||
highest = i > highest ? i : highest;
|
||||
setBlock(x, i + 1, z, mbx.material, mbx.data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(i == 0)
|
||||
{
|
||||
mb = BEDROCK;
|
||||
}
|
||||
|
||||
if(!Iris.settings.gen.flatBedrock ? i <= 2 : i < scatterInt(x, i, z, 3))
|
||||
{
|
||||
mb = BEDROCK;
|
||||
}
|
||||
|
||||
setBlock(x, i, z, mb.material, mb.data);
|
||||
highest = i > highest ? i : highest;
|
||||
setBlock(x, i, z, mb.material, mb.data);
|
||||
}
|
||||
|
||||
glCaves.genCaves(wxx, wzx, x, z, height, this);
|
||||
@@ -317,16 +309,8 @@ public class IrisGenerator extends ParallelChunkGenerator
|
||||
for(int i = highest; i > 0; i--)
|
||||
{
|
||||
Material t = getType(x, i, z);
|
||||
|
||||
if(i > seaLevel && hw == 0 && (t.equals(Material.WATER) || t.equals(Material.STATIONARY_WATER)))
|
||||
{
|
||||
hw = i;
|
||||
}
|
||||
|
||||
else if(hl == 0 && !t.equals(Material.AIR))
|
||||
{
|
||||
hl = i;
|
||||
}
|
||||
hw = i > seaLevel && hw == 0 && (t.equals(Material.WATER) || t.equals(Material.STATIONARY_WATER)) ? i : hw;
|
||||
hl = hl == 0 && !t.equals(Material.AIR) ? i : hl;
|
||||
}
|
||||
|
||||
plan.setRealHeight(x, z, hl);
|
||||
|
||||
@@ -150,7 +150,7 @@ public class GenLayerCarving extends GenLayer
|
||||
{
|
||||
if(!fail)
|
||||
{
|
||||
MB mb = biome.getDirtRNG();
|
||||
MB mb = biome.getSubSurface(wxx, i, wzx, g.getRTerrain());
|
||||
g.setBlock(x, i, z, mb.material, mb.data);
|
||||
}
|
||||
|
||||
|
||||
@@ -150,7 +150,7 @@ public class GenLayerCaverns extends GenLayer
|
||||
{
|
||||
if(!fail)
|
||||
{
|
||||
MB mb = biome.getDirtRNG();
|
||||
MB mb = biome.getSubSurface(wxx, i, wzx, g.getRTerrain());
|
||||
g.setBlock(x, i, z, mb.material, mb.data);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
package ninja.bytecode.iris.generator.layer;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.World;
|
||||
|
||||
import ninja.bytecode.iris.generator.IrisGenerator;
|
||||
import ninja.bytecode.iris.util.GenLayer;
|
||||
import ninja.bytecode.shuriken.math.CNG;
|
||||
import ninja.bytecode.shuriken.math.RNG;
|
||||
|
||||
public class GenLayerCliffs extends GenLayer
|
||||
{
|
||||
private double block;
|
||||
private CNG gen;
|
||||
private CNG sh;
|
||||
private CNG ch;
|
||||
|
||||
public GenLayerCliffs(IrisGenerator iris, World world, Random random, RNG rng)
|
||||
{
|
||||
//@builder
|
||||
super(iris, world, random, rng);
|
||||
block = 1D / 255D;
|
||||
gen = new CNG(rng.nextParallelRNG(128), 1D, 4).scale(0.02);
|
||||
sh = new CNG(rng.nextParallelRNG(127), 1D, 1).scale(0.00367);
|
||||
ch = new CNG(rng.nextParallelRNG(127), 1D, 1).scale(0.00413);
|
||||
//@done
|
||||
}
|
||||
|
||||
@Override
|
||||
public double generateLayer(double gnoise, double dx, double dz)
|
||||
{
|
||||
return generateLayer(gnoise, dx, dz, 1D, 0.37D);
|
||||
}
|
||||
|
||||
public double generateLayer(double gnoise, double dx, double dz, double cliffs, double chance)
|
||||
{
|
||||
if(gnoise < block * 66)
|
||||
{
|
||||
return gnoise;
|
||||
}
|
||||
|
||||
double shift = 10.25 + (sh.noise(dx, dz) * 2.25) * cliffs;
|
||||
double hits = 183D / shift;
|
||||
double n = gnoise;
|
||||
|
||||
for(int i = (int) hits; i > 0; i--)
|
||||
{
|
||||
if(ch.noise(dx + (i * -1000), dz + (i * 1000)) >= chance)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
double var = 6.2 * block;
|
||||
double varCombined = 15.45 * block;
|
||||
double sep = (shift / 1.8D) * block;
|
||||
double height = (47 + (i * shift)) * block;
|
||||
double sh = ((gen.noise(dx + dz, dz - dx) - 0.5D) * 2D) * varCombined;
|
||||
double shv = ((gen.noise(dz + dx, dx - dz) - 0.5D) * 2D) * varCombined;
|
||||
double lo = (gen.noise(dx + (i * -1000), dz + (i * 1000)) * var) + height + sh;
|
||||
double hi = (gen.noise(dz + (i * 1000), dx + (i * -1000)) * var) + height + sep + shv;
|
||||
n = n > lo && n < hi ? lo : n;
|
||||
}
|
||||
|
||||
return n;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user