mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 16:54:04 +00:00
Allow empty sea and shore lists
- Keep the column biome when a region lists no shore biomes - Keep the column biome when a region lists no sea biomes - Pick continental sea from land in regions without sea biomes - Fail complex compile when a region has no usable land biome - Report regions without landBiomes as blocking validation errors - Report regions whose land biomes are all version-excluded - Use the region-aware base type in studio map noise views - Handle missing sea biomes in studio sea layer views
This commit is contained in:
10 files changed
+281
-25
No files matched your search
@@ -269,9 +269,13 @@ public final class DimensionTerrainContext implements DataProvider {
|
||||
Interpolated.of(value -> 0D, value -> focusBiome.getInferredType())
|
||||
);
|
||||
|
||||
boolean sealessRegions = IrisComplex.lacks(preparedBiomeStreams, InferredType.SEA);
|
||||
ProceduralStream<IrisBiome> proceduralBaseBiomeStream = focusBiome == null
|
||||
? bridgeStream
|
||||
.convertAware2D((type, x, z) -> {
|
||||
.convertAware2D((continent, x, z) -> {
|
||||
InferredType type = sealessRegions
|
||||
? IrisComplex.baseType(preparedBiomeStreams, regionStream.get(x, z), continent)
|
||||
: continent;
|
||||
ProceduralStream<IrisBiome> stream = inferredStreams.get(type);
|
||||
return stream != null
|
||||
? stream.get(x, z)
|
||||
@@ -536,13 +540,17 @@ public final class DimensionTerrainContext implements DataProvider {
|
||||
IrisRegion region,
|
||||
InferredType type
|
||||
) {
|
||||
if ((type == InferredType.SEA || type == InferredType.SHORE) && loadInferredBiomes(runtime.data(), biomeKeys(region, type), type).isEmpty()) {
|
||||
return IrisComplex.NO_BIOMES;
|
||||
}
|
||||
return switch (type) {
|
||||
case LAND -> dimension.getLandBiomeStyle()
|
||||
.create(rng.nextParallelRNG(InferredType.LAND.ordinal()), runtime).stream()
|
||||
.zoom(dimension.getBiomeZoom())
|
||||
.zoom(dimension.getLandZoom())
|
||||
.zoom(region.getLandBiomeZoom())
|
||||
.selectRarity(loadInferredBiomes(runtime.data(), region.getLandBiomes(), InferredType.LAND));
|
||||
.selectRarity(IrisComplex.requireLandBiomes(region,
|
||||
loadInferredBiomes(runtime.data(), region.getLandBiomes(), InferredType.LAND)));
|
||||
case SEA -> dimension.getSeaBiomeStyle()
|
||||
.create(rng.nextParallelRNG(InferredType.SEA.ordinal()), runtime).stream()
|
||||
.zoom(dimension.getBiomeZoom())
|
||||
@@ -558,6 +566,10 @@ public final class DimensionTerrainContext implements DataProvider {
|
||||
};
|
||||
}
|
||||
|
||||
private static KList<String> biomeKeys(IrisRegion region, InferredType type) {
|
||||
return type == InferredType.SEA ? region.getSeaBiomes() : region.getShoreBiomes();
|
||||
}
|
||||
|
||||
private static KList<IrisBiome> loadInferredBiomes(
|
||||
IrisData data,
|
||||
KList<String> keys,
|
||||
|
||||
@@ -154,6 +154,12 @@ public class IrisComplex implements DataProvider {
|
||||
InferredType.SEA,
|
||||
InferredType.SHORE
|
||||
};
|
||||
/**
|
||||
* The biome stream of a sea or shore list a region leaves empty. It answers null everywhere, which tells the
|
||||
* surface resolution to keep the column's own biome instead of converting it.
|
||||
*/
|
||||
static final ProceduralStream<IrisBiome> NO_BIOMES = ProceduralStream.of((x, z) -> null,
|
||||
Interpolated.of(value -> 0D, value -> null));
|
||||
@Getter(AccessLevel.NONE)
|
||||
private final transient ThreadSlots<GridBoundsCache> gridBoundsCache = new ThreadSlots<>(GridBoundsCache::new);
|
||||
@Getter(AccessLevel.NONE)
|
||||
@@ -206,6 +212,8 @@ public class IrisComplex implements DataProvider {
|
||||
private ProceduralStream<Double> regionStyleStream;
|
||||
private ProceduralStream<Double> regionIdentityStream;
|
||||
private ProceduralStream<InferredType> bridgeStream;
|
||||
@Getter(AccessLevel.NONE)
|
||||
private ProceduralStream<InferredType> baseTypeStream;
|
||||
private ProceduralStream<IrisBiome> landBiomeStream;
|
||||
private ProceduralStream<IrisBiome> caveBiomeStream;
|
||||
private ProceduralStream<IrisBiome> seaBiomeStream;
|
||||
@@ -455,9 +463,15 @@ public class IrisComplex implements DataProvider {
|
||||
bridgeStream = focusedBiomes != null ? focusedBiomes.convert(IrisBiome::getInferredType) :
|
||||
ContinentGenerator.create(engine.getDimension(), rng, packRuntime).stream()
|
||||
.convert((v) -> v >= engine.getDimension().getLandChance() ? InferredType.SEA : InferredType.LAND);
|
||||
// A region without sea biomes picks its continental sea from its land biomes.
|
||||
baseTypeStream = focusedBiomes != null || !lacks(inferredBiomeStreams, InferredType.SEA) ? bridgeStream
|
||||
: ProceduralStream.of(
|
||||
(x, z) -> baseType(inferredBiomeStreams, contextRegionStream.get(x, z), bridgeStream.get(x, z)),
|
||||
(x, y, z) -> baseType(inferredBiomeStreams, contextRegionStream.get(x, z), bridgeStream.get(x, y, z)),
|
||||
Interpolated.of(value -> 0D, value -> null));
|
||||
ProceduralStream<IrisBiome> proceduralBaseBiomeStream = focusedBiomes != null ? focusedBiomes
|
||||
: ProceduralStream.of(this::proceduralBaseBiome,
|
||||
(x, y, z) -> implode(inferredByType.get(bridgeStream.get(x, y, z)).get(x, z), x, z),
|
||||
(x, y, z) -> implode(inferredByType.get(baseTypeStream.get(x, y, z)).get(x, z), x, z),
|
||||
Interpolated.of(value -> 0D, value -> null));
|
||||
baseBiomeSource = focusedBiomes != null || !imageMapRuntime.has(IrisImageMapApplication.BIOME)
|
||||
? proceduralBaseBiomeStream : ProceduralStream.of((x, z) -> {
|
||||
@@ -1067,7 +1081,7 @@ public class IrisComplex implements DataProvider {
|
||||
}
|
||||
|
||||
private IrisBiome proceduralBaseBiome(double x, double z) {
|
||||
return implode(inferredByType.get(bridgeStream.get(x, z)).get(x, z), x, z);
|
||||
return implode(inferredByType.get(baseTypeStream.get(x, z)).get(x, z), x, z);
|
||||
}
|
||||
|
||||
private final class BakeSource implements PlaneSource {
|
||||
@@ -1168,9 +1182,53 @@ public class IrisComplex implements DataProvider {
|
||||
InferredType inferredType,
|
||||
IrisBiome emptyBiome
|
||||
) {
|
||||
ProceduralStream<IrisBiome> picked = new RarityStream<>(biomePickNoiseStream(engine.getDimension(), region, inferredType),
|
||||
loadInferredBiomes(biomeKeys(region, inferredType), inferredType));
|
||||
return inferredType == InferredType.CAVE ? picked.onNull(emptyBiome) : picked;
|
||||
ProceduralStream<Double> noise = biomePickNoiseStream(engine.getDimension(), region, inferredType);
|
||||
KList<IrisBiome> biomes = loadInferredBiomes(biomeKeys(region, inferredType), inferredType);
|
||||
return switch (inferredType) {
|
||||
case CAVE -> new RarityStream<>(noise, biomes).onNull(emptyBiome);
|
||||
case LAND -> new RarityStream<>(noise, requireLandBiomes(region, biomes));
|
||||
case SEA, SHORE -> biomes.isEmpty() ? NO_BIOMES : new RarityStream<>(noise, biomes);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Every region needs a land biome: the surface falls back to land wherever it leaves sea or shore, and a region
|
||||
* without sea biomes picks its continental sea from land too.
|
||||
*/
|
||||
static KList<IrisBiome> requireLandBiomes(IrisRegion region, KList<IrisBiome> landBiomes) {
|
||||
if (!landBiomes.isEmpty()) {
|
||||
return landBiomes;
|
||||
}
|
||||
String regionKey = region.getLoadKey() == null || region.getLoadKey().isBlank() ? "<unkeyed>" : region.getLoadKey();
|
||||
throw new IllegalStateException(region.getLandBiomes().isEmpty()
|
||||
? "Region '" + regionKey + "' has no landBiomes; every region needs at least one land biome."
|
||||
: "Region '" + regionKey + "' has no landBiomes this Minecraft version can generate; every listed land biome is excluded.");
|
||||
}
|
||||
|
||||
/** Whether any prepared region left the given biome list empty. */
|
||||
static boolean lacks(Map<IrisRegion, Map<InferredType, ProceduralStream<IrisBiome>>> streams, InferredType inferredType) {
|
||||
for (Map<InferredType, ProceduralStream<IrisBiome>> regionStreams : streams.values()) {
|
||||
if (regionStreams.get(inferredType) == NO_BIOMES) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** The biome list a spot's base biome comes from: the continent's choice, or land where the region has no sea. */
|
||||
static InferredType baseType(
|
||||
Map<IrisRegion, Map<InferredType, ProceduralStream<IrisBiome>>> streams,
|
||||
IrisRegion region,
|
||||
InferredType continent
|
||||
) {
|
||||
return continent == InferredType.SEA && preparedInferredBiomeStream(streams, region, InferredType.SEA) == NO_BIOMES
|
||||
? InferredType.LAND
|
||||
: continent;
|
||||
}
|
||||
|
||||
/** The biome list the given region picks this spot's base biome from. */
|
||||
public InferredType baseTypeIn(IrisRegion region, double x, double z) {
|
||||
return baseTypeStream == bridgeStream ? bridgeStream.get(x, z) : baseType(inferredBiomeStreams, region, bridgeStream.get(x, z));
|
||||
}
|
||||
|
||||
private ProceduralStream<Double> biomePickNoiseStream(IrisDimension dimension, IrisRegion region, InferredType inferredType) {
|
||||
@@ -1252,7 +1310,7 @@ public class IrisComplex implements DataProvider {
|
||||
if (focusBiome != null) {
|
||||
return new BiomePick(focusBiome, focusBiome.getInferredType());
|
||||
}
|
||||
InferredType type = bridgeStream.get(x, z);
|
||||
InferredType type = baseTypeIn(region, x, z);
|
||||
return new BiomePick(implode(createInferredBiomeStream(region, type).get(x, z), x, z), type);
|
||||
}
|
||||
|
||||
@@ -1924,7 +1982,7 @@ public class IrisComplex implements DataProvider {
|
||||
|
||||
if (height >= fluidHeight - 1 && !biome.isShore()) {
|
||||
if (!aboveShoreBand(height, region, x, z, fluidHeight, shoreSlopes)) {
|
||||
return shoreBiomes.get(x, z);
|
||||
return convertedOrKept(shoreBiomes.get(x, z), biome);
|
||||
}
|
||||
if (!biome.isLand()) {
|
||||
return landBiomes.get(x, z);
|
||||
@@ -1934,16 +1992,21 @@ public class IrisComplex implements DataProvider {
|
||||
}
|
||||
|
||||
if (height < fluidHeight && !biome.isAquatic()) {
|
||||
return seaBiomes.get(x, z);
|
||||
return convertedOrKept(seaBiomes.get(x, z), biome);
|
||||
}
|
||||
|
||||
if (height == fluidHeight && !biome.isShore()) {
|
||||
return shoreBiomes.get(x, z);
|
||||
return convertedOrKept(shoreBiomes.get(x, z), biome);
|
||||
}
|
||||
|
||||
return biome;
|
||||
}
|
||||
|
||||
// A null conversion comes from NO_BIOMES: the region lists no biomes of that type, so the column keeps its own.
|
||||
private static IrisBiome convertedOrKept(IrisBiome converted, IrisBiome biome) {
|
||||
return converted == null ? biome : converted;
|
||||
}
|
||||
|
||||
private double interpolateGenerators(Engine engine, IrisInterpolator interpolator, int interpolatorIndex, IrisGenerator[] generators, double x, double z, long seed) {
|
||||
if (generators.length == 0) {
|
||||
return 0;
|
||||
@@ -2536,7 +2599,7 @@ public class IrisComplex implements DataProvider {
|
||||
|
||||
private List<IrisBiome> childLineage(IrisBiome biome, int x, int z) {
|
||||
IrisBiome[] rootFirst = new IrisBiome[IrisBiome.CHILD_HOPS + 1];
|
||||
IrisBiome current = inferredByType.get(bridgeStream.get(x, z)).get(x, z);
|
||||
IrisBiome current = inferredByType.get(baseTypeStream.get(x, z)).get(x, z);
|
||||
rootFirst[0] = current;
|
||||
int size = 1;
|
||||
for (int hop = 0; hop < IrisBiome.CHILD_HOPS && !current.getChildren().isEmpty(); hop++) {
|
||||
@@ -2885,7 +2948,7 @@ public class IrisComplex implements DataProvider {
|
||||
if (constant != null) {
|
||||
return constant;
|
||||
}
|
||||
InferredType type = pick != null ? pick.type() : complex.bridgeStream.get(x, z);
|
||||
InferredType type = pick != null ? pick.type() : complex.baseTypeIn(region, x, z);
|
||||
constant = constants == null ? null : constants.typed(type, group);
|
||||
if (constant != null) {
|
||||
return constant;
|
||||
|
||||
@@ -104,12 +104,13 @@ final class PackDimensionValidator {
|
||||
continue;
|
||||
}
|
||||
|
||||
int anyBiome = countBiomeRefs(regionJson, "landBiomes", biomesFolder, regionKey, warnings)
|
||||
+ countBiomeRefs(regionJson, "seaBiomes", biomesFolder, regionKey, warnings)
|
||||
+ countBiomeRefs(regionJson, "shoreBiomes", biomesFolder, regionKey, warnings)
|
||||
+ countBiomeRefs(regionJson, "caveBiomes", biomesFolder, regionKey, warnings);
|
||||
if (anyBiome == 0) {
|
||||
blockingErrors.add("Region '" + regionKey + "' has no resolvable biomes.");
|
||||
// Sea, shore and cave lists may be empty; land is what every other list falls back to.
|
||||
int landBiomes = countBiomeRefs(regionJson, "landBiomes", biomesFolder, regionKey, warnings);
|
||||
countBiomeRefs(regionJson, "seaBiomes", biomesFolder, regionKey, warnings);
|
||||
countBiomeRefs(regionJson, "shoreBiomes", biomesFolder, regionKey, warnings);
|
||||
countBiomeRefs(regionJson, "caveBiomes", biomesFolder, regionKey, warnings);
|
||||
if (landBiomes == 0) {
|
||||
blockingErrors.add("Region '" + regionKey + "' has no landBiomes; every region needs at least one land biome.");
|
||||
}
|
||||
resolvedRegions++;
|
||||
}
|
||||
|
||||
@@ -211,6 +211,7 @@ public final class PackValidator {
|
||||
applyCompatFindings(minecraftVersion, dimensions.anyExcluded(), findings, blockingErrors, warnings);
|
||||
applyRequireAllContent(packFolder.getName(), dimensions.reachedByRequiringDimension(),
|
||||
minecraftVersion, findings, blockingErrors);
|
||||
addDistinct(blockingErrors, excludedLandErrors(data, dimensions.regionKeys(), minecraftVersion));
|
||||
return findings;
|
||||
} catch (Throwable e) {
|
||||
IrisLogging.reportError("Version-content gating failed for pack '" + packFolder.getName() + "'", e);
|
||||
@@ -239,6 +240,7 @@ public final class PackValidator {
|
||||
private static GatedDimensions loadEverything(File packFolder, IrisData data, File[] dimensionFiles) {
|
||||
boolean dimensionExcluded = false;
|
||||
Map<String, Set<String>> reachedByRequiringDimension = new LinkedHashMap<>();
|
||||
Set<String> regionKeys = new LinkedHashSet<>();
|
||||
List<String> folders = data.getLoaders().values().stream().map(ResourceLoader::getFolderName).toList();
|
||||
File dimensionsFolder = new File(packFolder, DIMENSIONS_FOLDER);
|
||||
for (File dimensionFile : dimensionFiles) {
|
||||
@@ -249,6 +251,8 @@ public final class PackValidator {
|
||||
}
|
||||
if (dimension.isCompatExcluded()) {
|
||||
dimensionExcluded = true;
|
||||
} else {
|
||||
regionKeys.addAll(dimension.getRegions());
|
||||
}
|
||||
if (dimension.isRequireAllContent()) {
|
||||
reachedByRequiringDimension.put(dimension.getLoadKey(), PackContentReach.referencedFrom(
|
||||
@@ -271,10 +275,31 @@ public final class PackValidator {
|
||||
for (IrisObjectPlacement placement : placements) {
|
||||
placement.evaluateCompat(data);
|
||||
}
|
||||
return new GatedDimensions(dimensionExcluded, reachedByRequiringDimension);
|
||||
return new GatedDimensions(dimensionExcluded, reachedByRequiringDimension, regionKeys);
|
||||
}
|
||||
|
||||
private record GatedDimensions(boolean anyExcluded, Map<String, Set<String>> reachedByRequiringDimension) {
|
||||
private record GatedDimensions(boolean anyExcluded, Map<String, Set<String>> reachedByRequiringDimension,
|
||||
Set<String> regionKeys) {
|
||||
}
|
||||
|
||||
/**
|
||||
* A region whose land biomes the version-content gate excluded cannot generate. Regions that list no land biome
|
||||
* at all are already reported by {@link PackDimensionValidator}.
|
||||
*/
|
||||
private static List<String> excludedLandErrors(IrisData data, Collection<String> regionKeys, String minecraftVersion) {
|
||||
List<String> errors = new ArrayList<>();
|
||||
for (String regionKey : regionKeys) {
|
||||
IrisRegion region = data.getRegionLoader().load(regionKey, false);
|
||||
if (region == null || region.isCompatExcluded()) {
|
||||
continue;
|
||||
}
|
||||
List<IrisBiome> land = data.getBiomeLoader().loadAll(region.getLandBiomes());
|
||||
if (!land.isEmpty() && land.stream().allMatch(IrisBiome::isCompatExcluded)) {
|
||||
errors.add("Region '" + regionKey + "' has no landBiomes Minecraft " + versionOrUnknown(minecraftVersion)
|
||||
+ " can generate; every listed land biome is excluded.");
|
||||
}
|
||||
}
|
||||
return errors;
|
||||
}
|
||||
|
||||
private static void collectPlacements(IrisRegistrant registrant, Set<IrisObjectPlacement> out) {
|
||||
|
||||
@@ -141,7 +141,7 @@ final class BiomeExplorer {
|
||||
|
||||
private void add(double x, double z) {
|
||||
count++;
|
||||
InferredType type = complex.getBridgeStream().get(x, z);
|
||||
InferredType type = complex.baseTypeIn(region, x, z);
|
||||
for (TypedSpread typed : spreads) {
|
||||
if (typed.type() == type) {
|
||||
typed.spread().add(noiseByType.computeIfAbsent(type, shown -> complex.biomePickNoiseStream(region, shown)).get(x, z));
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
package art.arcane.iris.studio.map;
|
||||
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.iris.generation.biome.IrisBiome;
|
||||
import art.arcane.iris.generation.runtime.IrisComplex;
|
||||
import art.arcane.iris.generation.terrain.IrisRegion;
|
||||
import art.arcane.iris.studio.map.components.MapLayer;
|
||||
@@ -43,7 +44,7 @@ final class PackFileOpener {
|
||||
File file = switch (layer.type()) {
|
||||
case BIOME, HEIGHT, RIVER, OBJECT_LOAD, DECORATOR_LOAD, LAYER_LOAD -> complex.getTrueBiomeStream().get(worldX, worldZ).openInVSCode();
|
||||
case BIOME_LAND -> complex.getLandBiomeStream().get(worldX, worldZ).openInVSCode();
|
||||
case BIOME_SEA -> complex.getSeaBiomeStream().get(worldX, worldZ).openInVSCode();
|
||||
case BIOME_SEA -> openBiome(complex.getSeaBiomeStream().get(worldX, worldZ));
|
||||
case REGION -> complex.getRegionStream().get(worldX, worldZ).openInVSCode();
|
||||
case REGION_PREVIEW -> openPreviewedBiome(engine, layer.previewRegionKey(), worldX, worldZ);
|
||||
case CAVE_LAND -> complex.getCaveBiomeStream().get(worldX, worldZ).openInVSCode();
|
||||
@@ -51,6 +52,11 @@ final class PackFileOpener {
|
||||
return Optional.ofNullable(file).map(File::getName);
|
||||
}
|
||||
|
||||
/** A region without sea biomes has none to open. */
|
||||
private static File openBiome(IrisBiome biome) {
|
||||
return biome == null ? null : biome.openInVSCode();
|
||||
}
|
||||
|
||||
private static File openPreviewedBiome(Engine engine, String regionKey, double worldX, double worldZ) {
|
||||
IrisRegion region = engine.getData().getRegionLoader().load(regionKey);
|
||||
return region == null ? null : engine.getComplex().surfaceBiomeAsIfIn(region, worldX, worldZ).openInVSCode();
|
||||
|
||||
@@ -236,12 +236,11 @@ public final class MapTileRenderer {
|
||||
// The biome view shows each spot's base biome, which its own region picks from the biome list of the spot's type.
|
||||
private static NoiseField baseBiomePickNoise(IrisComplex complex) {
|
||||
ProceduralStream<IrisRegion> regions = complex.getRegionStream();
|
||||
ProceduralStream<InferredType> types = complex.getBridgeStream();
|
||||
Map<IrisRegion, Map<InferredType, ProceduralStream<Double>>> noiseByRegion = new IdentityHashMap<>();
|
||||
return (gridIndex, x, z) -> {
|
||||
IrisRegion region = regions.get(x, z);
|
||||
return noiseByRegion.computeIfAbsent(region, subject -> new EnumMap<>(InferredType.class))
|
||||
.computeIfAbsent(types.get(x, z), type -> complex.biomePickNoiseStream(region, type))
|
||||
.computeIfAbsent(complex.baseTypeIn(region, x, z), type -> complex.biomePickNoiseStream(region, type))
|
||||
.get(x, z);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -176,6 +176,8 @@ public final class IrisRenderer {
|
||||
return Math.max(1, Math.min(resolution, (int) Math.floor(16D / absoluteStep)));
|
||||
}
|
||||
|
||||
private static final int NO_BIOME_COLOR = 0xFF000000;
|
||||
|
||||
private PixelShader shader(RenderType currentType) {
|
||||
IrisComplex complex = renderer.getComplex();
|
||||
return switch (currentType) {
|
||||
@@ -193,6 +195,9 @@ public final class IrisRenderer {
|
||||
IdentityHashMap<IrisBiome, Integer> colors = new IdentityHashMap<>();
|
||||
return (double x, double z) -> {
|
||||
IrisBiome biome = stream.get(x, z);
|
||||
if (biome == null) {
|
||||
return NO_BIOME_COLOR;
|
||||
}
|
||||
Integer color = colors.get(biome);
|
||||
if (color == null) {
|
||||
color = biome.getColor(renderer, currentType).getRGB();
|
||||
|
||||
+90
@@ -339,6 +339,96 @@ public class IrisComplexSurfaceBiomeTest {
|
||||
assertSame(shore, resolved);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shorelineWithoutShoreBiomesKeepsTheBaseBiome() {
|
||||
IrisBiome base = mock(IrisBiome.class);
|
||||
IrisRegion region = mock(IrisRegion.class);
|
||||
doReturn(false).when(base).isShore();
|
||||
doReturn(3D).when(region).getShoreHeight(12D, 18D);
|
||||
doReturn(1D).when(region).getShoreHeightMin();
|
||||
doReturn(5D).when(region).getShoreHeightMax();
|
||||
|
||||
IrisBiome resolved = IrisComplex.resolveSurfaceBiome(
|
||||
63D,
|
||||
base,
|
||||
region,
|
||||
12D,
|
||||
18D,
|
||||
63D,
|
||||
constant(base),
|
||||
constant(base),
|
||||
IrisComplex.NO_BIOMES,
|
||||
constantSlope(0D)
|
||||
);
|
||||
|
||||
assertSame(base, resolved);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void belowFluidWithoutSeaBiomesKeepsTheBaseBiome() {
|
||||
IrisBiome base = mock(IrisBiome.class);
|
||||
IrisRegion region = mock(IrisRegion.class);
|
||||
doReturn(false).when(base).isShore();
|
||||
doReturn(true).when(base).isLand();
|
||||
doReturn(false).when(base).isAquatic();
|
||||
doReturn(3D).when(region).getShoreHeight(12D, 18D);
|
||||
doReturn(1D).when(region).getShoreHeightMin();
|
||||
doReturn(5D).when(region).getShoreHeightMax();
|
||||
|
||||
IrisBiome resolved = IrisComplex.resolveSurfaceBiome(
|
||||
50D,
|
||||
base,
|
||||
region,
|
||||
12D,
|
||||
18D,
|
||||
63D,
|
||||
constant(base),
|
||||
IrisComplex.NO_BIOMES,
|
||||
IrisComplex.NO_BIOMES,
|
||||
constantSlope(0D)
|
||||
);
|
||||
|
||||
assertSame(base, resolved);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void continentSeaInARegionWithoutSeaBiomesPicksFromLand() {
|
||||
IrisRegion sealess = mock(IrisRegion.class);
|
||||
IrisRegion coastal = mock(IrisRegion.class);
|
||||
IrisBiome sea = mock(IrisBiome.class);
|
||||
java.util.Map<IrisRegion, java.util.Map<InferredType, ProceduralStream<IrisBiome>>> streams =
|
||||
IrisComplex.compileInferredBiomeStreams(List.of(sealess, coastal),
|
||||
(IrisRegion region, InferredType type) -> region == sealess && type == InferredType.SEA
|
||||
? IrisComplex.NO_BIOMES : constant(sea));
|
||||
|
||||
assertEquals(InferredType.LAND, IrisComplex.baseType(streams, sealess, InferredType.SEA));
|
||||
assertEquals(InferredType.LAND, IrisComplex.baseType(streams, sealess, InferredType.LAND));
|
||||
assertEquals(InferredType.SEA, IrisComplex.baseType(streams, coastal, InferredType.SEA));
|
||||
assertTrue(IrisComplex.lacks(streams, InferredType.SEA));
|
||||
assertFalse(IrisComplex.lacks(IrisComplex.compileInferredBiomeStreams(List.of(coastal),
|
||||
(IrisRegion region, InferredType type) -> constant(sea)), InferredType.SEA));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void regionWithoutUsableLandBiomesFailsNamingIt() {
|
||||
IrisRegion listed = new IrisRegion();
|
||||
listed.setLoadKey("void");
|
||||
listed.setLandBiomes(new KList<>("gone"));
|
||||
IrisRegion unlisted = new IrisRegion();
|
||||
unlisted.setLoadKey("bare");
|
||||
|
||||
IllegalStateException excluded = assertThrows(IllegalStateException.class,
|
||||
() -> IrisComplex.requireLandBiomes(listed, new KList<>()));
|
||||
IllegalStateException empty = assertThrows(IllegalStateException.class,
|
||||
() -> IrisComplex.requireLandBiomes(unlisted, new KList<>()));
|
||||
KList<IrisBiome> land = new KList<>(new IrisBiome());
|
||||
|
||||
assertTrue(excluded.getMessage(), excluded.getMessage().contains("Region 'void'"));
|
||||
assertTrue(excluded.getMessage(), excluded.getMessage().contains("Minecraft version"));
|
||||
assertTrue(empty.getMessage(), empty.getMessage().contains("Region 'bare'"));
|
||||
assertSame(land, IrisComplex.requireLandBiomes(unlisted, land));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void raisedAquaticBiomeReturnsToLand() {
|
||||
IrisBiome aquatic = mock(IrisBiome.class);
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
package art.arcane.iris.pack;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class PackValidatorRegionLandBiomesTest {
|
||||
@Rule
|
||||
public TemporaryFolder temporaryFolder = new TemporaryFolder();
|
||||
|
||||
@Test
|
||||
public void regionWithoutLandBiomesIsBlockingAndNamesTheRegion() throws IOException {
|
||||
List<String> errors = validate("{\"seaBiomes\":[\"ocean\"],\"shoreBiomes\":[\"ocean\"]}");
|
||||
|
||||
assertEquals(List.of("Region 'island' has no landBiomes; every region needs at least one land biome."), errors);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void regionWithOnlyMissingLandBiomesIsBlocking() throws IOException {
|
||||
List<String> errors = validate("{\"landBiomes\":[\"absent\"],\"seaBiomes\":[\"ocean\"]}");
|
||||
|
||||
assertEquals(List.of("Region 'island' has no landBiomes; every region needs at least one land biome."), errors);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void regionWithLandButNoSeaOrShoreBiomesIsValid() throws IOException {
|
||||
List<String> errors = validate("{\"landBiomes\":[\"ocean\"]}");
|
||||
|
||||
assertTrue(errors.toString(), errors.isEmpty());
|
||||
}
|
||||
|
||||
private List<String> validate(String region) throws IOException {
|
||||
File pack = temporaryFolder.newFolder();
|
||||
File dimensions = new File(pack, PackValidator.DIMENSIONS_FOLDER);
|
||||
File regions = new File(pack, "regions");
|
||||
File biomes = new File(pack, "biomes");
|
||||
assertTrue(dimensions.mkdirs() && regions.mkdirs() && biomes.mkdirs());
|
||||
File dimension = new File(dimensions, "main.json");
|
||||
Files.writeString(dimension.toPath(), "{\"regions\":[\"island\"]}");
|
||||
Files.writeString(new File(regions, "island.json").toPath(), region);
|
||||
Files.writeString(new File(biomes, "ocean.json").toPath(), "{}");
|
||||
List<String> errors = new ArrayList<>();
|
||||
PackDimensionValidator.validateDimensions(pack, new File[]{dimension}, errors, new ArrayList<>());
|
||||
return errors;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user