mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 16:54:04 +00:00
Batch 7 stage 4a: biome height, sky biome and platform biome writes
TerrainSampler.biomeHeight and skyBiome answer for a pack biome at any column; Mantle.setPlatformBiome makes a block show a platform biome, inside a chunk stage's own chunk. These replace the module's FloatingHost facade. README, DESIGN (ledger drops FloatingHost) and CONTRACTS updated.
This commit is contained in:
1 parent
f1eb619344
commit
95582abb6e
9 files changed
+79
-2
No files matched your search
@@ -8,6 +8,7 @@ import com.volmit.mantle.MantleEdit;
|
||||
import com.volmit.mantle.MantleKey;
|
||||
import com.volmit.mantle.MantleLayer;
|
||||
import com.volmit.mantle.MantleVisitor;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -55,6 +56,12 @@ final class ChunkMantle implements Mantle {
|
||||
return mantle.isCarved(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlatformBiome(int x, int y, int z, ResourceId biome) {
|
||||
requireOwnChunk(x, y, z);
|
||||
mantle.setPlatformBiome(x, y, z, biome);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MantleEdit edit() {
|
||||
throw new UnsupportedOperationException("Chunk stages write mantle layers directly, without an edit");
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.volmit.placement.PlacedBlock;
|
||||
import com.volmit.placement.PlacedMarker;
|
||||
import com.volmit.placement.PlacementAccess;
|
||||
import com.volmit.placement.PlacementEdit;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
@@ -135,6 +136,12 @@ final class PlacementViews {
|
||||
checkPosition(bounds(), x, y, z);
|
||||
return parent.isCarved(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlatformBiome(int x, int y, int z, ResourceId biome) {
|
||||
checkPosition(bounds(), x, y, z);
|
||||
parent.setPlatformBiome(x, y, z, biome);
|
||||
}
|
||||
}
|
||||
|
||||
private static final class RestrictedMantleLayer<T> implements MantleLayer<T> {
|
||||
|
||||
@@ -276,6 +276,23 @@ class ChunkPipelineTest {
|
||||
assertNull(mantle.get(VeinModule.ORE, CHUNK, 0, 0));
|
||||
}
|
||||
|
||||
@Test
|
||||
void chunkStagesSetPlatformBiomesInTheirOwnChunkOnly() {
|
||||
var mantle = new MemoryMantle();
|
||||
var aroundTheChunk = new BlockBox(-CHUNK, BOTTOM, -CHUNK, 2 * CHUNK, TOP, 2 * CHUNK);
|
||||
var sky = ResourceId.parse("minecraft:plains");
|
||||
var graph = TestSetups.stages(oreWriter((context, layer) -> {
|
||||
context.mantle().setPlatformBiome(15, 200, 0, sky);
|
||||
context.mantle().setPlatformBiome(CHUNK, 200, 0, sky);
|
||||
})).resolve(Pipeline.CHUNK);
|
||||
var inputs = TestContexts.generation(null, ColumnSettings.NONE, mantle.within(aroundTheChunk));
|
||||
|
||||
assertThrows(UnsupportedOperationException.class,
|
||||
() -> new ChunkRunner(graph).generate(inputs, TestContexts.SEED, StageTimings.NONE));
|
||||
assertEquals(sky, mantle.platformBiome(15, 200, 0));
|
||||
assertNull(mantle.platformBiome(CHUNK, 200, 0));
|
||||
}
|
||||
|
||||
private static IrisModule oreWriter(BiConsumer<ChunkStageContext, MantleLayer<Integer>> body) {
|
||||
var stage = Stage.chunk("test:writer/work");
|
||||
return new IrisModule() {
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.volmit.mantle.MantleEdit;
|
||||
import com.volmit.mantle.MantleKey;
|
||||
import com.volmit.mantle.MantleLayer;
|
||||
import com.volmit.mantle.MantleVisitor;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -24,6 +25,9 @@ public final class MemoryMantle {
|
||||
/** Where the carved voids are kept; the host owns them, so no module registers this layer. */
|
||||
private static final MantleKey<Boolean> CAVERNS = new MantleKey<>("host:caverns", Boolean.class);
|
||||
|
||||
/** Where the platform biomes stages set are kept; the host owns them, so no module registers this layer. */
|
||||
private static final MantleKey<ResourceId> PLATFORM_BIOMES = new MantleKey<>("host:platform-biomes", ResourceId.class);
|
||||
|
||||
private final Map<String, TreeMap<BlockPosition, Object>> layers = new HashMap<>();
|
||||
|
||||
/** A view that accepts reads and writes inside {@code bounds} only. */
|
||||
@@ -33,6 +37,10 @@ public final class MemoryMantle {
|
||||
public <T> MantleLayer<T> layer(MantleKey<T> key) { return new Layer<>(key, bounds, true); }
|
||||
public MantleLayer<BlockState> blocks() { return new Layer<>(PLANNED_BLOCKS, bounds, false); }
|
||||
public boolean isCarved(int x, int y, int z) { return new Layer<>(CAVERNS, bounds, false).get(x, y, z) != null; }
|
||||
public void setPlatformBiome(int x, int y, int z, ResourceId biome) {
|
||||
if (!bounds.contains(x, y, z)) throw new IndexOutOfBoundsException("Outside the mantle view: " + x + "," + y + "," + z);
|
||||
values(PLATFORM_BIOMES).put(new BlockPosition(x, y, z), biome);
|
||||
}
|
||||
public MantleEdit edit() { throw new UnsupportedOperationException("Edits are not used in these tests"); }
|
||||
};
|
||||
}
|
||||
@@ -47,6 +55,11 @@ public final class MemoryMantle {
|
||||
values(CAVERNS).put(new BlockPosition(x, y, z), Boolean.TRUE);
|
||||
}
|
||||
|
||||
/** The platform biome a stage set at the block; null where none did. */
|
||||
public ResourceId platformBiome(int x, int y, int z) {
|
||||
return get(PLATFORM_BIOMES, x, y, z);
|
||||
}
|
||||
|
||||
public <T> T get(MantleKey<T> key, int x, int y, int z) {
|
||||
return key.type().cast(values(key).get(new BlockPosition(x, y, z)));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user