This commit is contained in:
Daniel Mills 2020-08-19 02:18:31 -04:00
parent 4dfd033435
commit b8c4d66160
7 changed files with 131 additions and 138 deletions

View File

@ -704,8 +704,8 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator
catch(Throwable e)
{
e.printStackTrace();
Iris.warn("Failed to sample hi biome at " + rx + " " + rz + " using the generator " + gen.getLoadKey());
fail(e);
}
return 0;
});
@ -727,8 +727,8 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator
catch(Throwable e)
{
e.printStackTrace();
Iris.warn("Failed to sample lo biome at " + rx + " " + rz + " using the generator " + gen.getLoadKey());
fail(e);
}
return 0;

View File

@ -27,8 +27,6 @@ public class GenLayerBiome extends GenLayer
private BiomeDataProvider landProvider;
private BiomeDataProvider shoreProvider;
private BiomeDataProvider caveProvider;
private BiomeDataProvider islandProvider;
private BiomeDataProvider skylandProvider;
private DimensionChunkGenerator iris;
public GenLayerBiome(DimensionChunkGenerator iris, RNG rng)
@ -39,8 +37,6 @@ public class GenLayerBiome extends GenLayer
landProvider = new BiomeDataProvider(this, InferredType.LAND, rng);
shoreProvider = new BiomeDataProvider(this, InferredType.SHORE, rng);
caveProvider = new BiomeDataProvider(this, InferredType.CAVE, rng);
islandProvider = new BiomeDataProvider(this, InferredType.ISLAND, rng);
skylandProvider = new BiomeDataProvider(this, InferredType.SKYLAND, rng);
regionGenerator = iris.getDimension().getRegionStyle().create(rng.nextParallelRNG(1188519)).bake().scale(1D / iris.getDimension().getRegionZoom());
bridgeGenerator = iris.getDimension().getContinentalStyle().create(rng.nextParallelRNG(1541462)).bake().scale(1D / iris.getDimension().getContinentZoom());
}
@ -91,16 +87,6 @@ public class GenLayerBiome extends GenLayer
return caveProvider;
}
else if(type.equals(InferredType.ISLAND))
{
return islandProvider;
}
else if(type.equals(InferredType.SKYLAND))
{
return skylandProvider;
}
else
{
Iris.error("Cannot find a BiomeDataProvider for type " + type.name());
@ -119,18 +105,20 @@ public class GenLayerBiome extends GenLayer
double x = bx;
double z = bz;
double c = iris.getDimension().getLandChance();
InferredType bridge;
if(c >= 1)
{
return InferredType.LAND;
bridge = InferredType.LAND;
}
if(c <= 0)
{
return InferredType.SEA;
bridge = InferredType.SEA;
}
return bridgeGenerator.fitDouble(0, 1, x, z) < c ? InferredType.LAND : InferredType.SEA;
bridge = bridgeGenerator.fitDouble(0, 1, x, z) < c ? InferredType.LAND : InferredType.SEA;
return bridge;
}
public BiomeResult generateBiomeData(double bx, double bz, IrisRegion regionData, CNG cell, KList<IrisBiome> biomes, InferredType inferredType)

View File

@ -16,12 +16,6 @@ public enum InferredType
@DontObfuscate
CAVE,
@DontObfuscate
ISLAND,
@DontObfuscate
SKYLAND,
@DontObfuscate
DEFER;
}

View File

@ -55,6 +55,10 @@ public class IrisBiome extends IrisRegistrant implements IRare
@Desc("Layers no longer descend from the surface block, they descend from the max possible height the biome can produce (constant) creating mesa like layers.")
private boolean lockLayers = false;
@DontObfuscate
@Desc("The max layers to iterate below the surface for locked layer biomes (mesa).")
private int lockLayersMax = 7;
@MinNumber(1)
@MaxNumber(512)
@DontObfuscate
@ -226,11 +230,11 @@ public class IrisBiome extends IrisRegistrant implements IRare
return data;
}
public KList<BlockData> generateLockedLayers(double wx, double wz, RNG random, int maxDepth, int height)
public KList<BlockData> generateLockedLayers(double wx, double wz, RNG random, int maxDepthf, int height)
{
KList<BlockData> data = new KList<>();
KList<BlockData> real = new KList<>();
int maxDepth = Math.min(maxDepthf, getLockLayersMax());
if(maxDepth <= 0)
{
return data;

View File

@ -82,6 +82,10 @@ public class IrisDimension extends IrisRegistrant
@Desc("The placement style of biomes")
private IrisGeneratorStyle islandBiomeStyle = NoiseStyle.CELLULAR_IRIS_DOUBLE.style();
@DontObfuscate
@Desc("The placement style of biomes")
private IrisGeneratorStyle islandBiomeChanceStyle = NoiseStyle.CELLULAR_HEIGHT_IRIS_DOUBLE.style();
@DontObfuscate
@Desc("The placement style of biomes")
private IrisGeneratorStyle skylandBiomeStyle = NoiseStyle.CELLULAR_IRIS_DOUBLE.style();
@ -684,16 +688,12 @@ public class IrisDimension extends IrisRegistrant
{
case CAVE:
return caveBiomeStyle;
case ISLAND:
return islandBiomeStyle;
case LAND:
return landBiomeStyle;
case SEA:
return seaBiomeStyle;
case SHORE:
return shoreBiomeStyle;
case SKYLAND:
return skylandBiomeStyle;
default:
break;
}

View File

@ -22,7 +22,8 @@ import lombok.EqualsAndHashCode;
@Desc("Represents an iris region")
@Data
@EqualsAndHashCode(callSuper = false)
public class IrisRegion extends IrisRegistrant implements IRare {
public class IrisRegion extends IrisRegistrant implements IRare
{
@MinNumber(2)
@Required
@DontObfuscate
@ -76,21 +77,11 @@ public class IrisRegion extends IrisRegistrant implements IRare {
@Desc("How large sea biomes are in this region")
private double seaBiomeZoom = 1;
@MinNumber(0.0001)
@DontObfuscate
@Desc("How large island biomes are in this region")
private double islandBiomeZoom = 1;
@MinNumber(0.0001)
@DontObfuscate
@Desc("How large cave biomes are in this region")
private double caveBiomeZoom = 1;
@MinNumber(0.0001)
@DontObfuscate
@Desc("How large skyland biomes are in this region")
private double skylandBiomeZoom = 1;
@MinNumber(0.0001)
@MaxNumber(1)
@DontObfuscate
@ -125,16 +116,6 @@ public class IrisRegion extends IrisRegistrant implements IRare {
@Desc("A list of root-level biomes in this region. Don't specify child biomes of other biomes here. Just the root parents.")
private KList<String> caveBiomes = new KList<>();
@ArrayType(min = 1, type = String.class)
@DontObfuscate
@Desc("A list of root-level biomes in this region. Don't specify child biomes of other biomes here. Just the root parents.")
private KList<String> islandBiomes = new KList<>();
@ArrayType(min = 1, type = String.class)
@DontObfuscate
@Desc("A list of root-level biomes in this region. Don't specify child biomes of other biomes here. Just the root parents.")
private KList<String> skylandBiomes = new KList<>();
@ArrayType(min = 1, type = IrisRegionRidge.class)
@DontObfuscate
@Desc("Ridge biomes create a vein-like network like rivers through this region")
@ -155,33 +136,31 @@ public class IrisRegion extends IrisRegistrant implements IRare {
private transient AtomicCache<KList<IrisBiome>> realLandBiomes = new AtomicCache<>();
private transient AtomicCache<KList<IrisBiome>> realSeaBiomes = new AtomicCache<>();
private transient AtomicCache<KList<IrisBiome>> realShoreBiomes = new AtomicCache<>();
private transient AtomicCache<KList<IrisBiome>> realIslandBiomes = new AtomicCache<>();
private transient AtomicCache<KList<IrisBiome>> realSkylandBiomes = new AtomicCache<>();
private transient AtomicCache<KList<IrisBiome>> realCaveBiomes = new AtomicCache<>();
public double getBiomeZoom(InferredType t) {
switch (t) {
case CAVE:
return caveBiomeZoom;
case ISLAND:
return islandBiomeZoom;
case LAND:
return landBiomeZoom;
case SEA:
return seaBiomeZoom;
case SHORE:
return shoreBiomeZoom;
case SKYLAND:
return skylandBiomeZoom;
default:
break;
public double getBiomeZoom(InferredType t)
{
switch(t)
{
case CAVE:
return caveBiomeZoom;
case LAND:
return landBiomeZoom;
case SEA:
return seaBiomeZoom;
case SHORE:
return shoreBiomeZoom;
default:
break;
}
return 1;
}
public KList<String> getRidgeBiomeKeys() {
return cacheRidge.aquire(() -> {
public KList<String> getRidgeBiomeKeys()
{
return cacheRidge.aquire(() ->
{
KList<String> cacheRidge = new KList<String>();
ridgeBiomes.forEach((i) -> cacheRidge.add(i.getBiome()));
@ -189,41 +168,46 @@ public class IrisRegion extends IrisRegistrant implements IRare {
});
}
public KList<String> getSpotBiomeKeys() {
return cacheSpot.aquire(() -> {
public KList<String> getSpotBiomeKeys()
{
return cacheSpot.aquire(() ->
{
KList<String> cacheSpot = new KList<String>();
spotBiomes.forEach((i) -> cacheSpot.add(i.getBiome()));
return cacheSpot;
});
}
public CNG getShoreHeightGenerator() {
return shoreHeightGenerator.aquire(() -> {
return CNG.signature(new RNG((long) (getName().length() + getIslandBiomes().size() + getLandBiomeZoom()
+ getLandBiomes().size() + 3458612)));
public CNG getShoreHeightGenerator()
{
return shoreHeightGenerator.aquire(() ->
{
return CNG.signature(new RNG((long) (getName().length() + getLandBiomeZoom() + getLandBiomes().size() + 3458612)));
});
}
public double getShoreHeight(double x, double z) {
return getShoreHeightGenerator().fitDouble(shoreHeightMin, shoreHeightMax, x / shoreHeightZoom,
z / shoreHeightZoom);
public double getShoreHeight(double x, double z)
{
return getShoreHeightGenerator().fitDouble(shoreHeightMin, shoreHeightMax, x / shoreHeightZoom, z / shoreHeightZoom);
}
public KList<IrisBiome> getAllBiomes(ContextualChunkGenerator g) {
public KList<IrisBiome> getAllBiomes(ContextualChunkGenerator g)
{
KMap<String, IrisBiome> b = new KMap<>();
KSet<String> names = new KSet<>();
names.addAll(landBiomes);
names.addAll(islandBiomes);
names.addAll(caveBiomes);
names.addAll(skylandBiomes);
names.addAll(seaBiomes);
names.addAll(shoreBiomes);
spotBiomes.forEach((i) -> names.add(i.getBiome()));
ridgeBiomes.forEach((i) -> names.add(i.getBiome()));
while (!names.isEmpty()) {
for (String i : new KList<>(names)) {
if (b.containsKey(i)) {
while(!names.isEmpty())
{
for(String i : new KList<>(names))
{
if(b.containsKey(i))
{
names.remove(i);
continue;
}
@ -238,39 +222,39 @@ public class IrisRegion extends IrisRegistrant implements IRare {
return b.v();
}
public KList<IrisBiome> getBiomes(ContextualChunkGenerator g, InferredType type) {
if (type.equals(InferredType.LAND)) {
public KList<IrisBiome> getBiomes(ContextualChunkGenerator g, InferredType type)
{
if(type.equals(InferredType.LAND))
{
return getRealLandBiomes(g);
}
else if (type.equals(InferredType.SEA)) {
else if(type.equals(InferredType.SEA))
{
return getRealSeaBiomes(g);
}
else if (type.equals(InferredType.SHORE)) {
else if(type.equals(InferredType.SHORE))
{
return getRealShoreBiomes(g);
}
else if (type.equals(InferredType.CAVE)) {
else if(type.equals(InferredType.CAVE))
{
return getRealCaveBiomes(g);
}
else if (type.equals(InferredType.ISLAND)) {
return getRealIslandBiomes(g);
}
else if (type.equals(InferredType.SKYLAND)) {
return getRealSkylandBiomes(g);
}
return new KList<>();
}
public KList<IrisBiome> getRealCaveBiomes(ContextualChunkGenerator g) {
return realCaveBiomes.aquire(() -> {
public KList<IrisBiome> getRealCaveBiomes(ContextualChunkGenerator g)
{
return realCaveBiomes.aquire(() ->
{
KList<IrisBiome> realCaveBiomes = new KList<>();
for (String i : getCaveBiomes()) {
for(String i : getCaveBiomes())
{
realCaveBiomes.add((g == null ? Iris.globaldata : g.getData()).getBiomeLoader().load(i));
}
@ -278,35 +262,14 @@ public class IrisRegion extends IrisRegistrant implements IRare {
});
}
public KList<IrisBiome> getRealSkylandBiomes(ContextualChunkGenerator g) {
return realSkylandBiomes.aquire(() -> {
KList<IrisBiome> realSkylandBiomes = new KList<>();
for (String i : getSkylandBiomes()) {
realSkylandBiomes.add((g == null ? Iris.globaldata : g.getData()).getBiomeLoader().load(i));
}
return realSkylandBiomes;
});
}
public KList<IrisBiome> getRealIslandBiomes(ContextualChunkGenerator g) {
return realIslandBiomes.aquire(() -> {
KList<IrisBiome> realIslandBiomes = new KList<>();
for (String i : getIslandBiomes()) {
realIslandBiomes.add((g == null ? Iris.globaldata : g.getData()).getBiomeLoader().load(i));
}
return realIslandBiomes;
});
}
public KList<IrisBiome> getRealShoreBiomes(ContextualChunkGenerator g) {
return realShoreBiomes.aquire(() -> {
public KList<IrisBiome> getRealShoreBiomes(ContextualChunkGenerator g)
{
return realShoreBiomes.aquire(() ->
{
KList<IrisBiome> realShoreBiomes = new KList<>();
for (String i : getShoreBiomes()) {
for(String i : getShoreBiomes())
{
realShoreBiomes.add((g == null ? Iris.globaldata : g.getData()).getBiomeLoader().load(i));
}
@ -314,11 +277,14 @@ public class IrisRegion extends IrisRegistrant implements IRare {
});
}
public KList<IrisBiome> getRealSeaBiomes(ContextualChunkGenerator g) {
return realSeaBiomes.aquire(() -> {
public KList<IrisBiome> getRealSeaBiomes(ContextualChunkGenerator g)
{
return realSeaBiomes.aquire(() ->
{
KList<IrisBiome> realSeaBiomes = new KList<>();
for (String i : getSeaBiomes()) {
for(String i : getSeaBiomes())
{
realSeaBiomes.add((g == null ? Iris.globaldata : g.getData()).getBiomeLoader().load(i));
}
@ -326,11 +292,14 @@ public class IrisRegion extends IrisRegistrant implements IRare {
});
}
public KList<IrisBiome> getRealLandBiomes(ContextualChunkGenerator g) {
return realLandBiomes.aquire(() -> {
public KList<IrisBiome> getRealLandBiomes(ContextualChunkGenerator g)
{
return realLandBiomes.aquire(() ->
{
KList<IrisBiome> realLandBiomes = new KList<>();
for (String i : getLandBiomes()) {
for(String i : getLandBiomes())
{
realLandBiomes.add((g == null ? Iris.globaldata : g.getData()).getBiomeLoader().load(i));
}

View File

@ -103,6 +103,8 @@ public class PregenJob
public void nextPosition()
{
int lx = mcaX;
int lz = mcaZ;
rcx++;
if(rcx > 31)
@ -140,10 +142,47 @@ public class PregenJob
onDone.run();
}
}
if(!completed)
{
try
{
verify(lx, lz);
Iris.verbose("Verified " + lx + " " + lz);
}
catch(Throwable e)
{
e.printStackTrace();
}
}
}
}
}
private void verify(int lx, int lz) throws Throwable
{
for(int x = 0; x < 32; x++)
{
for(int z = 0; z < 32; z++)
{
if(isChunkWithin(x + (lx * 32), z + (lz * 32)))
{
Chunk c = world.getChunkAt(x + (lx * 32), z + (lz * 32));
c.load(true);
}
}
}
saveAll();
}
public void saveAll()
{
world.save();
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "save-all");
}
public void gen()
{
try
@ -152,7 +191,6 @@ public class PregenJob
{
Chunk c = world.getChunkAt(rcx + minMCA(mcaX), rcz + minMCA(mcaZ));
c.load(true);
world.unloadChunkRequest(rcx + minMCA(mcaX), rcz + minMCA(mcaZ));
genned++;
}
}