mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 18:23:06 +00:00
Shatter Me
This commit is contained in:
parent
a28c08be99
commit
e5e46f3239
@ -58,7 +58,7 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator
|
|||||||
double noise = getNoiseHeight(rx, rz);
|
double noise = getNoiseHeight(rx, rz);
|
||||||
int height = (int) Math.round(noise) + fluidHeight;
|
int height = (int) Math.round(noise) + fluidHeight;
|
||||||
IrisBiome biome = sampleTrueBiome(rx, rz).getBiome();
|
IrisBiome biome = sampleTrueBiome(rx, rz).getBiome();
|
||||||
KList<BlockData> layers = biome.generateLayers(wx, wz, masterRandom, height);
|
KList<BlockData> layers = biome.generateLayers(wx, wz, masterRandom, height, height - getFluidHeight());
|
||||||
KList<BlockData> seaLayers = biome.isSea() ? biome.generateSeaLayers(wx, wz, masterRandom, fluidHeight - height) : new KList<>();
|
KList<BlockData> seaLayers = biome.isSea() ? biome.generateSeaLayers(wx, wz, masterRandom, fluidHeight - height) : new KList<>();
|
||||||
cacheBiome(x, z, biome);
|
cacheBiome(x, z, biome);
|
||||||
|
|
||||||
|
@ -28,6 +28,9 @@ public class IrisBiome extends IrisRegistrant
|
|||||||
@Desc("This zooms in the biome colors if multiple derivatives are chosen")
|
@Desc("This zooms in the biome colors if multiple derivatives are chosen")
|
||||||
private double biomeZoom = 1;
|
private double biomeZoom = 1;
|
||||||
|
|
||||||
|
@Desc("Layers no longer descend from the surface block, they descend from the max possible height the biome can produce (constant) creating mesa like layers.")
|
||||||
|
private boolean lockLayers = false;
|
||||||
|
|
||||||
@Desc("The rarity of this biome (integer)")
|
@Desc("The rarity of this biome (integer)")
|
||||||
private int rarity = 1;
|
private int rarity = 1;
|
||||||
|
|
||||||
@ -68,6 +71,8 @@ public class IrisBiome extends IrisRegistrant
|
|||||||
private transient CellGenerator childrenCell;
|
private transient CellGenerator childrenCell;
|
||||||
private transient InferredType inferredType;
|
private transient InferredType inferredType;
|
||||||
private transient CNG biomeGenerator;
|
private transient CNG biomeGenerator;
|
||||||
|
private transient int maxHeight = Integer.MIN_VALUE;
|
||||||
|
private transient KList<BlockData> fullLayerSpec;
|
||||||
private transient KList<CNG> layerHeightGenerators;
|
private transient KList<CNG> layerHeightGenerators;
|
||||||
private transient KList<CNG> layerSeaHeightGenerators;
|
private transient KList<CNG> layerSeaHeightGenerators;
|
||||||
private transient KList<CNG> layerSurfaceGenerators;
|
private transient KList<CNG> layerSurfaceGenerators;
|
||||||
@ -111,8 +116,13 @@ public class IrisBiome extends IrisRegistrant
|
|||||||
return childrenCell;
|
return childrenCell;
|
||||||
}
|
}
|
||||||
|
|
||||||
public KList<BlockData> generateLayers(double wx, double wz, RNG random, int maxDepth)
|
public KList<BlockData> generateLayers(double wx, double wz, RNG random, int maxDepth, int height)
|
||||||
{
|
{
|
||||||
|
if(isLockLayers())
|
||||||
|
{
|
||||||
|
return generateLockedLayers(wx, wz, random, maxDepth, height);
|
||||||
|
}
|
||||||
|
|
||||||
KList<BlockData> data = new KList<>();
|
KList<BlockData> data = new KList<>();
|
||||||
|
|
||||||
if(maxDepth <= 0)
|
if(maxDepth <= 0)
|
||||||
@ -157,6 +167,74 @@ public class IrisBiome extends IrisRegistrant
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public KList<BlockData> generateLockedLayers(double wx, double wz, RNG random, int maxDepth, int height)
|
||||||
|
{
|
||||||
|
KList<BlockData> data = new KList<>();
|
||||||
|
KList<BlockData> real = new KList<>();
|
||||||
|
|
||||||
|
if(maxDepth <= 0)
|
||||||
|
{
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int i = 0; i < layers.size(); i++)
|
||||||
|
{
|
||||||
|
CNG hgen = getLayerHeightGenerators(random).get(i);
|
||||||
|
int d = hgen.fit(layers.get(i).getMinHeight(), layers.get(i).getMaxHeight(), wx / layers.get(i).getTerrainZoom(), wz / layers.get(i).getTerrainZoom());
|
||||||
|
|
||||||
|
if(d < 0)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int j = 0; j < d; j++)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
data.add(getLayers().get(i).get(random.nextParallelRNG(i + j), (wx + j) / layers.get(i).getTerrainZoom(), j, (wz - j) / layers.get(i).getTerrainZoom()));
|
||||||
|
}
|
||||||
|
|
||||||
|
catch(Throwable e)
|
||||||
|
{
|
||||||
|
L.ex(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(data.isEmpty())
|
||||||
|
{
|
||||||
|
return real;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int i = 0; i < maxDepth; i++)
|
||||||
|
{
|
||||||
|
int offset = (getMaxHeight() - height) - i;
|
||||||
|
int index = offset % data.size();
|
||||||
|
real.add(data.get(index < 0 ? 0 : index));
|
||||||
|
}
|
||||||
|
|
||||||
|
return real;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getMaxHeight()
|
||||||
|
{
|
||||||
|
if(maxHeight == Integer.MIN_VALUE)
|
||||||
|
{
|
||||||
|
lock.lock();
|
||||||
|
|
||||||
|
maxHeight = 0;
|
||||||
|
|
||||||
|
for(IrisBiomeGeneratorLink i : getGenerators())
|
||||||
|
{
|
||||||
|
maxHeight += i.getMax();
|
||||||
|
}
|
||||||
|
|
||||||
|
lock.unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
return maxHeight;
|
||||||
|
}
|
||||||
|
|
||||||
public IrisBiome infer(InferredType t, InferredType type)
|
public IrisBiome infer(InferredType t, InferredType type)
|
||||||
{
|
{
|
||||||
setInferredType(t.equals(InferredType.DEFER) ? type : t);
|
setInferredType(t.equals(InferredType.DEFER) ? type : t);
|
||||||
|
@ -4,6 +4,7 @@ import lombok.Data;
|
|||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import ninja.bytecode.iris.Iris;
|
import ninja.bytecode.iris.Iris;
|
||||||
import ninja.bytecode.iris.util.Desc;
|
import ninja.bytecode.iris.util.Desc;
|
||||||
|
import ninja.bytecode.iris.util.IrisInterpolation;
|
||||||
import ninja.bytecode.shuriken.collections.KList;
|
import ninja.bytecode.shuriken.collections.KList;
|
||||||
|
|
||||||
@Desc("Represents a composite generator of noise gens")
|
@Desc("Represents a composite generator of noise gens")
|
||||||
@ -32,14 +33,28 @@ public class IrisGenerator extends IrisRegistrant
|
|||||||
@Desc("The interpolation distance scale (blocks) when two biomes use different heights but this same generator")
|
@Desc("The interpolation distance scale (blocks) when two biomes use different heights but this same generator")
|
||||||
private double interpolationScale = 7;
|
private double interpolationScale = 7;
|
||||||
|
|
||||||
|
@Desc("Cliff Height Max. Disable with 0 for min and max")
|
||||||
|
private double cliffHeightMax = 0;
|
||||||
|
|
||||||
|
@Desc("Cliff Height Min. Disable with 0 for min and max")
|
||||||
|
private double cliffHeightMin = 0;
|
||||||
|
|
||||||
@Desc("The list of noise gens this gen contains.")
|
@Desc("The list of noise gens this gen contains.")
|
||||||
private KList<IrisNoiseGenerator> composite = new KList<IrisNoiseGenerator>();
|
private KList<IrisNoiseGenerator> composite = new KList<IrisNoiseGenerator>();
|
||||||
|
|
||||||
|
@Desc("The noise gen for cliff height.")
|
||||||
|
private IrisNoiseGenerator cliffHeightGenerator = new IrisNoiseGenerator();
|
||||||
|
|
||||||
public double getMax()
|
public double getMax()
|
||||||
{
|
{
|
||||||
return opacity;
|
return opacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasCliffs()
|
||||||
|
{
|
||||||
|
return cliffHeightMax > 0;
|
||||||
|
}
|
||||||
|
|
||||||
public double getHeight(double rx, double rz, long superSeed)
|
public double getHeight(double rx, double rz, long superSeed)
|
||||||
{
|
{
|
||||||
if(composite.isEmpty())
|
if(composite.isEmpty())
|
||||||
@ -65,7 +80,19 @@ public class IrisGenerator extends IrisRegistrant
|
|||||||
Iris.warn("Nan value on gen: " + getLoadKey() + ": H = " + h + " TP = " + tp + " OPACITY = " + opacity + " ZOOM = " + zoom);
|
Iris.warn("Nan value on gen: " + getLoadKey() + ": H = " + h + " TP = " + tp + " OPACITY = " + opacity + " ZOOM = " + zoom);
|
||||||
}
|
}
|
||||||
|
|
||||||
return v;
|
return hasCliffs() ? cliff(rx, rz, v, superSeed + 294596) : v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public double getCliffHeight(double rx, double rz, double superSeed)
|
||||||
|
{
|
||||||
|
int hc = hashCode();
|
||||||
|
double h = cliffHeightGenerator.getNoise((long) (seed + superSeed + hc), (rx + offsetX) / zoom, (rz + offsetZ) / zoom);
|
||||||
|
return IrisInterpolation.lerp(cliffHeightMin, cliffHeightMax, h);
|
||||||
|
}
|
||||||
|
|
||||||
|
public double cliff(double rx, double rz, double v, double superSeed)
|
||||||
|
{
|
||||||
|
double cliffHeight = getCliffHeight(rx, rz, superSeed - 34857);
|
||||||
|
return (Math.round((v * 255D) / cliffHeight) * cliffHeight) / 255D;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user