Lava impl

This commit is contained in:
DanLT 2021-09-01 13:26:30 -08:00
parent 8e873ccd00
commit 93936a7498
4 changed files with 56 additions and 19 deletions

View File

@ -55,6 +55,9 @@ public class IrisCave extends IrisRegistrant {
@Desc("Limit the worm from ever getting higher or lower than this range") @Desc("Limit the worm from ever getting higher or lower than this range")
private IrisRange verticalRange = new IrisRange(3, 255); private IrisRange verticalRange = new IrisRange(3, 255);
@Desc("To fill this cave with lava, set the lava level to a height from the bottom most point of the cave.")
private int lavaLevel = -1;
@Override @Override
public String getFolderName() { public String getFolderName() {
return "caves"; return "caves";
@ -72,12 +75,10 @@ public class IrisCave extends IrisRegistrant {
public void generate(MantleWriter writer, RNG rng, Engine engine, int x, int y, int z, int waterHint) { 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()); double girth = getWorm().getGirth().get(rng, x, z, engine.getData());
KList<IrisPosition> points = getWorm().generate(rng, engine.getData(), writer, verticalRange, x, y, z, KList<IrisPosition> points = getWorm().generate(rng, engine.getData(), writer, verticalRange, x, y, z, (at) -> {});
(at) -> {
});
int highestWater = Math.max(waterHint, -1); int highestWater = Math.max(waterHint, -1);
boolean water = false; int lowestPoint = Integer.MAX_VALUE;
if (highestWater == -1) { if (highestWater == -1) {
for (IrisPosition i : points) { for (IrisPosition i : points) {
double yy = i.getY() + girth; double yy = i.getY() + girth;
@ -85,12 +86,17 @@ public class IrisCave extends IrisRegistrant {
if (yy > th && th < engine.getDimension().getFluidHeight()) { if (yy > th && th < engine.getDimension().getFluidHeight()) {
highestWater = Math.max(highestWater, (int) yy); highestWater = Math.max(highestWater, (int) yy);
water = true;
break; break;
} }
} }
} else { }
water = true;
if(lavaLevel >= 0)
{
for(IrisPosition i : points)
{
lowestPoint = Math.min(i.getY(), lowestPoint);
}
} }
int h = Math.min(Math.max(highestWater, waterHint), engine.getDimension().getFluidHeight()); int h = Math.min(Math.max(highestWater, waterHint), engine.getDimension().getFluidHeight());
@ -99,9 +105,13 @@ public class IrisCave extends IrisRegistrant {
fork.doCarving(writer, rng, engine, i.getX(), i.getY(), i.getZ(), h); fork.doCarving(writer, rng, engine, i.getX(), i.getY(), i.getZ(), h);
} }
MatterCavern c = new MatterCavern(true, customBiome, (byte) 0);
MatterCavern w = h >= 0 ? new MatterCavern(true, customBiome, (byte) 1) : null;
MatterCavern l = lavaLevel >= 0 ? new MatterCavern(true, customBiome, (byte) 2) : null;
int flp = lowestPoint;
writer.setLineConsumer(points, writer.setLineConsumer(points,
girth, true, girth, true,
(xf, yf, zf) -> new MatterCavern(true, customBiome, yf <= h)); (xf, yf, zf) -> (lavaLevel + flp >= yf) ? l : (yf <= h ? w : c));
} }
@Override @Override

View File

@ -71,6 +71,9 @@ public class IrisRavine extends IrisRegistrant {
@Desc("The angle at which the ravine widens as it gets closer to the surface") @Desc("The angle at which the ravine widens as it gets closer to the surface")
private double topAngle = 38; private double topAngle = 38;
@Desc("To fill this cave with lava, set the lava level to a height from the bottom most point of the cave.")
private int lavaLevel = -1;
@Desc("How many worm nodes must be placed to actually generate a ravine? Higher reduces the chances but also reduces ravine 'holes'") @Desc("How many worm nodes must be placed to actually generate a ravine? Higher reduces the chances but also reduces ravine 'holes'")
private int nodeThreshold = 5; private int nodeThreshold = 5;
@ -94,13 +97,21 @@ public class IrisRavine extends IrisRegistrant {
} }
public void generate(MantleWriter writer, RNG rng, Engine engine, int x, int y, int z, int waterHint) { 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) -> { KList<IrisPosition> pos = getWorm().generate(rng, engine.getData(), writer, null, x, y, z, (at) -> {
}); });
CNG dg = depthStyle.getGenerator().createNoCache(rng, engine.getData()); CNG dg = depthStyle.getGenerator().createNoCache(rng, engine.getData());
CNG bw = baseWidthStyle.getGenerator().createNoCache(rng, engine.getData()); CNG bw = baseWidthStyle.getGenerator().createNoCache(rng, engine.getData());
int highestWater = Math.max(waterHint, -1); int highestWater = Math.max(waterHint, -1);
boolean water = false; boolean water = false;
int lowestPoint = Integer.MAX_VALUE;
if(lavaLevel >= 0)
{
for(IrisPosition i : pos)
{
lowestPoint = Math.min(i.getY(), lowestPoint);
}
}
if (highestWater == -1) { if (highestWater == -1) {
for (IrisPosition i : pos) { for (IrisPosition i : pos) {
@ -120,7 +131,8 @@ public class IrisRavine extends IrisRegistrant {
water = true; water = true;
} }
MatterCavern c = new MatterCavern(true, customBiome, water); MatterCavern c = new MatterCavern(true, customBiome, (byte) (water ? 1 : 0));
MatterCavern l = lavaLevel >= 0 ? new MatterCavern(true, customBiome, (byte) 2) : null;
if (pos.size() < nodeThreshold) { if (pos.size() < nodeThreshold) {
return; return;
@ -146,7 +158,7 @@ public class IrisRavine extends IrisRegistrant {
break; break;
} }
writer.setElipsoid(p.getX(), i, p.getZ(), v, ribThickness, v, true, c); writer.setElipsoid(p.getX(), i, p.getZ(), v, ribThickness, v, true, (lavaLevel + lowestPoint) >= i ? l : c);
} }
} }
@ -162,7 +174,7 @@ public class IrisRavine extends IrisRegistrant {
break; break;
} }
writer.setElipsoid(p.getX(), i, p.getZ(), v, ribThickness, v, true, c); writer.setElipsoid(p.getX(), i, p.getZ(), v, ribThickness, v, true, (lavaLevel + lowestPoint) >= i ? l : c);
} }
} }
} }

View File

@ -26,5 +26,20 @@ import lombok.Data;
public class MatterCavern { public class MatterCavern {
private final boolean cavern; private final boolean cavern;
private final String customBiome; private final String customBiome;
private final boolean water; private final byte liquid; // 0 none 1 water 2 lava
public boolean isAir()
{
return liquid == 0;
}
public boolean isWater()
{
return liquid == 1;
}
public boolean isLava()
{
return liquid == 2;
}
} }

View File

@ -27,8 +27,8 @@ import java.io.IOException;
@Sliced @Sliced
public class CavernMatter extends RawMatter<MatterCavern> { public class CavernMatter extends RawMatter<MatterCavern> {
public static MatterCavern get(String customBiome, boolean underwater) { public static MatterCavern get(String customBiome, int liquid) {
return new MatterCavern(true, customBiome, underwater); return new MatterCavern(true, customBiome, (byte) liquid);
} }
public CavernMatter() { public CavernMatter() {
@ -42,16 +42,16 @@ public class CavernMatter extends RawMatter<MatterCavern> {
@Override @Override
public void writeNode(MatterCavern b, DataOutputStream dos) throws IOException { public void writeNode(MatterCavern b, DataOutputStream dos) throws IOException {
dos.writeBoolean(b.isCavern()); dos.writeBoolean(b.isCavern());
dos.writeBoolean(b.isWater());
dos.writeUTF(b.getCustomBiome()); dos.writeUTF(b.getCustomBiome());
dos.writeByte(b.getLiquid());
} }
@Override @Override
public MatterCavern readNode(DataInputStream din) throws IOException { public MatterCavern readNode(DataInputStream din) throws IOException {
boolean b = din.readBoolean(); boolean b = din.readBoolean();
boolean w = din.readBoolean();
String v = din.readUTF(); String v = din.readUTF();
byte l = din.readByte();
return new MatterCavern(b, v, w); return new MatterCavern(b, v, l);
} }
} }