Hand IrisApi heights above the dimension's bottom: terrain bounds and the mantle bridge no longer use the world's minimum height, and a test covers a dimension that starts at -64

This commit is contained in:
piexel committed 2026-10-08 14:58:04 +02:00
1 parent 9b20fc9c91
commit 818dbef261
10 files changed
+379 -113

No files matched your search

@@ -0,0 +1,229 @@
/*
* Iris is a World Generator for Minecraft Servers
* Copyright (c) 2026 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.core.modules;
import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.engine.IrisComplex;
import art.arcane.iris.engine.UsableBlockPlatform;
import art.arcane.iris.engine.framework.Engine;
import art.arcane.iris.engine.object.placement.IObjectPlacer;
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
import art.arcane.iris.engine.object.prefab.IrisObject;
import art.arcane.iris.engine.object.world.biome.IrisBiome;
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
import art.arcane.iris.engine.object.world.region.IrisRegion;
import art.arcane.iris.spi.PlatformBlockState;
import art.arcane.iris.util.common.data.B;
import art.arcane.iris.util.project.hunk.Hunk;
import art.arcane.iris.util.project.stream.ProceduralStream;
import art.arcane.volmlib.util.math.RNG;
import com.volmit.FeatureRegistry;
import com.volmit.IrisModule;
import com.volmit.ModuleInfo;
import com.volmit.block.BlockState;
import com.volmit.host.LoadedPack;
import com.volmit.host.ModuleHost;
import com.volmit.mantle.BlockBox;
import com.volmit.mantle.MantleCodec;
import com.volmit.mantle.MantleKey;
import com.volmit.mantle.MantleLifetime;
import com.volmit.placement.PlacedBlock;
import com.volmit.stage.Stage;
import com.volmit.stage.StageGraph;
import com.volmit.world.BlockPosition;
import com.volmit.world.TerrainSampler;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
/**
* IrisApi measures every height from the dimension's bottom, whatever the dimension's minimum height is. A
* dimension reaching down to world Y -64 is the case that tells the two apart: a chunk stage, a mantle stage and a
* placement stage each write at height 0 and must hit the bottom block of the dimension, with terrain samples and
* bounds in the same heights.
*/
public class DimensionBottomTest {
private static final int WORLD_MIN_HEIGHT = -64;
private static final int DIMENSION_HEIGHT = 64;
private static final int BOTTOM = 0;
private static final int SURFACE_HEIGHT = 10;
private static final BlockBox WHOLE_HEIGHT_OF_ONE_CHUNK = new BlockBox(0, BOTTOM, 0, 16, DIMENSION_HEIGHT, 16);
private static final BlockState STONE = BlockState.parse("minecraft:stone");
private static final MantleKey<String> MARKS = new MantleKey<>("test:bottom/mark", String.class);
private static final MantleCodec<String> TEXT = new MantleCodec<>() {
public int version() { return 1; }
public void write(DataOutput output, String value) throws IOException { output.writeUTF(value); }
public String read(DataInput input, int storedVersion) throws IOException { return input.readUTF(); }
};
@Rule
public TemporaryFolder folder = new TemporaryFolder();
private final InMemoryMantle storage = new InMemoryMantle(DIMENSION_HEIGHT / 16);
private final List<BlockBox> terrainBounds = new ArrayList<>();
private final List<BlockBox> viewBounds = new ArrayList<>();
private final List<Double> surfaces = new ArrayList<>();
private Engine engine;
private IrisData data;
private LoadedPack pack;
/** Writes its mark and block at height 0 in whichever pipeline it runs, and records the heights it was shown. */
private final class BottomModule implements IrisModule {
public ModuleInfo info() { return ModuleInfo.of("test:bottom", "Bottom", "1"); }
public void install(StageGraph graph) {
graph.define(Stage.chunk("test:bottom/chunk")).run(context -> {
record(context.terrain());
viewBounds.add(context.mantle().bounds());
context.hunk(BlockState.class).set(0, BOTTOM, 0, STONE);
});
graph.define(Stage.mantle("test:bottom/mantle")).reach(0).writesMantle(MARKS).run(context -> {
record(context.terrain());
viewBounds.add(context.mantle().bounds());
context.mantle().layer(MARKS).set(context.originX(), BOTTOM, context.originZ(), "bottom");
});
graph.define(Stage.placement("test:bottom/placement")).run(context -> {
record(context.terrain());
viewBounds.add(context.access().bounds());
IrisPlacement.current().anchoredAt(BOTTOM);
context.access().set(new PlacedBlock(new BlockPosition(0, BOTTOM, 0), STONE, Optional.empty()));
context.access().mantle().layer(MARKS).set(0, BOTTOM, 0, "bottom");
});
}
public void register(FeatureRegistry registry) {
registry.registerMantle(MARKS, MantleLifetime.GENERATION, TEXT);
}
}
private void record(TerrainSampler terrain) {
terrainBounds.add(terrain.bounds());
surfaces.add(terrain.column(0, 0).surfaceY());
}
@Before
public void loadPackOfADimensionBelowWorldYZero() throws IOException {
UsableBlockPlatform.bind();
pack = LoadedPack.load(folder.newFolder("pack").toPath(),
ModuleHost.of(List.of(new BottomModule())).copyingJarsTo(folder.newFolder("copies").toPath()));
engine = mock(Engine.class);
data = mock(IrisData.class);
IrisComplex complex = mock(IrisComplex.class);
when(complex.getHeightStream()).thenReturn(ProceduralStream.ofDouble((x, z) -> (double) SURFACE_HEIGHT));
when(complex.getSlopeStream()).thenReturn(ProceduralStream.ofDouble((x, z) -> 0D));
when(engine.getComplex()).thenReturn(complex);
when(engine.getMinHeight()).thenReturn(WORLD_MIN_HEIGHT);
when(engine.getHeight()).thenReturn(DIMENSION_HEIGHT);
when(engine.getData()).thenReturn(data);
when(engine.getDimension()).thenReturn(new IrisDimension());
when(engine.getRegion(anyInt(), anyInt())).thenReturn(new IrisRegion());
when(engine.getSurfaceBiome(anyInt(), anyInt())).thenReturn(new IrisBiome());
BuiltInPack.seedWorld(engine, 7L);
PackModuleSet moduleSet = mock(PackModuleSet.class);
when(moduleSet.pack()).thenReturn(pack);
when(data.getModules()).thenReturn(moduleSet);
when(data.getDataFolder()).thenReturn(folder.getRoot());
when(data.getEngine()).thenReturn(engine);
storage.bindTo(engine);
}
@After
public void unload() {
pack.close();
UsableBlockPlatform.unbind();
}
@Test
public void aChunkStageWritingAtHeightZeroHitsTheBottomBlockOfTheChunk() {
Hunk<PlatformBlockState> blocks = Hunk.newArrayHunk(16, DIMENSION_HEIGHT, 16);
ModuleChunkGeneration.generate(pack, engine, 0, 0, blocks, null, false, null, B::getState);
assertEquals("minecraft:stone", blocks.get(0, BOTTOM, 0).key());
assertEquals("the chunk's block hunk starts at the bottom, not at the world's minimum height", 1, countBlocks(blocks));
assertSamplesAndBoundsAgree();
}
@Test
public void aMantleStageWritingAtHeightZeroHitsTheBottomOfTheMantle() {
ModuleMantleComponent.forPack(engine, pack, Set.of()).stream()
.filter(component -> component.stage().stage().id().toString().equals("test:bottom/mantle"))
.forEach(component -> component.generate(0, 0, storage::chunk));
assertEquals("bottom", storage.value(MARKS, TEXT, 0, BOTTOM, 0));
assertSamplesAndBoundsAgree();
}
@Test
public void aPlacementStageWritingAtHeightZeroHitsTheBottomBlockAndTheBottomOfTheMantle() {
IObjectPlacer placer = mock(IObjectPlacer.class);
when(placer.getEngine()).thenReturn(engine);
IrisObject object = new IrisObject(1, 1, 1);
object.setUnsigned(0, 0, 0, B.getState("minecraft:stone"));
ModuleObjectPlacement.place(object, 0, BOTTOM, 0, placer, new IrisObjectPlacement(), new RNG(2L), null, null, data);
verify(placer).set(eq(0), eq(BOTTOM), eq(0), any(PlatformBlockState.class));
assertEquals("bottom", storage.value(MARKS, TEXT, 0, BOTTOM, 0));
BlockBox terrain = terrainBounds.getFirst();
assertEquals(BOTTOM, terrain.minY());
assertEquals(DIMENSION_HEIGHT, terrain.maxY());
assertEquals(List.of(Double.valueOf(SURFACE_HEIGHT)), surfaces);
assertTrue("a placement may reach beyond the dimension, so its view holds at least the terrain's heights",
viewBounds.getFirst().contains(terrain));
}
private void assertSamplesAndBoundsAgree() {
assertEquals(List.of(WHOLE_HEIGHT_OF_ONE_CHUNK), terrainBounds);
assertEquals("the mantle view covers the same heights as the terrain", terrainBounds, viewBounds);
assertEquals("the terrain samples count from the same bottom", List.of(Double.valueOf(SURFACE_HEIGHT)), surfaces);
assertTrue(terrainBounds.getFirst().contains(0, SURFACE_HEIGHT, 0));
}
private static int countBlocks(Hunk<PlatformBlockState> blocks) {
int count = 0;
for (int y = 0; y < blocks.getHeight(); y++) {
for (int x = 0; x < blocks.getWidth(); x++) {
for (int z = 0; z < blocks.getDepth(); z++) {
count += blocks.get(x, y, z) != null ? 1 : 0;
}
}
}
return count;
}
}
@@ -75,8 +75,10 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
public class IrisModuleMantleTest {
private static final int MIN_Y = -64;
/** A dimension whose bottom is below world Y 0: IrisApi heights must not depend on it. */
private static final int WORLD_MIN_HEIGHT = -64;
private static final int SECTIONS = 4;
private static final int HEIGHT = SECTIONS * 16;
private static final MantleKey<String> MARKS = new MantleKey<>("iris:marks/mark", String.class);
private static final MantleKey<Integer> DEPTHS = new MantleKey<>("iris:marks/depth", Integer.class);
private static final MantleCodec<String> TEXT = new MantleCodec<>() {
@@ -109,55 +111,55 @@ public class IrisModuleMantleTest {
}
private IrisModuleMantle mantle(BlockBox bounds) {
return new IrisModuleMantle(bounds, MIN_Y, this::chunk, LAYERS);
return new IrisModuleMantle(bounds, this::chunk, LAYERS);
}
@Test
public void layersShareABlockAndReadInWorldCoordinatesAcrossChunks() {
IrisModuleMantle mantle = mantle(new BlockBox(-16, MIN_Y, -16, 32, 0, 32));
IrisModuleMantle mantle = mantle(new BlockBox(-16, 0, -16, 32, HEIGHT, 32));
mantle.layer(MARKS).set(-1, -60, 20, "west");
mantle.layer(MARKS).set(17, -1, 3, "east");
mantle.layer(DEPTHS).set(17, -1, 3, 9);
mantle.layer(MARKS).set(-1, 4, 20, "west");
mantle.layer(MARKS).set(17, 63, 3, "east");
mantle.layer(DEPTHS).set(17, 63, 3, 9);
assertEquals("west", mantle.layer(MARKS).get(-1, -60, 20));
assertEquals("east", mantle.layer(MARKS).get(17, -1, 3));
assertEquals(Integer.valueOf(9), mantle.layer(DEPTHS).get(17, -1, 3));
mantle.layer(MARKS).remove(17, -1, 3);
assertNull(mantle.layer(MARKS).get(17, -1, 3));
assertEquals(Integer.valueOf(9), mantle.layer(DEPTHS).get(17, -1, 3));
assertEquals("west", mantle.layer(MARKS).get(-1, 4, 20));
assertEquals("east", mantle.layer(MARKS).get(17, 63, 3));
assertEquals(Integer.valueOf(9), mantle.layer(DEPTHS).get(17, 63, 3));
mantle.layer(MARKS).remove(17, 63, 3);
assertNull(mantle.layer(MARKS).get(17, 63, 3));
assertEquals(Integer.valueOf(9), mantle.layer(DEPTHS).get(17, 63, 3));
assertEquals("another invocation sees the same mantle", Integer.valueOf(9),
mantle(new BlockBox(16, MIN_Y, 0, 32, 0, 16)).layer(DEPTHS).get(17, -1, 3));
mantle(new BlockBox(16, 0, 0, 32, HEIGHT, 16)).layer(DEPTHS).get(17, 63, 3));
}
@Test
public void visitsInXThenYThenZOrderAndClearsOnlyItsArea() {
IrisModuleMantle mantle = mantle(new BlockBox(-16, MIN_Y, -16, 32, 0, 32));
mantle.layer(MARKS).set(20, -50, 0, "c");
mantle.layer(MARKS).set(-3, -10, 5, "a");
mantle.layer(MARKS).set(20, -60, 9, "b");
mantle.layer(DEPTHS).set(0, -20, 0, 1);
IrisModuleMantle mantle = mantle(new BlockBox(-16, 0, -16, 32, HEIGHT, 32));
mantle.layer(MARKS).set(20, 14, 0, "c");
mantle.layer(MARKS).set(-3, 54, 5, "a");
mantle.layer(MARKS).set(20, 4, 9, "b");
mantle.layer(DEPTHS).set(0, 44, 0, 1);
List<String> visited = new ArrayList<>();
mantle.layer(MARKS).visit(new BlockBox(-16, MIN_Y, -16, 32, 0, 32), (x, y, z, value) -> visited.add(value + "@" + x + "," + y + "," + z));
mantle.layer(MARKS).clear(new BlockBox(16, MIN_Y, -16, 32, 0, 32));
mantle.layer(MARKS).visit(new BlockBox(-16, 0, -16, 32, HEIGHT, 32), (x, y, z, value) -> visited.add(value + "@" + x + "," + y + "," + z));
mantle.layer(MARKS).clear(new BlockBox(16, 0, -16, 32, HEIGHT, 32));
assertEquals(List.of("a@-3,-10,5", "b@20,-60,9", "c@20,-50,0"), visited);
assertNull(mantle.layer(MARKS).get(20, -50, 0));
assertEquals("a", mantle.layer(MARKS).get(-3, -10, 5));
assertEquals(Integer.valueOf(1), mantle.layer(DEPTHS).get(0, -20, 0));
assertEquals(List.of("a@-3,54,5", "b@20,4,9", "c@20,14,0"), visited);
assertNull(mantle.layer(MARKS).get(20, 14, 0));
assertEquals("a", mantle.layer(MARKS).get(-3, 54, 5));
assertEquals(Integer.valueOf(1), mantle.layer(DEPTHS).get(0, 44, 0));
}
@Test
public void refusesLayersNobodyRegisteredWrongTypesAndBlocksOutsideItsBounds() {
IrisModuleMantle mantle = mantle(new BlockBox(0, MIN_Y, 0, 16, 0, 16));
IrisModuleMantle mantle = mantle(new BlockBox(0, 0, 0, 16, HEIGHT, 16));
IllegalArgumentException unregistered = assertThrows(IllegalArgumentException.class,
() -> mantle.layer(new MantleKey<>("iris:marks/other", String.class)));
assertEquals("Mantle layer iris:marks/other is not registered by any module of the pack", unregistered.getMessage());
assertThrows(IllegalArgumentException.class, () -> mantle.layer(new MantleKey<>("iris:marks/mark", Integer.class)));
assertThrows(IndexOutOfBoundsException.class, () -> mantle.layer(MARKS).set(16, -60, 0, "out"));
assertThrows(IndexOutOfBoundsException.class, () -> mantle.layer(MARKS).visit(new BlockBox(0, MIN_Y, 0, 17, 0, 16), (x, y, z, v) -> { }));
assertThrows(IndexOutOfBoundsException.class, () -> mantle.layer(MARKS).set(16, 4, 0, "out"));
assertThrows(IndexOutOfBoundsException.class, () -> mantle.layer(MARKS).visit(new BlockBox(0, 0, 0, 17, HEIGHT, 16), (x, y, z, v) -> { }));
}
@Test
@@ -173,88 +175,88 @@ public class IrisModuleMantleTest {
@Test
public void anEditBuffersChangesAcrossLayersUntilItCommits() {
IrisModuleMantle mantle = mantle(new BlockBox(-16, MIN_Y, -16, 32, 0, 32));
mantle.layer(MARKS).set(1, -60, 1, "stored");
mantle.layer(MARKS).set(2, -60, 1, "removed");
IrisModuleMantle mantle = mantle(new BlockBox(-16, 0, -16, 32, HEIGHT, 32));
mantle.layer(MARKS).set(1, 4, 1, "stored");
mantle.layer(MARKS).set(2, 4, 1, "removed");
List<String> visited = new ArrayList<>();
try (MantleEdit edit = mantle.edit()) {
edit.layer(MARKS).set(20, -50, 0, "added");
edit.layer(MARKS).remove(2, -60, 1);
edit.layer(DEPTHS).set(20, -50, 0, 3);
edit.layer(MARKS).visit(new BlockBox(-16, MIN_Y, -16, 32, 0, 32), (x, y, z, value) -> visited.add(value + "@" + x));
edit.layer(MARKS).set(20, 14, 0, "added");
edit.layer(MARKS).remove(2, 4, 1);
edit.layer(DEPTHS).set(20, 14, 0, 3);
edit.layer(MARKS).visit(new BlockBox(-16, 0, -16, 32, HEIGHT, 32), (x, y, z, value) -> visited.add(value + "@" + x));
assertEquals("added", edit.layer(MARKS).get(20, -50, 0));
assertNull(edit.layer(MARKS).get(2, -60, 1));
assertNull("the mantle is unchanged until the commit", mantle.layer(MARKS).get(20, -50, 0));
assertEquals("removed", mantle.layer(MARKS).get(2, -60, 1));
assertEquals("added", edit.layer(MARKS).get(20, 14, 0));
assertNull(edit.layer(MARKS).get(2, 4, 1));
assertNull("the mantle is unchanged until the commit", mantle.layer(MARKS).get(20, 14, 0));
assertEquals("removed", mantle.layer(MARKS).get(2, 4, 1));
edit.commit();
}
assertEquals(List.of("stored@1", "added@20"), visited);
assertEquals("added", mantle.layer(MARKS).get(20, -50, 0));
assertEquals(Integer.valueOf(3), mantle.layer(DEPTHS).get(20, -50, 0));
assertNull(mantle.layer(MARKS).get(2, -60, 1));
assertEquals("stored", mantle.layer(MARKS).get(1, -60, 1));
assertEquals("added", mantle.layer(MARKS).get(20, 14, 0));
assertEquals(Integer.valueOf(3), mantle.layer(DEPTHS).get(20, 14, 0));
assertNull(mantle.layer(MARKS).get(2, 4, 1));
assertEquals("stored", mantle.layer(MARKS).get(1, 4, 1));
}
@Test
public void aClosedEditChangesNothingAndAnOpenEditKeepsTheMantleReadOnly() {
IrisModuleMantle mantle = mantle(new BlockBox(0, MIN_Y, 0, 16, 0, 16));
IrisModuleMantle mantle = mantle(new BlockBox(0, 0, 0, 16, HEIGHT, 16));
MantleEdit edit = mantle.edit();
MantleLayer<String> marks = edit.layer(MARKS);
marks.set(1, -60, 1, "discarded");
marks.set(1, 4, 1, "discarded");
assertThrows(IllegalStateException.class, () -> mantle.layer(MARKS).set(0, -60, 0, "direct"));
assertThrows(IllegalStateException.class, () -> mantle.layer(MARKS).set(0, 4, 0, "direct"));
assertThrows(IllegalStateException.class, mantle::edit);
assertThrows(UnsupportedOperationException.class, edit::edit);
assertThrows(IndexOutOfBoundsException.class, () -> marks.set(16, -60, 0, "out"));
assertThrows(IndexOutOfBoundsException.class, () -> marks.set(16, 4, 0, "out"));
edit.close();
edit.close();
assertNull(mantle.layer(MARKS).get(1, -60, 1));
IllegalStateException closed = assertThrows(IllegalStateException.class, () -> marks.get(1, -60, 1));
assertNull(mantle.layer(MARKS).get(1, 4, 1));
IllegalStateException closed = assertThrows(IllegalStateException.class, () -> marks.get(1, 4, 1));
assertEquals("This mantle edit is closed; open a new one with edit()", closed.getMessage());
assertThrows(IllegalStateException.class, edit::commit);
mantle.layer(MARKS).set(0, -60, 0, "direct");
mantle.layer(MARKS).set(0, 4, 0, "direct");
mantle.edit().commit();
}
@Test
public void aCommitThatCannotReachEveryChunkPublishesNothing() {
IrisModuleMantle mantle = new IrisModuleMantle(new BlockBox(0, MIN_Y, 0, 32, 0, 16), MIN_Y,
IrisModuleMantle mantle = new IrisModuleMantle(new BlockBox(0, 0, 0, 32, HEIGHT, 16),
(chunkX, chunkZ) -> chunkX == 0 ? chunk(chunkX, chunkZ) : null, LAYERS);
MantleEdit edit = mantle.edit();
edit.layer(MARKS).set(1, -60, 1, "first");
edit.layer(MARKS).set(20, -60, 1, "unprepared");
edit.layer(MARKS).set(1, 4, 1, "first");
edit.layer(MARKS).set(20, 4, 1, "unprepared");
assertThrows(IllegalStateException.class, edit::commit);
assertNull(mantle.layer(MARKS).get(1, -60, 1));
assertNull(mantle.layer(MARKS).get(1, 4, 1));
assertThrows(IllegalStateException.class, edit::commit);
assertThrows(IllegalStateException.class, () -> mantle.layer(MARKS).set(2, -60, 1, "still open"));
assertThrows(IllegalStateException.class, () -> mantle.layer(MARKS).set(2, 4, 1, "still open"));
edit.close();
mantle.layer(MARKS).set(2, -60, 1, "after close");
mantle.layer(MARKS).set(2, 4, 1, "after close");
}
@Test
public void cleanupRemovesGenerationLayersAndKeepsPersistentAndUnknownOnes() throws IOException {
IrisModuleMantle mantle = mantle(new BlockBox(0, MIN_Y, 0, 16, 0, 16));
mantle.layer(MARKS).set(1, -60, 1, "short-lived");
mantle.layer(DEPTHS).set(1, -60, 1, 7);
mantle.layer(MARKS).set(2, -10, 3, "alone");
IrisModuleMantle mantle = mantle(new BlockBox(0, 0, 0, 16, HEIGHT, 16));
mantle.layer(MARKS).set(1, 4, 1, "short-lived");
mantle.layer(DEPTHS).set(1, 4, 1, 7);
mantle.layer(MARKS).set(2, 54, 3, "alone");
MantleKey<String> unknown = new MantleKey<>("iris:gone/layer", String.class);
ModuleLayerValues fromDisk = ModuleLayerValues.read(input(bytes(ModuleLayerValues.EMPTY.with(unknown, TEXT, "kept")
.with(MARKS, TEXT, "old"))));
chunk(0, 0).getOrCreate((-30 - MIN_Y) >> 4).slice(ModuleLayerValues.class).set(4, (-30 - MIN_Y) & 15, 4, fromDisk);
chunk(0, 0).getOrCreate(34 >> 4).slice(ModuleLayerValues.class).set(4, 34 & 15, 4, fromDisk);
GenerationLayers.of(LAYERS).removeFrom(chunk(0, 0));
assertNull(mantle.layer(MARKS).get(1, -60, 1));
assertEquals(Integer.valueOf(7), mantle.layer(DEPTHS).get(1, -60, 1));
assertNull("a block left without values holds nothing", chunk(0, 0).get((-10 - MIN_Y) >> 4)
.<ModuleLayerValues>slice(ModuleLayerValues.class).get(2, (-10 - MIN_Y) & 15, 3));
assertNull(mantle.layer(MARKS).get(4, -30, 4));
ModuleLayerValues left = chunk(0, 0).get((-30 - MIN_Y) >> 4).<ModuleLayerValues>slice(ModuleLayerValues.class).get(4, (-30 - MIN_Y) & 15, 4);
assertNull(mantle.layer(MARKS).get(1, 4, 1));
assertEquals(Integer.valueOf(7), mantle.layer(DEPTHS).get(1, 4, 1));
assertNull("a block left without values holds nothing", chunk(0, 0).get(54 >> 4)
.<ModuleLayerValues>slice(ModuleLayerValues.class).get(2, 54 & 15, 3));
assertNull(mantle.layer(MARKS).get(4, 34, 4));
ModuleLayerValues left = chunk(0, 0).get(34 >> 4).<ModuleLayerValues>slice(ModuleLayerValues.class).get(4, 34 & 15, 4);
assertEquals("a layer no module registers stays", "kept", left.get(unknown, TEXT));
}
@@ -265,7 +267,7 @@ public class IrisModuleMantleTest {
public ModuleInfo info() { return ModuleInfo.of("iris:veins", "Veins", "1"); }
public void install(StageGraph graph) {
graph.define(Stage.mantle("iris:veins/plan")).reach(16).writesMantle(planned)
.run(context -> context.mantle().layer(planned).set(context.originX() + 20, -30, context.originZ() + 3, "vein"));
.run(context -> context.mantle().layer(planned).set(context.originX() + 20, 34, context.originZ() + 3, "vein"));
}
public void register(FeatureRegistry registry) { registry.registerMantle(planned, MantleLifetime.GENERATION, TEXT); }
};
@@ -278,15 +280,15 @@ public class IrisModuleMantleTest {
when(engine.getDimension()).thenReturn(new IrisDimension());
when(engine.getRegion(anyInt(), anyInt())).thenReturn(new IrisRegion());
when(engine.getSurfaceBiome(anyInt(), anyInt())).thenReturn(new IrisBiome());
when(engine.getMinHeight()).thenReturn(MIN_Y);
when(engine.getMinHeight()).thenReturn(WORLD_MIN_HEIGHT);
when(engine.getHeight()).thenReturn(SECTIONS * 16);
try (LoadedPack pack = LoadedPack.load(folder.newFolder("pack").toPath(),
ModuleHost.of(List.of(veins)).copyingJarsTo(folder.newFolder("copies").toPath()))) {
ModuleMantleComponent.forPack(engine, pack, Set.of()).getFirst().generate(0, 0, this::chunk);
IrisModuleMantle neighbor = new IrisModuleMantle(new BlockBox(16, MIN_Y, 0, 32, 0, 16), MIN_Y, this::chunk, pack.catalog().mantle());
assertEquals("vein", neighbor.layer(planned).get(20, -30, 3));
IrisModuleMantle neighbor = new IrisModuleMantle(new BlockBox(16, 0, 0, 32, HEIGHT, 16), this::chunk, pack.catalog().mantle());
assertEquals("vein", neighbor.layer(planned).get(20, 34, 3));
}
assertTrue(chunks.containsKey(1L << 32));
}
@@ -311,7 +313,7 @@ public class IrisModuleMantleTest {
when(engine.getDimension()).thenReturn(new IrisDimension());
when(engine.getRegion(anyInt(), anyInt())).thenReturn(new IrisRegion());
when(engine.getSurfaceBiome(anyInt(), anyInt())).thenReturn(new IrisBiome());
when(engine.getMinHeight()).thenReturn(MIN_Y);
when(engine.getMinHeight()).thenReturn(WORLD_MIN_HEIGHT);
when(engine.getHeight()).thenReturn(SECTIONS * 16);
try (LoadedPack pack = LoadedPack.load(folder.newFolder("finder-pack").toPath(),