mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-29 09:15:27 +00:00
Host the batch 2 IrisApi: settings stacks, tool world, chunk scan
- ChunkModuleSettings returns SettingsStacks and keeps them per pack snapshot (SettingsStacks), so at() allocates nothing for a column whose region and biome were seen before. - declaredInChunk is answered from the chunk's distinct regions and biomes, each asked for its settings once. - A studio paste runs in a ToolWorld with the pack's resources and settings and its own state, so world() always answers. - Level replaces FeatureAttachment.Target across decoding, schema and packaging; IrisTerrainSampler gives surfaceHeight. - Tests: chunk scan parity and order, the stack cache, the tool world; engine mocks now serve pack resources as real engines do.
This commit is contained in:
1 parent
466d5149db
commit
7fc4445ab7
64 files changed
+844
-448
No files matched your search
@@ -25,7 +25,7 @@ import art.arcane.iris.builtin.decorant.Decorator;
|
||||
import art.arcane.iris.builtin.deposit.DepositGenerator;
|
||||
import art.arcane.iris.builtin.deposit.DepositSettings;
|
||||
import art.arcane.iris.builtin.structure.StructureSettings;
|
||||
import com.volmit.FeatureAttachment.Target;
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.IrisFeature;
|
||||
import com.volmit.IrisModule;
|
||||
import com.volmit.ModuleInfo;
|
||||
@@ -103,7 +103,7 @@ public class BuiltInGenerationGraphTest {
|
||||
@Test
|
||||
public void depositsAreTheListOfGeneratorsOfEveryLevelWrittenUnderDeposits() throws IOException {
|
||||
try (LoadedPack pack = BuiltInPack.serve(mock(IrisData.class), folder, List.of())) {
|
||||
for (Target level : List.of(Target.DIMENSION, Target.REGION, Target.BIOME)) {
|
||||
for (Level level : List.of(Level.DIMENSION, Level.REGION, Level.BIOME)) {
|
||||
FeatureSchema deposits = pack.schema().fields(level).stream()
|
||||
.filter(feature -> feature.settings().name().equals(DepositSettings.class.getName()))
|
||||
.findFirst().orElseThrow();
|
||||
@@ -121,7 +121,7 @@ public class BuiltInGenerationGraphTest {
|
||||
@Test
|
||||
public void importedStructuresAreAnObjectOfOptionsOfTheDimension() throws IOException {
|
||||
try (LoadedPack pack = BuiltInPack.serve(mock(IrisData.class), folder, List.of())) {
|
||||
FeatureSchema structures = pack.schema().fields(Target.DIMENSION).stream()
|
||||
FeatureSchema structures = pack.schema().fields(Level.DIMENSION).stream()
|
||||
.filter(feature -> feature.settings().name().equals(StructureSettings.class.getName()))
|
||||
.findFirst().orElseThrow();
|
||||
|
||||
@@ -135,7 +135,7 @@ public class BuiltInGenerationGraphTest {
|
||||
@Test
|
||||
public void theBuiltInKeysAreUniquePerTargetAndNoFieldOfIris() throws IOException {
|
||||
try (LoadedPack pack = BuiltInPack.serve(mock(IrisData.class), folder, List.of())) {
|
||||
for (Target target : Target.values()) {
|
||||
for (Level target : Level.values()) {
|
||||
List<String> keys = pack.schema().fields(target).stream().map(FeatureSchema::key).toList();
|
||||
assertEquals(target + " " + keys, keys.size(), keys.stream().distinct().count());
|
||||
assertTrue(target + " " + keys, keys.stream().noneMatch(ModuleTargets.reservedFields().get(target)::contains));
|
||||
@@ -156,11 +156,11 @@ public class BuiltInGenerationGraphTest {
|
||||
+ " give one of the settings another key in its @Feature", field.getMessage());
|
||||
}
|
||||
|
||||
@Feature(id = "test:rival/deposits", name = "Rival deposits", key = "deposits", targets = Target.REGION)
|
||||
@Feature(id = "test:rival/deposits", name = "Rival deposits", key = "deposits", targets = Level.REGION)
|
||||
public static final class TakesDeposits implements IrisFeature {
|
||||
}
|
||||
|
||||
@Feature(id = "test:rival/generators", name = "Rival generators", key = "generators", targets = Target.BIOME)
|
||||
@Feature(id = "test:rival/generators", name = "Rival generators", key = "generators", targets = Level.BIOME)
|
||||
public static final class TakesAHostField implements IrisFeature {
|
||||
}
|
||||
|
||||
@@ -195,11 +195,11 @@ public class BuiltInGenerationGraphTest {
|
||||
@Test
|
||||
public void decoratorsAreTheBiomesListOfDecoratorsWrittenUnderDecorators() throws IOException {
|
||||
try (LoadedPack pack = BuiltInPack.serve(mock(IrisData.class), folder, List.of())) {
|
||||
for (Target level : List.of(Target.DIMENSION, Target.REGION)) {
|
||||
for (Level level : List.of(Level.DIMENSION, Level.REGION)) {
|
||||
assertTrue(level + " has no decorators", pack.schema().fields(level).stream()
|
||||
.noneMatch(feature -> feature.settings().name().equals(DecorantSettings.class.getName())));
|
||||
}
|
||||
FeatureSchema decorant = pack.schema().fields(Target.BIOME).stream()
|
||||
FeatureSchema decorant = pack.schema().fields(Level.BIOME).stream()
|
||||
.filter(feature -> feature.settings().name().equals(DecorantSettings.class.getName()))
|
||||
.findFirst().orElseThrow();
|
||||
assertEquals("decorators", decorant.key());
|
||||
|
||||
@@ -110,6 +110,8 @@ public final class BuiltInPack {
|
||||
when(moduleSet.pack()).thenReturn(pack);
|
||||
when(data.getModules()).thenReturn(moduleSet);
|
||||
when(data.getDataFolder()).thenReturn(folder.getRoot());
|
||||
IrisPackResources resources = new IrisPackResources(data);
|
||||
when(data.getPackResources()).thenReturn(resources);
|
||||
return pack;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ import art.arcane.iris.builtin.carve.CaveProfile;
|
||||
import art.arcane.iris.builtin.carve.UpperDimensionCarvingSettings;
|
||||
import art.arcane.volmlib.util.json.JSONObject;
|
||||
import com.google.gson.Gson;
|
||||
import com.volmit.FeatureAttachment.Target;
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.host.LoadedPack;
|
||||
import com.volmit.host.ModuleHost;
|
||||
import org.junit.After;
|
||||
@@ -81,7 +81,7 @@ public class CarveSettingsDecodingTest {
|
||||
|
||||
@Test
|
||||
public void theOverworldReadsItsCaveProfileItsCarvingBandsAndCarvingEnabled() throws IOException {
|
||||
ModuleSettings settings = decoder.decode(Target.DIMENSION, file("dimensions/overworld.json"), "dimension overworld");
|
||||
ModuleSettings settings = decoder.decode(Level.DIMENSION, file("dimensions/overworld.json"), "dimension overworld");
|
||||
|
||||
CaveProfile profile = settings.find(CaveProfile.class).orElseThrow();
|
||||
assertTrue(profile.enabled());
|
||||
@@ -117,7 +117,7 @@ public class CarveSettingsDecodingTest {
|
||||
public void aRegionReadsItsCaveProfile() throws IOException {
|
||||
JSONObject region = file("regions/forests.json");
|
||||
|
||||
CaveProfile profile = decoder.decode(Target.REGION, region, "region forests").find(CaveProfile.class).orElseThrow();
|
||||
CaveProfile profile = decoder.decode(Level.REGION, region, "region forests").find(CaveProfile.class).orElseThrow();
|
||||
|
||||
assertTrue(profile.enabled());
|
||||
assertEquals(6, profile.verticalRange().min(), 0);
|
||||
@@ -130,7 +130,7 @@ public class CarveSettingsDecodingTest {
|
||||
public void aBiomeReadsItsCaveProfileAndItsMinimumDepth() throws IOException {
|
||||
JSONObject biome = file("biomes/carving/amethyst.json");
|
||||
|
||||
ModuleSettings settings = decoder.decode(Target.BIOME, biome, "biome carving/amethyst");
|
||||
ModuleSettings settings = decoder.decode(Level.BIOME, biome, "biome carving/amethyst");
|
||||
|
||||
CaveProfile profile = settings.find(CaveProfile.class).orElseThrow();
|
||||
assertTrue(profile.enabled());
|
||||
@@ -144,7 +144,7 @@ public class CarveSettingsDecodingTest {
|
||||
|
||||
@Test
|
||||
public void aCaveProfileMayBeWrittenAsASnippetReference() {
|
||||
ModuleSettings settings = decoder.decode(Target.BIOME, new JSONObject("{\"caveProfile\": \"snippet/cave-profile/shallow\"}"), "biome test");
|
||||
ModuleSettings settings = decoder.decode(Level.BIOME, new JSONObject("{\"caveProfile\": \"snippet/cave-profile/shallow\"}"), "biome test");
|
||||
|
||||
CaveProfile profile = settings.find(CaveProfile.class).orElseThrow();
|
||||
assertTrue(profile.enabled());
|
||||
@@ -163,7 +163,7 @@ public class CarveSettingsDecodingTest {
|
||||
], "carvingEnabled": false}
|
||||
""");
|
||||
|
||||
ModuleSettings settings = decoder.decode(Target.DIMENSION, json, "dimension test");
|
||||
ModuleSettings settings = decoder.decode(Level.DIMENSION, json, "dimension test");
|
||||
|
||||
List<CarvingEntry> bands = settings.find(CarvingSettings.class).orElseThrow().entries();
|
||||
assertEquals(3, bands.size());
|
||||
@@ -183,7 +183,7 @@ public class CarveSettingsDecodingTest {
|
||||
|
||||
@Test
|
||||
public void carvingBiomeIsABiomeKeyAndRegistersItWithTheBiomeTree() {
|
||||
ModuleSettings settings = decoder.decode(Target.BIOME, new JSONObject("{\"carvingBiome\": \"carving/mushroom\"}"), "biome test");
|
||||
ModuleSettings settings = decoder.decode(Level.BIOME, new JSONObject("{\"carvingBiome\": \"carving/mushroom\"}"), "biome test");
|
||||
|
||||
assertEquals("carving/mushroom", settings.find(CarvingBiomeSettings.class).orElseThrow().biome());
|
||||
assertEquals(Set.of("carving/mushroom"), settings.treeBiomes());
|
||||
@@ -192,11 +192,11 @@ public class CarveSettingsDecodingTest {
|
||||
|
||||
@Test
|
||||
public void theOverworldReadsItsUpperDimensionCarvingAndANumberIsTheCaveLavaHeight() throws IOException {
|
||||
ModuleSettings overworld = decoder.decode(Target.DIMENSION, file("dimensions/overworld.json"), "dimension overworld");
|
||||
ModuleSettings overworld = decoder.decode(Level.DIMENSION, file("dimensions/overworld.json"), "dimension overworld");
|
||||
assertFalse(overworld.find(UpperDimensionCarvingSettings.class).orElseThrow().enabled());
|
||||
assertTrue("the overworld writes no cave lava height", overworld.find(CaveLavaHeightSettings.class).isEmpty());
|
||||
|
||||
ModuleSettings written = decoder.decode(Target.DIMENSION, new JSONObject("{\"caveLavaHeight\": 18, \"upperDimensionCarving\": true}"), "dimension test");
|
||||
ModuleSettings written = decoder.decode(Level.DIMENSION, new JSONObject("{\"caveLavaHeight\": 18, \"upperDimensionCarving\": true}"), "dimension test");
|
||||
assertEquals(18, written.find(CaveLavaHeightSettings.class).orElseThrow().height());
|
||||
assertTrue(written.find(UpperDimensionCarvingSettings.class).orElseThrow().enabled());
|
||||
assertEquals(8, CaveLavaHeightSettings.DEFAULT_HEIGHT);
|
||||
@@ -204,12 +204,12 @@ public class CarveSettingsDecodingTest {
|
||||
|
||||
@Test
|
||||
public void everyKeyIsOnlyReadAtTheLevelsTheOldFieldExistedAt() {
|
||||
assertTrue(decoder.keys(Target.DIMENSION).containsAll(List.of("caveProfile", "carving", "carvingEnabled", "caveLavaHeight", "upperDimensionCarving")));
|
||||
assertTrue(decoder.keys(Target.REGION).contains("caveProfile"));
|
||||
assertTrue(decoder.keys(Target.BIOME).containsAll(List.of("caveProfile", "carvingBiome", "caveMinDepthBelowSurface")));
|
||||
assertFalse(decoder.keys(Target.REGION).contains("carving"));
|
||||
assertFalse(decoder.keys(Target.DIMENSION).contains("carvingBiome"));
|
||||
assertFalse(decoder.keys(Target.DIMENSION).contains("caveMinDepthBelowSurface"));
|
||||
assertTrue(decoder.keys(Level.DIMENSION).containsAll(List.of("caveProfile", "carving", "carvingEnabled", "caveLavaHeight", "upperDimensionCarving")));
|
||||
assertTrue(decoder.keys(Level.REGION).contains("caveProfile"));
|
||||
assertTrue(decoder.keys(Level.BIOME).containsAll(List.of("caveProfile", "carvingBiome", "caveMinDepthBelowSurface")));
|
||||
assertFalse(decoder.keys(Level.REGION).contains("carving"));
|
||||
assertFalse(decoder.keys(Level.DIMENSION).contains("carvingBiome"));
|
||||
assertFalse(decoder.keys(Level.DIMENSION).contains("caveMinDepthBelowSurface"));
|
||||
}
|
||||
|
||||
private JSONObject file(String name) throws IOException {
|
||||
|
||||
@@ -22,7 +22,8 @@ import art.arcane.iris.builtin.IrisSeed;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.core.loader.ResourceLoader;
|
||||
import art.arcane.iris.engine.object.material.IrisBlockData;
|
||||
import com.volmit.FeatureAttachment.Target;
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.config.SettingsStack;
|
||||
import com.volmit.IrisFeature;
|
||||
import com.volmit.ModuleLog;
|
||||
import com.volmit.block.BlockFace;
|
||||
@@ -76,14 +77,14 @@ public final class CarveTestWorld implements PackWorld, IrisSeed.Source {
|
||||
private final Resources resources = new Resources();
|
||||
private long carveSeed = 1337L;
|
||||
|
||||
public CarveTestWorld declare(Target level, String key, IrisFeature value) {
|
||||
public CarveTestWorld declare(Level level, String key, IrisFeature value) {
|
||||
String kind = level.name().toLowerCase();
|
||||
declared.add(new Entry<>(level, new ResourceId(NAMESPACE, kind + "/" + key), value));
|
||||
return this;
|
||||
}
|
||||
|
||||
public CarveTestWorld dimension(IrisFeature value) {
|
||||
return declare(Target.DIMENSION, "overworld", value);
|
||||
return declare(Level.DIMENSION, "overworld", value);
|
||||
}
|
||||
|
||||
public CarveTestWorld biome(String key, int rarity) {
|
||||
@@ -121,8 +122,8 @@ public final class CarveTestWorld implements PackWorld, IrisSeed.Source {
|
||||
return new PackSettings() {
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <F extends IrisFeature> List<Entry<F>> declared(Class<F> featureType) {
|
||||
return declared.stream().filter(entry -> featureType.isInstance(entry.value())).map(entry -> (Entry<F>) entry).toList();
|
||||
public <F extends IrisFeature> SettingsStack<F> declared(Class<F> featureType) {
|
||||
return SettingsStack.of(declared.stream().filter(entry -> featureType.isInstance(entry.value())).map(entry -> (Entry<F>) entry).toList());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
/*
|
||||
* 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.IrisRegistrant;
|
||||
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 com.volmit.IrisFeature;
|
||||
import com.volmit.config.Feature;
|
||||
import com.volmit.config.FeatureSettings;
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.config.SettingsStack;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertSame;
|
||||
|
||||
/** Iris answers a chunk's settings from its distinct regions and biomes, and keeps a column's stack per pack snapshot. */
|
||||
public class ChunkModuleSettingsTest {
|
||||
private static final int CHUNK_X = 3;
|
||||
private static final int CHUNK_Z = -2;
|
||||
private static final int CHUNK_MIDDLE = 8;
|
||||
|
||||
@Rule
|
||||
public TemporaryFolder folder = new TemporaryFolder();
|
||||
|
||||
@Feature(id = "test:stacked", name = "Stacked", key = "stacked", targets = {Level.DIMENSION, Level.REGION, Level.BIOME})
|
||||
static final class StackedSettings implements IrisFeature {
|
||||
}
|
||||
|
||||
private final SettingsStacks snapshotStacks = new SettingsStacks();
|
||||
private PackResourceIds ids;
|
||||
private IrisDimension dimension;
|
||||
private IrisRegion westRegion;
|
||||
private IrisRegion eastRegion;
|
||||
private IrisBiome northBiome;
|
||||
private IrisBiome southBiome;
|
||||
|
||||
@Before
|
||||
public void createLevels() {
|
||||
ids = new PackResourceIds(folder.getRoot());
|
||||
dimension = configured(new IrisDimension(), "overworld");
|
||||
westRegion = configured(new IrisRegion(), "west");
|
||||
eastRegion = configured(new IrisRegion(), "east");
|
||||
northBiome = configured(new IrisBiome(), "north");
|
||||
southBiome = new IrisBiome();
|
||||
southBiome.setLoadKey("south");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aChunksSettingsAreTheDimensionThenItsRegionsThenItsBiomesEachOnceInTheOrderTheScanMeetsThem() {
|
||||
SettingsStack<StackedSettings> declared = settings().declaredInChunk(StackedSettings.class, CHUNK_X, CHUNK_Z);
|
||||
|
||||
assertEquals(List.of(Level.DIMENSION, Level.REGION, Level.REGION, Level.BIOME),
|
||||
declared.entries().stream().map(FeatureSettings.Entry::level).toList());
|
||||
assertEquals(List.of(ids.of("dimension", "overworld"), ids.of("region", "west"), ids.of("region", "east"), ids.of("biome", "north")),
|
||||
declared.entries().stream().map(FeatureSettings.Entry::source).toList());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aChunksSettingsMatchTheColumnByColumnScanOfTheApi() {
|
||||
ChunkModuleSettings settings = settings();
|
||||
FeatureSettings columnByColumn = settings::at;
|
||||
|
||||
assertEquals(columnByColumn.declaredInChunk(StackedSettings.class, CHUNK_X, CHUNK_Z).entries(),
|
||||
settings.declaredInChunk(StackedSettings.class, CHUNK_X, CHUNK_Z).entries());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aColumnWhoseLevelsWereSeenBeforeGetsTheSameStackInAnyChunkOfTheSnapshot() {
|
||||
int worldX = CHUNK_X * 16;
|
||||
int worldZ = CHUNK_Z * 16;
|
||||
SettingsStack<StackedSettings> first = settings().at(StackedSettings.class, worldX, worldZ);
|
||||
|
||||
assertSame(first, settings().at(StackedSettings.class, worldX + 1, worldZ + 1));
|
||||
}
|
||||
|
||||
private ChunkModuleSettings settings() {
|
||||
return new ChunkModuleSettings(new SplitLevels(), ids);
|
||||
}
|
||||
|
||||
private static <T extends IrisRegistrant> T configured(T owner, String key) {
|
||||
owner.setLoadKey(key);
|
||||
owner.setModuleSettings(ModuleSettings.of(Map.of(StackedSettings.class, new StackedSettings())));
|
||||
return owner;
|
||||
}
|
||||
|
||||
/** One region west of each chunk's middle and one east of it; a configured biome north of the middle, a bare one south. */
|
||||
private final class SplitLevels implements ChunkModuleSettings.Levels {
|
||||
@Override
|
||||
public IrisRegistrant dimension() {
|
||||
return dimension;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IrisRegistrant region(int worldX, int worldZ) {
|
||||
return Math.floorMod(worldX, 16) < CHUNK_MIDDLE ? westRegion : eastRegion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IrisRegistrant surfaceBiome(int worldX, int worldZ) {
|
||||
return Math.floorMod(worldZ, 16) < CHUNK_MIDDLE ? northBiome : southBiome;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IrisBiome biome(ResourceId id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SettingsStacks stacks() {
|
||||
return snapshotStacks;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,7 @@ import art.arcane.iris.engine.framework.Engine;
|
||||
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 com.volmit.FeatureAttachment.Target;
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.IrisFeature;
|
||||
import com.volmit.IrisModule;
|
||||
import com.volmit.ModuleInfo;
|
||||
@@ -35,7 +35,6 @@ import com.volmit.host.MantleRunner;
|
||||
import com.volmit.host.ModuleHost;
|
||||
import com.volmit.host.StageTimings;
|
||||
import com.volmit.mantle.Mantle;
|
||||
import com.volmit.resource.PackResources;
|
||||
import com.volmit.stage.MantleStage;
|
||||
import com.volmit.stage.Stage;
|
||||
import com.volmit.world.PackWorld;
|
||||
@@ -71,7 +70,7 @@ public class ChunkSettingsScanTimingTest {
|
||||
@Rule
|
||||
public TemporaryFolder folder = new TemporaryFolder();
|
||||
|
||||
@Feature(id = "test:scan", name = "Scan", key = "scan", targets = {Target.DIMENSION, Target.REGION, Target.BIOME})
|
||||
@Feature(id = "test:scan", name = "Scan", key = "scan", targets = {Level.DIMENSION, Level.REGION, Level.BIOME})
|
||||
static final class ScanSettings implements IrisFeature {
|
||||
}
|
||||
|
||||
@@ -131,11 +130,9 @@ public class ChunkSettingsScanTimingTest {
|
||||
return new MantleGenerationContext() {
|
||||
public int originX() { return originX; }
|
||||
public int originZ() { return 0; }
|
||||
public long worldSeed() { return 0L; }
|
||||
public TerrainSampler terrain() { throw new UnsupportedOperationException(); }
|
||||
public FeatureSettings settings() { return settings; }
|
||||
public Mantle mantle() { throw new UnsupportedOperationException(); }
|
||||
public PackResources resources() { throw new UnsupportedOperationException(); }
|
||||
public PackWorld world() { throw new UnsupportedOperationException(); }
|
||||
};
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import art.arcane.iris.builtin.decorant.DecorationPart;
|
||||
import art.arcane.iris.builtin.decorant.Decorator;
|
||||
import art.arcane.volmlib.util.json.JSONObject;
|
||||
import com.google.gson.Gson;
|
||||
import com.volmit.FeatureAttachment.Target;
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.block.BlockSpec;
|
||||
import com.volmit.host.LoadedPack;
|
||||
import com.volmit.host.ModuleHost;
|
||||
@@ -136,23 +136,23 @@ public class DecorantSettingsDecodingTest {
|
||||
public void theFeatureIdIsNotAKey() {
|
||||
JSONObject byId = new JSONObject("{\"iris:decorant\": [{\"chance\": 1}]}");
|
||||
|
||||
assertSame(ModuleSettings.NONE, decoder.decode(Target.BIOME, byId, "biome meadow"));
|
||||
assertTrue(decoder.keys(Target.BIOME).containsAll(Set.of("decorators", "deposits")));
|
||||
assertFalse(decoder.keys(Target.BIOME).contains("iris:decorant"));
|
||||
assertSame(ModuleSettings.NONE, decoder.decode(Level.BIOME, byId, "biome meadow"));
|
||||
assertTrue(decoder.keys(Level.BIOME).containsAll(Set.of("decorators", "deposits")));
|
||||
assertFalse(decoder.keys(Level.BIOME).contains("iris:decorant"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void anObjectOfOptionsUnderDecoratorsIsRefused() {
|
||||
JSONObject object = new JSONObject("{\"decorators\": {\"decorators\": [{\"chance\": 1}]}}");
|
||||
|
||||
IllegalArgumentException refused = assertThrows(IllegalArgumentException.class, () -> decoder.decode(Target.BIOME, object, "biome meadow"));
|
||||
IllegalArgumentException refused = assertThrows(IllegalArgumentException.class, () -> decoder.decode(Level.BIOME, object, "biome meadow"));
|
||||
|
||||
assertEquals("Cannot read settings iris:decorant under \"decorators\" in biome meadow: write a list, [...], of the decorators,"
|
||||
+ " not an object of options", refused.getMessage());
|
||||
}
|
||||
|
||||
private List<Decorator> decorators(String biomeJson) {
|
||||
return decoder.decode(Target.BIOME, new JSONObject(biomeJson), "biome meadow")
|
||||
return decoder.decode(Level.BIOME, new JSONObject(biomeJson), "biome meadow")
|
||||
.find(DecorantSettings.class).orElseThrow().decorators();
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@ import art.arcane.iris.builtin.deposit.DepositSettings;
|
||||
import art.arcane.iris.builtin.deposit.DepositShape;
|
||||
import art.arcane.volmlib.util.json.JSONObject;
|
||||
import com.google.gson.Gson;
|
||||
import com.volmit.FeatureAttachment.Target;
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.block.BlockSpec;
|
||||
import com.volmit.host.LoadedPack;
|
||||
import com.volmit.host.ModuleHost;
|
||||
@@ -146,16 +146,16 @@ public class DepositSettingsDecodingTest {
|
||||
public void theFeatureIdIsNotAKey() {
|
||||
JSONObject byId = new JSONObject("{\"iris:deposit\": [{\"maxHeight\": 16}]}");
|
||||
|
||||
assertSame(ModuleSettings.NONE, decoder.decode(Target.REGION, byId, "region forests"));
|
||||
assertTrue(decoder.keys(Target.REGION).contains("deposits"));
|
||||
assertFalse(decoder.keys(Target.REGION).contains("iris:deposit"));
|
||||
assertSame(ModuleSettings.NONE, decoder.decode(Level.REGION, byId, "region forests"));
|
||||
assertTrue(decoder.keys(Level.REGION).contains("deposits"));
|
||||
assertFalse(decoder.keys(Level.REGION).contains("iris:deposit"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void anObjectOfOptionsUnderDepositsIsRefused() {
|
||||
JSONObject object = new JSONObject("{\"deposits\": {\"generators\": [{\"maxHeight\": 16}]}}");
|
||||
|
||||
IllegalArgumentException refused = assertThrows(IllegalArgumentException.class, () -> decoder.decode(Target.REGION, object, "region forests"));
|
||||
IllegalArgumentException refused = assertThrows(IllegalArgumentException.class, () -> decoder.decode(Level.REGION, object, "region forests"));
|
||||
|
||||
assertEquals("Cannot read settings iris:deposit under \"deposits\" in region forests: write a list, [...], of the generators,"
|
||||
+ " not an object of options", refused.getMessage());
|
||||
@@ -165,7 +165,7 @@ public class DepositSettingsDecodingTest {
|
||||
public void nullUnderDepositsIsRefused() {
|
||||
JSONObject nothing = new JSONObject("{\"deposits\": null}");
|
||||
|
||||
IllegalArgumentException refused = assertThrows(IllegalArgumentException.class, () -> decoder.decode(Target.REGION, nothing, "region forests"));
|
||||
IllegalArgumentException refused = assertThrows(IllegalArgumentException.class, () -> decoder.decode(Level.REGION, nothing, "region forests"));
|
||||
|
||||
assertTrue(refused.getMessage(), refused.getMessage().contains("under \"deposits\" in region forests: the value is null; write a list"));
|
||||
}
|
||||
@@ -174,13 +174,13 @@ public class DepositSettingsDecodingTest {
|
||||
public void aWronglyShapedGeneratorNamesTheKeyAndTheFile() {
|
||||
JSONObject broken = new JSONObject("{\"deposits\": [{\"maxHeight\": \"tall\"}]}");
|
||||
|
||||
IllegalArgumentException refused = assertThrows(IllegalArgumentException.class, () -> decoder.decode(Target.REGION, broken, "region forests"));
|
||||
IllegalArgumentException refused = assertThrows(IllegalArgumentException.class, () -> decoder.decode(Level.REGION, broken, "region forests"));
|
||||
|
||||
assertTrue(refused.getMessage(), refused.getMessage().startsWith("Cannot read settings iris:deposit under \"deposits\" in region forests: "));
|
||||
}
|
||||
|
||||
private List<DepositGenerator> deposits(String regionJson) {
|
||||
return decoder.decode(Target.REGION, new JSONObject(regionJson), "region forests")
|
||||
return decoder.decode(Level.REGION, new JSONObject(regionJson), "region forests")
|
||||
.find(DepositSettings.class).orElseThrow().generators();
|
||||
}
|
||||
}
|
||||
@@ -158,6 +158,8 @@ public class DimensionBottomTest {
|
||||
when(moduleSet.pack()).thenReturn(pack);
|
||||
when(data.getModules()).thenReturn(moduleSet);
|
||||
when(data.getDataFolder()).thenReturn(folder.getRoot());
|
||||
IrisPackResources resources = new IrisPackResources(data, List::of);
|
||||
when(data.getPackResources()).thenReturn(resources);
|
||||
when(data.getEngine()).thenReturn(engine);
|
||||
storage.bindTo(engine);
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ import art.arcane.iris.builtin.floating.MergeFloatingChildrenSettings;
|
||||
import art.arcane.iris.builtin.floating.TopShapeMode;
|
||||
import art.arcane.volmlib.util.json.JSONObject;
|
||||
import com.google.gson.Gson;
|
||||
import com.volmit.FeatureAttachment.Target;
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.host.LoadedPack;
|
||||
import com.volmit.host.ModuleHost;
|
||||
import org.junit.After;
|
||||
@@ -81,7 +81,7 @@ public class FloatingSettingsDecodingTest {
|
||||
public void aBiomeReadsItsFloatingChildrenAndTheMergeFlag() throws IOException {
|
||||
JSONObject biome = file("biomes/magnetics/plains.json");
|
||||
|
||||
ModuleSettings settings = decoder.decode(Target.BIOME, biome, "biome magnetics/plains");
|
||||
ModuleSettings settings = decoder.decode(Level.BIOME, biome, "biome magnetics/plains");
|
||||
|
||||
List<FloatingChildBiome> children = settings.find(FloatingChildSettings.class).orElseThrow().children();
|
||||
assertEquals(biome.getJSONArray("floatingChildBiomes").length(), children.size());
|
||||
@@ -106,19 +106,19 @@ public class FloatingSettingsDecodingTest {
|
||||
|
||||
@Test
|
||||
public void aBiomeWithoutFloatingChildrenDeclaresNone() {
|
||||
ModuleSettings settings = decoder.decode(Target.BIOME, new JSONObject("{\"mergeFloatingChildBiomes\": false, \"floatingChildBiomes\": [{}]}"), "biome test");
|
||||
ModuleSettings settings = decoder.decode(Level.BIOME, new JSONObject("{\"mergeFloatingChildBiomes\": false, \"floatingChildBiomes\": [{}]}"), "biome test");
|
||||
|
||||
assertFalse(settings.find(MergeFloatingChildrenSettings.class).orElseThrow().merge());
|
||||
assertEquals(1, settings.find(FloatingChildSettings.class).orElseThrow().children().size());
|
||||
assertEquals("an empty child keeps Iris's defaults", 160, settings.find(FloatingChildSettings.class).orElseThrow().children().getFirst().minHeightAboveSurface());
|
||||
assertTrue(decoder.decode(Target.BIOME, new JSONObject("{}"), "biome test").isEmpty());
|
||||
assertTrue(decoder.decode(Level.BIOME, new JSONObject("{}"), "biome test").isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void theTargetAndTheCarvingOfEveryChildAreBiomesTheDimensionUses() throws IOException {
|
||||
JSONObject biome = file("biomes/magnetics/plains.json");
|
||||
ModuleSettings biomeSettings = decoder.decode(Target.BIOME, biome, "biome magnetics/plains");
|
||||
ModuleSettings dimensionSettings = decoder.decode(Target.DIMENSION, file("dimensions/overworld.json"), "dimension overworld");
|
||||
ModuleSettings biomeSettings = decoder.decode(Level.BIOME, biome, "biome magnetics/plains");
|
||||
ModuleSettings dimensionSettings = decoder.decode(Level.DIMENSION, file("dimensions/overworld.json"), "dimension overworld");
|
||||
|
||||
Set<String> used = biomeSettings.usedBiomes(dimensionSettings);
|
||||
|
||||
@@ -140,9 +140,9 @@ public class FloatingSettingsDecodingTest {
|
||||
|
||||
@Test
|
||||
public void bothKeysAreOnlyReadAtBiomes() {
|
||||
assertTrue(decoder.keys(Target.BIOME).containsAll(List.of("floatingChildBiomes", "mergeFloatingChildBiomes")));
|
||||
assertFalse(decoder.keys(Target.REGION).contains("floatingChildBiomes"));
|
||||
assertFalse(decoder.keys(Target.DIMENSION).contains("mergeFloatingChildBiomes"));
|
||||
assertTrue(decoder.keys(Level.BIOME).containsAll(List.of("floatingChildBiomes", "mergeFloatingChildBiomes")));
|
||||
assertFalse(decoder.keys(Level.REGION).contains("floatingChildBiomes"));
|
||||
assertFalse(decoder.keys(Level.DIMENSION).contains("mergeFloatingChildBiomes"));
|
||||
}
|
||||
|
||||
private JSONObject file(String name) throws IOException {
|
||||
|
||||
@@ -288,6 +288,8 @@ public class IrisModuleMantleTest {
|
||||
SeedManager seeds = mock(SeedManager.class);
|
||||
when(engine.getData()).thenReturn(data);
|
||||
when(data.getDataFolder()).thenReturn(folder.getRoot());
|
||||
IrisPackResources resources = new IrisPackResources(data, List::of);
|
||||
when(data.getPackResources()).thenReturn(resources);
|
||||
when(engine.getSeedManager()).thenReturn(seeds);
|
||||
when(engine.getDimension()).thenReturn(new IrisDimension());
|
||||
when(engine.getRegion(anyInt(), anyInt())).thenReturn(new IrisRegion());
|
||||
@@ -306,37 +308,6 @@ public class IrisModuleMantleTest {
|
||||
assertTrue(chunks.containsKey(1L << 32));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aMantleStageFindsTheSnapshotsPackResources() throws IOException {
|
||||
List<Object> found = new ArrayList<>();
|
||||
IrisModule finder = new IrisModule() {
|
||||
public ModuleInfo info() { return ModuleInfo.of("iris:finder", "Finder", "1"); }
|
||||
public void setup(ModuleSetup setup) {
|
||||
setup.stages().define(Stage.mantle("iris:finder/oak")).reach(0).run(context ->
|
||||
found.add(context.resources().find(PackResourceFixture.oakKey(folder.getRoot())).orElseThrow()));
|
||||
}
|
||||
};
|
||||
Engine engine = mock(Engine.class);
|
||||
IrisData data = mock(IrisData.class);
|
||||
SeedManager seeds = mock(SeedManager.class);
|
||||
when(engine.getData()).thenReturn(data);
|
||||
when(data.getDataFolder()).thenReturn(folder.getRoot());
|
||||
PackResourceFixture.serve(data);
|
||||
when(engine.getSeedManager()).thenReturn(seeds);
|
||||
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(WORLD_MIN_HEIGHT);
|
||||
when(engine.getHeight()).thenReturn(SECTIONS * 16);
|
||||
|
||||
try (LoadedPack pack = LoadedPack.load(folder.newFolder("finder-pack").toPath(),
|
||||
ModuleHost.of(List.of(finder)).copyingJarsTo(folder.newFolder("finder-copies").toPath()))) {
|
||||
ModuleMantleComponent.forPack(engine, pack, Set.of()).getFirst().generate(0, 0, this::chunk);
|
||||
}
|
||||
|
||||
assertEquals(List.of(PackResourceFixture.OAK), found);
|
||||
}
|
||||
|
||||
private static byte[] bytes(ModuleLayerValues values) throws IOException {
|
||||
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
|
||||
values.write(new DataOutputStream(bytes));
|
||||
|
||||
@@ -35,7 +35,7 @@ import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.loot.LootResources;
|
||||
import art.arcane.volmlib.util.json.JSONObject;
|
||||
import com.google.gson.Gson;
|
||||
import com.volmit.FeatureAttachment.Target;
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.block.BlockSpec;
|
||||
import com.volmit.host.LoadedPack;
|
||||
import com.volmit.host.ModuleHost;
|
||||
@@ -93,7 +93,7 @@ public class LootAndSpawnPackDecodingTest {
|
||||
|
||||
@Test
|
||||
public void theDimensionReadsItsLootReference() throws IOException {
|
||||
ModuleSettings settings = decoder.decode(Target.DIMENSION, file("dimensions/overworld.json"), "dimension overworld");
|
||||
ModuleSettings settings = decoder.decode(Level.DIMENSION, file("dimensions/overworld.json"), "dimension overworld");
|
||||
|
||||
LootSettings loot = settings.find(LootSettings.class).orElseThrow();
|
||||
assertEquals(LootMode.FALLBACK, loot.mode());
|
||||
@@ -105,7 +105,7 @@ public class LootAndSpawnPackDecodingTest {
|
||||
|
||||
@Test
|
||||
public void aRegionReadsItsLootAndItsSpawners() throws IOException {
|
||||
ModuleSettings settings = decoder.decode(Target.REGION, file("regions/terralost.json"), "region terralost");
|
||||
ModuleSettings settings = decoder.decode(Level.REGION, file("regions/terralost.json"), "region terralost");
|
||||
|
||||
LootSettings loot = settings.find(LootSettings.class).orElseThrow();
|
||||
assertEquals(LootMode.FALLBACK, loot.mode());
|
||||
@@ -117,7 +117,7 @@ public class LootAndSpawnPackDecodingTest {
|
||||
|
||||
@Test
|
||||
public void aRegionReadsItsBlockDrops() throws IOException {
|
||||
ModuleSettings settings = decoder.decode(Target.REGION, file("regions/swamp.json"), "region swamp");
|
||||
ModuleSettings settings = decoder.decode(Level.REGION, file("regions/swamp.json"), "region swamp");
|
||||
|
||||
List<BlockDrop> drops = settings.find(BlockDropSettings.class).orElseThrow().drops();
|
||||
assertEquals(1, drops.size());
|
||||
@@ -135,7 +135,7 @@ public class LootAndSpawnPackDecodingTest {
|
||||
public void aRegionReadsItsEffectsLootAndBlockDropsTogether() throws IOException {
|
||||
JSONObject region = file("regions/mushroom.json");
|
||||
|
||||
ModuleSettings settings = decoder.decode(Target.REGION, region, "region mushroom");
|
||||
ModuleSettings settings = decoder.decode(Level.REGION, region, "region mushroom");
|
||||
|
||||
List<AmbientEffect> effects = settings.find(EffectSettings.class).orElseThrow().effects();
|
||||
assertEquals(region.getJSONArray("effects").length(), effects.size());
|
||||
@@ -162,7 +162,7 @@ public class LootAndSpawnPackDecodingTest {
|
||||
|
||||
@Test
|
||||
public void aRegionsPotionEffectKeepsItsStrengthAndTicks() throws IOException {
|
||||
ModuleSettings settings = decoder.decode(Target.REGION, file("regions/hot.json"), "region hot");
|
||||
ModuleSettings settings = decoder.decode(Level.REGION, file("regions/hot.json"), "region hot");
|
||||
|
||||
AmbientEffect potion = settings.find(EffectSettings.class).orElseThrow().effects().getFirst();
|
||||
assertEquals("CONFUSION", potion.potionEffect());
|
||||
@@ -175,7 +175,7 @@ public class LootAndSpawnPackDecodingTest {
|
||||
|
||||
@Test
|
||||
public void aBiomeReadsItsEffects() throws IOException {
|
||||
ModuleSettings settings = decoder.decode(Target.BIOME, file("biomes/tropical/volcanoes.json"), "biome tropical/volcanoes");
|
||||
ModuleSettings settings = decoder.decode(Level.BIOME, file("biomes/tropical/volcanoes.json"), "biome tropical/volcanoes");
|
||||
|
||||
AmbientEffect smoke = settings.find(EffectSettings.class).orElseThrow().effects().getFirst();
|
||||
assertEquals("CAMPFIRE_SIGNAL_SMOKE", smoke.particleEffect());
|
||||
@@ -191,12 +191,12 @@ public class LootAndSpawnPackDecodingTest {
|
||||
public void aDimensionHasNoEffects() throws IOException {
|
||||
JSONObject dimension = new JSONObject("{\"effects\": [{\"chance\": 1}], \"loot\": {}}");
|
||||
|
||||
ModuleSettings settings = decoder.decode(Target.DIMENSION, dimension, "dimension overworld");
|
||||
ModuleSettings settings = decoder.decode(Level.DIMENSION, dimension, "dimension overworld");
|
||||
|
||||
assertTrue(settings.find(EffectSettings.class).isEmpty());
|
||||
assertFalse(decoder.keys(Target.DIMENSION).contains("effects"));
|
||||
assertTrue(decoder.keys(Target.REGION).contains("effects"));
|
||||
assertTrue(decoder.keys(Target.BIOME).containsAll(Set.of("loot", "blockDrops", "entitySpawners", "effects")));
|
||||
assertFalse(decoder.keys(Level.DIMENSION).contains("effects"));
|
||||
assertTrue(decoder.keys(Level.REGION).contains("effects"));
|
||||
assertTrue(decoder.keys(Level.BIOME).containsAll(Set.of("loot", "blockDrops", "entitySpawners", "effects")));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -241,15 +241,15 @@ public class LootAndSpawnPackDecodingTest {
|
||||
public void theFeatureIdsAreNotKeys() {
|
||||
JSONObject byId = new JSONObject("{\"iris:loot\": {\"tables\": [\"a\"]}, \"iris:spawn\": [\"a\"]}");
|
||||
|
||||
assertSame(ModuleSettings.NONE, decoder.decode(Target.REGION, byId, "region forests"));
|
||||
assertSame(ModuleSettings.NONE, decoder.decode(Level.REGION, byId, "region forests"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aWrongShapeNamesTheKeyAndTheFile() {
|
||||
IllegalArgumentException list = assertThrows(IllegalArgumentException.class,
|
||||
() -> decoder.decode(Target.REGION, new JSONObject("{\"entitySpawners\": {\"spawners\": [\"a\"]}}"), "region forests"));
|
||||
() -> decoder.decode(Level.REGION, new JSONObject("{\"entitySpawners\": {\"spawners\": [\"a\"]}}"), "region forests"));
|
||||
IllegalArgumentException object = assertThrows(IllegalArgumentException.class,
|
||||
() -> decoder.decode(Target.REGION, new JSONObject("{\"loot\": [\"a\"]}"), "region forests"));
|
||||
() -> decoder.decode(Level.REGION, new JSONObject("{\"loot\": [\"a\"]}"), "region forests"));
|
||||
|
||||
assertTrue(list.getMessage(), list.getMessage().contains("under \"entitySpawners\" in region forests"));
|
||||
assertTrue(object.getMessage(), object.getMessage().contains("under \"loot\" in region forests"));
|
||||
@@ -259,9 +259,9 @@ public class LootAndSpawnPackDecodingTest {
|
||||
public void settingsEncodeBackToTheJsonThePackWrote() throws IOException {
|
||||
for (String file : List.of("regions/terralost.json", "regions/swamp.json", "regions/mushroom.json", "regions/hot.json")) {
|
||||
JSONObject region = this.file(file);
|
||||
ModuleSettings settings = decoder.decode(Target.REGION, region, "region " + file);
|
||||
ModuleSettings settings = decoder.decode(Level.REGION, region, "region " + file);
|
||||
|
||||
JSONObject written = decoder.encode(Target.REGION, settings);
|
||||
JSONObject written = decoder.encode(Level.REGION, settings);
|
||||
|
||||
for (String key : List.of("loot", "blockDrops", "entitySpawners", "effects")) {
|
||||
assertEquals(file + " " + key, region.has(key), written.has(key));
|
||||
|
||||
@@ -26,7 +26,7 @@ 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.project.hunk.Hunk;
|
||||
import com.volmit.FeatureAttachment.Target;
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.IrisFeature;
|
||||
import com.volmit.IrisModule;
|
||||
import com.volmit.ModuleInfo;
|
||||
@@ -65,7 +65,7 @@ public class ModuleChunkGenerationTest {
|
||||
private Engine engine;
|
||||
private Hunk<PlatformBlockState> blocks;
|
||||
|
||||
@Feature(id = "iris:pillar", name = "Pillar", key = "pillar", targets = {Target.BIOME, Target.REGION, Target.DIMENSION})
|
||||
@Feature(id = "iris:pillar", name = "Pillar", key = "pillar", targets = {Level.BIOME, Level.REGION, Level.DIMENSION})
|
||||
public static final class PillarSettings implements IrisFeature {
|
||||
private BlockState block = BlockState.parse("minecraft:stone");
|
||||
private int x;
|
||||
@@ -81,7 +81,7 @@ public class ModuleChunkGenerationTest {
|
||||
@Override
|
||||
public void setup(ModuleSetup setup) {
|
||||
setup.stages().define(Stage.chunk("iris:pillar/raise")).when(PillarSettings.class).run(context -> {
|
||||
PillarSettings pillar = context.configured(PillarSettings.class).getLast().value();
|
||||
PillarSettings pillar = context.configured(PillarSettings.class).mostSpecific().orElseThrow();
|
||||
com.volmit.hunk.Hunk<BlockState> chunk = context.hunk(BlockState.class);
|
||||
chunk.set(0, 1, 0, chunk.get(0, 0, 0));
|
||||
chunk.set(pillar.x, 2, 0, pillar.block);
|
||||
@@ -98,6 +98,8 @@ public class ModuleChunkGenerationTest {
|
||||
SeedManager seeds = mock(SeedManager.class);
|
||||
when(engine.getData()).thenReturn(data);
|
||||
when(data.getDataFolder()).thenReturn(folder.getRoot());
|
||||
IrisPackResources resources = new IrisPackResources(data, List::of);
|
||||
when(data.getPackResources()).thenReturn(resources);
|
||||
when(engine.getSeedManager()).thenReturn(seeds);
|
||||
when(seeds.getSeed()).thenReturn(1L);
|
||||
when(engine.getDimension()).thenReturn(new IrisDimension());
|
||||
@@ -195,28 +197,4 @@ public class ModuleChunkGenerationTest {
|
||||
when(state.key()).thenReturn(key);
|
||||
return state;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aChunkStageFindsTheSnapshotsPackResources() throws IOException {
|
||||
IrisData data = engine.getData();
|
||||
PackResourceFixture.serve(data);
|
||||
List<Object> found = new ArrayList<>();
|
||||
IrisModule finder = new IrisModule() {
|
||||
public ModuleInfo info() { return ModuleInfo.of("test:finder", "Finder", "1"); }
|
||||
public void setup(ModuleSetup setup) {
|
||||
setup.stages().define(Stage.chunk("test:finder/oak")).run(context ->
|
||||
found.add(context.resources().find(PackResourceFixture.oakKey(folder.getRoot())).orElseThrow()));
|
||||
}
|
||||
};
|
||||
|
||||
try (LoadedPack finderPack = LoadedPack.load(folder.newFolder("finder-pack").toPath(),
|
||||
ModuleHost.of(List.of(finder)).copyingJarsTo(folder.newFolder("finder-copies").toPath()))) {
|
||||
when(engine.getRegion(anyInt(), anyInt())).thenReturn(new IrisRegion());
|
||||
when(engine.getSurfaceBiome(anyInt(), anyInt())).thenReturn(new IrisBiome());
|
||||
|
||||
ModuleChunkGeneration.generate(finderPack, engine, 0, 0, blocks, null, false, null, ModuleChunkGenerationTest::platformState);
|
||||
}
|
||||
|
||||
assertEquals(List.of(PackResourceFixture.OAK), found);
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,7 @@ import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.TypeAdapter;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import com.volmit.FeatureAttachment.Target;
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.IrisFeature;
|
||||
import com.volmit.IrisModule;
|
||||
import com.volmit.ModuleInfo;
|
||||
@@ -69,7 +69,7 @@ public class ModuleSettingsDecoderTest {
|
||||
private LoadedPack pack;
|
||||
private ModuleSettingsDecoder decoder;
|
||||
|
||||
@Feature(id = "iris:moss", name = "Moss", key = "moss", targets = {Target.BIOME, Target.REGION})
|
||||
@Feature(id = "iris:moss", name = "Moss", key = "moss", targets = {Level.BIOME, Level.REGION})
|
||||
public static final class MossSettings implements IrisFeature {
|
||||
private int radius = 3;
|
||||
private BlockState block = new BlockState("minecraft:moss_block");
|
||||
@@ -82,17 +82,17 @@ public class ModuleSettingsDecoderTest {
|
||||
private int size = 1;
|
||||
}
|
||||
|
||||
@Feature(id = "iris:moss/cover", name = "Cover", key = "mossCover", targets = Target.BIOME)
|
||||
@Feature(id = "iris:moss/cover", name = "Cover", key = "mossCover", targets = Level.BIOME)
|
||||
public static final class CoverSettings implements IrisFeature {
|
||||
private double amount = 1;
|
||||
}
|
||||
|
||||
@Feature(id = "iris:moss/marks", name = "Marks", key = "mossMarks", targets = Target.BIOME)
|
||||
@Feature(id = "iris:moss/marks", name = "Marks", key = "mossMarks", targets = Level.BIOME)
|
||||
public static final class MarksSettings implements IrisFeature {
|
||||
private List<IrisPosition> marks = List.of();
|
||||
}
|
||||
|
||||
@Feature(id = "iris:moss/values", name = "Values", key = "mossValues", targets = Target.BIOME)
|
||||
@Feature(id = "iris:moss/values", name = "Values", key = "mossValues", targets = Level.BIOME)
|
||||
public static final class ValuesSettings implements IrisFeature {
|
||||
private List<BlockSpec> palette = List.of();
|
||||
private NoiseStyle style = NoiseStyle.of("SIMPLEX");
|
||||
@@ -133,7 +133,7 @@ public class ModuleSettingsDecoderTest {
|
||||
}
|
||||
|
||||
private MossSettings moss(String json) {
|
||||
return decoder.decode(Target.BIOME, new JSONObject(json), "biome desert/dunes").find(MossSettings.class).orElseThrow();
|
||||
return decoder.decode(Level.BIOME, new JSONObject(json), "biome desert/dunes").find(MossSettings.class).orElseThrow();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -151,13 +151,13 @@ public class ModuleSettingsDecoderTest {
|
||||
|
||||
@Test
|
||||
public void declaresNothingWhereNoKeyIsPresent() {
|
||||
assertSame(ModuleSettings.NONE, decoder.decode(Target.BIOME, new JSONObject("{\"name\": \"Dunes\"}"), "biome desert/dunes"));
|
||||
assertSame(ModuleSettings.NONE, decoder.decode(Target.DIMENSION, new JSONObject("{\"moss\": {}}"), "dimension overworld"));
|
||||
assertSame(ModuleSettings.NONE, decoder.decode(Level.BIOME, new JSONObject("{\"name\": \"Dunes\"}"), "biome desert/dunes"));
|
||||
assertSame(ModuleSettings.NONE, decoder.decode(Level.DIMENSION, new JSONObject("{\"moss\": {}}"), "dimension overworld"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void theFeatureIdIsNotAKeyOfTheSettings() {
|
||||
assertSame(ModuleSettings.NONE, decoder.decode(Target.BIOME, new JSONObject("{\"iris:moss\": {\"radius\": 7}}"), "biome desert/dunes"));
|
||||
assertSame(ModuleSettings.NONE, decoder.decode(Level.BIOME, new JSONObject("{\"iris:moss\": {\"radius\": 7}}"), "biome desert/dunes"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -184,7 +184,7 @@ public class ModuleSettingsDecoderTest {
|
||||
public void apiValueTypesReadTheJsonIrisClassesRead() throws IOException {
|
||||
Path styles = Files.createDirectories(packFolder.resolve("snippet/style"));
|
||||
Files.writeString(styles.resolve("deepslate.json"), "{\"style\": \"STATIC\"}");
|
||||
ValuesSettings values = decoder.decode(Target.BIOME, new JSONObject("""
|
||||
ValuesSettings values = decoder.decode(Level.BIOME, new JSONObject("""
|
||||
{"mossValues": {
|
||||
"palette": [{"block": "minecraft:oak_log", "data": {"axis": "y", "waterlogged": true, "level": 3}, "weight": 2,
|
||||
"backup": {"block": "stone"}, "tileData": {"Delay": 20, "SpawnData": {"entity": {"id": "zombie"}}}},
|
||||
@@ -226,18 +226,18 @@ public class ModuleSettingsDecoderTest {
|
||||
|
||||
@Test
|
||||
public void listsTheKeysModulesReadPerTarget() {
|
||||
assertEquals(Set.of("moss", "mossCover", "mossMarks", "mossValues"), decoder.keys(Target.BIOME));
|
||||
assertEquals(Set.of(), decoder.keys(Target.DIMENSION));
|
||||
assertEquals(Set.of("moss", "mossCover", "mossMarks", "mossValues"), decoder.keys(Level.BIOME));
|
||||
assertEquals(Set.of(), decoder.keys(Level.DIMENSION));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void settingsAreAlwaysAnObjectEvenWithOneOption() {
|
||||
assertEquals(0.25, decoder.decode(Target.BIOME, new JSONObject("{\"mossCover\": {\"amount\": 0.25}}"), "biome desert/dunes")
|
||||
assertEquals(0.25, decoder.decode(Level.BIOME, new JSONObject("{\"mossCover\": {\"amount\": 0.25}}"), "biome desert/dunes")
|
||||
.find(CoverSettings.class).orElseThrow().amount, 0);
|
||||
|
||||
for (String bare : List.of("0.5", "[1, 2]", "true")) {
|
||||
IllegalArgumentException refused = assertThrows(IllegalArgumentException.class,
|
||||
() -> decoder.decode(Target.BIOME, new JSONObject("{\"mossCover\": " + bare + "}"), "biome desert/dunes"));
|
||||
() -> decoder.decode(Level.BIOME, new JSONObject("{\"mossCover\": " + bare + "}"), "biome desert/dunes"));
|
||||
assertEquals("Cannot read settings iris:moss/cover under \"mossCover\" in biome desert/dunes: write the settings as an object,"
|
||||
+ " {\"<option>\": ...}", refused.getMessage());
|
||||
}
|
||||
@@ -260,7 +260,7 @@ public class ModuleSettingsDecoderTest {
|
||||
}).create();
|
||||
ModuleSettingsDecoder withIrisGson = new ModuleSettingsDecoder(pack.catalog(), packFolder, () -> iris);
|
||||
|
||||
List<IrisPosition> marks = withIrisGson.decode(Target.BIOME, new JSONObject("{\"mossMarks\": {\"marks\": [\"a\", \"b\"]}}"), "biome desert/dunes")
|
||||
List<IrisPosition> marks = withIrisGson.decode(Level.BIOME, new JSONObject("{\"mossMarks\": {\"marks\": [\"a\", \"b\"]}}"), "biome desert/dunes")
|
||||
.find(MarksSettings.class).orElseThrow().marks;
|
||||
|
||||
assertEquals(List.of(marked, marked), marks);
|
||||
|
||||
@@ -26,10 +26,9 @@ import com.volmit.IrisModule;
|
||||
import com.volmit.ModuleInfo;
|
||||
import com.volmit.ModuleLifecycle;
|
||||
import com.volmit.ModuleSetup;
|
||||
import com.volmit.config.PackSettings;
|
||||
import com.volmit.PackContext;
|
||||
import com.volmit.host.LoadedPack;
|
||||
import com.volmit.host.ModuleHost;
|
||||
import com.volmit.resource.PackResources;
|
||||
import com.volmit.world.PackWorld;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
@@ -93,7 +92,7 @@ public class ModuleWorldsTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void packLoaded(PackResources resources, PackSettings settings) {
|
||||
public void packLoaded(PackContext pack) {
|
||||
record("loaded");
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -31,7 +31,7 @@ import art.arcane.iris.spi.PlatformRegistries;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.volmit.FeatureAttachment.Target;
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.IrisFeature;
|
||||
import com.volmit.IrisModule;
|
||||
import com.volmit.ModuleInfo;
|
||||
@@ -77,7 +77,7 @@ public class ObjectPlacementModuleSettingsTest {
|
||||
private LoadedPack pack;
|
||||
private Gson gson;
|
||||
|
||||
@Feature(id = "example:glow", name = "Glow", key = "glow", targets = Target.OBJECT_PLACEMENT)
|
||||
@Feature(id = "example:glow", name = "Glow", key = "glow", targets = Level.PLACEMENT)
|
||||
public static final class GlowSettings implements IrisFeature {
|
||||
private String block = "minecraft:glowstone";
|
||||
}
|
||||
@@ -95,7 +95,7 @@ public class ObjectPlacementModuleSettingsTest {
|
||||
public void setup(ModuleSetup setup) {
|
||||
setup.stages().define(TOP).when(GlowSettings.class).requires(IrisStages.Blocks.COMPLETE, IrisStages.Anchor.FINAL).run(context -> {
|
||||
int y = context.output(IrisStages.Anchor.FINAL).y() + 1;
|
||||
String block = context.configured(GlowSettings.class).getFirst().value().block;
|
||||
String block = context.configured(GlowSettings.class).values().getFirst().block;
|
||||
context.access().set(new PlacedBlock(new BlockPosition(0, y, 0), com.volmit.block.BlockState.parse(block), Optional.empty()));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ import art.arcane.iris.builtin.terrain.OreGenerator;
|
||||
import art.arcane.iris.builtin.terrain.OreSettings;
|
||||
import art.arcane.volmlib.util.json.JSONObject;
|
||||
import com.google.gson.Gson;
|
||||
import com.volmit.FeatureAttachment.Target;
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.block.BlockSpec;
|
||||
import com.volmit.host.LoadedPack;
|
||||
import com.volmit.host.ModuleHost;
|
||||
@@ -81,7 +81,7 @@ public class OreSettingsDecodingTest {
|
||||
public void theOverworldReadsItsOresInTheOrderTheFileListsThem() throws IOException {
|
||||
JSONObject dimension = new JSONObject(Files.readString(packFolder.resolve("dimensions/overworld.json")));
|
||||
|
||||
List<OreGenerator> ores = decoder.decode(Target.DIMENSION, dimension, "dimension overworld")
|
||||
List<OreGenerator> ores = decoder.decode(Level.DIMENSION, dimension, "dimension overworld")
|
||||
.find(OreSettings.class).orElseThrow().generators();
|
||||
|
||||
assertEquals(dimension.getJSONArray("ores").length(), ores.size());
|
||||
@@ -113,7 +113,7 @@ public class OreSettingsDecodingTest {
|
||||
]}
|
||||
""");
|
||||
|
||||
for (Target target : List.of(Target.REGION, Target.BIOME)) {
|
||||
for (Level target : List.of(Level.REGION, Level.BIOME)) {
|
||||
List<OreGenerator> read = decoder.decode(target, ores, "test").find(OreSettings.class).orElseThrow().generators();
|
||||
|
||||
assertEquals(2, read.size());
|
||||
@@ -130,12 +130,12 @@ public class OreSettingsDecodingTest {
|
||||
|
||||
@Test
|
||||
public void hideOresForHiddenOreIsABooleanOnTheDimension() {
|
||||
ModuleSettings hidden = decoder.decode(Target.DIMENSION, new JSONObject("{\"hideOresForHiddenOre\": true}"), "dimension test");
|
||||
ModuleSettings shown = decoder.decode(Target.DIMENSION, new JSONObject("{\"hideOresForHiddenOre\": false}"), "dimension test");
|
||||
ModuleSettings hidden = decoder.decode(Level.DIMENSION, new JSONObject("{\"hideOresForHiddenOre\": true}"), "dimension test");
|
||||
ModuleSettings shown = decoder.decode(Level.DIMENSION, new JSONObject("{\"hideOresForHiddenOre\": false}"), "dimension test");
|
||||
|
||||
assertTrue(hidden.find(HideOresSettings.class).orElseThrow().hide());
|
||||
assertFalse(shown.find(HideOresSettings.class).orElseThrow().hide());
|
||||
assertTrue("a dimension that does not write it declares nothing", decoder.decode(Target.DIMENSION, new JSONObject("{}"), "dimension test").isEmpty());
|
||||
assertTrue("a dimension that does not write it declares nothing", decoder.decode(Level.DIMENSION, new JSONObject("{}"), "dimension test").isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -147,7 +147,7 @@ public class OreSettingsDecodingTest {
|
||||
]}
|
||||
""");
|
||||
|
||||
for (Target target : List.of(Target.DIMENSION, Target.REGION, Target.BIOME)) {
|
||||
for (Level target : List.of(Level.DIMENSION, Level.REGION, Level.BIOME)) {
|
||||
List<DepositVariant> variants = decoder.decode(target, json, "test").find(DepositVariantSettings.class).orElseThrow().variants();
|
||||
|
||||
assertEquals(2, variants.size());
|
||||
@@ -163,8 +163,8 @@ public class OreSettingsDecodingTest {
|
||||
|
||||
@Test
|
||||
public void theTwoOreDepositMultipliersAreNumbersOnTheBiome() {
|
||||
ModuleSettings tuned = decoder.decode(Target.BIOME, new JSONObject("{\"oreDepositFrequencyMultiplier\": 0.4, \"oreDepositSizeMultiplier\": 2}"), "biome test");
|
||||
ModuleSettings plain = decoder.decode(Target.BIOME, new JSONObject("{}"), "biome test");
|
||||
ModuleSettings tuned = decoder.decode(Level.BIOME, new JSONObject("{\"oreDepositFrequencyMultiplier\": 0.4, \"oreDepositSizeMultiplier\": 2}"), "biome test");
|
||||
ModuleSettings plain = decoder.decode(Level.BIOME, new JSONObject("{}"), "biome test");
|
||||
|
||||
assertEquals(0.4, tuned.find(OreFrequencySettings.class).orElseThrow().multiplier(), 0);
|
||||
assertEquals(2, tuned.find(OreSizeSettings.class).orElseThrow().multiplier(), 0);
|
||||
@@ -174,10 +174,10 @@ public class OreSettingsDecodingTest {
|
||||
|
||||
@Test
|
||||
public void everyKeyIsOnlyReadAtTheLevelsTheOldFieldExistedAt() {
|
||||
assertTrue(decoder.keys(Target.DIMENSION).containsAll(List.of("ores", "hideOresForHiddenOre", "depositVariants")));
|
||||
assertTrue(decoder.keys(Target.REGION).containsAll(List.of("ores", "depositVariants")));
|
||||
assertFalse(decoder.keys(Target.REGION).contains("hideOresForHiddenOre"));
|
||||
assertTrue(decoder.keys(Target.BIOME).containsAll(List.of("ores", "depositVariants", "oreDepositFrequencyMultiplier", "oreDepositSizeMultiplier")));
|
||||
assertFalse(decoder.keys(Target.DIMENSION).contains("oreDepositFrequencyMultiplier"));
|
||||
assertTrue(decoder.keys(Level.DIMENSION).containsAll(List.of("ores", "hideOresForHiddenOre", "depositVariants")));
|
||||
assertTrue(decoder.keys(Level.REGION).containsAll(List.of("ores", "depositVariants")));
|
||||
assertFalse(decoder.keys(Level.REGION).contains("hideOresForHiddenOre"));
|
||||
assertTrue(decoder.keys(Level.BIOME).containsAll(List.of("ores", "depositVariants", "oreDepositFrequencyMultiplier", "oreDepositSizeMultiplier")));
|
||||
assertFalse(decoder.keys(Level.DIMENSION).contains("oreDepositFrequencyMultiplier"));
|
||||
}
|
||||
}
|
||||
+10
-10
@@ -32,7 +32,7 @@ import art.arcane.volmlib.util.json.JSONObject;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.volmit.FeatureAttachment.Target;
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.block.BlockSpec;
|
||||
import com.volmit.host.LoadedPack;
|
||||
import com.volmit.host.ModuleHost;
|
||||
@@ -88,7 +88,7 @@ public class PackBeforeThePortDecodingTest {
|
||||
public void aBiomeWithDecoratorsAndDepositsReadsBothUnderTheirOldKeys() throws IOException {
|
||||
JSONObject biome = file("biomes/mesa/red.json");
|
||||
|
||||
ModuleSettings settings = decoder.decode(Target.BIOME, biome, "biome mesa/red");
|
||||
ModuleSettings settings = decoder.decode(Level.BIOME, biome, "biome mesa/red");
|
||||
|
||||
List<Decorator> decorators = settings.find(DecorantSettings.class).orElseThrow().decorators();
|
||||
assertEquals(biome.getJSONArray("decorators").length(), decorators.size());
|
||||
@@ -110,7 +110,7 @@ public class PackBeforeThePortDecodingTest {
|
||||
public void aBiomeWithManyDecoratorsAndDepositsReadsEveryEntry() throws IOException {
|
||||
JSONObject biome = file("biomes/temperate/roughplains.json");
|
||||
|
||||
ModuleSettings settings = decoder.decode(Target.BIOME, biome, "biome temperate/roughplains");
|
||||
ModuleSettings settings = decoder.decode(Level.BIOME, biome, "biome temperate/roughplains");
|
||||
|
||||
assertEquals(biome.getJSONArray("decorators").length(), settings.find(DecorantSettings.class).orElseThrow().decorators().size());
|
||||
List<DepositGenerator> deposits = settings.find(DepositSettings.class).orElseThrow().generators();
|
||||
@@ -123,7 +123,7 @@ public class PackBeforeThePortDecodingTest {
|
||||
public void aRegionReadsItsDeposits() throws IOException {
|
||||
JSONObject region = file("regions/magnetics.json");
|
||||
|
||||
List<DepositGenerator> deposits = decoder.decode(Target.REGION, region, "region magnetics")
|
||||
List<DepositGenerator> deposits = decoder.decode(Level.REGION, region, "region magnetics")
|
||||
.find(DepositSettings.class).orElseThrow().generators();
|
||||
|
||||
assertEquals(8, deposits.size());
|
||||
@@ -136,7 +136,7 @@ public class PackBeforeThePortDecodingTest {
|
||||
public void theDimensionReadsItsDepositsAndItsImportedStructures() throws IOException {
|
||||
JSONObject dimension = file("dimensions/overworld.json");
|
||||
|
||||
ModuleSettings settings = decoder.decode(Target.DIMENSION, dimension, "dimension overworld");
|
||||
ModuleSettings settings = decoder.decode(Level.DIMENSION, dimension, "dimension overworld");
|
||||
|
||||
List<DepositGenerator> deposits = settings.find(DepositSettings.class).orElseThrow().generators();
|
||||
assertEquals(23, deposits.size());
|
||||
@@ -155,7 +155,7 @@ public class PackBeforeThePortDecodingTest {
|
||||
public void aBiomeReadsItsObjectPlacementsAndKeepsTheJsonIrisReadsThemFrom() throws IOException {
|
||||
JSONObject biome = file("biomes/temperate/roughplains.json");
|
||||
|
||||
List<ObjectPlacement> objects = decoder.decode(Target.BIOME, biome, "biome temperate/roughplains")
|
||||
List<ObjectPlacement> objects = decoder.decode(Level.BIOME, biome, "biome temperate/roughplains")
|
||||
.find(ObjectSettings.class).orElseThrow().objects();
|
||||
|
||||
assertEquals(biome.getJSONArray("objects").length(), objects.size());
|
||||
@@ -171,7 +171,7 @@ public class PackBeforeThePortDecodingTest {
|
||||
public void aBiomeReadsItsProceduralTreesWithTheirPalettes() throws IOException {
|
||||
JSONObject biome = file("biomes/estranged/bloomspire-orchard.json");
|
||||
|
||||
ProceduralObjectSettings procedural = decoder.decode(Target.BIOME, biome, "biome estranged/bloomspire-orchard")
|
||||
ProceduralObjectSettings procedural = decoder.decode(Level.BIOME, biome, "biome estranged/bloomspire-orchard")
|
||||
.find(ProceduralObjectSettings.class).orElseThrow();
|
||||
|
||||
assertEquals(biome.getJSONObject("proceduralObjects").getJSONArray("trees").length(), procedural.trees().size());
|
||||
@@ -185,10 +185,10 @@ public class PackBeforeThePortDecodingTest {
|
||||
|
||||
@Test
|
||||
public void everyTopLevelKeyOfTheseFilesIsAFieldOfIrisOrAKeyOfAModule() throws IOException {
|
||||
Map<String, Target> files = Map.of("biomes/mesa/red.json", Target.BIOME, "biomes/temperate/roughplains.json", Target.BIOME,
|
||||
"biomes/estranged/bloomspire-orchard.json", Target.BIOME, "regions/magnetics.json", Target.REGION, "dimensions/overworld.json", Target.DIMENSION);
|
||||
Map<String, Level> files = Map.of("biomes/mesa/red.json", Level.BIOME, "biomes/temperate/roughplains.json", Level.BIOME,
|
||||
"biomes/estranged/bloomspire-orchard.json", Level.BIOME, "regions/magnetics.json", Level.REGION, "dimensions/overworld.json", Level.DIMENSION);
|
||||
|
||||
for (Map.Entry<String, Target> file : files.entrySet()) {
|
||||
for (Map.Entry<String, Level> file : files.entrySet()) {
|
||||
Set<String> unknown = new TreeSet<>(file(file.getKey()).keySet());
|
||||
unknown.removeAll(ModuleTargets.reservedFields().get(file.getValue()));
|
||||
unknown.removeAll(decoder.keys(file.getValue()));
|
||||
|
||||
+8
-8
@@ -28,7 +28,7 @@ import art.arcane.iris.builtin.structure.StructureTerrainMode;
|
||||
import art.arcane.iris.engine.framework.StructurePlacementGrid;
|
||||
import art.arcane.volmlib.util.json.JSONObject;
|
||||
import com.google.gson.Gson;
|
||||
import com.volmit.FeatureAttachment.Target;
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.host.LoadedPack;
|
||||
import com.volmit.host.ModuleHost;
|
||||
import org.junit.After;
|
||||
@@ -137,7 +137,7 @@ public class StructurePlacementSettingsDecodingTest {
|
||||
|
||||
@Test
|
||||
public void theOverworldPlacementReadsAsThePackWroteIt() {
|
||||
StructurePlacement placement = placements(Target.DIMENSION, OVERWORLD).getFirst();
|
||||
StructurePlacement placement = placements(Level.DIMENSION, OVERWORLD).getFirst();
|
||||
|
||||
assertEquals(List.of("minecraft:ancient_city"), placement.nativeStructures().stream().map(NativeStructureSource::structure).toList());
|
||||
assertEquals(1, placement.nativeStructures().getFirst().weight());
|
||||
@@ -160,8 +160,8 @@ public class StructurePlacementSettingsDecodingTest {
|
||||
|
||||
@Test
|
||||
public void placementsKeepTheirIdentityAndStarts() {
|
||||
StructurePlacement overworld = placements(Target.DIMENSION, OVERWORLD).getFirst();
|
||||
StructurePlacement anonymous = placements(Target.BIOME, ANONYMOUS).getFirst();
|
||||
StructurePlacement overworld = placements(Level.DIMENSION, OVERWORLD).getFirst();
|
||||
StructurePlacement anonymous = placements(Level.BIOME, ANONYMOUS).getFirst();
|
||||
|
||||
assertEquals(-5401497891314909808L, StructurePlacementGrid.placementIdentity(overworld));
|
||||
assertEquals(-2165116524116229836L, StructurePlacementGrid.placementRng(overworld, 7, -11, 123L).getSeed());
|
||||
@@ -173,12 +173,12 @@ public class StructurePlacementSettingsDecodingTest {
|
||||
|
||||
@Test
|
||||
public void regionsAndBiomesDeclarePlacementsUnderTheSameKey() {
|
||||
assertTrue(decoder.keys(Target.REGION).contains("structures"));
|
||||
assertTrue(decoder.keys(Target.BIOME).contains("structures"));
|
||||
assertEquals(1, placements(Target.REGION, OVERWORLD).size());
|
||||
assertTrue(decoder.keys(Level.REGION).contains("structures"));
|
||||
assertTrue(decoder.keys(Level.BIOME).contains("structures"));
|
||||
assertEquals(1, placements(Level.REGION, OVERWORLD).size());
|
||||
}
|
||||
|
||||
private List<StructurePlacement> placements(Target target, String json) {
|
||||
private List<StructurePlacement> placements(Level target, String json) {
|
||||
return decoder.decode(target, new JSONObject(json), "test resource")
|
||||
.find(StructurePlacementSettings.class).orElseThrow().placements();
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import art.arcane.iris.builtin.structure.StructureTerrain;
|
||||
import art.arcane.iris.builtin.structure.StructureTerrainMode;
|
||||
import art.arcane.volmlib.util.json.JSONObject;
|
||||
import com.google.gson.Gson;
|
||||
import com.volmit.FeatureAttachment.Target;
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.block.BlockSpec;
|
||||
import com.volmit.host.LoadedPack;
|
||||
import com.volmit.host.ModuleHost;
|
||||
@@ -121,9 +121,9 @@ public class StructureSettingsDecodingTest {
|
||||
public void theFeatureIdIsNotAKeyAndEmptySettingsHaveTheDefaults() {
|
||||
JSONObject byId = new JSONObject("{\"iris:structure\": {\"disabled\": [\"minecraft:village\"]}}");
|
||||
|
||||
assertSame(ModuleSettings.NONE, decoder.decode(Target.DIMENSION, byId, "dimension overworld"));
|
||||
assertTrue(decoder.keys(Target.DIMENSION).contains("importedStructures"));
|
||||
assertFalse(decoder.keys(Target.DIMENSION).contains("iris:structure"));
|
||||
assertSame(ModuleSettings.NONE, decoder.decode(Level.DIMENSION, byId, "dimension overworld"));
|
||||
assertTrue(decoder.keys(Level.DIMENSION).contains("importedStructures"));
|
||||
assertFalse(decoder.keys(Level.DIMENSION).contains("iris:structure"));
|
||||
StructureSettings defaults = settings("{\"importedStructures\": {}}");
|
||||
assertTrue(defaults.datapackOverrides());
|
||||
assertEquals(List.of(), defaults.disabled());
|
||||
@@ -136,14 +136,14 @@ public class StructureSettingsDecodingTest {
|
||||
JSONObject list = new JSONObject("{\"importedStructures\": [\"minecraft:village\"]}");
|
||||
|
||||
IllegalArgumentException refused = assertThrows(IllegalArgumentException.class,
|
||||
() -> decoder.decode(Target.DIMENSION, list, "dimension overworld"));
|
||||
() -> decoder.decode(Level.DIMENSION, list, "dimension overworld"));
|
||||
|
||||
assertEquals("Cannot read settings iris:structure under \"importedStructures\" in dimension overworld:"
|
||||
+ " write the settings as an object, {\"<option>\": ...}", refused.getMessage());
|
||||
}
|
||||
|
||||
private StructureSettings settings(String dimensionJson) {
|
||||
return decoder.decode(Target.DIMENSION, new JSONObject(dimensionJson), "dimension overworld")
|
||||
return decoder.decode(Level.DIMENSION, new JSONObject(dimensionJson), "dimension overworld")
|
||||
.find(StructureSettings.class).orElseThrow();
|
||||
}
|
||||
}
|
||||
@@ -37,7 +37,7 @@ import art.arcane.iris.builtin.terrain.SlabSettings;
|
||||
import art.arcane.iris.builtin.terrain.WallSettings;
|
||||
import art.arcane.volmlib.util.json.JSONObject;
|
||||
import com.google.gson.Gson;
|
||||
import com.volmit.FeatureAttachment.Target;
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.block.BlockSpec;
|
||||
import com.volmit.host.LoadedPack;
|
||||
import com.volmit.host.ModuleHost;
|
||||
@@ -95,7 +95,7 @@ public class TerrainSettingsDecodingTest {
|
||||
public void aLockedBiomeReadsItsLayersAndWall() throws IOException {
|
||||
JSONObject biome = file("biomes/mesa/yellow.json");
|
||||
|
||||
ModuleSettings settings = decoder.decode(Target.BIOME, biome, "biome mesa/yellow");
|
||||
ModuleSettings settings = decoder.decode(Level.BIOME, biome, "biome mesa/yellow");
|
||||
|
||||
List<PaletteLayer> layers = settings.find(LayersSettings.class).orElseThrow().layers();
|
||||
assertEquals(biome.getJSONArray("layers").length(), layers.size());
|
||||
@@ -118,7 +118,7 @@ public class TerrainSettingsDecodingTest {
|
||||
|
||||
@Test
|
||||
public void aSlabIsOneLayerWithIrisDefaults() throws IOException {
|
||||
ModuleSettings settings = decoder.decode(Target.BIOME, file("biomes/mountain/shore/beach.json"), "biome mountain/shore/beach");
|
||||
ModuleSettings settings = decoder.decode(Level.BIOME, file("biomes/mountain/shore/beach.json"), "biome mountain/shore/beach");
|
||||
|
||||
PaletteLayer slab = settings.find(SlabSettings.class).orElseThrow().layer();
|
||||
|
||||
@@ -136,7 +136,7 @@ public class TerrainSettingsDecodingTest {
|
||||
public void seaLayersKeepTheirNoiseAndWeights() throws IOException {
|
||||
JSONObject biome = file("biomes/frozen/sea/river.json");
|
||||
|
||||
List<PaletteLayer> seaLayers = decoder.decode(Target.BIOME, biome, "biome frozen/sea/river").find(SeaLayersSettings.class).orElseThrow().layers();
|
||||
List<PaletteLayer> seaLayers = decoder.decode(Level.BIOME, biome, "biome frozen/sea/river").find(SeaLayersSettings.class).orElseThrow().layers();
|
||||
|
||||
assertEquals(biome.getJSONArray("seaLayers").length(), seaLayers.size());
|
||||
PaletteLayer first = seaLayers.getFirst();
|
||||
@@ -154,7 +154,7 @@ public class TerrainSettingsDecodingTest {
|
||||
public void caveCeilingLayersAreAListOfLayers() throws IOException {
|
||||
JSONObject biome = file("biomes/carving/polarity-grotto.json");
|
||||
|
||||
List<PaletteLayer> ceiling = decoder.decode(Target.BIOME, biome, "biome carving/polarity-grotto")
|
||||
List<PaletteLayer> ceiling = decoder.decode(Level.BIOME, biome, "biome carving/polarity-grotto")
|
||||
.find(CaveCeilingLayersSettings.class).orElseThrow().layers();
|
||||
|
||||
assertEquals(1, ceiling.size());
|
||||
@@ -166,7 +166,7 @@ public class TerrainSettingsDecodingTest {
|
||||
|
||||
@Test
|
||||
public void lockLayersMaxIsANumberAndLockLayersABoolean() {
|
||||
ModuleSettings settings = decoder.decode(Target.BIOME, new JSONObject("{\"lockLayers\": false, \"lockLayersMax\": 4}"), "biome mesa");
|
||||
ModuleSettings settings = decoder.decode(Level.BIOME, new JSONObject("{\"lockLayers\": false, \"lockLayersMax\": 4}"), "biome mesa");
|
||||
|
||||
assertFalse(settings.find(LockLayersSettings.class).orElseThrow().locked());
|
||||
assertEquals(4, settings.find(LockLayersMaxSettings.class).orElseThrow().layers());
|
||||
@@ -175,7 +175,7 @@ public class TerrainSettingsDecodingTest {
|
||||
|
||||
@Test
|
||||
public void aLayerWrittenWithoutOptionsHasIrisDefaults() {
|
||||
ModuleSettings settings = decoder.decode(Target.BIOME, new JSONObject("{\"layers\": [{}], \"slab\": {}}"), "biome plain");
|
||||
ModuleSettings settings = decoder.decode(Level.BIOME, new JSONObject("{\"layers\": [{}], \"slab\": {}}"), "biome plain");
|
||||
|
||||
PaletteLayer layer = settings.find(LayersSettings.class).orElseThrow().layers().getFirst();
|
||||
assertEquals(List.of(BlockSpec.of("grass_block")), layer.palette());
|
||||
@@ -195,7 +195,7 @@ public class TerrainSettingsDecodingTest {
|
||||
Files.writeString(snippets.resolve("sandy.json"), "{\"minHeight\": 2, \"maxHeight\": 4, \"palette\": [{\"block\": \"sand\"}]}");
|
||||
ModuleSettingsDecoder snippetDecoder = new ModuleSettingsDecoder(pack.catalog(), snippets.getParent().getParent(), Gson::new);
|
||||
|
||||
PaletteLayer layer = snippetDecoder.decode(Target.BIOME, new JSONObject("{\"layers\": [\"snippet/biome-palette/sandy\", \"snippet/sandy\"]}"), "biome dunes")
|
||||
PaletteLayer layer = snippetDecoder.decode(Level.BIOME, new JSONObject("{\"layers\": [\"snippet/biome-palette/sandy\", \"snippet/sandy\"]}"), "biome dunes")
|
||||
.find(LayersSettings.class).orElseThrow().layers().getFirst();
|
||||
|
||||
assertEquals(4, layer.maxHeight());
|
||||
@@ -204,7 +204,7 @@ public class TerrainSettingsDecodingTest {
|
||||
|
||||
@Test
|
||||
public void theDimensionReadsItsPalettesAndPostProcessingSwitches() {
|
||||
ModuleSettings settings = decoder.decode(Target.DIMENSION, new JSONObject("""
|
||||
ModuleSettings settings = decoder.decode(Level.DIMENSION, new JSONObject("""
|
||||
{"rockPalette": {"style": {"style": "SIMPLEX", "zoom": 2}, "zoom": 9,
|
||||
"palette": [{"block": "minecraft:stone", "weight": 3}, {"block": "minecraft:granite"}]},
|
||||
"fluidPalette": {"palette": [{"block": "minecraft:lava"}]},
|
||||
@@ -224,7 +224,7 @@ public class TerrainSettingsDecodingTest {
|
||||
|
||||
@Test
|
||||
public void theDimensionReadsItsBedrockDecoratingAndExplodedPaletteKeysAsPacksWriteThem() {
|
||||
ModuleSettings settings = decoder.decode(Target.DIMENSION, new JSONObject(
|
||||
ModuleSettings settings = decoder.decode(Level.DIMENSION, new JSONObject(
|
||||
"{\"bedrock\": false, \"decorate\": false, \"explodeBiomePalettes\": true, \"explodeBiomePaletteSize\": 5}"), "dimension flat");
|
||||
|
||||
assertFalse(settings.find(BedrockSettings.class).orElseThrow().bedrock());
|
||||
@@ -232,14 +232,14 @@ public class TerrainSettingsDecodingTest {
|
||||
assertTrue(settings.find(ExplodeBiomePalettesSettings.class).orElseThrow().explode());
|
||||
assertEquals(5, settings.find(ExplodeBiomePaletteSizeSettings.class).orElseThrow().size());
|
||||
for (String key : Set.of("bedrock", "decorate", "explodeBiomePalettes", "explodeBiomePaletteSize")) {
|
||||
assertTrue(key, decoder.keys(Target.DIMENSION).contains(key));
|
||||
assertFalse(key + " is no field of Iris any more", ModuleTargets.reservedFields().get(Target.DIMENSION).contains(key));
|
||||
assertTrue(key, decoder.keys(Level.DIMENSION).contains(key));
|
||||
assertFalse(key + " is no field of Iris any more", ModuleTargets.reservedFields().get(Level.DIMENSION).contains(key));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aDimensionThatWritesNothingIsStoneAndWaterWithPostProcessingOn() {
|
||||
ModuleSettings settings = decoder.decode(Target.DIMENSION, new JSONObject("{}"), "dimension overworld");
|
||||
ModuleSettings settings = decoder.decode(Level.DIMENSION, new JSONObject("{}"), "dimension overworld");
|
||||
|
||||
assertTrue(settings.find(RockPaletteSettings.class).isEmpty());
|
||||
assertEquals(List.of(BlockSpec.of("stone")), new RockPaletteSettings().palette().palette());
|
||||
@@ -254,7 +254,7 @@ public class TerrainSettingsDecodingTest {
|
||||
@Test
|
||||
public void aBooleanWrittenAsAnObjectIsRefused() {
|
||||
IllegalArgumentException refused = assertThrows(IllegalArgumentException.class,
|
||||
() -> decoder.decode(Target.BIOME, new JSONObject("{\"lockLayers\": {\"locked\": true}}"), "biome mesa"));
|
||||
() -> decoder.decode(Level.BIOME, new JSONObject("{\"lockLayers\": {\"locked\": true}}"), "biome mesa"));
|
||||
|
||||
assertTrue(refused.getMessage(), refused.getMessage().startsWith("Cannot read settings iris:terrain/lock-layers under \"lockLayers\" in biome mesa:"));
|
||||
}
|
||||
@@ -262,7 +262,7 @@ public class TerrainSettingsDecodingTest {
|
||||
@Test
|
||||
public void layersWrittenAsAnObjectOfOptionsAreRefused() {
|
||||
IllegalArgumentException refused = assertThrows(IllegalArgumentException.class,
|
||||
() -> decoder.decode(Target.BIOME, new JSONObject("{\"layers\": {\"layers\": []}}"), "biome mesa"));
|
||||
() -> decoder.decode(Level.BIOME, new JSONObject("{\"layers\": {\"layers\": []}}"), "biome mesa"));
|
||||
|
||||
assertEquals("Cannot read settings iris:terrain/layers under \"layers\" in biome mesa: write a list, [...], of the layers, not an object of options",
|
||||
refused.getMessage());
|
||||
@@ -270,22 +270,22 @@ public class TerrainSettingsDecodingTest {
|
||||
|
||||
@Test
|
||||
public void theTerrainAndPostKeysAreModuleKeysAndNoLongerFieldsOfIris() {
|
||||
assertTrue(decoder.keys(Target.BIOME).containsAll(Set.of("layers", "seaLayers", "caveCeilingLayers", "slab", "wall", "lockLayers", "lockLayersMax")));
|
||||
assertTrue(decoder.keys(Target.DIMENSION).containsAll(Set.of("rockPalette", "fluidPalette", "postProcessing", "postProcessingSlabs", "postProcessingWalls")));
|
||||
assertTrue(decoder.keys(Level.BIOME).containsAll(Set.of("layers", "seaLayers", "caveCeilingLayers", "slab", "wall", "lockLayers", "lockLayersMax")));
|
||||
assertTrue(decoder.keys(Level.DIMENSION).containsAll(Set.of("rockPalette", "fluidPalette", "postProcessing", "postProcessingSlabs", "postProcessingWalls")));
|
||||
for (String key : Set.of("layers", "seaLayers", "caveCeilingLayers", "slab", "wall", "lockLayers", "lockLayersMax")) {
|
||||
assertFalse(key, ModuleTargets.reservedFields().get(Target.BIOME).contains(key));
|
||||
assertFalse(key, ModuleTargets.reservedFields().get(Level.BIOME).contains(key));
|
||||
}
|
||||
for (String key : Set.of("rockPalette", "fluidPalette", "postProcessing", "postProcessingSlabs", "postProcessingWalls")) {
|
||||
assertFalse(key, ModuleTargets.reservedFields().get(Target.DIMENSION).contains(key));
|
||||
assertFalse(key, ModuleTargets.reservedFields().get(Level.DIMENSION).contains(key));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void everyTopLevelKeyOfTheseFilesIsAFieldOfIrisOrAKeyOfAModule() throws IOException {
|
||||
Map<String, Target> files = Map.of("biomes/mesa/yellow.json", Target.BIOME, "biomes/mountain/shore/beach.json", Target.BIOME,
|
||||
"biomes/frozen/sea/river.json", Target.BIOME, "biomes/carving/polarity-grotto.json", Target.BIOME);
|
||||
Map<String, Level> files = Map.of("biomes/mesa/yellow.json", Level.BIOME, "biomes/mountain/shore/beach.json", Level.BIOME,
|
||||
"biomes/frozen/sea/river.json", Level.BIOME, "biomes/carving/polarity-grotto.json", Level.BIOME);
|
||||
|
||||
for (Map.Entry<String, Target> file : files.entrySet()) {
|
||||
for (Map.Entry<String, Level> file : files.entrySet()) {
|
||||
Set<String> unknown = new TreeSet<>(file(file.getKey()).keySet());
|
||||
unknown.removeAll(ModuleTargets.reservedFields().get(file.getValue()));
|
||||
unknown.removeAll(decoder.keys(file.getValue()));
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* 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 com.volmit.ModuleLog;
|
||||
import com.volmit.config.PackSettings;
|
||||
import com.volmit.resource.PackResources;
|
||||
import com.volmit.world.PackWorld;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
/** The world of a tool's placement shares its state with every log view and closes it with the placement. */
|
||||
public class ToolWorldTest {
|
||||
private static final long SEED = 42L;
|
||||
|
||||
static final class Tracked implements AutoCloseable {
|
||||
private boolean closed;
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
closed = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void everyLogViewSharesTheStateAndClosingTheWorldClosesIt() {
|
||||
PackResources resources = mock(PackResources.class);
|
||||
Tracked tracked;
|
||||
try (ToolWorld world = new ToolWorld(SEED, resources, mock(PackSettings.class))) {
|
||||
tracked = world.state(Tracked.class, ignored -> new Tracked());
|
||||
PackWorld view = world.withLog(mock(ModuleLog.class));
|
||||
|
||||
assertSame(tracked, view.state(Tracked.class, ignored -> new Tracked()));
|
||||
assertSame(resources, view.resources());
|
||||
assertEquals(SEED, view.seed());
|
||||
assertEquals(0, view.minHeight());
|
||||
assertFalse(tracked.closed);
|
||||
}
|
||||
|
||||
assertTrue(tracked.closed);
|
||||
}
|
||||
}
|
||||
+5
-5
@@ -21,7 +21,7 @@ package art.arcane.iris.core.modules;
|
||||
import art.arcane.iris.builtin.vanillafeatures.ImportedFeaturesSettings;
|
||||
import art.arcane.volmlib.util.json.JSONObject;
|
||||
import com.google.gson.Gson;
|
||||
import com.volmit.FeatureAttachment.Target;
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.host.LoadedPack;
|
||||
import com.volmit.host.ModuleHost;
|
||||
import com.volmit.vanilla.DecorationStep;
|
||||
@@ -90,8 +90,8 @@ public class VanillaFeaturesSettingsDecodingTest {
|
||||
assertEquals(List.of(), defaults.disabled());
|
||||
assertEquals(List.of(), defaults.steps());
|
||||
assertEquals(List.of(), defaults.disabledSteps());
|
||||
assertSame(ModuleSettings.NONE, decoder.decode(Target.DIMENSION, byId, "dimension overworld"));
|
||||
assertTrue(decoder.keys(Target.DIMENSION).contains("importedFeatures"));
|
||||
assertSame(ModuleSettings.NONE, decoder.decode(Level.DIMENSION, byId, "dimension overworld"));
|
||||
assertTrue(decoder.keys(Level.DIMENSION).contains("importedFeatures"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -99,14 +99,14 @@ public class VanillaFeaturesSettingsDecodingTest {
|
||||
JSONObject bare = new JSONObject("{\"importedFeatures\": true}");
|
||||
|
||||
IllegalArgumentException refused = assertThrows(IllegalArgumentException.class,
|
||||
() -> decoder.decode(Target.DIMENSION, bare, "dimension overworld"));
|
||||
() -> decoder.decode(Level.DIMENSION, bare, "dimension overworld"));
|
||||
|
||||
assertEquals("Cannot read settings iris:vanilla-features under \"importedFeatures\" in dimension overworld:"
|
||||
+ " write the settings as an object, {\"<option>\": ...}", refused.getMessage());
|
||||
}
|
||||
|
||||
private ImportedFeaturesSettings settings(String dimensionJson) {
|
||||
return decoder.decode(Target.DIMENSION, new JSONObject(dimensionJson), "dimension overworld")
|
||||
return decoder.decode(Level.DIMENSION, new JSONObject(dimensionJson), "dimension overworld")
|
||||
.find(ImportedFeaturesSettings.class).orElseThrow();
|
||||
}
|
||||
}
|
||||
@@ -62,7 +62,7 @@ import art.arcane.volmlib.util.json.JSONArray;
|
||||
import art.arcane.volmlib.util.json.JSONObject;
|
||||
import art.arcane.iris.core.modules.PackModuleSet;
|
||||
import art.arcane.iris.core.modules.ModuleResourceFixture;
|
||||
import com.volmit.FeatureAttachment.Target;
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.IrisFeature;
|
||||
import art.arcane.iris.core.modules.BuiltInPack;
|
||||
import art.arcane.iris.core.modules.IrisModuleHost;
|
||||
@@ -874,7 +874,7 @@ public class SchemaBuilderParityTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Feature(id = "example:tint", name = "Tint", key = "tint", targets = Target.OBJECT_PLACEMENT)
|
||||
@Feature(id = "example:tint", name = "Tint", key = "tint", targets = Level.PLACEMENT)
|
||||
public static final class TintSettings implements IrisFeature {
|
||||
@com.volmit.config.MinItems(1)
|
||||
private List<com.volmit.block.BlockSpec> palette = List.of();
|
||||
@@ -902,7 +902,7 @@ public class SchemaBuilderParityTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Feature(id = "example:glow", name = "Glow", key = "glow", targets = Target.OBJECT_PLACEMENT)
|
||||
@Feature(id = "example:glow", name = "Glow", key = "glow", targets = Level.PLACEMENT)
|
||||
public static final class GlowSettings implements IrisFeature {
|
||||
@com.volmit.config.Desc("How bright the glow is")
|
||||
@com.volmit.config.MinNumber(1)
|
||||
|
||||
@@ -3,7 +3,8 @@ package art.arcane.iris.engine.actuator;
|
||||
import art.arcane.iris.builtin.terrain.OreSettings;
|
||||
import art.arcane.iris.engine.modifier.ApiChunk;
|
||||
import art.arcane.iris.engine.terrain.TestPackWorld;
|
||||
import com.volmit.FeatureAttachment.Target;
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.config.SettingsStack;
|
||||
import com.volmit.IrisFeature;
|
||||
import com.volmit.config.FeatureSettings.Entry;
|
||||
import com.volmit.config.PackSettings;
|
||||
@@ -31,19 +32,19 @@ public class OreWarmUpTest {
|
||||
TerrainOres ores = mock(TerrainOres.class);
|
||||
List<Entry<OreSettings>> declared = new ArrayList<>();
|
||||
// The pack lists the dimension first, then regions and biomes, in no particular order.
|
||||
declared.add(entry(Target.DIMENSION, "dimension/overworld", ores, "d0"));
|
||||
declared.add(entry(Target.REGION, "region/y", ores, "y0"));
|
||||
declared.add(entry(Target.BIOME, "biome/b", ores, "b0", "b1"));
|
||||
declared.add(entry(Target.REGION, "region/x", ores, "x0", "x1"));
|
||||
declared.add(entry(Target.BIOME, "biome/a", ores, "a0"));
|
||||
declared.add(entry(Level.DIMENSION, "dimension/overworld", ores, "d0"));
|
||||
declared.add(entry(Level.REGION, "region/y", ores, "y0"));
|
||||
declared.add(entry(Level.BIOME, "biome/b", ores, "b0", "b1"));
|
||||
declared.add(entry(Level.REGION, "region/x", ores, "x0", "x1"));
|
||||
declared.add(entry(Level.BIOME, "biome/a", ores, "a0"));
|
||||
PackSettings settings = new PackSettings() {
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <F extends IrisFeature> List<Entry<F>> declared(Class<F> featureType) {
|
||||
return (List<Entry<F>>) (List<?>) declared;
|
||||
public <F extends IrisFeature> SettingsStack<F> declared(Class<F> featureType) {
|
||||
return SettingsStack.of((List<Entry<F>>) (List<?>) declared);
|
||||
}
|
||||
};
|
||||
TestPackWorld world = new TestPackWorld(new ApiChunk(0, 0, 16).resources(), settings, COMPONENT_SEED);
|
||||
TestPackWorld world = new TestPackWorld(new ApiChunk(0, 0, 16).world().resources(), settings, COMPONENT_SEED);
|
||||
|
||||
new OreWarmUp(world, ores).warm();
|
||||
|
||||
@@ -51,7 +52,7 @@ public class OreWarmUpTest {
|
||||
"x0@" + (ROOT_SEED + 3), "x1@" + (ROOT_SEED + 4), "y0@" + (ROOT_SEED + 5), "d0@" + (ROOT_SEED + 6)), warmed);
|
||||
}
|
||||
|
||||
private Entry<OreSettings> entry(Target level, String source, TerrainOres ores, String... oreNames) {
|
||||
private Entry<OreSettings> entry(Level level, String source, TerrainOres ores, String... oreNames) {
|
||||
OreSettings settings = new OreSettings(List.of());
|
||||
ResolvedOres declared = resolved(oreNames);
|
||||
when(ores.of(settings)).thenReturn(declared);
|
||||
|
||||
@@ -91,7 +91,7 @@ public class BiomeDecoratorsTest {
|
||||
public void warmingResolvesEveryDecoratorOfEveryBiomeThePackDeclares() {
|
||||
decorators.warm();
|
||||
|
||||
assertEquals(2, decorators.decorators(new DecoratedBiome("plains", chunk.world().settings().declared(DecorantSettings.class).getFirst().value(),
|
||||
assertEquals(2, decorators.decorators(new DecoratedBiome("plains", chunk.world().settings().declared(DecorantSettings.class).values().getFirst(),
|
||||
BiomeKind.LAND), DecorationPart.NONE).length);
|
||||
}
|
||||
|
||||
|
||||
+5
-4
@@ -20,10 +20,11 @@ package art.arcane.iris.engine.framework.vanillafeatures;
|
||||
|
||||
import art.arcane.iris.builtin.vanillafeatures.ImportedFeaturesSettings;
|
||||
import art.arcane.iris.engine.object.TestSettings;
|
||||
import com.volmit.FeatureAttachment.Target;
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.IrisFeature;
|
||||
import com.volmit.config.FeatureSettings.Entry;
|
||||
import com.volmit.config.PackSettings;
|
||||
import com.volmit.config.SettingsStack;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.vanilla.DecorationStep;
|
||||
import com.volmit.world.PackWorld;
|
||||
@@ -112,11 +113,11 @@ public class ImportedFeaturesTest {
|
||||
when(world.settings()).thenReturn(new PackSettings() {
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <F extends IrisFeature> List<Entry<F>> declared(Class<F> featureType) {
|
||||
public <F extends IrisFeature> SettingsStack<F> declared(Class<F> featureType) {
|
||||
if (settings == null || featureType != ImportedFeaturesSettings.class) {
|
||||
return List.of();
|
||||
return SettingsStack.empty();
|
||||
}
|
||||
return List.of((Entry<F>) new Entry<>(Target.DIMENSION, ResourceId.parse("test:overworld"), settings));
|
||||
return SettingsStack.of(List.of((Entry<F>) new Entry<>(Level.DIMENSION, ResourceId.parse("test:overworld"), settings)));
|
||||
}
|
||||
});
|
||||
return world;
|
||||
|
||||
@@ -6,11 +6,12 @@ import art.arcane.iris.builtin.loot.LootTable;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.core.modules.ModuleResourceFixture;
|
||||
import art.arcane.iris.engine.object.TestSettings;
|
||||
import com.volmit.FeatureAttachment.Target;
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.IrisFeature;
|
||||
import com.volmit.config.FeatureSettings.Entry;
|
||||
import com.volmit.config.MaxNumber;
|
||||
import com.volmit.config.PackSettings;
|
||||
import com.volmit.config.SettingsStack;
|
||||
import com.volmit.resource.PackResources;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.validation.Problem;
|
||||
@@ -44,14 +45,14 @@ public class LootValidatorTest {
|
||||
public void acceptsValidLootTableAndReference() {
|
||||
table("global/clutter", "{\"name\":\"Clutter\",\"minPicked\":1,\"maxPicked\":2,"
|
||||
+ "\"loot\":[{\"type\":\"stick\",\"rarity\":2,\"minAmount\":1,\"maxAmount\":3}]}");
|
||||
reference(Target.DIMENSION, "main", "{\"mode\":\"FALLBACK\",\"multiplier\":0.5,\"tables\":[\"global/clutter\"]}");
|
||||
reference(Level.DIMENSION, "main", "{\"mode\":\"FALLBACK\",\"multiplier\":0.5,\"tables\":[\"global/clutter\"]}");
|
||||
|
||||
assertTrue(errors().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rejectsMissingLootReference() {
|
||||
reference(Target.DIMENSION, "main", "{\"tables\":[\"missing\"]}");
|
||||
reference(Level.DIMENSION, "main", "{\"tables\":[\"missing\"]}");
|
||||
|
||||
assertEquals(List.of("Dimension 'main'.loot.tables[0] references missing loot table 'missing'."), errors());
|
||||
}
|
||||
@@ -82,17 +83,17 @@ public class LootValidatorTest {
|
||||
|
||||
@Test
|
||||
public void rejectsInvalidReferenceMultiplier() {
|
||||
reference(Target.DIMENSION, "main", "{\"multiplier\":-1,\"tables\":[]}");
|
||||
reference(Level.DIMENSION, "main", "{\"multiplier\":-1,\"tables\":[]}");
|
||||
|
||||
assertEquals(List.of("Dimension 'main'.loot.multiplier must be a finite number from 0 to 16."), errors());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void enforcesPublishedLootMultiplierCap() {
|
||||
reference(Target.DIMENSION, "accepted", "{\"multiplier\":16,\"tables\":[]}");
|
||||
reference(Level.DIMENSION, "accepted", "{\"multiplier\":16,\"tables\":[]}");
|
||||
assertTrue(errors().isEmpty());
|
||||
|
||||
reference(Target.DIMENSION, "rejected", "{\"multiplier\":16.01,\"tables\":[]}");
|
||||
reference(Level.DIMENSION, "rejected", "{\"multiplier\":16.01,\"tables\":[]}");
|
||||
assertEquals(List.of("Dimension 'rejected'.loot.multiplier must be a finite number from 0 to 16."), errors());
|
||||
}
|
||||
|
||||
@@ -136,7 +137,7 @@ public class LootValidatorTest {
|
||||
@Test
|
||||
public void clearModeWithTablesWarnsWithoutBlocking() {
|
||||
table("t", "{\"loot\":[{\"type\":\"minecraft:stone\"}]}");
|
||||
reference(Target.BIOME, "x", "{\"mode\":\"CLEAR\",\"tables\":[\"t\"]}");
|
||||
reference(Level.BIOME, "x", "{\"mode\":\"CLEAR\",\"tables\":[\"t\"]}");
|
||||
|
||||
assertTrue(errors().isEmpty());
|
||||
assertEquals(List.of("Biome 'x'.loot uses mode CLEAR and lists 1 table(s); CLEAR clears parent tables"
|
||||
@@ -146,7 +147,7 @@ public class LootValidatorTest {
|
||||
|
||||
@Test
|
||||
public void clearModeWithMissingTableStillBlocksOnTheDanglingKey() {
|
||||
reference(Target.BIOME, "x", "{\"mode\":\"CLEAR\",\"tables\":[\"missing\"]}");
|
||||
reference(Level.BIOME, "x", "{\"mode\":\"CLEAR\",\"tables\":[\"missing\"]}");
|
||||
|
||||
assertTrue(errors().contains("Biome 'x'.loot.tables[0] references missing loot table 'missing'."));
|
||||
}
|
||||
@@ -163,7 +164,7 @@ public class LootValidatorTest {
|
||||
@Test
|
||||
public void referencesAreFoundByTheIdThePackGivesTheirKey() {
|
||||
table("Global/Clutter", "{\"loot\":[{\"type\":\"stick\"}]}");
|
||||
reference(Target.REGION, "plains", "{\"tables\":[\"Global/Clutter\"]}");
|
||||
reference(Level.REGION, "plains", "{\"tables\":[\"Global/Clutter\"]}");
|
||||
|
||||
assertTrue(errors().isEmpty());
|
||||
}
|
||||
@@ -172,7 +173,7 @@ public class LootValidatorTest {
|
||||
tables.resource(LootResources.TABLES, key, TestSettings.of(LootTable.class, json));
|
||||
}
|
||||
|
||||
private void reference(Target level, String key, String json) {
|
||||
private void reference(Level level, String key, String json) {
|
||||
String folder = switch (level) {
|
||||
case DIMENSION -> "dimension";
|
||||
case REGION -> "region";
|
||||
@@ -207,8 +208,8 @@ public class LootValidatorTest {
|
||||
return new PackSettings() {
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <F extends IrisFeature> List<Entry<F>> declared(Class<F> featureType) {
|
||||
return featureType == LootSettings.class ? (List<Entry<F>>) (List<?>) List.copyOf(references) : List.of();
|
||||
public <F extends IrisFeature> SettingsStack<F> declared(Class<F> featureType) {
|
||||
return featureType == LootSettings.class ? SettingsStack.of((List<Entry<F>>) (List<?>) List.copyOf(references)) : SettingsStack.empty();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ public class CaveAnchorsTest {
|
||||
|
||||
private static TerrainSampler terrain() {
|
||||
TerrainSampler terrain = mock(TerrainSampler.class);
|
||||
when(terrain.surfaceY(anyInt(), anyInt())).thenReturn((double) SURFACE);
|
||||
when(terrain.surfaceHeight(anyInt(), anyInt())).thenReturn(SURFACE);
|
||||
when(terrain.biome(anyInt(), anyInt(), anyInt())).thenReturn(new BiomeSample(BIOME, BIOME, Optional.of(BIOME)));
|
||||
return terrain;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ import art.arcane.iris.engine.object.TestSettings;
|
||||
import art.arcane.volmlib.util.mantle.runtime.MantleChunk;
|
||||
import art.arcane.volmlib.util.matter.Matter;
|
||||
import art.arcane.volmlib.util.matter.MatterCavern;
|
||||
import com.volmit.FeatureAttachment.Target;
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.config.Range;
|
||||
import com.volmit.noise.NoiseStyle;
|
||||
import com.volmit.noise.StyledRange;
|
||||
@@ -71,7 +71,7 @@ public class CaveCarvingTest {
|
||||
public void aDisabledProfileDeclaresNothingAndTheDimensionsStillCarves() {
|
||||
world.dimension(profile(true));
|
||||
int dimensionOnly = carvedBlocks(BiomeSample::surfaceBiome);
|
||||
world = newWorld().dimension(profile(true)).declare(Target.REGION, "region", profile(false));
|
||||
world = newWorld().dimension(profile(true)).declare(Level.REGION, "region", profile(false));
|
||||
|
||||
assertTrue(dimensionOnly > 0);
|
||||
assertEquals(dimensionOnly, carvedBlocks(BiomeSample::surfaceBiome));
|
||||
@@ -79,7 +79,7 @@ public class CaveCarvingTest {
|
||||
|
||||
@Test
|
||||
public void anEnabledProfileOfARegionReplacesTheDimensionsWithinItsOwnBounds() {
|
||||
world.dimension(profile(true)).declare(Target.REGION, "region", TestSettings.with(profile(true), "verticalRange", Range.of(50D, 60D)));
|
||||
world.dimension(profile(true)).declare(Level.REGION, "region", TestSettings.with(profile(true), "verticalRange", Range.of(50D, 60D)));
|
||||
|
||||
int carved = carvedBlocks(BiomeSample::surfaceBiome);
|
||||
|
||||
@@ -89,7 +89,7 @@ public class CaveCarvingTest {
|
||||
|
||||
@Test
|
||||
public void theCaveBiomeOfAColumnCarvesWithItsOwnProfileWhereTheDimensionDeclaresNone() {
|
||||
world.declare(Target.BIOME, "cave/lush", profile(true));
|
||||
world.declare(Level.BIOME, "cave/lush", profile(true));
|
||||
|
||||
assertEquals("the surface biome declares none", 0, carvedBlocks(BiomeSample::surfaceBiome));
|
||||
assertTrue(carvedBlocks(sample -> sample.caveBiome().orElseThrow()) > 0);
|
||||
|
||||
+5
-3
@@ -25,10 +25,11 @@ import art.arcane.iris.builtin.objects.ObjectHost;
|
||||
import art.arcane.iris.builtin.objects.ObjectPlacement;
|
||||
import art.arcane.iris.builtin.objects.ObjectSize;
|
||||
import art.arcane.iris.engine.object.TestSettings;
|
||||
import com.volmit.FeatureAttachment.Target;
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.IrisFeature;
|
||||
import com.volmit.config.FeatureSettings.Entry;
|
||||
import com.volmit.config.PackSettings;
|
||||
import com.volmit.config.SettingsStack;
|
||||
import com.volmit.host.ModuleLogs;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import org.junit.Test;
|
||||
@@ -58,8 +59,9 @@ public class FloatingObjectPlacingBoundaryRadiusTest {
|
||||
return new FloatingPack() {
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends IrisFeature> List<Entry<T>> declared(Class<T> featureType) {
|
||||
return featureType == FloatingChildSettings.class ? List.of(new Entry<>(Target.BIOME, BIOME, (T) declared)) : List.of();
|
||||
public <T extends IrisFeature> SettingsStack<T> declared(Class<T> featureType) {
|
||||
return featureType == FloatingChildSettings.class ? SettingsStack.of(List.of(new Entry<>(Level.BIOME, BIOME, (T) declared)))
|
||||
: SettingsStack.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -9,7 +9,7 @@ import art.arcane.iris.builtin.objects.ProceduralObjectSettings;
|
||||
import art.arcane.iris.builtin.objects.ProceduralPlacement;
|
||||
import art.arcane.iris.engine.object.TestSettings;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.FeatureAttachment.Target;
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.world.PackWorld;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -40,11 +40,11 @@ public class ObjectWarmUpTest {
|
||||
when(host.procedural(eq(biomeProceduralSettings), any())).thenReturn(List.of(biomeTree));
|
||||
when(host.procedural(eq(regionProceduralSettings), any())).thenReturn(List.of(regionTree));
|
||||
when(host.declarations(ObjectSettings.class)).thenReturn(List.of(
|
||||
new Declaration<>(Target.REGION, "region", objects(regionPlacement)),
|
||||
new Declaration<>(Target.BIOME, "biome", objects(biomePlacement))));
|
||||
new Declaration<>(Level.REGION, "region", objects(regionPlacement)),
|
||||
new Declaration<>(Level.BIOME, "biome", objects(biomePlacement))));
|
||||
when(host.declarations(ProceduralObjectSettings.class)).thenReturn(List.of(
|
||||
new Declaration<>(Target.REGION, "region", regionProceduralSettings),
|
||||
new Declaration<>(Target.BIOME, "biome", biomeProceduralSettings)));
|
||||
new Declaration<>(Level.REGION, "region", regionProceduralSettings),
|
||||
new Declaration<>(Level.BIOME, "biome", biomeProceduralSettings)));
|
||||
|
||||
new ObjectWarmUp(world).warm();
|
||||
|
||||
|
||||
@@ -21,10 +21,11 @@ import art.arcane.volmlib.util.mantle.flag.ReservedFlag;
|
||||
import art.arcane.volmlib.util.mantle.runtime.Mantle;
|
||||
import art.arcane.volmlib.util.mantle.runtime.MantleChunk;
|
||||
import art.arcane.volmlib.util.matter.Matter;
|
||||
import com.volmit.FeatureAttachment.Target;
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.IrisFeature;
|
||||
import com.volmit.config.FeatureSettings.Entry;
|
||||
import com.volmit.config.PackSettings;
|
||||
import com.volmit.config.SettingsStack;
|
||||
import com.volmit.host.ModuleLogs;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import org.junit.Test;
|
||||
@@ -134,8 +135,8 @@ public class PlacementReachTest {
|
||||
return new PackSettings() {
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends IrisFeature> List<Entry<T>> declared(Class<T> featureType) {
|
||||
return featureType == type ? List.of(new Entry<>(Target.BIOME, SOURCE, (T) settings)) : List.of();
|
||||
public <T extends IrisFeature> SettingsStack<T> declared(Class<T> featureType) {
|
||||
return featureType == type ? SettingsStack.of(List.of(new Entry<>(Level.BIOME, SOURCE, (T) settings))) : SettingsStack.empty();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -23,7 +23,8 @@ import art.arcane.iris.builtin.objects.ObjectPlacement;
|
||||
import art.arcane.iris.builtin.objects.ObjectSettings;
|
||||
import art.arcane.iris.builtin.objects.TreeGrowthSettings;
|
||||
import art.arcane.iris.engine.object.TestSettings;
|
||||
import com.volmit.FeatureAttachment.Target;
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.config.SettingsStack;
|
||||
import com.volmit.config.FeatureSettings;
|
||||
import com.volmit.config.FeatureSettings.Entry;
|
||||
import com.volmit.resource.ResourceId;
|
||||
@@ -68,7 +69,7 @@ public class TreeGrowingTest {
|
||||
|
||||
@Test
|
||||
public void aDimensionWithoutTreeOverridesLeavesTheGrowthToThePlatform() {
|
||||
when(settings.at(TreeGrowthSettings.class, 10, 20)).thenReturn(List.of());
|
||||
when(settings.at(TreeGrowthSettings.class, 10, 20)).thenReturn(SettingsStack.empty());
|
||||
|
||||
Optional<SaplingGrowth.Growth> growth = new TreeGrowing().grow(world, OAK_SAPLING, mock(SaplingGrowth.Surroundings.class));
|
||||
|
||||
@@ -79,7 +80,7 @@ public class TreeGrowingTest {
|
||||
@Test
|
||||
public void withoutAPlacementThatGrowsTheSpeciesTheGrowthIsLeftToThePlatform() {
|
||||
TreeGrowthSettings enabled = TestSettings.of(TreeGrowthSettings.class, "{\"enabled\":true}");
|
||||
when(settings.at(TreeGrowthSettings.class, 10, 20)).thenReturn(List.of(new Entry<>(Target.DIMENSION, SOURCE, enabled)));
|
||||
when(settings.at(TreeGrowthSettings.class, 10, 20)).thenReturn(SettingsStack.of(List.of(new Entry<>(Level.DIMENSION, SOURCE, enabled))));
|
||||
ObjectSettings objects = TestSettings.with(new ObjectSettings(), "objects",
|
||||
List.of(TestSettings.of(ObjectPlacement.class, "{\"place\":[\"a\"]}")));
|
||||
when(host.biomeAt(10, 70, 20)).thenReturn(BIOME);
|
||||
|
||||
@@ -34,7 +34,7 @@ import art.arcane.iris.builtin.terrain.PaletteLayer;
|
||||
import art.arcane.iris.builtin.terrain.SlabSettings;
|
||||
import art.arcane.iris.builtin.terrain.WallSettings;
|
||||
import art.arcane.iris.engine.object.TestSettings;
|
||||
import com.volmit.FeatureAttachment.Target;
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.IrisFeature;
|
||||
import com.volmit.IrisModule;
|
||||
import com.volmit.ModuleInfo;
|
||||
@@ -49,6 +49,7 @@ import com.volmit.block.PaletteSampler;
|
||||
import com.volmit.block.PaletteSpec;
|
||||
import com.volmit.config.FeatureSettings;
|
||||
import com.volmit.config.PackSettings;
|
||||
import com.volmit.config.SettingsStack;
|
||||
import com.volmit.generation.GenerationContext;
|
||||
import com.volmit.host.ArrayHunk;
|
||||
import com.volmit.host.ChunkRunner;
|
||||
@@ -321,12 +322,8 @@ public final class ApiChunk implements GenerationContext {
|
||||
public FeatureSettings settings() {
|
||||
return new FeatureSettings() {
|
||||
@Override
|
||||
public <F extends IrisFeature> List<Entry<F>> at(Class<F> featureType, int worldX, int worldZ) {
|
||||
List<Entry<F>> entries = new ArrayList<>();
|
||||
addEntries(entries, featureType, Target.DIMENSION, DIMENSION, dimensionSettings);
|
||||
addEntries(entries, featureType, Target.REGION, REGION, regionSettings);
|
||||
addEntries(entries, featureType, Target.BIOME, BIOME, biomeSettings);
|
||||
return entries;
|
||||
public <F extends IrisFeature> SettingsStack<F> at(Class<F> featureType, int worldX, int worldZ) {
|
||||
return declaredAtEveryLevel(featureType);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -350,22 +347,20 @@ public final class ApiChunk implements GenerationContext {
|
||||
return (Hunk<T>) blocks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long worldSeed() {
|
||||
return SEED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackResources resources() {
|
||||
return world.resources;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackWorld world() {
|
||||
return world;
|
||||
}
|
||||
|
||||
private static <F extends IrisFeature> void addEntries(List<Entry<F>> entries, Class<F> type, Target level, ResourceId source,
|
||||
private <F extends IrisFeature> SettingsStack<F> declaredAtEveryLevel(Class<F> featureType) {
|
||||
List<Entry<F>> entries = new ArrayList<>();
|
||||
addEntries(entries, featureType, Level.DIMENSION, DIMENSION, dimensionSettings);
|
||||
addEntries(entries, featureType, Level.REGION, REGION, regionSettings);
|
||||
addEntries(entries, featureType, Level.BIOME, BIOME, biomeSettings);
|
||||
return SettingsStack.of(entries);
|
||||
}
|
||||
|
||||
private static <F extends IrisFeature> void addEntries(List<Entry<F>> entries, Class<F> type, Level level, ResourceId source,
|
||||
List<IrisFeature> declared) {
|
||||
declared.stream().filter(type::isInstance).map(type::cast).forEach(value -> entries.add(new Entry<>(level, source, value)));
|
||||
}
|
||||
@@ -604,12 +599,8 @@ public final class ApiChunk implements GenerationContext {
|
||||
public PackSettings settings() {
|
||||
return new PackSettings() {
|
||||
@Override
|
||||
public <F extends IrisFeature> List<Entry<F>> declared(Class<F> featureType) {
|
||||
List<Entry<F>> entries = new ArrayList<>();
|
||||
addEntries(entries, featureType, Target.DIMENSION, DIMENSION, dimensionSettings);
|
||||
addEntries(entries, featureType, Target.REGION, REGION, regionSettings);
|
||||
addEntries(entries, featureType, Target.BIOME, BIOME, biomeSettings);
|
||||
return entries;
|
||||
public <F extends IrisFeature> SettingsStack<F> declared(Class<F> featureType) {
|
||||
return declaredAtEveryLevel(featureType);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ import art.arcane.iris.builtin.carve.CarvingSettings;
|
||||
import art.arcane.iris.builtin.carve.CaveDepthSettings;
|
||||
import art.arcane.iris.core.modules.CarveTestWorld;
|
||||
import com.google.gson.Gson;
|
||||
import com.volmit.FeatureAttachment.Target;
|
||||
import com.volmit.config.Level;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -50,7 +50,7 @@ public class CaveBiomeBandsTest {
|
||||
world = new CarveTestWorld()
|
||||
.biome("band/shallow", 1).biome("band/padded", 1).biome("band/disabled", 1)
|
||||
.dimension(new CarvingSettings(entries))
|
||||
.declare(Target.BIOME, "band/shallow", new CaveDepthSettings(30));
|
||||
.declare(Level.BIOME, "band/shallow", new CaveDepthSettings(30));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -21,10 +21,11 @@ package art.arcane.iris.engine.modifier;
|
||||
import art.arcane.iris.builtin.deposit.DepositSettings;
|
||||
import art.arcane.iris.builtin.deposit.DepositGenerator;
|
||||
import art.arcane.iris.engine.object.TestSettings;
|
||||
import com.volmit.FeatureAttachment.Target;
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.IrisFeature;
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.config.FeatureSettings;
|
||||
import com.volmit.config.SettingsStack;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -35,10 +36,11 @@ import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class DepositModuleTest {
|
||||
private static final int CENTRE = 7;
|
||||
private static final int COLUMN_X = 39;
|
||||
private static final int COLUMN_Z = -9;
|
||||
|
||||
@Test
|
||||
public void everyLevelAtTheCentreColumnStacksInLevelOrder() {
|
||||
public void everyLevelAtTheColumnStacksInLevelOrder() {
|
||||
DepositGenerator dimension = new DepositGenerator();
|
||||
DepositGenerator region = new DepositGenerator();
|
||||
DepositGenerator biome = new DepositGenerator();
|
||||
@@ -46,20 +48,20 @@ public class DepositModuleTest {
|
||||
FeatureSettings settings = new FeatureSettings() {
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <F extends IrisFeature> List<Entry<F>> at(Class<F> type, int worldX, int worldZ) {
|
||||
if (worldX != 32 + CENTRE || worldZ != -16 + CENTRE) {
|
||||
return List.of((Entry<F>) entry(Target.BIOME, "biome/other", elsewhere));
|
||||
public <F extends IrisFeature> SettingsStack<F> at(Class<F> type, int worldX, int worldZ) {
|
||||
if (worldX != COLUMN_X || worldZ != COLUMN_Z) {
|
||||
return SettingsStack.of(List.of((Entry<F>) entry(Level.BIOME, "biome/other", elsewhere)));
|
||||
}
|
||||
return List.of((Entry<F>) entry(Target.DIMENSION, "dimension/overworld", dimension),
|
||||
(Entry<F>) entry(Target.REGION, "region/hot", region),
|
||||
(Entry<F>) entry(Target.BIOME, "biome/desert", biome));
|
||||
return SettingsStack.of(List.of((Entry<F>) entry(Level.DIMENSION, "dimension/overworld", dimension),
|
||||
(Entry<F>) entry(Level.REGION, "region/hot", region),
|
||||
(Entry<F>) entry(Level.BIOME, "biome/desert", biome)));
|
||||
}
|
||||
};
|
||||
|
||||
assertEquals(List.of(dimension, region, biome), DepositModule.generatorsAtCentre(settings, 32, -16));
|
||||
assertEquals(List.of(dimension, region, biome), DepositModule.generatorsAt(settings, COLUMN_X, COLUMN_Z));
|
||||
}
|
||||
|
||||
private static FeatureSettings.Entry<DepositSettings> entry(Target level, String source, DepositGenerator generator) {
|
||||
private static FeatureSettings.Entry<DepositSettings> entry(Level level, String source, DepositGenerator generator) {
|
||||
return new FeatureSettings.Entry<>(level, ResourceId.parse("pack:" + source), new DepositSettings(List.of(generator)));
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import art.arcane.iris.engine.decorator.BiomeDecorators;
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.config.FeatureSettings;
|
||||
import com.volmit.config.PackSettings;
|
||||
import com.volmit.config.SettingsStack;
|
||||
import com.volmit.host.ModuleLogs;
|
||||
import com.volmit.hunk.Hunk;
|
||||
import com.volmit.resource.PackResources;
|
||||
@@ -44,7 +45,9 @@ public class FloatingIslandsTest {
|
||||
when(context.originZ()).thenReturn(CHUNK_ORIGIN);
|
||||
when(context.world()).thenReturn(world);
|
||||
when(context.hunk(BlockState.class)).thenReturn(output);
|
||||
when(context.settings()).thenReturn(mock(FeatureSettings.class));
|
||||
FeatureSettings nothingConfigured = mock(FeatureSettings.class);
|
||||
when(nothingConfigured.at(any(), anyInt(), anyInt())).thenAnswer(invocation -> SettingsStack.empty());
|
||||
when(context.settings()).thenReturn(nothingConfigured);
|
||||
when(context.mantle()).thenReturn(null);
|
||||
FloatingIslands islands = FloatingIslands.of(world, ModuleLogs.discarding());
|
||||
|
||||
@@ -61,7 +64,9 @@ public class FloatingIslandsTest {
|
||||
when(((FloatingHost.Source) world).floating()).thenReturn(host);
|
||||
when(((ObjectHost.Source) world).objects()).thenReturn(mock(ObjectHost.class));
|
||||
when(world.resources()).thenReturn(mock(PackResources.class));
|
||||
when(world.settings()).thenReturn(mock(PackSettings.class));
|
||||
PackSettings nothingDeclared = mock(PackSettings.class);
|
||||
when(nothingDeclared.declared(any())).thenAnswer(invocation -> SettingsStack.empty());
|
||||
when(world.settings()).thenReturn(nothingDeclared);
|
||||
when(world.state(any(), any())).thenAnswer(invocation -> {
|
||||
Class<?> type = invocation.getArgument(0);
|
||||
if (type == BiomeDecorators.class) {
|
||||
|
||||
+8
-7
@@ -103,6 +103,7 @@ public class IrisObjectPlacementRegressionTest {
|
||||
BuiltInPack.seedWorld(engine, 7L);
|
||||
data = mock(IrisData.class);
|
||||
when(data.getEngine()).thenReturn(engine);
|
||||
when(engine.getData()).thenReturn(data);
|
||||
usePack(List.of());
|
||||
solid = registryState("minecraft:stone");
|
||||
schematicAir = registryState("minecraft:air");
|
||||
@@ -438,17 +439,17 @@ public class IrisObjectPlacementRegressionTest {
|
||||
@Override
|
||||
public void setup(ModuleSetup setup) {
|
||||
setup.stages().define(FIND).requires(IrisStages.Blocks.COMPLETE).run(context ->
|
||||
found.add(context.resources().find(PackResourceFixture.oakKey(packFolder)).orElseThrow()));
|
||||
found.add(context.world().resources().find(PackResourceFixture.oakKey(packFolder)).orElseThrow()));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aPlacementStageFindsTheSnapshotsPackResources() throws IOException {
|
||||
PackResourceFixture.serve(data);
|
||||
public void aPasteWithoutAnEngineFindsThePacksResourcesThroughItsWorld() throws IOException {
|
||||
List<Object> found = new ArrayList<>();
|
||||
usePack(List.of(new FindModule(folder.getRoot(), found)));
|
||||
PackResourceFixture.serve(data);
|
||||
|
||||
ObjectPlacementResult result = place(placement(), ANCHOR_Y, new RecordingPlacer(engine), null);
|
||||
ObjectPlacementResult result = place(placement(), ANCHOR_Y, new RecordingPlacer(null), null);
|
||||
|
||||
assertTrue(result.isPlaced());
|
||||
assertEquals(List.of(PackResourceFixture.OAK), found);
|
||||
@@ -526,18 +527,18 @@ public class IrisObjectPlacementRegressionTest {
|
||||
@Override
|
||||
public void setup(ModuleSetup setup) {
|
||||
setup.stages().define(TURN).requires(IrisStages.Blocks.COMPLETE).run(context -> turned.add(context.objects().transform(
|
||||
context.resources().require(PackResourceFixture.oakKey(packFolder)),
|
||||
context.world().resources().require(PackResourceFixture.oakKey(packFolder)),
|
||||
new ObjectTransform(90, 0, 0, 1, 1, 1, false, false, false))));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aPlacementStageTurnsAnObjectThroughTheObjectTransformer() throws IOException {
|
||||
PackResourceFixture.serve(data);
|
||||
List<GeneratedObject> turned = new ArrayList<>();
|
||||
usePack(List.of(new TurnModule(folder.getRoot(), turned)));
|
||||
PackResourceFixture.serve(data);
|
||||
|
||||
ObjectPlacementResult result = place(placement(), ANCHOR_Y, new RecordingPlacer(engine), null);
|
||||
ObjectPlacementResult result = place(placement(), ANCHOR_Y, new RecordingPlacer(null), null);
|
||||
|
||||
assertTrue(result.isPlaced());
|
||||
assertEquals(List.of(new BlockPosition(0, 0, 0), new BlockPosition(0, 0, 1)),
|
||||
|
||||
+1
@@ -86,6 +86,7 @@ public class IrisObjectSurfaceSupportPlacementTest {
|
||||
BuiltInPack.seedWorld(engine, 7L);
|
||||
data = mock(IrisData.class);
|
||||
when(data.getEngine()).thenReturn(engine);
|
||||
when(engine.getData()).thenReturn(data);
|
||||
pack = BuiltInPack.serve(data, folder, List.of());
|
||||
}
|
||||
|
||||
|
||||
@@ -78,6 +78,7 @@ public class ObjectPlaceModePinTest {
|
||||
BuiltInPack.seedWorld(engine, WORLD_SEED);
|
||||
data = mock(IrisData.class);
|
||||
when(data.getEngine()).thenReturn(engine);
|
||||
when(engine.getData()).thenReturn(data);
|
||||
pack = BuiltInPack.serve(data, folder, List.of());
|
||||
}
|
||||
|
||||
|
||||
+1
@@ -84,6 +84,7 @@ public class NativeStructureObjectVetoTest {
|
||||
BuiltInPack.seedWorld(engine, 7L);
|
||||
data = mock(IrisData.class);
|
||||
when(data.getEngine()).thenReturn(engine);
|
||||
when(engine.getData()).thenReturn(data);
|
||||
pack = BuiltInPack.serve(data, folder, List.of());
|
||||
}
|
||||
|
||||
|
||||
@@ -20,12 +20,13 @@ package art.arcane.iris.engine.terrain;
|
||||
|
||||
import art.arcane.iris.builtin.IrisSeed;
|
||||
import art.arcane.iris.core.modules.ModuleSettings;
|
||||
import com.volmit.FeatureAttachment.Target;
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.IrisFeature;
|
||||
import com.volmit.ModuleLog;
|
||||
import com.volmit.config.FeatureSettings;
|
||||
import com.volmit.config.FeatureSettings.Entry;
|
||||
import com.volmit.config.PackSettings;
|
||||
import com.volmit.config.SettingsStack;
|
||||
import com.volmit.host.ModuleLogs;
|
||||
import com.volmit.resource.PackResources;
|
||||
import com.volmit.resource.ResourceId;
|
||||
@@ -49,9 +50,8 @@ public final class TestPackWorld implements PackWorld, IrisSeed.Source {
|
||||
public TestPackWorld(PackResources resources, ModuleSettings dimensionSettings, long seed) {
|
||||
this(resources, new PackSettings() {
|
||||
@Override
|
||||
public <F extends IrisFeature> List<Entry<F>> declared(Class<F> featureType) {
|
||||
Optional<F> found = dimensionSettings.find(featureType);
|
||||
return found.map(value -> List.of(new Entry<>(Target.DIMENSION, DIMENSION, value))).orElse(List.of());
|
||||
public <F extends IrisFeature> SettingsStack<F> declared(Class<F> featureType) {
|
||||
return dimensionStack(dimensionSettings, featureType);
|
||||
}
|
||||
}, seed);
|
||||
}
|
||||
@@ -67,12 +67,17 @@ public final class TestPackWorld implements PackWorld, IrisSeed.Source {
|
||||
public static FeatureSettings dimensionLevel(ModuleSettings settings) {
|
||||
return new FeatureSettings() {
|
||||
@Override
|
||||
public <F extends IrisFeature> List<Entry<F>> at(Class<F> featureType, int worldX, int worldZ) {
|
||||
return settings.find(featureType).map(value -> List.of(new Entry<>(Target.DIMENSION, DIMENSION, value))).orElse(List.of());
|
||||
public <F extends IrisFeature> SettingsStack<F> at(Class<F> featureType, int worldX, int worldZ) {
|
||||
return dimensionStack(settings, featureType);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private static <F extends IrisFeature> SettingsStack<F> dimensionStack(ModuleSettings settings, Class<F> featureType) {
|
||||
return settings.find(featureType).map(value -> SettingsStack.of(List.of(new Entry<>(Level.DIMENSION, DIMENSION, value))))
|
||||
.orElseGet(SettingsStack::empty);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long seed() {
|
||||
return seed;
|
||||
|
||||
Reference in new issue
Block a user