mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-04-05 23:36:12 +00:00
Surfaces and subsurfaces
This commit is contained in:
@@ -42,16 +42,28 @@ public class IrisBiome
|
||||
private Biome realBiome;
|
||||
private double height;
|
||||
private double amp;
|
||||
private GList<MB> rock;
|
||||
private int rockDepth;
|
||||
private GList<MB> surface;
|
||||
private GList<MB> dirt;
|
||||
private GMap<MB, Double> scatterChance;
|
||||
private boolean scatterSurface;
|
||||
private boolean scatterSurfaceRock;
|
||||
private boolean scatterSurfaceSub;
|
||||
private boolean core;
|
||||
private int dirtDepth;
|
||||
private boolean simplexScatter;
|
||||
private boolean simplexScatterRock;
|
||||
private boolean simplexScatterSub;
|
||||
private double snow;
|
||||
private double cliffChance;
|
||||
private double cliffScale;
|
||||
private boolean cliffs;
|
||||
private String region;
|
||||
private GMap<String, Double> schematicGroups;
|
||||
private PolygonGenerator.EnumPolygonGenerator<MB> poly;
|
||||
private PolygonGenerator.EnumPolygonGenerator<MB> polySub;
|
||||
private PolygonGenerator.EnumPolygonGenerator<MB> polyRock;
|
||||
|
||||
public static double getMaxHeight()
|
||||
{
|
||||
@@ -114,12 +126,38 @@ public class IrisBiome
|
||||
this.region = "default";
|
||||
this.core = false;
|
||||
this.name = name;
|
||||
cliffs = false;
|
||||
cliffScale = 1;
|
||||
cliffChance = 0.37;
|
||||
dirtDepth = 2;
|
||||
this.realBiome = realBiome;
|
||||
this.height = IDEAL_HEIGHT;
|
||||
this.amp = 0.31;
|
||||
rockDepth = 11;
|
||||
simplexScatterRock = false;
|
||||
scatterSurfaceRock = true;
|
||||
simplexScatterSub = false;
|
||||
scatterSurfaceSub = true;
|
||||
scatterChance = new GMap<>();
|
||||
schematicGroups = new GMap<>();
|
||||
surface(new MB(Material.GRASS)).dirt(new MB(Material.DIRT), new MB(Material.DIRT, 1));
|
||||
//@builder
|
||||
surface(new MB(Material.GRASS))
|
||||
.dirt(new MB(Material.DIRT), new MB(Material.DIRT, 1))
|
||||
.rock(MB.of(Material.STONE),
|
||||
MB.of(Material.STONE),
|
||||
MB.of(Material.STONE),
|
||||
MB.of(Material.STONE),
|
||||
MB.of(Material.STONE),
|
||||
MB.of(Material.STONE),
|
||||
MB.of(Material.STONE, 5),
|
||||
MB.of(Material.STONE, 5),
|
||||
MB.of(Material.COBBLESTONE),
|
||||
MB.of(Material.COBBLESTONE),
|
||||
MB.of(Material.SMOOTH_BRICK),
|
||||
MB.of(Material.SMOOTH_BRICK, 1),
|
||||
MB.of(Material.SMOOTH_BRICK, 2),
|
||||
MB.of(Material.SMOOTH_BRICK, 3));
|
||||
//@done
|
||||
}
|
||||
|
||||
public void fromJSON(JSONObject o)
|
||||
@@ -134,18 +172,30 @@ public class IrisBiome
|
||||
J.attempt(() -> region = o.getString("region"));
|
||||
J.attempt(() -> height = o.getDouble("height"));
|
||||
J.attempt(() -> snow = o.getDouble("snow"));
|
||||
J.attempt(() -> dirtDepth = o.getInt("subSurfaceDepth"));
|
||||
J.attempt(() -> dirtDepth = o.getInt("dirtDepth"));
|
||||
J.attempt(() -> rockDepth = o.getInt("rockDepth"));
|
||||
J.attempt(() -> cliffScale = o.getDouble("cliffScale"));
|
||||
J.attempt(() -> cliffChance = o.getDouble("cliffChance"));
|
||||
J.attempt(() -> cliffs = o.getBoolean("cliffs"));
|
||||
J.attempt(() -> surface = mbListFromJSON(o.getJSONArray("surface")));
|
||||
J.attempt(() -> rock = mbListFromJSON(o.getJSONArray("rock")));
|
||||
J.attempt(() -> dirt = mbListFromJSON(o.getJSONArray("subSurface")));
|
||||
J.attempt(() -> dirt = mbListFromJSON(o.getJSONArray("dirt")));
|
||||
J.attempt(() -> scatterChance = scatterFromJSON(o.getJSONArray("scatter")));
|
||||
J.attempt(() -> simplexScatter = o.getString("surfaceType").equalsIgnoreCase("simplex"));
|
||||
J.attempt(() -> scatterSurface = o.getString("surfaceType").equalsIgnoreCase("scatter"));
|
||||
J.attempt(() -> simplexScatterRock = o.getString("rockType").equalsIgnoreCase("simplex"));
|
||||
J.attempt(() -> scatterSurfaceRock = o.getString("rockType").equalsIgnoreCase("scatter"));
|
||||
J.attempt(() -> simplexScatterSub = o.getString("subSurfaceType").equalsIgnoreCase("simplex"));
|
||||
J.attempt(() -> scatterSurfaceSub = o.getString("subSurfaceType").equalsIgnoreCase("scatter"));
|
||||
J.attempt(() ->
|
||||
{
|
||||
if(Iris.settings.gen.genObjects)
|
||||
{
|
||||
schematicGroups = strFromJSON(o.getJSONArray("objects"));
|
||||
}
|
||||
|
||||
|
||||
else
|
||||
{
|
||||
schematicGroups = new GMap<>();
|
||||
@@ -172,10 +222,18 @@ public class IrisBiome
|
||||
J.attempt(() -> j.put("derivative", realBiome.name().toLowerCase().replaceAll("_", " ")));
|
||||
J.attempt(() -> j.put("height", height));
|
||||
J.attempt(() -> j.put("snow", snow));
|
||||
J.attempt(() -> j.put("cliffs", cliffs));
|
||||
J.attempt(() -> j.put("cliffScale", cliffScale));
|
||||
J.attempt(() -> j.put("cliffChance", cliffChance));
|
||||
J.attempt(() -> j.put("surface", mbListToJSON(surface)));
|
||||
J.attempt(() -> j.put("dirt", mbListToJSON(dirt)));
|
||||
J.attempt(() -> j.put("rock", mbListToJSON(rock)));
|
||||
J.attempt(() -> j.put("subSurfaceDepth", dirtDepth));
|
||||
J.attempt(() -> j.put("rockDepth", rockDepth));
|
||||
J.attempt(() -> j.put("subSurface", mbListToJSON(dirt)));
|
||||
J.attempt(() -> j.put("scatter", scatterToJson(scatterChance)));
|
||||
J.attempt(() -> j.put("surfaceType", simplexScatter ? "simplex" : scatterSurface ? "scatter" : "na"));
|
||||
J.attempt(() -> j.put("subSurfaceType", simplexScatterSub ? "simplex" : scatterSurfaceSub ? "scatter" : "na"));
|
||||
J.attempt(() -> j.put("rockType", simplexScatterRock ? "simplex" : scatterSurfaceRock ? "scatter" : "na"));
|
||||
J.attempt(() -> j.put("objects", strToJson(schematicGroups)));
|
||||
|
||||
return j;
|
||||
@@ -321,6 +379,12 @@ public class IrisBiome
|
||||
return this;
|
||||
}
|
||||
|
||||
public IrisBiome rock(MB... mbs)
|
||||
{
|
||||
rock = new GList<>(mbs);
|
||||
return this;
|
||||
}
|
||||
|
||||
public IrisBiome height(double height)
|
||||
{
|
||||
if(height >= 0)
|
||||
@@ -367,6 +431,11 @@ public class IrisBiome
|
||||
return surface;
|
||||
}
|
||||
|
||||
public GList<MB> getRock()
|
||||
{
|
||||
return rock;
|
||||
}
|
||||
|
||||
public GList<MB> getDirt()
|
||||
{
|
||||
return dirt;
|
||||
@@ -405,9 +474,70 @@ public class IrisBiome
|
||||
return getSurface().getRandom();
|
||||
}
|
||||
|
||||
public MB getDirtRNG()
|
||||
public MB getSubSurface(double x, double i, double z, RNG rng)
|
||||
{
|
||||
return getDirt().getRandom();
|
||||
double wx = x + 1000D;
|
||||
double wz = z + 1000D;
|
||||
if(simplexScatterSub)
|
||||
{
|
||||
if(polySub == null)
|
||||
{
|
||||
polySub = new PolygonGenerator.EnumPolygonGenerator<MB>(rng, 0.125, 2, getDirt().toArray(new MB[getDirt().size()]), (g) ->
|
||||
{
|
||||
return g.scale(0.05).fractureWith(new CNG(rng.nextParallelRNG(526), 1D, 2).scale(0.0955), 55);
|
||||
});
|
||||
}
|
||||
|
||||
return polySub.getChoice(wx / 3, i / 3, wz / 3);
|
||||
}
|
||||
|
||||
if(scatterSurfaceSub)
|
||||
{
|
||||
if(polySub == null)
|
||||
{
|
||||
polySub = new PolygonGenerator.EnumPolygonGenerator<MB>(rng, 15.05, 2, getDirt().toArray(new MB[getDirt().size()]), (g) ->
|
||||
{
|
||||
return g.fractureWith(new CNG(rng.nextParallelRNG(515), 1D, 2).scale(0.0155), 224);
|
||||
});
|
||||
}
|
||||
|
||||
return polySub.getChoice(wx * 0.2D, i / 3, wz * 0.2D);
|
||||
}
|
||||
|
||||
return getSurface().getRandom();
|
||||
}
|
||||
|
||||
public MB getRock(double x, double i, double z, RNG rng)
|
||||
{
|
||||
double wx = x + 1000D;
|
||||
double wz = z + 1000D;
|
||||
if(simplexScatterRock)
|
||||
{
|
||||
if(polyRock == null)
|
||||
{
|
||||
polyRock = new PolygonGenerator.EnumPolygonGenerator<MB>(rng, 0.125, 2, getRock().toArray(new MB[getRock().size()]), (g) ->
|
||||
{
|
||||
return g.scale(0.05).fractureWith(new CNG(rng.nextParallelRNG(562), 1D, 2).scale(0.0955), 55);
|
||||
});
|
||||
}
|
||||
|
||||
return polyRock.getChoice(wx / 3, i / 3, wz / 3);
|
||||
}
|
||||
|
||||
if(scatterSurfaceRock)
|
||||
{
|
||||
if(polyRock == null)
|
||||
{
|
||||
polyRock = new PolygonGenerator.EnumPolygonGenerator<MB>(rng, 15.05, 2, getRock().toArray(new MB[getRock().size()]), (g) ->
|
||||
{
|
||||
return g.fractureWith(new CNG(rng.nextParallelRNG(551), 1D, 2).scale(0.0155), 224);
|
||||
});
|
||||
}
|
||||
|
||||
return polyRock.getChoice(wx * 0.2D, i * 0.2D, wz * 0.2D);
|
||||
}
|
||||
|
||||
return getSurface().getRandom();
|
||||
}
|
||||
|
||||
public GMap<MB, Double> getScatterChance()
|
||||
@@ -480,4 +610,34 @@ public class IrisBiome
|
||||
{
|
||||
return snow;
|
||||
}
|
||||
|
||||
public double getCliffScale()
|
||||
{
|
||||
return cliffScale;
|
||||
}
|
||||
|
||||
public boolean hasCliffs()
|
||||
{
|
||||
return cliffs;
|
||||
}
|
||||
|
||||
public int getDirtDepth()
|
||||
{
|
||||
return dirtDepth;
|
||||
}
|
||||
|
||||
public int getRockDepth()
|
||||
{
|
||||
return rockDepth;
|
||||
}
|
||||
|
||||
public boolean isCliffs()
|
||||
{
|
||||
return cliffs;
|
||||
}
|
||||
|
||||
public double getCliffChance()
|
||||
{
|
||||
return cliffChance;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user