mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-04-06 07:46:08 +00:00
Underwater caves
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
|
||||
package com.volmit.iris.engine.object.carving;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.loader.IrisData;
|
||||
import com.volmit.iris.core.loader.IrisRegistrant;
|
||||
import com.volmit.iris.engine.data.cache.AtomicCache;
|
||||
@@ -25,9 +26,14 @@ import com.volmit.iris.engine.framework.Engine;
|
||||
import com.volmit.iris.engine.mantle.MantleWriter;
|
||||
import com.volmit.iris.engine.object.annotations.Desc;
|
||||
import com.volmit.iris.engine.object.annotations.RegistryListResource;
|
||||
import com.volmit.iris.engine.object.basic.IrisPosition;
|
||||
import com.volmit.iris.engine.object.basic.IrisRange;
|
||||
import com.volmit.iris.engine.object.biome.IrisBiome;
|
||||
import com.volmit.iris.engine.object.block.IrisBlockData;
|
||||
import com.volmit.iris.engine.object.noise.IrisWorm;
|
||||
import com.volmit.iris.engine.object.objects.IrisObjectLimit;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.data.B;
|
||||
import com.volmit.iris.util.json.JSONObject;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
import com.volmit.iris.util.matter.MatterCavern;
|
||||
@@ -38,6 +44,9 @@ import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Accessors(chain = true)
|
||||
@@ -52,6 +61,10 @@ public class IrisCave extends IrisRegistrant {
|
||||
@Desc("Define potential forking features")
|
||||
private IrisCarving fork = new IrisCarving();
|
||||
|
||||
@RegistryListResource(IrisBiome.class)
|
||||
@Desc("Force this cave to only generate the specified custom biome")
|
||||
private String customBiome = "";
|
||||
|
||||
@Desc("Limit the worm from ever getting higher or lower than this range")
|
||||
private IrisRange verticalRange = new IrisRange(3, 255);
|
||||
|
||||
@@ -65,12 +78,27 @@ public class IrisCave extends IrisRegistrant {
|
||||
return "Cave";
|
||||
}
|
||||
|
||||
public void generate(MantleWriter writer, RNG rng, Engine engine, int x, int y, int z, MatterCavern biome) {
|
||||
public void generate(MantleWriter writer, RNG rng, Engine engine, int x, int y, int z) {
|
||||
|
||||
writer.setLine(getWorm().generate(rng, engine.getData(), writer, verticalRange, x, y, z,
|
||||
(at) -> fork.doCarving(writer, rng, engine, at.getX(), at.getY(), at.getZ())),
|
||||
getWorm().getGirth().get(rng, x, z, engine.getData()), true,
|
||||
biome);
|
||||
double girth = getWorm().getGirth().get(rng, x, z, engine.getData());
|
||||
KList<IrisPosition> points = getWorm().generate(rng, engine.getData(), writer, verticalRange, x, y, z,
|
||||
(at) -> fork.doCarving(writer, rng, engine, at.getX(), at.getY(), at.getZ()));
|
||||
boolean water = false;
|
||||
for(IrisPosition i : points)
|
||||
{
|
||||
double yy = i.getY() + girth;
|
||||
int th = engine.getHeight(x, z, true);
|
||||
|
||||
if(yy > th && th < engine.getDimension().getFluidHeight())
|
||||
{
|
||||
water = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
writer.setLine(points,
|
||||
girth, true,
|
||||
new MatterCavern(true, customBiome, water));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -23,19 +23,15 @@ import com.volmit.iris.core.loader.IrisData;
|
||||
import com.volmit.iris.engine.data.cache.AtomicCache;
|
||||
import com.volmit.iris.engine.framework.Engine;
|
||||
import com.volmit.iris.engine.mantle.MantleWriter;
|
||||
import com.volmit.iris.engine.modifier.IrisCarveModifier;
|
||||
import com.volmit.iris.engine.object.annotations.Desc;
|
||||
import com.volmit.iris.engine.object.annotations.MinNumber;
|
||||
import com.volmit.iris.engine.object.annotations.RegistryListResource;
|
||||
import com.volmit.iris.engine.object.annotations.Required;
|
||||
import com.volmit.iris.engine.object.biome.IrisBiome;
|
||||
import com.volmit.iris.engine.object.common.IRare;
|
||||
import com.volmit.iris.engine.object.noise.IrisGeneratorStyle;
|
||||
import com.volmit.iris.engine.object.noise.IrisStyledRange;
|
||||
import com.volmit.iris.engine.object.noise.NoiseStyle;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
import com.volmit.iris.util.matter.MatterCavern;
|
||||
import com.volmit.iris.util.matter.slices.CavernMatter;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
@@ -66,11 +62,6 @@ public class IrisCavePlacer implements IRare {
|
||||
@Desc("The height range this cave can spawn at. If breakSurface is false, the output of this range will be clamped by the current world height to prevent surface breaking.")
|
||||
private IrisStyledRange caveStartHeight = new IrisStyledRange(13, 120, new IrisGeneratorStyle(NoiseStyle.STATIC));
|
||||
|
||||
@RegistryListResource(IrisBiome.class)
|
||||
@Desc("Force this cave to only generate the specified custom biome")
|
||||
private String customBiome = "";
|
||||
|
||||
private transient final AtomicCache<MatterCavern> matterNodeCache = new AtomicCache<>();
|
||||
private transient final AtomicCache<IrisCave> caveCache = new AtomicCache<>();
|
||||
private transient final AtomicBoolean fail = new AtomicBoolean(false);
|
||||
|
||||
@@ -103,8 +94,7 @@ public class IrisCavePlacer implements IRare {
|
||||
}
|
||||
|
||||
try {
|
||||
cave.generate(mantle, rng, engine, x + rng.nextInt(15), y, z + rng.nextInt(15),
|
||||
matterNodeCache.aquire(() -> customBiome.isEmpty() ? CavernMatter.ON : CavernMatter.get(customBiome)));
|
||||
cave.generate(mantle, rng, engine, x + rng.nextInt(15), y, z + rng.nextInt(15));
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
fail.set(true);
|
||||
|
||||
@@ -62,7 +62,7 @@ public class IrisElipsoid implements IRare {
|
||||
writer.setElipsoid(x, y, z,
|
||||
xRadius.get(rng, z, y, engine.getData()),
|
||||
yRadius.get(rng, x, z, engine.getData()),
|
||||
zRadius.get(rng, y, x, engine.getData()), true, matterNodeCache.aquire(() -> CavernMatter.get(getCustomBiome())));
|
||||
zRadius.get(rng, y, x, engine.getData()), true, matterNodeCache.aquire(() -> CavernMatter.get(getCustomBiome(), false)));
|
||||
}
|
||||
|
||||
public double maxSize() {
|
||||
|
||||
@@ -53,7 +53,7 @@ public class IrisPyramid implements IRare {
|
||||
private transient final AtomicCache<MatterCavern> matterNodeCache = new AtomicCache<>();
|
||||
|
||||
public void generate(RNG rng, Engine engine, MantleWriter writer, int x, int y, int z) {
|
||||
writer.setPyramid(x, y, z, matterNodeCache.aquire(() -> CavernMatter.get(getCustomBiome())),
|
||||
writer.setPyramid(x, y, z, matterNodeCache.aquire(() -> CavernMatter.get(getCustomBiome(), false)),
|
||||
(int) baseWidth.get(rng, z, y, engine.getData()), true);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package com.volmit.iris.engine.object.carving;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.loader.IrisData;
|
||||
import com.volmit.iris.core.loader.IrisRegistrant;
|
||||
import com.volmit.iris.engine.data.cache.AtomicCache;
|
||||
@@ -28,6 +29,7 @@ import com.volmit.iris.engine.object.annotations.MaxNumber;
|
||||
import com.volmit.iris.engine.object.annotations.MinNumber;
|
||||
import com.volmit.iris.engine.object.annotations.RegistryListResource;
|
||||
import com.volmit.iris.engine.object.basic.IrisPosition;
|
||||
import com.volmit.iris.engine.object.basic.IrisRange;
|
||||
import com.volmit.iris.engine.object.biome.IrisBiome;
|
||||
import com.volmit.iris.engine.object.noise.IrisShapedGeneratorStyle;
|
||||
import com.volmit.iris.engine.object.noise.IrisWorm;
|
||||
@@ -55,6 +57,10 @@ public class IrisRavine extends IrisRegistrant {
|
||||
@Desc("Define the shape of this ravine (2d, ignores Y)")
|
||||
private IrisWorm worm;
|
||||
|
||||
@RegistryListResource(IrisBiome.class)
|
||||
@Desc("Force this cave to only generate the specified custom biome")
|
||||
private String customBiome = "";
|
||||
|
||||
@Desc("Define potential forking features")
|
||||
private IrisCarving fork = new IrisCarving();
|
||||
|
||||
@@ -92,54 +98,80 @@ public class IrisRavine extends IrisRegistrant {
|
||||
return "Ravine";
|
||||
}
|
||||
|
||||
public void generate(MantleWriter writer, RNG rng, Engine engine, int x, int y, int z, MatterCavern biome) {
|
||||
public void generate(MantleWriter writer, RNG rng, Engine engine, int x, int y, int z) {
|
||||
|
||||
KList<IrisPosition> pos = getWorm().generate(rng, engine.getData(), writer, null, x, y, z, (at) -> {
|
||||
});
|
||||
KList<IrisPosition> pos = getWorm().generate(rng, engine.getData(), writer, null, x, y, z, (at) -> {});
|
||||
CNG dg = depthStyle.getGenerator().createNoCache(rng, engine.getData());
|
||||
CNG bw = baseWidthStyle.getGenerator().createNoCache(rng, engine.getData());
|
||||
|
||||
if (pos.size() < nodeThreshold) {
|
||||
boolean water = false;
|
||||
for(IrisPosition i : pos)
|
||||
{
|
||||
int rsurface = y == -1 ? engine.getComplex().getHeightStream().get(x, z).intValue() : y;
|
||||
int depth = (int) Math.round(dg.fitDouble(depthStyle.getMin(), depthStyle.getMax(), i.getX(), i.getZ()));
|
||||
int width = (int) Math.round(bw.fitDouble(baseWidthStyle.getMin(), baseWidthStyle.getMax(), i.getX(), i.getZ()));
|
||||
int surface = (int) Math.round(rsurface - depth * 0.45);
|
||||
int yy = surface + depth;
|
||||
int th = engine.getHeight(x, z, true);
|
||||
|
||||
if(yy > th && th < engine.getDimension().getFluidHeight())
|
||||
{
|
||||
water = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
MatterCavern c = new MatterCavern(true, customBiome, water);
|
||||
|
||||
if(pos.size() < nodeThreshold)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (IrisPosition p : pos) {
|
||||
for(IrisPosition p : pos)
|
||||
{
|
||||
int rsurface = y == -1 ? engine.getComplex().getHeightStream().get(x, z).intValue() : y;
|
||||
int depth = (int) Math.round(dg.fitDouble(depthStyle.getMin(), depthStyle.getMax(), p.getX(), p.getZ()));
|
||||
int width = (int) Math.round(bw.fitDouble(baseWidthStyle.getMin(), baseWidthStyle.getMax(), p.getX(), p.getZ()));
|
||||
int surface = (int) Math.round(rsurface - depth * 0.45);
|
||||
|
||||
fork.doCarving(writer, rng, engine, p.getX(), rng.i(surface - depth, surface), p.getZ());
|
||||
fork.doCarving(writer, rng, engine, p.getX(), rng.i(surface-depth, surface), p.getZ());
|
||||
|
||||
for (int i = surface + depth; i >= surface; i--) {
|
||||
if (i % ribThickness == 0) {
|
||||
for(int i = surface + depth; i >= surface; i--)
|
||||
{
|
||||
if(i % ribThickness == 0) {
|
||||
double v = width + ((((surface + depth) - i) * (angle / 360D)));
|
||||
|
||||
if (v <= 0.25) {
|
||||
if(v <= 0.25)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (i <= ribThickness + 2) {
|
||||
if(i <= ribThickness+2)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
writer.setElipsoid(p.getX(), i, p.getZ(), v, ribThickness, v, true, biome);
|
||||
writer.setElipsoid(p.getX(), i, p.getZ(), v, ribThickness, v, true, c);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = surface - depth; i <= surface; i++) {
|
||||
if (i % ribThickness == 0) {
|
||||
for(int i = surface - depth; i <= surface; i++)
|
||||
{
|
||||
if(i % ribThickness == 0) {
|
||||
double v = width - ((((surface - depth) - i) * (angle / 360D)));
|
||||
|
||||
if (v <= 0.25) {
|
||||
if(v <= 0.25)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (i <= ribThickness + 2) {
|
||||
if(i <= ribThickness+2)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
writer.setElipsoid(p.getX(), i, p.getZ(), v, ribThickness, v, true, biome);
|
||||
writer.setElipsoid(p.getX(), i, p.getZ(), v, ribThickness, v, true, c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,11 +27,8 @@ import com.volmit.iris.engine.object.annotations.Desc;
|
||||
import com.volmit.iris.engine.object.annotations.MinNumber;
|
||||
import com.volmit.iris.engine.object.annotations.RegistryListResource;
|
||||
import com.volmit.iris.engine.object.annotations.Required;
|
||||
import com.volmit.iris.engine.object.biome.IrisBiome;
|
||||
import com.volmit.iris.engine.object.common.IRare;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
import com.volmit.iris.util.matter.MatterCavern;
|
||||
import com.volmit.iris.util.matter.slices.CavernMatter;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
@@ -56,11 +53,6 @@ public class IrisRavinePlacer implements IRare {
|
||||
@RegistryListResource(IrisRavine.class)
|
||||
private String ravine;
|
||||
|
||||
@RegistryListResource(IrisBiome.class)
|
||||
@Desc("Force this cave to only generate the specified custom biome")
|
||||
private String customBiome = "";
|
||||
|
||||
private transient final AtomicCache<MatterCavern> matterNodeCache = new AtomicCache<>();
|
||||
private transient final AtomicCache<IrisRavine> ravineCache = new AtomicCache<>();
|
||||
private transient final AtomicBoolean fail = new AtomicBoolean(false);
|
||||
|
||||
@@ -89,8 +81,7 @@ public class IrisRavinePlacer implements IRare {
|
||||
try {
|
||||
int xx = x + rng.nextInt(15);
|
||||
int zz = z + rng.nextInt(15);
|
||||
ravine.generate(mantle, rng, engine, xx, y, zz,
|
||||
matterNodeCache.aquire(() -> customBiome.isEmpty() ? CavernMatter.ON : CavernMatter.get(customBiome)));
|
||||
ravine.generate(mantle, rng, engine, xx, y, zz);
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
fail.set(true);
|
||||
|
||||
@@ -53,7 +53,7 @@ public class IrisSphere implements IRare {
|
||||
private transient final AtomicCache<MatterCavern> matterNodeCache = new AtomicCache<>();
|
||||
|
||||
public void generate(RNG rng, Engine engine, MantleWriter writer, int x, int y, int z) {
|
||||
writer.setSphere(x, y, z, radius.get(rng, z, y, engine.getData()), true, matterNodeCache.aquire(() -> CavernMatter.get(getCustomBiome())));
|
||||
writer.setSphere(x, y, z, radius.get(rng, z, y, engine.getData()), true, matterNodeCache.aquire(() -> CavernMatter.get(getCustomBiome(), false)));
|
||||
}
|
||||
|
||||
public double maxSize() {
|
||||
|
||||
Reference in New Issue
Block a user