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")
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
public String getFolderName() {
return "caves";
@ -72,11 +75,9 @@ public class IrisCave extends IrisRegistrant {
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) -> {
});
KList<IrisPosition> points = getWorm().generate(rng, engine.getData(), writer, verticalRange, x, y, z, (at) -> {});
int highestWater = Math.max(waterHint, -1);
boolean water = false;
int lowestPoint = Integer.MAX_VALUE;
if (highestWater == -1) {
for (IrisPosition i : points) {
@ -85,12 +86,17 @@ public class IrisCave extends IrisRegistrant {
if (yy > th && th < engine.getDimension().getFluidHeight()) {
highestWater = Math.max(highestWater, (int) yy);
water = true;
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());
@ -99,9 +105,13 @@ public class IrisCave extends IrisRegistrant {
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,
girth, true,
(xf, yf, zf) -> new MatterCavern(true, customBiome, yf <= h));
(xf, yf, zf) -> (lavaLevel + flp >= yf) ? l : (yf <= h ? w : c));
}
@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")
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'")
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) {
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;
int lowestPoint = Integer.MAX_VALUE;
if(lavaLevel >= 0)
{
for(IrisPosition i : pos)
{
lowestPoint = Math.min(i.getY(), lowestPoint);
}
}
if (highestWater == -1) {
for (IrisPosition i : pos) {
@ -120,7 +131,8 @@ public class IrisRavine extends IrisRegistrant {
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) {
return;
@ -146,7 +158,7 @@ public class IrisRavine extends IrisRegistrant {
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;
}
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 {
private final boolean cavern;
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
public class CavernMatter extends RawMatter<MatterCavern> {
public static MatterCavern get(String customBiome, boolean underwater) {
return new MatterCavern(true, customBiome, underwater);
public static MatterCavern get(String customBiome, int liquid) {
return new MatterCavern(true, customBiome, (byte) liquid);
}
public CavernMatter() {
@ -42,16 +42,16 @@ public class CavernMatter extends RawMatter<MatterCavern> {
@Override
public void writeNode(MatterCavern b, DataOutputStream dos) throws IOException {
dos.writeBoolean(b.isCavern());
dos.writeBoolean(b.isWater());
dos.writeUTF(b.getCustomBiome());
dos.writeByte(b.getLiquid());
}
@Override
public MatterCavern readNode(DataInputStream din) throws IOException {
boolean b = din.readBoolean();
boolean w = din.readBoolean();
String v = din.readUTF();
byte l = din.readByte();
return new MatterCavern(b, v, w);
return new MatterCavern(b, v, l);
}
}