mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 16:54:04 +00:00
Give cave ceiling layers their own thickness noise
Ceiling layers borrowed the thickness noise of the surface layer at the same index, so ceiling layers beyond the surface layer count were dropped and the validator rejected such packs. Each ceiling layer now has its own cached noise, seeded as before, every declared layer is generated, and the validator accepts any count.
TerrainLayersPinTest re-baselined (length 143112 -> 147047, hash 149645537 -> 216639495). Only the MEADOW ceiling output changed, in both the plain and the exploded runs; surface, sea and smoothing output of every biome is identical, and the biomes without ceiling layers are untouched:
- MEADOW ceiling, plain: 5724 -> 7400 characters. Its fourth layer (basalt) is now emitted instead of cut off at the three surface layers.
- MEADOW ceiling, exploded: 13788 -> 16047 characters. Same fourth layer, plus the barrier separators around it.
- Layers 0 to 2 of MEADOW's ceiling now take thickness from their own style and zoom instead of the surface layers' (SIMPLEX zoom 0.3 against the default style for layer 0, the default style against CELLULAR zoom 0.25 for layer 1), so their block counts change at most columns, e.g. column -400,-400 went from "clay tuff deepslate calcite" to "clay clay tuff deepslate tuff calcite basalt".
Upstream: 23bad0e1a
This commit is contained in:
1 parent
5a2c5b2592
commit
7b2a232a42
8 files changed
+160
-60
No files matched your search
@@ -11,7 +11,6 @@ import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class PackBiomeLayerValidatorTest {
|
||||
@@ -19,25 +18,21 @@ public class PackBiomeLayerValidatorTest {
|
||||
public TemporaryFolder temporaryFolder = new TemporaryFolder();
|
||||
|
||||
@Test
|
||||
public void rejectsMoreCeilingLayersThanLayers() throws Exception {
|
||||
public void acceptsMoreCeilingLayersThanSurfaceLayers() throws Exception {
|
||||
File pack = temporaryFolder.newFolder("pack");
|
||||
write(pack, "biomes/nested/cave.json",
|
||||
"{\"layers\":[{}],\"caveCeilingLayers\":[{},{},{}]}");
|
||||
|
||||
assertEquals(List.of(
|
||||
"Biome 'nested/cave' declares 3 caveCeilingLayers but only 1 layers. caveCeilingLayers reuses the layers height generators and must not have more entries."
|
||||
), PackBiomeLayerValidator.validateCeilingLayerCounts(new File(pack, "biomes")));
|
||||
assertTrue(PackBiomeLayerValidator.validateLayers(new File(pack, "biomes")).isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void respectsIndependentDefaultsWhenFieldsAreAbsent() throws Exception {
|
||||
public void acceptsCeilingLayersWhenSurfaceLayersAreAbsent() throws Exception {
|
||||
File pack = temporaryFolder.newFolder("pack");
|
||||
write(pack, "biomes/defaulted.json", "{\"name\":\"Defaulted\"}");
|
||||
write(pack, "biomes/implicit.json", "{\"caveCeilingLayers\":[{},{}]}");
|
||||
|
||||
assertEquals(List.of(
|
||||
"Biome 'implicit' declares 2 caveCeilingLayers but only 1 layers. caveCeilingLayers reuses the layers height generators and must not have more entries."
|
||||
), PackBiomeLayerValidator.validateCeilingLayerCounts(new File(pack, "biomes")));
|
||||
assertTrue(PackBiomeLayerValidator.validateLayers(new File(pack, "biomes")).isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -45,7 +40,7 @@ public class PackBiomeLayerValidatorTest {
|
||||
File pack = temporaryFolder.newFolder("pack");
|
||||
write(pack, "biomes/ok.json", "{\"layers\":[{},{},{}],\"caveCeilingLayers\":[{},{}]}");
|
||||
|
||||
assertTrue(PackBiomeLayerValidator.validateCeilingLayerCounts(new File(pack, "biomes")).isEmpty());
|
||||
assertTrue(PackBiomeLayerValidator.validateLayers(new File(pack, "biomes")).isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -56,11 +51,11 @@ public class PackBiomeLayerValidatorTest {
|
||||
assertEquals(List.of(
|
||||
"Biome 'bad' layers must be an array.",
|
||||
"Biome 'bad' caveCeilingLayers must be an array."
|
||||
), PackBiomeLayerValidator.validateCeilingLayerCounts(new File(pack, "biomes")));
|
||||
), PackBiomeLayerValidator.validateLayers(new File(pack, "biomes")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void ceilingLayerOverflowBlocksFullPackValidation() throws Exception {
|
||||
public void independentCeilingLayersPassFullPackValidation() throws Exception {
|
||||
File pack = temporaryFolder.newFolder("pack");
|
||||
write(pack, "dimensions/main.json", "{\"regions\":[\"region\"]}");
|
||||
write(pack, "regions/region.json", "{\"landBiomes\":[\"biome\"]}");
|
||||
@@ -68,9 +63,7 @@ public class PackBiomeLayerValidatorTest {
|
||||
|
||||
PackValidationResult result = PackValidator.validate(pack);
|
||||
|
||||
assertFalse(result.isLoadable());
|
||||
assertTrue(result.getBlockingErrors().contains(
|
||||
"Biome 'biome' declares 2 caveCeilingLayers but only 1 layers. caveCeilingLayers reuses the layers height generators and must not have more entries."));
|
||||
assertTrue(result.getBlockingErrors().toString(), result.isLoadable());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -41,8 +41,8 @@ import static org.mockito.Mockito.when;
|
||||
*/
|
||||
public class TerrainLayersPinTest {
|
||||
private static final long TERRAIN_SEED = 1337L;
|
||||
private static final int TRANSCRIPT_LENGTH = 143112;
|
||||
private static final int TRANSCRIPT_HASH = 149645537;
|
||||
private static final int TRANSCRIPT_LENGTH = 147047;
|
||||
private static final int TRANSCRIPT_HASH = 216639495;
|
||||
private static final int COLUMN_STEP_X = 61;
|
||||
private static final int COLUMN_STEP_Z = 67;
|
||||
private static final int COLUMN_RANGE = 400;
|
||||
|
||||
@@ -50,7 +50,7 @@ public class BiomeLayersCeilingGuardTest {
|
||||
KList<BlockState> result = layersOf(data()).generateCeilingLayers(
|
||||
biome, PaletteExplosion.NONE, 0, 0, new RNG(1), 8);
|
||||
|
||||
assertTrue("extra ceiling layers are skipped, not crashed on", result.isEmpty());
|
||||
assertTrue("zeroed palettes with zero heights produce no blocks", result.isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
package art.arcane.iris.engine.terrain;
|
||||
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.core.loader.ResourceLoader;
|
||||
import art.arcane.iris.core.modules.IrisPackResources;
|
||||
import art.arcane.iris.engine.UsableBlockPlatform;
|
||||
import art.arcane.iris.engine.object.material.IrisBlockData;
|
||||
import art.arcane.iris.modules.terrain.BiomeLayers;
|
||||
import art.arcane.iris.modules.terrain.LayeredBiome;
|
||||
import art.arcane.iris.modules.terrain.PaletteExplosion;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.host.ModuleLogs;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class BiomeLayersCeilingTest {
|
||||
private static final int CEILING_DEPTH = 8;
|
||||
private static final int RNG_SEED = 37;
|
||||
private static final int COLUMN_SPAN = 200;
|
||||
private static final int COLUMN_STEP = 7;
|
||||
private static final String CEILING = """
|
||||
"caveCeilingLayers": [
|
||||
{"minHeight": 2, "maxHeight": 2, "palette": [{"block": "moss_block"}]},
|
||||
{"minHeight": 1, "maxHeight": 1, "palette": [{"block": "calcite"}]},
|
||||
{"minHeight": 2, "maxHeight": 2, "palette": [{"block": "basalt"}]}
|
||||
]""";
|
||||
private static final String VARIABLE_CEILING = """
|
||||
"caveCeilingLayers": [
|
||||
{"minHeight": 0, "maxHeight": 6, "zoom": 0.3, "style": {"style": "SIMPLEX", "zoom": 1}, "palette": [{"block": "moss_block"}]},
|
||||
{"minHeight": 0, "maxHeight": 6, "palette": [{"block": "calcite"}]}
|
||||
]""";
|
||||
|
||||
private IrisData data;
|
||||
|
||||
@Before
|
||||
public void bindPlatform() {
|
||||
UsableBlockPlatform.bind();
|
||||
data = mock(IrisData.class);
|
||||
@SuppressWarnings("unchecked")
|
||||
ResourceLoader<IrisBlockData> blocks = mock(ResourceLoader.class);
|
||||
when(data.getBlockLoader()).thenReturn(blocks);
|
||||
when(data.getDataFolder()).thenReturn(new File("pack"));
|
||||
IrisPackResources resources = new IrisPackResources(data);
|
||||
when(data.getPackResources()).thenReturn(resources);
|
||||
}
|
||||
|
||||
@After
|
||||
public void unbindPlatform() {
|
||||
UsableBlockPlatform.unbind();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void emitsEveryCeilingLayerBeyondTheSurfaceLayers() {
|
||||
LayeredBiome biome = biome("{" + CEILING + "}");
|
||||
|
||||
KList<BlockState> blocks = layers().generateCeilingLayers(biome, PaletteExplosion.NONE, 13, -27, new RNG(RNG_SEED), CEILING_DEPTH);
|
||||
|
||||
assertEquals(List.of("moss_block", "moss_block", "calcite", "basalt", "basalt"), keys(blocks));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void ceilingLayerBlockPicksWhatGenerationStacks() {
|
||||
LayeredBiome biome = biome("{" + CEILING + "}");
|
||||
BiomeLayers layers = layers();
|
||||
|
||||
List<String> picked = new ArrayList<>();
|
||||
for (int index = 0; index < 3; index++) {
|
||||
for (int depth = 0; depth < 2; depth++) {
|
||||
BlockState block = layers.ceilingLayerBlock(biome, index, depth, 13, -27, new RNG(RNG_SEED));
|
||||
if (block != null) {
|
||||
picked.add(key(block));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
assertEquals(List.of("moss_block", "moss_block", "calcite", "basalt", "basalt"), picked);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void ceilingThicknessDoesNotDependOnSurfaceLayers() {
|
||||
LayeredBiome bare = biome("{" + VARIABLE_CEILING + "}");
|
||||
LayeredBiome layered = biome("""
|
||||
{"layers": [
|
||||
{"minHeight": 1, "maxHeight": 3, "zoom": 5, "style": {"style": "PERLIN", "zoom": 1}, "palette": [{"block": "dirt"}]},
|
||||
{"minHeight": 1, "maxHeight": 3, "zoom": 9, "style": {"style": "CELLULAR", "zoom": 1}, "palette": [{"block": "stone"}]}],
|
||||
%s}""".formatted(VARIABLE_CEILING));
|
||||
BiomeLayers bareLayers = layers();
|
||||
BiomeLayers layeredLayers = layers();
|
||||
|
||||
for (int x = -COLUMN_SPAN; x <= COLUMN_SPAN; x += COLUMN_STEP) {
|
||||
RNG rng = new RNG(RNG_SEED);
|
||||
assertEquals("column " + x,
|
||||
keys(bareLayers.generateCeilingLayers(bare, PaletteExplosion.NONE, x, -x, rng, CEILING_DEPTH)),
|
||||
keys(layeredLayers.generateCeilingLayers(layered, PaletteExplosion.NONE, x, -x, rng, CEILING_DEPTH)));
|
||||
}
|
||||
}
|
||||
|
||||
private LayeredBiome biome(String json) {
|
||||
return TestLayeredBiomes.of(TerrainTestSettings.of(json));
|
||||
}
|
||||
|
||||
private BiomeLayers layers() {
|
||||
return new BiomeLayers(TestLayerBlocks.of(data.getPackResources()), () -> data.getPackResources().noise(), ModuleLogs.discarding());
|
||||
}
|
||||
|
||||
private static List<String> keys(KList<BlockState> blocks) {
|
||||
List<String> keys = new ArrayList<>();
|
||||
for (BlockState block : blocks) {
|
||||
keys.add(key(block));
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
|
||||
private static String key(BlockState block) {
|
||||
return block.key().replace("minecraft:", "");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user