mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-29 01:04:29 +00:00
Batch 6 part 1: one bottom-Y name, no silently-wrong defaults, geometry package, blocks
Finding 43: PackWorld.minHeight(), PlatformStart.bottomY() and StructureFit.bottomY() become minWorldY(), the name TerrainSampler already used, and none of them has a default. FeatureSettings.declaredBy, TerrainSampler.surfaceBlock/upperDimension and BlockRegistry.oreFor lose defaults that answered wrong for a host that forgot them. BlockBox, BlockPosition and BlockFace move to com.volmit.geometry. Finding 44: BlockRegistry keeps resolve(BlockSpec) and adds find(key), which is empty for a block the platform lacks; resolve(String) and resolve(BlockState) go. BlockTrait drops INVENTORY, BLOCK_ENTITY and NEEDS_UPDATE, which nothing asked; BlockAccess.is answers every trait. GenerationContext.hunk(Class) becomes blocks().
This commit is contained in:
1 parent
9473c827fe
commit
05f621d82d
63 files changed
+187
-143
No files matched your search
@@ -1,6 +1,7 @@
|
||||
package com.volmit.host;
|
||||
|
||||
import com.volmit.IrisFeature;
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.config.FeatureSettings;
|
||||
import com.volmit.config.SettingsStack;
|
||||
import com.volmit.generation.GenerationContext;
|
||||
@@ -68,8 +69,8 @@ final class ChunkInvocation implements ChunkStageContext {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Hunk<T> hunk(Class<T> type) {
|
||||
return inputs.hunk(type);
|
||||
public Hunk<BlockState> blocks() {
|
||||
return inputs.blocks();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.volmit.host;
|
||||
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.generation.ChunkContext;
|
||||
import com.volmit.mantle.BlockBox;
|
||||
import com.volmit.geometry.BlockBox;
|
||||
import com.volmit.mantle.Mantle;
|
||||
import com.volmit.mantle.MantleEdit;
|
||||
import com.volmit.mantle.MantleKey;
|
||||
|
||||
@@ -45,8 +45,8 @@ final class ModuleWorld implements PackWorld {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int minHeight() {
|
||||
return world.minHeight();
|
||||
public int minWorldY() {
|
||||
return world.minWorldY();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.volmit.host;
|
||||
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.mantle.BlockBox;
|
||||
import com.volmit.geometry.BlockBox;
|
||||
import com.volmit.mantle.Mantle;
|
||||
import com.volmit.mantle.MantleEdit;
|
||||
import com.volmit.mantle.MantleKey;
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.volmit;
|
||||
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.host.ArrayHunk;
|
||||
import com.volmit.mantle.BlockBox;
|
||||
import com.volmit.geometry.*;
|
||||
import com.volmit.object.*;
|
||||
import com.volmit.placement.PlacementRequest;
|
||||
import com.volmit.resource.*;
|
||||
|
||||
@@ -20,7 +20,7 @@ import com.volmit.host.LoadedModules;
|
||||
import com.volmit.host.MantleRunner;
|
||||
import com.volmit.host.StageTimings;
|
||||
import com.volmit.hunk.Hunk;
|
||||
import com.volmit.mantle.BlockBox;
|
||||
import com.volmit.geometry.BlockBox;
|
||||
import com.volmit.mantle.MantleLayer;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.stage.ChunkStageContext;
|
||||
@@ -66,7 +66,7 @@ class ChunkPipelineTest {
|
||||
|
||||
private static Hunk<BlockState> generate(ColumnSettings settings) {
|
||||
var blocks = new ArrayHunk<>(BlockState.class, SIZE, HEIGHT, SIZE, AIR);
|
||||
runner().generate(TestContexts.generation(Map.of(BlockState.class, blocks), settings, null), TestContexts.SEED, StageTimings.NONE);
|
||||
runner().generate(TestContexts.generation(blocks, settings, null), TestContexts.SEED, StageTimings.NONE);
|
||||
return blocks;
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ class ChunkPipelineTest {
|
||||
var settings = new ColumnSettings((x, z) -> List.of(dimension, x < 8 ? swamp : plains));
|
||||
|
||||
new ChunkRunner(TestSetups.stages(module).resolve(Pipeline.CHUNK))
|
||||
.generate(TestContexts.generation(Map.of(), settings, null), TestContexts.SEED, StageTimings.NONE);
|
||||
.generate(TestContexts.generation(null,settings, null), TestContexts.SEED, StageTimings.NONE);
|
||||
|
||||
assertEquals(List.of(List.of(DIMENSION, SWAMP, PLAINS), List.of(DIMENSION, SWAMP)), received,
|
||||
"the body sees every level of every column, a column read that column's levels");
|
||||
@@ -150,7 +150,7 @@ class ChunkPipelineTest {
|
||||
var blocks = new ArrayHunk<>(BlockState.class, CHUNK, HEIGHT, CHUNK, AIR);
|
||||
var chunkArea = new BlockBox(0, BOTTOM, 0, CHUNK, TOP, CHUNK);
|
||||
new ChunkRunner(loaded.chunk()).generate(
|
||||
TestContexts.generation(Map.of(BlockState.class, blocks), ColumnSettings.NONE, mantle.within(chunkArea)), TestContexts.SEED,
|
||||
TestContexts.generation(blocks, ColumnSettings.NONE, mantle.within(chunkArea)), TestContexts.SEED,
|
||||
StageTimings.NONE);
|
||||
assertEquals(VeinModule.ORE_BLOCK, blocks.get(7, 4, 7));
|
||||
assertEquals(VeinModule.ORE_BLOCK, blocks.get(15, 4, 7));
|
||||
@@ -169,7 +169,7 @@ class ChunkPipelineTest {
|
||||
public ModuleInfo info() { return ModuleInfo.of("test:copy", "Copy", "1"); }
|
||||
public void setup(ModuleSetup setup) {
|
||||
setup.stages().define(copy).run(context -> {
|
||||
var blocks = context.hunk(BlockState.class);
|
||||
var blocks = context.blocks();
|
||||
context.mantle().blocks().visit(chunkArea, (x, y, z, block) -> blocks.set(x, y, z, block));
|
||||
});
|
||||
}
|
||||
@@ -177,7 +177,7 @@ class ChunkPipelineTest {
|
||||
var blocks = new ArrayHunk<>(BlockState.class, CHUNK, HEIGHT, CHUNK, GRASS);
|
||||
|
||||
new ChunkRunner(TestSetups.stages(module).resolve(Pipeline.CHUNK)).generate(
|
||||
TestContexts.generation(Map.of(BlockState.class, blocks), ColumnSettings.NONE, mantle.within(chunkArea)), TestContexts.SEED,
|
||||
TestContexts.generation(blocks, ColumnSettings.NONE, mantle.within(chunkArea)), TestContexts.SEED,
|
||||
StageTimings.NONE);
|
||||
|
||||
assertEquals(stone, blocks.get(3, 2, 5));
|
||||
@@ -205,7 +205,7 @@ class ChunkPipelineTest {
|
||||
var blocks = new ArrayHunk<>(BlockState.class, CHUNK, HEIGHT, CHUNK, AIR);
|
||||
|
||||
new ChunkRunner(TestSetups.stages(module).resolve(Pipeline.CHUNK)).generate(
|
||||
TestContexts.generation(Map.of(BlockState.class, blocks), ColumnSettings.NONE, mantle.within(chunkArea)), TestContexts.SEED,
|
||||
TestContexts.generation(blocks, ColumnSettings.NONE, mantle.within(chunkArea)), TestContexts.SEED,
|
||||
StageTimings.NONE);
|
||||
|
||||
assertEquals(List.of("true", "false"), carved);
|
||||
@@ -216,7 +216,7 @@ class ChunkPipelineTest {
|
||||
var timed = new ArrayList<String>();
|
||||
var blocks = new ArrayHunk<>(BlockState.class, SIZE, HEIGHT, SIZE, AIR);
|
||||
|
||||
runner().generate(TestContexts.generation(Map.of(BlockState.class, blocks), ColumnSettings.NONE, null), TestContexts.SEED,
|
||||
runner().generate(TestContexts.generation(blocks, ColumnSettings.NONE, null), TestContexts.SEED,
|
||||
(stage, nanos) -> timed.add(stage.stage().id() + (nanos >= 0 ? "" : " ran backwards")));
|
||||
|
||||
assertEquals(List.of("iris:terrain/surface"), timed, "grass has no settings here, so it does not run and is not reported");
|
||||
@@ -228,7 +228,7 @@ class ChunkPipelineTest {
|
||||
var aroundTheChunk = new BlockBox(-CHUNK, BOTTOM, -CHUNK, 2 * CHUNK, TOP, 2 * CHUNK);
|
||||
var graph = TestSetups.stages(oreWriter((context, layer) -> layer.set(15, 3, 0, 1))).resolve(Pipeline.CHUNK);
|
||||
|
||||
new ChunkRunner(graph).generate(TestContexts.generation(Map.of(), ColumnSettings.NONE, mantle.within(aroundTheChunk)),
|
||||
new ChunkRunner(graph).generate(TestContexts.generation(null,ColumnSettings.NONE, mantle.within(aroundTheChunk)),
|
||||
TestContexts.SEED, StageTimings.NONE);
|
||||
|
||||
assertEquals(1, mantle.get(VeinModule.ORE, 15, 3, 0));
|
||||
@@ -248,7 +248,7 @@ class ChunkPipelineTest {
|
||||
views.add(context.mantle().blocks());
|
||||
})).resolve(Pipeline.CHUNK);
|
||||
|
||||
new ChunkRunner(graph).generate(TestContexts.generation(Map.of(), ColumnSettings.NONE, mantle.within(aroundTheChunk)),
|
||||
new ChunkRunner(graph).generate(TestContexts.generation(null,ColumnSettings.NONE, mantle.within(aroundTheChunk)),
|
||||
TestContexts.SEED, StageTimings.NONE);
|
||||
|
||||
assertSame(views.get(0), views.get(1));
|
||||
@@ -265,7 +265,7 @@ class ChunkPipelineTest {
|
||||
read.add(layer.get(CHUNK, 0, 0));
|
||||
layer.set(CHUNK, 0, 0, 1);
|
||||
})).resolve(Pipeline.CHUNK);
|
||||
var inputs = TestContexts.generation(Map.of(), ColumnSettings.NONE, mantle.within(aroundTheChunk));
|
||||
var inputs = TestContexts.generation(null,ColumnSettings.NONE, mantle.within(aroundTheChunk));
|
||||
|
||||
var failure = assertThrows(UnsupportedOperationException.class,
|
||||
() -> new ChunkRunner(graph).generate(inputs, TestContexts.SEED, StageTimings.NONE));
|
||||
|
||||
@@ -11,7 +11,8 @@ import com.volmit.host.PlacementRunner;
|
||||
import com.volmit.host.ResolvedGraph;
|
||||
import com.volmit.host.StageStreams;
|
||||
import com.volmit.host.StageTimings;
|
||||
import com.volmit.mantle.BlockBox;
|
||||
import com.volmit.geometry.BlockBox;
|
||||
import com.volmit.geometry.BlockPosition;
|
||||
import com.volmit.object.GeneratedObject;
|
||||
import com.volmit.object.ObjectBlock;
|
||||
import com.volmit.placement.PlacedBlock;
|
||||
@@ -24,7 +25,6 @@ import com.volmit.support.MemoryEdit;
|
||||
import com.volmit.support.TestContexts;
|
||||
import com.volmit.support.TestSetups;
|
||||
import com.volmit.support.TestTerrain;
|
||||
import com.volmit.world.BlockPosition;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
||||
@@ -30,7 +30,7 @@ public final class GrassModule implements IrisModule {
|
||||
|
||||
private static void cover(ChunkStageContext context) {
|
||||
var heights = context.output(TerrainModule.SURFACE);
|
||||
var blocks = context.hunk(BlockState.class);
|
||||
var blocks = context.blocks();
|
||||
for (int x = 0; x < blocks.width(); x++) {
|
||||
for (int z = 0; z < blocks.depth(); z++) {
|
||||
var here = context.settings().at(GrassSettings.class, context.originX() + x, context.originZ() + z).mostSpecific();
|
||||
|
||||
@@ -30,7 +30,7 @@ public final class TerrainModule implements IrisModule {
|
||||
}
|
||||
|
||||
private static SurfaceHeights shape(ChunkStageContext context) {
|
||||
var blocks = context.hunk(BlockState.class);
|
||||
var blocks = context.blocks();
|
||||
var heights = new SurfaceHeights(blocks.width(), blocks.depth());
|
||||
for (int x = 0; x < blocks.width(); x++) {
|
||||
for (int z = 0; z < blocks.depth(); z++) {
|
||||
|
||||
@@ -6,7 +6,7 @@ import com.volmit.ModuleSetup;
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.config.PackSettings;
|
||||
import com.volmit.generation.ChunkContext;
|
||||
import com.volmit.mantle.BlockBox;
|
||||
import com.volmit.geometry.BlockBox;
|
||||
import com.volmit.mantle.MantleCodec;
|
||||
import com.volmit.mantle.MantleKey;
|
||||
import com.volmit.mantle.MantleLifetime;
|
||||
@@ -62,7 +62,7 @@ public final class VeinModule implements IrisModule {
|
||||
}
|
||||
|
||||
private static void place(ChunkStageContext context) {
|
||||
var blocks = context.hunk(BlockState.class);
|
||||
var blocks = context.blocks();
|
||||
var chunk = new BlockBox(context.originX(), 0, context.originZ(),
|
||||
context.originX() + blocks.width(), blocks.height(), context.originZ() + blocks.depth());
|
||||
context.mantle().layer(ORE).visit(chunk, (x, y, z, planned) ->
|
||||
|
||||
@@ -6,7 +6,7 @@ import com.volmit.ModuleSetup;
|
||||
import com.volmit.stage.PlacementStage;
|
||||
import com.volmit.stage.PlacementStageContext;
|
||||
import com.volmit.stage.Stage;
|
||||
import com.volmit.world.BlockPosition;
|
||||
import com.volmit.geometry.BlockPosition;
|
||||
import com.volmit.world.BlockView;
|
||||
|
||||
/** Port of PlacementModuleAnchor with center-height sampling: rest the anchor on the surface. */
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.volmit.example.placement;
|
||||
|
||||
import com.volmit.placement.PlacementRequest;
|
||||
import com.volmit.world.BlockPosition;
|
||||
import com.volmit.geometry.BlockPosition;
|
||||
|
||||
/** The world position the object's local anchor is placed at. */
|
||||
public record AnchorResult(BlockPosition anchor) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.volmit.example.placement;
|
||||
|
||||
import com.volmit.world.BlockPosition;
|
||||
import com.volmit.geometry.BlockPosition;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
@@ -8,7 +8,7 @@ import com.volmit.stage.BlockStage;
|
||||
import com.volmit.stage.PlacementStage;
|
||||
import com.volmit.stage.PlacementStageContext;
|
||||
import com.volmit.stage.Stage;
|
||||
import com.volmit.world.BlockPosition;
|
||||
import com.volmit.geometry.BlockPosition;
|
||||
|
||||
/** Port of PlacementModuleStilt: collect the lowest layer per block, then fill down after writes. */
|
||||
public final class StiltModule implements IrisModule {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.volmit.example.placement;
|
||||
|
||||
import com.volmit.world.BlockPosition;
|
||||
import com.volmit.geometry.BlockPosition;
|
||||
|
||||
/** Placement-wide rotation chosen once per attempt, like Iris's spin kernel. */
|
||||
public record Transforms(int quarterTurns) {
|
||||
|
||||
@@ -95,7 +95,7 @@ class WorldStateExampleTest {
|
||||
var startedWith = RuinsModule.planted(world);
|
||||
assertEquals(TestContexts.SEED, startedWith.seed);
|
||||
|
||||
new ChunkRunner(pack.chunk()).generate(TestContexts.generation(Map.of(), ColumnSettings.NONE, null, world), TestContexts.SEED,
|
||||
new ChunkRunner(pack.chunk()).generate(TestContexts.generation(null,ColumnSettings.NONE, null, world), TestContexts.SEED,
|
||||
StageTimings.NONE);
|
||||
|
||||
assertSame(startedWith, RuinsModule.planted(world), "the stage used the state the hook built");
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.volmit.IrisModule;
|
||||
import com.volmit.ModuleInfo;
|
||||
import com.volmit.ModuleLog;
|
||||
import com.volmit.ModuleSetup;
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.config.FeatureSettings;
|
||||
import com.volmit.config.PackSettings;
|
||||
import com.volmit.generation.GenerationContext;
|
||||
@@ -49,7 +50,7 @@ class ExtensionsTest {
|
||||
}
|
||||
};
|
||||
var world = new OfferingWorld(new WorldOffer("iris"));
|
||||
var inputs = new OfferingChunk(TestContexts.generation(Map.of(), null, null, world), new ChunkOffer(0));
|
||||
var inputs = new OfferingChunk(TestContexts.generation(null, null, null, world), new ChunkOffer(0));
|
||||
|
||||
new ChunkRunner(TestSetups.stages(module).resolve(Pipeline.CHUNK)).generate(inputs, TestContexts.SEED, StageTimings.NONE);
|
||||
|
||||
@@ -81,6 +82,7 @@ class ExtensionsTest {
|
||||
public long seed() { return TestContexts.SEED; }
|
||||
public PackResources resources() { throw new AssertionError("Unused resources"); }
|
||||
public PackSettings settings() { throw new AssertionError("Unused settings"); }
|
||||
public int minWorldY() { return 0; }
|
||||
public <T> T state(Class<T> type, Function<? super PackWorld, ? extends T> create) { return states.state(type, () -> create.apply(this)); }
|
||||
public ModuleLog log() { return ModuleLogs.discarding(); }
|
||||
|
||||
@@ -96,7 +98,7 @@ class ExtensionsTest {
|
||||
public TerrainSampler terrain() { return inputs.terrain(); }
|
||||
public FeatureSettings settings() { return inputs.settings(); }
|
||||
public Mantle mantle() { return inputs.mantle(); }
|
||||
public <T> Hunk<T> hunk(Class<T> type) { return inputs.hunk(type); }
|
||||
public Hunk<BlockState> blocks() { return inputs.blocks(); }
|
||||
public PackWorld world() { return inputs.world(); }
|
||||
|
||||
@Override
|
||||
|
||||
@@ -224,7 +224,7 @@ class ModuleLogTest {
|
||||
var runner = new ChunkRunner(builder.resolve(Pipeline.CHUNK));
|
||||
|
||||
try (var world = new TestWorld()) {
|
||||
runner.generate(TestContexts.generation(Map.of(), null, null, world), TestContexts.SEED, StageTimings.NONE);
|
||||
runner.generate(TestContexts.generation(null, null, null, world), TestContexts.SEED, StageTimings.NONE);
|
||||
}
|
||||
|
||||
assertEquals(List.of("[test:alpha] context", "[test:alpha] world", "[test:beta] context", "[test:beta] world"),
|
||||
@@ -305,7 +305,7 @@ class ModuleLogTest {
|
||||
|
||||
try (var first = new TestWorld(); var second = new TestWorld()) {
|
||||
for (var world : List.of(first, first, second)) {
|
||||
runner.generate(TestContexts.generation(Map.of(), null, null, world), TestContexts.SEED, StageTimings.NONE);
|
||||
runner.generate(TestContexts.generation(null, null, null, world), TestContexts.SEED, StageTimings.NONE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -494,7 +494,7 @@ class PackSchemaTest {
|
||||
import com.volmit.config.Range;
|
||||
import com.volmit.noise.NoiseStyle;
|
||||
import com.volmit.noise.StyledRange;
|
||||
import com.volmit.world.BlockPosition;
|
||||
import com.volmit.geometry.BlockPosition;
|
||||
import java.util.*;
|
||||
|
||||
@Feature(id = "example:flora", name = "Flora", key = "flora", targets = Level.BIOME)
|
||||
@@ -520,7 +520,7 @@ class PackSchemaTest {
|
||||
assertEquals(new ObjectKind("com.volmit.noise.StyledRange"), option(settings, "height").kind());
|
||||
assertEquals(new ObjectKind("com.volmit.config.Range"), option(settings, "light").kind());
|
||||
assertEquals(Optional.of(Map.of("max", 15.0, "min", 0.0)), option(settings, "light").defaultValue());
|
||||
assertEquals(new ObjectKind("com.volmit.world.BlockPosition"), option(settings, "offset").kind());
|
||||
assertEquals(new ObjectKind("com.volmit.geometry.BlockPosition"), option(settings, "offset").kind());
|
||||
assertEquals(Optional.of(Map.of("x", 1L, "y", 2L, "z", 3L)), option(settings, "offset").defaultValue());
|
||||
assertEquals(new AnyKind(), option(settings, "extra").kind(), "Object holds any JSON value");
|
||||
|
||||
|
||||
@@ -9,7 +9,8 @@ import com.volmit.ModuleSetup;
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.config.Feature;
|
||||
import com.volmit.config.FeatureSettings.Entry;
|
||||
import com.volmit.mantle.BlockBox;
|
||||
import com.volmit.geometry.BlockBox;
|
||||
import com.volmit.geometry.BlockPosition;
|
||||
import com.volmit.mantle.MantleCodec;
|
||||
import com.volmit.mantle.MantleKey;
|
||||
import com.volmit.mantle.MantleLifetime;
|
||||
@@ -33,7 +34,6 @@ import com.volmit.support.MemoryMantle;
|
||||
import com.volmit.support.TestContexts;
|
||||
import com.volmit.support.TestSetups;
|
||||
import com.volmit.support.TestTerrain;
|
||||
import com.volmit.world.BlockPosition;
|
||||
import com.volmit.example.placement.SnowModule;
|
||||
import com.volmit.example.placement.SnowSettings;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@@ -4,7 +4,8 @@ import com.volmit.IrisModule;
|
||||
import com.volmit.ModuleInfo;
|
||||
import com.volmit.ModuleSetup;
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.mantle.BlockBox;
|
||||
import com.volmit.geometry.BlockBox;
|
||||
import com.volmit.geometry.BlockPosition;
|
||||
import com.volmit.object.GeneratedObject;
|
||||
import com.volmit.object.ObjectBlock;
|
||||
import com.volmit.placement.PlacementRequest;
|
||||
@@ -17,7 +18,6 @@ import com.volmit.support.MemoryEdit;
|
||||
import com.volmit.support.TestContexts;
|
||||
import com.volmit.support.TestSetups;
|
||||
import com.volmit.support.TestTerrain;
|
||||
import com.volmit.world.BlockPosition;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
@@ -131,7 +131,7 @@ class StageStreamsTest {
|
||||
var graph = resolve(Pipeline.CHUNK, module("a:mod", stages -> stages.define(Stage.chunk("a:mod/ores"))
|
||||
.run(context -> drawn.add((long) context.random().nextInt(BOUND)))));
|
||||
|
||||
new ChunkRunner(graph).generate(TestContexts.generation(Map.of()), TestContexts.SEED, StageTimings.NONE);
|
||||
new ChunkRunner(graph).generate(TestContexts.generation(null), TestContexts.SEED, StageTimings.NONE);
|
||||
|
||||
assertEquals(firstDraws(TestContexts.SEED, "a:mod/ores", 1), drawn);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,9 @@ package com.volmit.support;
|
||||
import com.volmit.IrisFeature;
|
||||
import com.volmit.config.FeatureSettings;
|
||||
import com.volmit.config.SettingsStack;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
/** Settings declared per world column by a function, for chunk and mantle tests. */
|
||||
@@ -30,4 +32,9 @@ public final class ColumnSettings implements FeatureSettings {
|
||||
.map(entry -> (Entry<F>) entry)
|
||||
.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public <F extends IrisFeature> Optional<F> declaredBy(ResourceId biome, Class<F> featureType) {
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
package com.volmit.support;
|
||||
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.mantle.BlockBox;
|
||||
import com.volmit.geometry.BlockBox;
|
||||
import com.volmit.geometry.BlockPosition;
|
||||
import com.volmit.mantle.Mantle;
|
||||
import com.volmit.placement.PlacedBlock;
|
||||
import com.volmit.placement.PlacedMarker;
|
||||
import com.volmit.placement.PlacementEdit;
|
||||
import com.volmit.world.BlockPosition;
|
||||
import com.volmit.world.BlockView;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package com.volmit.support;
|
||||
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.mantle.BlockBox;
|
||||
import com.volmit.geometry.BlockBox;
|
||||
import com.volmit.geometry.BlockPosition;
|
||||
import com.volmit.mantle.Mantle;
|
||||
import com.volmit.mantle.MantleEdit;
|
||||
import com.volmit.mantle.MantleKey;
|
||||
import com.volmit.mantle.MantleLayer;
|
||||
import com.volmit.mantle.MantleVisitor;
|
||||
import com.volmit.world.BlockPosition;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.volmit.support;
|
||||
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.config.FeatureSettings;
|
||||
import com.volmit.generation.GenerationContext;
|
||||
import com.volmit.generation.MantleGenerationContext;
|
||||
@@ -10,7 +11,6 @@ import com.volmit.placement.PlacementContext;
|
||||
import com.volmit.world.TerrainSampler;
|
||||
import com.volmit.world.BlockView;
|
||||
import com.volmit.world.PackWorld;
|
||||
import java.util.Map;
|
||||
|
||||
/** Tests needing no platform facilities fail loudly if code starts using one. */
|
||||
public final class TestContexts {
|
||||
@@ -18,17 +18,20 @@ public final class TestContexts {
|
||||
|
||||
private TestContexts() {}
|
||||
|
||||
public static GenerationContext generation(Map<Class<?>, Hunk<?>> hunks) {
|
||||
return generation(hunks, null, null);
|
||||
/** The chunk at the origin; a null {@code blocks} fails when used. */
|
||||
public static GenerationContext generation(Hunk<BlockState> blocks) {
|
||||
return generation(blocks, null, null);
|
||||
}
|
||||
|
||||
/** The chunk at the origin; a null {@code settings} or {@code mantle} fails when used. */
|
||||
public static GenerationContext generation(Map<Class<?>, Hunk<?>> hunks, FeatureSettings settings, Mantle mantle) {
|
||||
return generation(hunks, settings, mantle, null);
|
||||
/** The chunk at the origin; a null {@code blocks}, {@code settings} or {@code mantle} fails when used. */
|
||||
public static GenerationContext generation(Hunk<BlockState> blocks, FeatureSettings settings, Mantle mantle) {
|
||||
return generation(blocks, settings, mantle, null);
|
||||
}
|
||||
|
||||
/** The chunk at the origin in {@code world}; a null {@code settings}, {@code mantle} or {@code world} fails when used. */
|
||||
public static GenerationContext generation(Map<Class<?>, Hunk<?>> hunks, FeatureSettings settings, Mantle mantle, PackWorld world) {
|
||||
/** The chunk at the origin in {@code world}; a null {@code blocks}, {@code settings}, {@code mantle} or {@code world}
|
||||
* fails when used.
|
||||
*/
|
||||
public static GenerationContext generation(Hunk<BlockState> blocks, FeatureSettings settings, Mantle mantle, PackWorld world) {
|
||||
return new GenerationContext() {
|
||||
public int originX() { return 0; }
|
||||
public int originZ() { return 0; }
|
||||
@@ -36,12 +39,7 @@ public final class TestContexts {
|
||||
public TerrainSampler terrain() { throw new AssertionError("Unused terrain"); }
|
||||
public FeatureSettings settings() { return used(settings, "settings"); }
|
||||
public Mantle mantle() { return used(mantle, "mantle"); }
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> Hunk<T> hunk(Class<T> type) {
|
||||
var hunk = hunks.get(type);
|
||||
if (hunk == null) throw new IllegalArgumentException("No hunk of " + type.getName());
|
||||
return (Hunk<T>) hunk;
|
||||
}
|
||||
public Hunk<BlockState> blocks() { return used(blocks, "blocks"); }
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.volmit.support;
|
||||
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.mantle.BlockBox;
|
||||
import com.volmit.geometry.BlockBox;
|
||||
import com.volmit.world.BlockView;
|
||||
import java.util.function.IntBinaryOperator;
|
||||
|
||||
|
||||
@@ -43,6 +43,11 @@ public final class TestWorld implements PackWorld, AutoCloseable {
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public int minWorldY() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T state(Class<T> type, Function<? super PackWorld, ? extends T> create) {
|
||||
return states.state(type, () -> create.apply(this));
|
||||
|
||||
Reference in new issue
Block a user