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

View File

@ -27,8 +27,6 @@ public class GenLayerBiome extends GenLayer
private BiomeDataProvider landProvider; private BiomeDataProvider landProvider;
private BiomeDataProvider shoreProvider; private BiomeDataProvider shoreProvider;
private BiomeDataProvider caveProvider; private BiomeDataProvider caveProvider;
private BiomeDataProvider islandProvider;
private BiomeDataProvider skylandProvider;
private DimensionChunkGenerator iris; private DimensionChunkGenerator iris;
public GenLayerBiome(DimensionChunkGenerator iris, RNG rng) public GenLayerBiome(DimensionChunkGenerator iris, RNG rng)
@ -39,8 +37,6 @@ public class GenLayerBiome extends GenLayer
landProvider = new BiomeDataProvider(this, InferredType.LAND, rng); landProvider = new BiomeDataProvider(this, InferredType.LAND, rng);
shoreProvider = new BiomeDataProvider(this, InferredType.SHORE, rng); shoreProvider = new BiomeDataProvider(this, InferredType.SHORE, rng);
caveProvider = new BiomeDataProvider(this, InferredType.CAVE, 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()); 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()); 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; return caveProvider;
} }
else if(type.equals(InferredType.ISLAND))
{
return islandProvider;
}
else if(type.equals(InferredType.SKYLAND))
{
return skylandProvider;
}
else else
{ {
Iris.error("Cannot find a BiomeDataProvider for type " + type.name()); Iris.error("Cannot find a BiomeDataProvider for type " + type.name());
@ -119,18 +105,20 @@ public class GenLayerBiome extends GenLayer
double x = bx; double x = bx;
double z = bz; double z = bz;
double c = iris.getDimension().getLandChance(); double c = iris.getDimension().getLandChance();
InferredType bridge;
if(c >= 1) if(c >= 1)
{ {
return InferredType.LAND; bridge = InferredType.LAND;
} }
if(c <= 0) 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) 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 @DontObfuscate
CAVE, CAVE,
@DontObfuscate
ISLAND,
@DontObfuscate
SKYLAND,
@DontObfuscate @DontObfuscate
DEFER; 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.") @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; 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) @MinNumber(1)
@MaxNumber(512) @MaxNumber(512)
@DontObfuscate @DontObfuscate
@ -226,11 +230,11 @@ public class IrisBiome extends IrisRegistrant implements IRare
return data; 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> data = new KList<>();
KList<BlockData> real = new KList<>(); KList<BlockData> real = new KList<>();
int maxDepth = Math.min(maxDepthf, getLockLayersMax());
if(maxDepth <= 0) if(maxDepth <= 0)
{ {
return data; return data;

View File

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

View File

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

View File

@ -103,6 +103,8 @@ public class PregenJob
public void nextPosition() public void nextPosition()
{ {
int lx = mcaX;
int lz = mcaZ;
rcx++; rcx++;
if(rcx > 31) if(rcx > 31)
@ -140,9 +142,46 @@ public class PregenJob
onDone.run(); 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() public void gen()
{ {
@ -152,7 +191,6 @@ public class PregenJob
{ {
Chunk c = world.getChunkAt(rcx + minMCA(mcaX), rcz + minMCA(mcaZ)); Chunk c = world.getChunkAt(rcx + minMCA(mcaX), rcz + minMCA(mcaZ));
c.load(true); c.load(true);
world.unloadChunkRequest(rcx + minMCA(mcaX), rcz + minMCA(mcaZ));
genned++; genned++;
} }
} }