mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 10:12:53 +00:00
*Better* Underwater Caves
This commit is contained in:
parent
e540596c20
commit
f3d899cbf5
@ -28,6 +28,7 @@ import com.volmit.iris.engine.object.feature.IrisFeaturePositional;
|
||||
import com.volmit.iris.engine.object.tile.TileData;
|
||||
import com.volmit.iris.util.collection.KMap;
|
||||
import com.volmit.iris.util.collection.KSet;
|
||||
import com.volmit.iris.util.function.Function3;
|
||||
import com.volmit.iris.util.mantle.Mantle;
|
||||
import com.volmit.iris.util.mantle.MantleChunk;
|
||||
import com.volmit.iris.util.matter.Matter;
|
||||
@ -298,6 +299,11 @@ public class MantleWriter implements IObjectPlacer {
|
||||
setLine(ImmutableList.of(a, b), radius, filled, data);
|
||||
}
|
||||
|
||||
|
||||
public <T> void setLine(List<IrisPosition> vectors, double radius, boolean filled, T data) {
|
||||
setLineConsumer(vectors, radius, filled, (_x, _y, _z) -> data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set lines for points
|
||||
*
|
||||
@ -307,7 +313,7 @@ public class MantleWriter implements IObjectPlacer {
|
||||
* @param data the data to set
|
||||
* @param <T> the type of data to apply to the mantle
|
||||
*/
|
||||
public <T> void setLine(List<IrisPosition> vectors, double radius, boolean filled, T data) {
|
||||
public <T> void setLineConsumer(List<IrisPosition> vectors, double radius, boolean filled, Function3<Integer, Integer, Integer, T> data) {
|
||||
Set<IrisPosition> vset = new KSet<>();
|
||||
|
||||
for (int i = 0; vectors.size() != 0 && i < vectors.size() - 1; i++) {
|
||||
@ -365,7 +371,7 @@ public class MantleWriter implements IObjectPlacer {
|
||||
vset = getHollowed(vset);
|
||||
}
|
||||
|
||||
set(vset, data);
|
||||
setConsumer(vset, data);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -469,6 +475,12 @@ public class MantleWriter implements IObjectPlacer {
|
||||
}
|
||||
}
|
||||
|
||||
public <T> void setConsumer(Set<IrisPosition> positions, Function3<Integer,Integer,Integer,T> data) {
|
||||
for (IrisPosition i : positions) {
|
||||
set(i, data.apply(i.getX(), i.getY(), i.getZ()));
|
||||
}
|
||||
}
|
||||
|
||||
private static Set<IrisPosition> getBallooned(Set<IrisPosition> vset, double radius) {
|
||||
Set<IrisPosition> returnset = new HashSet<>();
|
||||
int ceilrad = (int) Math.ceil(radius);
|
||||
|
@ -57,17 +57,23 @@ public class IrisCarving {
|
||||
@Desc("Define pyramids")
|
||||
private KList<IrisPyramid> pyramids = new KList<>();
|
||||
|
||||
|
||||
@BlockCoordinates
|
||||
public void doCarving(MantleWriter writer, RNG rng, Engine engine, int x, int y, int z) {
|
||||
doCarving(writer, rng, engine, x, y, z, -1);
|
||||
}
|
||||
|
||||
@BlockCoordinates
|
||||
public void doCarving(MantleWriter writer, RNG rng, Engine engine, int x, int y, int z, int waterHint) {
|
||||
if (caves.isNotEmpty()) {
|
||||
for (IrisCavePlacer i : caves) {
|
||||
i.generateCave(writer, rng, engine, x, y, z);
|
||||
i.generateCave(writer, rng, engine, x, y, z, waterHint);
|
||||
}
|
||||
}
|
||||
|
||||
if (ravines.isNotEmpty()) {
|
||||
for (IrisRavinePlacer i : ravines) {
|
||||
i.generateRavine(writer, rng, engine, x, y, z);
|
||||
i.generateRavine(writer, rng, engine, x, y, z, waterHint);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -78,27 +78,50 @@ public class IrisCave extends IrisRegistrant {
|
||||
return "Cave";
|
||||
}
|
||||
|
||||
|
||||
public void generate(MantleWriter writer, RNG rng, Engine engine, int x, int y, int z) {
|
||||
generate(writer, rng, engine, x, y, z, -1);
|
||||
}
|
||||
|
||||
public void generate(MantleWriter writer, RNG rng, Engine engine, int x, int y, int z, int waterHint) {
|
||||
|
||||
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()));
|
||||
(at) -> {});
|
||||
int highestWater = Math.max(waterHint, -1);
|
||||
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())
|
||||
if(highestWater == -1)
|
||||
{
|
||||
for(IrisPosition i : points)
|
||||
{
|
||||
water = true;
|
||||
break;
|
||||
double yy = i.getY() + girth;
|
||||
int th = engine.getHeight(x, z, true);
|
||||
|
||||
if(yy > th && th < engine.getDimension().getFluidHeight())
|
||||
{
|
||||
highestWater = Math.max(highestWater, (int)yy);
|
||||
water = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
writer.setLine(points,
|
||||
else
|
||||
{
|
||||
water = true;
|
||||
}
|
||||
|
||||
int h = Math.min(Math.max(highestWater, waterHint), engine.getDimension().getFluidHeight());
|
||||
|
||||
for(IrisPosition i : points)
|
||||
{
|
||||
fork.doCarving(writer, rng, engine, i.getX(), i.getY(), i.getZ(), h);
|
||||
}
|
||||
|
||||
writer.setLineConsumer(points,
|
||||
girth, true,
|
||||
new MatterCavern(true, customBiome, water));
|
||||
(xf, yf, zf) -> new MatterCavern(true, customBiome, yf <= h));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -68,8 +68,11 @@ public class IrisCavePlacer implements IRare {
|
||||
public IrisCave getRealCave(IrisData data) {
|
||||
return caveCache.aquire(() -> data.getCaveLoader().load(getCave()));
|
||||
}
|
||||
|
||||
public void generateCave(MantleWriter mantle, RNG rng, Engine engine, int x, int y, int z) {
|
||||
generateCave(mantle, rng, engine, x, y, z, -1);
|
||||
}
|
||||
|
||||
public void generateCave(MantleWriter mantle, RNG rng, Engine engine, int x, int y, int z, int waterHint) {
|
||||
if (fail.get()) {
|
||||
return;
|
||||
}
|
||||
@ -94,7 +97,7 @@ public class IrisCavePlacer implements IRare {
|
||||
}
|
||||
|
||||
try {
|
||||
cave.generate(mantle, rng, engine, x + rng.nextInt(15), y, z + rng.nextInt(15));
|
||||
cave.generate(mantle, rng, engine, x + rng.nextInt(15), y, z + rng.nextInt(15), waterHint);
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
fail.set(true);
|
||||
|
@ -97,30 +97,42 @@ public class IrisRavine extends IrisRegistrant {
|
||||
public String getTypeName() {
|
||||
return "Ravine";
|
||||
}
|
||||
|
||||
public void generate(MantleWriter writer, RNG rng, Engine engine, int x, int y, int z) {
|
||||
generate(writer, rng, engine, x, y, z, -1);
|
||||
}
|
||||
|
||||
public void generate(MantleWriter writer, RNG rng, Engine engine, int x, int y, int z, int waterHint) {
|
||||
|
||||
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());
|
||||
|
||||
int highestWater = Math.max(waterHint, -1);
|
||||
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())
|
||||
if(highestWater == -1)
|
||||
{
|
||||
for(IrisPosition i : pos)
|
||||
{
|
||||
water = true;
|
||||
break;
|
||||
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 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())
|
||||
{
|
||||
highestWater = Math.max(highestWater, yy);
|
||||
water = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
water = true;
|
||||
}
|
||||
|
||||
MatterCavern c = new MatterCavern(true, customBiome, water);
|
||||
|
||||
if(pos.size() < nodeThreshold)
|
||||
@ -135,7 +147,7 @@ public class IrisRavine extends IrisRegistrant {
|
||||
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(), Math.max(highestWater, waterHint));
|
||||
|
||||
for(int i = surface + depth; i >= surface; i--)
|
||||
{
|
||||
|
@ -61,6 +61,10 @@ public class IrisRavinePlacer implements IRare {
|
||||
}
|
||||
|
||||
public void generateRavine(MantleWriter mantle, RNG rng, Engine engine, int x, int y, int z) {
|
||||
generateRavine(mantle, rng, engine, x, y, z, -1);
|
||||
}
|
||||
|
||||
public void generateRavine(MantleWriter mantle, RNG rng, Engine engine, int x, int y, int z, int waterHint) {
|
||||
if (fail.get()) {
|
||||
return;
|
||||
}
|
||||
@ -81,7 +85,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);
|
||||
ravine.generate(mantle, rng, engine, xx, y, zz, waterHint);
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
fail.set(true);
|
||||
|
Loading…
x
Reference in New Issue
Block a user