mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-30 01:34:04 +00:00
Batch 6 part 3: host side of structure locating and the decoding contract
Structure locating goes through StructureLocator. Ownership records hold one memo text and no placement identity (schema 3; older records fail closed). NativeStructureStartsTest drops the identity column of its golden; the other columns are unchanged. ModuleSettingsDecoder applies the decoding contract (DecodingContract: null members are left out, unknown enum names are errors). NoiseStyle no longer carries cacheSize, a cache knob only. PlacementRequest has no id. Dimension settings reach LinkedBiomes as PackSettings.
This commit is contained in:
1 parent
dc0d61ce63
commit
711fdd078a
31 files changed
+367
-280
No files matched your search
@@ -188,7 +188,7 @@ public class CarveSettingsDecodingTest {
|
||||
assertEquals("carving/mushroom", settings.find(CarvingBiomeSettings.class).orElseThrow().biome());
|
||||
IrisPackResources resources = PackResourceFixture.empty(packFolder.toFile());
|
||||
assertEquals(Set.of("carving/mushroom"), settings.treeBiomes(resources));
|
||||
assertEquals(Set.of(), settings.usedBiomes(resources, ModuleSettings.NONE));
|
||||
assertEquals(Set.of(), settings.usedBiomes(resources, ModuleSettings.NONE, "overworld"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -121,7 +121,7 @@ public class FloatingSettingsDecodingTest {
|
||||
ModuleSettings dimensionSettings = decoder.decode(Level.DIMENSION, file("dimensions/overworld.json"), "dimension overworld");
|
||||
|
||||
IrisPackResources resources = PackResourceFixture.empty(packFolder.toFile());
|
||||
Set<String> used = biomeSettings.usedBiomes(resources, dimensionSettings);
|
||||
Set<String> used = biomeSettings.usedBiomes(resources, dimensionSettings, "overworld");
|
||||
|
||||
assertEquals(new LinkedHashSet<>(List.of("mushroom/forest", "carving/mushroom", "tropical/wilds", "carving/lush-child")), used);
|
||||
assertEquals(Set.of(), biomeSettings.treeBiomes(resources));
|
||||
@@ -135,9 +135,9 @@ public class FloatingSettingsDecodingTest {
|
||||
ModuleSettings dimensionSettings = BuiltInPack.settings(new CarvingSettings(List.of(band)));
|
||||
|
||||
IrisPackResources resources = PackResourceFixture.empty(packFolder.toFile());
|
||||
assertEquals(new LinkedHashSet<>(List.of("floating/target", "carving/deep")), biomeSettings.usedBiomes(resources, dimensionSettings));
|
||||
assertEquals(new LinkedHashSet<>(List.of("floating/target", "carving/deep")), biomeSettings.usedBiomes(resources, dimensionSettings, "overworld"));
|
||||
assertEquals("without bands the name is taken as a biome key", new LinkedHashSet<>(List.of("floating/target", "deep")),
|
||||
biomeSettings.usedBiomes(resources, ModuleSettings.NONE));
|
||||
biomeSettings.usedBiomes(resources, ModuleSettings.NONE, "overworld"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -47,7 +47,8 @@ import static org.mockito.Mockito.when;
|
||||
/** IrisApi's value types read the JSON of Iris's own classes and resolve, and build noise, exactly as those do. */
|
||||
public class IrisValuesTest {
|
||||
private static final double[][] COLUMNS = {{0, 0}, {17.5, -3}, {-640, 1280}, {12345.25, 678.5}};
|
||||
private static final Map<Class<?>, Set<String>> IRIS_ONLY_FIELDS = Map.of(IrisBlockData.class, Set.of("debug"));
|
||||
private static final Map<Class<?>, Set<String>> IRIS_ONLY_FIELDS = Map.of(IrisBlockData.class, Set.of("debug"),
|
||||
IrisGeneratorStyle.class, Set.of("cacheSize"));
|
||||
|
||||
@After
|
||||
public void unbindPlatform() {
|
||||
|
||||
@@ -39,6 +39,7 @@ import com.volmit.host.LoadedPack;
|
||||
import com.volmit.host.ModuleHost;
|
||||
import com.volmit.noise.NoiseStyle;
|
||||
import com.volmit.noise.StyledRange;
|
||||
import com.volmit.vanilla.JigsawOverrides;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.stage.Stage;
|
||||
import com.volmit.geometry.BlockPosition;
|
||||
@@ -100,6 +101,7 @@ public class ModuleSettingsDecoderTest {
|
||||
private Range light = Range.of(0, 15);
|
||||
private BlockPosition offset = new BlockPosition(0, 0, 0);
|
||||
private Map<String, Object> extra = Map.of();
|
||||
private JigsawOverrides jigsaw = JigsawOverrides.none();
|
||||
}
|
||||
|
||||
public static final class MossModule implements IrisModule {
|
||||
@@ -216,6 +218,36 @@ public class ModuleSettingsDecoderTest {
|
||||
assertEquals(Map.of("list", List.of(1.0, "a", true)), values.extra);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aNullMemberIsLeftOutSoTheFieldKeepsItsInitialiser() {
|
||||
ValuesSettings values = values("""
|
||||
{"mossValues": {
|
||||
"palette": [{"block": null, "data": null, "tileData": null}],
|
||||
"style": null,
|
||||
"height": {"style": null},
|
||||
"jigsaw": {"liquidSettings": null, "startPool": null}
|
||||
}}
|
||||
""");
|
||||
|
||||
assertEquals(BlockSpec.of("air"), values.palette.getFirst());
|
||||
assertEquals(NoiseStyle.of("SIMPLEX"), values.style);
|
||||
assertEquals(NoiseStyle.of("STATIC"), values.height.style());
|
||||
assertEquals(JigsawOverrides.none(), values.jigsaw);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void anUnknownEnumNameIsAnErrorNamingTheKnownOnes() {
|
||||
IllegalArgumentException failure = assertThrows(IllegalArgumentException.class,
|
||||
() -> values("{\"mossValues\": {\"jigsaw\": {\"liquidSettings\": \"WET\"}}}"));
|
||||
|
||||
assertTrue(failure.getMessage(), failure.getMessage().contains(
|
||||
"\"WET\" is not one of [SOURCE, IGNORE_WATERLOGGING, APPLY_WATERLOGGING]"));
|
||||
}
|
||||
|
||||
private ValuesSettings values(String json) {
|
||||
return decoder.decode(Level.BIOME, new JSONObject(json), "biome desert/dunes").find(ValuesSettings.class).orElseThrow();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void badValuesNameTheSettingsKeyAndResource() {
|
||||
IllegalArgumentException failure = assertThrows(IllegalArgumentException.class,
|
||||
|
||||
+22
-36
@@ -28,8 +28,8 @@ public class NativeStructureOwnershipRecordTest {
|
||||
|
||||
@Test
|
||||
public void binaryRoundTripPreservesMultipleVersionedOwnershipRecords() throws Exception {
|
||||
NativeStructureOwnershipRecord tavern = record("nova_structures:tavern_oak", 4, -7, 71L);
|
||||
NativeStructureOwnershipRecord crypt = record("nova_structures:undead_crypt", 4, -7, 72L);
|
||||
NativeStructureOwnershipRecord tavern = record("nova_structures:tavern_oak", 4, -7);
|
||||
NativeStructureOwnershipRecord crypt = record("nova_structures:undead_crypt", 4, -7);
|
||||
NativeStructureOwnershipBundle bundle = NativeStructureOwnershipBundle.empty()
|
||||
.with(tavern)
|
||||
.with(crypt);
|
||||
@@ -43,23 +43,23 @@ public class NativeStructureOwnershipRecordTest {
|
||||
assertEquals(crypt, restored.find("nova_structures:undead_crypt", 4, -7));
|
||||
}
|
||||
|
||||
/** The stilts and terrain fit JSON records written before memos hold, as the old Iris classes wrote them. */
|
||||
@Test
|
||||
public void recordsWrittenBeforeMemosReadAsTheStructureModulesMemo() throws Exception {
|
||||
String stilts = "{\"maxDepth\":91,\"palette\":{\"style\":{\"style\":\"STATIC\",\"cellularFrequency\":0.0,"
|
||||
+ "\"cellularZoom\":1.0,\"zoom\":1.0,\"multiplier\":1.0,\"exponent\":1.0,\"cacheSize\":0},\"zoom\":5.0,"
|
||||
+ "\"palette\":[{\"block\":\"minecraft:stone_bricks\",\"debug\":false,\"weight\":2,"
|
||||
+ "\"data\":{\"waterlogged\":false},\"tileData\":{}}]},\"spacing\":4,\"supportNonOccluding\":true}";
|
||||
public void theStructureModulesMemoRoundTripsUnchanged() throws Exception {
|
||||
String stilts = "{\"maxDepth\":91,\"palette\":{\"style\":{\"style\":\"STATIC\",\"zoom\":1.0},\"zoom\":5.0,"
|
||||
+ "\"palette\":[{\"block\":\"minecraft:stone_bricks\",\"weight\":2,\"data\":{\"waterlogged\":false}}]},"
|
||||
+ "\"spacing\":4,\"supportNonOccluding\":true}";
|
||||
String terrain = "{\"mode\":\"FORCE_CARVE\",\"horizontalPadding\":9,\"ceilingPadding\":3,\"floorPadding\":2,"
|
||||
+ "\"shape\":\"ERODED\",\"erosionStrength\":0.42,\"erosionFrequency\":0.17,\"lobeFrequency\":0.03,"
|
||||
+ "\"lobeStrength\":0.61}";
|
||||
String text = "{\"terrain\":" + terrain + ",\"stilts\":" + stilts + "}";
|
||||
ByteArrayOutputStream encoded = new ByteArrayOutputStream();
|
||||
new NativeStructureOwnershipRecord.MemoSnapshot(stilts, terrain).write(new DataOutputStream(encoded));
|
||||
NativeStructureOwnershipRecord.MemoSnapshot.of(new NativeStartMemo(text)).write(new DataOutputStream(encoded));
|
||||
|
||||
NativeStartMemo memo = NativeStructureOwnershipRecord.MemoSnapshot.read(
|
||||
new DataInputStream(new ByteArrayInputStream(encoded.toByteArray()))).restore();
|
||||
NativeStructureFit fit = NativeStructureFit.of(new StartMemo(memo.terrain(), memo.foundation()));
|
||||
NativeStructureFit fit = NativeStructureFit.of(new StartMemo(memo.text()));
|
||||
|
||||
assertEquals(text, memo.text());
|
||||
assertEquals(StructureTerrainMode.FORCE_CARVE, fit.terrain().resolvedMode());
|
||||
assertEquals(StructureCarveShape.ERODED, fit.terrain().resolvedShape());
|
||||
assertEquals(9, fit.terrain().horizontalPadding());
|
||||
@@ -83,7 +83,7 @@ public class NativeStructureOwnershipRecordTest {
|
||||
|
||||
@Test
|
||||
public void recordCarriesLocateAndReferenceEnvelopeState() {
|
||||
NativeStructureOwnershipRecord record = record("nova_structures:tavern_oak", -3, 9, 83L);
|
||||
NativeStructureOwnershipRecord record = record("nova_structures:tavern_oak", -3, 9);
|
||||
|
||||
assertEquals(47, record.baseY());
|
||||
assertEquals(43, record.contentMinY());
|
||||
@@ -91,20 +91,18 @@ public class NativeStructureOwnershipRecordTest {
|
||||
assertEquals(58, record.locatorY());
|
||||
assertTrue(record.covers(-5, 11));
|
||||
assertFalse(record.covers(-6, 11));
|
||||
assertEquals(83L, record.placementIdentity());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void referenceEnvelopeRefreshPreservesPersistedAuthority() {
|
||||
NativeStructureOwnershipRecord original = record(
|
||||
"nova_structures:tavern_oak", -3, 9, 83L);
|
||||
"nova_structures:tavern_oak", -3, 9);
|
||||
|
||||
NativeStructureOwnershipRecord refreshed = original.withReferenceEnvelope(
|
||||
-6, 0, 6, 12);
|
||||
|
||||
assertEquals(original.schema(), refreshed.schema());
|
||||
assertEquals(original.ownershipKey(), refreshed.ownershipKey());
|
||||
assertEquals(original.placementIdentity(), refreshed.placementIdentity());
|
||||
assertEquals(original.baseY(), refreshed.baseY());
|
||||
assertEquals(original.contentMinX(), refreshed.contentMinX());
|
||||
assertEquals(original.contentMinY(), refreshed.contentMinY());
|
||||
@@ -122,9 +120,9 @@ public class NativeStructureOwnershipRecordTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void ownershipRoundTripPreservesExactBoundsAndPriority() throws Exception {
|
||||
public void ownershipRoundTripPreservesExactBounds() throws Exception {
|
||||
NativeStructureOwnershipRecord ownership = record(
|
||||
"nova_structures:tavern_oak", -3, 9, 83L);
|
||||
"nova_structures:tavern_oak", -3, 9);
|
||||
NativeStructureOwnershipBundle bundle = NativeStructureOwnershipBundle.empty().with(ownership);
|
||||
ByteArrayOutputStream encoded = new ByteArrayOutputStream();
|
||||
bundle.write(new DataOutputStream(encoded));
|
||||
@@ -134,13 +132,13 @@ public class NativeStructureOwnershipRecordTest {
|
||||
.find(ownership.structureKey(), ownership.originChunkX(), ownership.originChunkZ());
|
||||
|
||||
assertNotNull(restored);
|
||||
assertEquals(ownership.placementIdentity(), restored.placementIdentity());
|
||||
assertEquals(ownership.contentMinX(), restored.contentMinX());
|
||||
assertEquals(ownership.contentMinY(), restored.contentMinY());
|
||||
assertEquals(ownership.contentMinZ(), restored.contentMinZ());
|
||||
assertEquals(ownership.contentMaxX(), restored.contentMaxX());
|
||||
assertEquals(ownership.contentMaxY(), restored.contentMaxY());
|
||||
assertEquals(ownership.contentMaxZ(), restored.contentMaxZ());
|
||||
assertEquals(ownership.memo(), restored.memo());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -150,7 +148,6 @@ public class NativeStructureOwnershipRecordTest {
|
||||
"nova_structures:tavern_oak",
|
||||
0,
|
||||
0,
|
||||
1L,
|
||||
47,
|
||||
0,
|
||||
43,
|
||||
@@ -170,7 +167,7 @@ public class NativeStructureOwnershipRecordTest {
|
||||
Map<NativeStructureOwnershipRecord.OwnershipKey, NativeStructureOwnershipRecord> records =
|
||||
new LinkedHashMap<>();
|
||||
for (int i = 0; i <= NativeStructureOwnershipBundle.MAX_RECORDS; i++) {
|
||||
NativeStructureOwnershipRecord record = record("test:structure_" + i, 0, 0, i);
|
||||
NativeStructureOwnershipRecord record = record("test:structure_" + i, 0, 0);
|
||||
records.put(record.ownershipKey(), record);
|
||||
}
|
||||
assertThrows(IllegalArgumentException.class,
|
||||
@@ -179,17 +176,13 @@ public class NativeStructureOwnershipRecordTest {
|
||||
Map<NativeStructureOwnershipRecord.OwnershipKey, NativeStructureOwnershipRecord> oversized =
|
||||
new LinkedHashMap<>();
|
||||
NativeStructureOwnershipRecord.MemoSnapshot largeDecision =
|
||||
new NativeStructureOwnershipRecord.MemoSnapshot(
|
||||
"null",
|
||||
"{\"unused\":\"" + "x".repeat(65_000) + "\"}"
|
||||
);
|
||||
new NativeStructureOwnershipRecord.MemoSnapshot("{\"unused\":\"" + "x".repeat(65_000) + "\"}");
|
||||
for (int i = 0; i < 33; i++) {
|
||||
NativeStructureOwnershipRecord record = new NativeStructureOwnershipRecord(
|
||||
NativeStructureOwnershipRecord.CURRENT_SCHEMA,
|
||||
"test:large_" + i,
|
||||
0,
|
||||
0,
|
||||
i,
|
||||
47,
|
||||
0,
|
||||
43,
|
||||
@@ -218,7 +211,6 @@ public class NativeStructureOwnershipRecordTest {
|
||||
"test:overflow",
|
||||
Integer.MAX_VALUE,
|
||||
0,
|
||||
1L,
|
||||
47,
|
||||
0,
|
||||
43,
|
||||
@@ -243,7 +235,6 @@ public class NativeStructureOwnershipRecordTest {
|
||||
"test:outside_envelope",
|
||||
0,
|
||||
0,
|
||||
1L,
|
||||
47,
|
||||
-16,
|
||||
43,
|
||||
@@ -268,7 +259,6 @@ public class NativeStructureOwnershipRecordTest {
|
||||
"test:displaced",
|
||||
0,
|
||||
0,
|
||||
1L,
|
||||
47,
|
||||
80,
|
||||
43,
|
||||
@@ -291,14 +281,14 @@ public class NativeStructureOwnershipRecordTest {
|
||||
|
||||
@Test
|
||||
public void nullableStiltRoundTripsAsNull() {
|
||||
NativeStructureOwnershipRecord record = record("test:no_stilt", 0, 0, 1L);
|
||||
NativeStructureOwnershipRecord record = record("test:no_stilt", 0, 0);
|
||||
NativeStartMemo memo = record.restoredMemo();
|
||||
assertNull(NativeStructureFit.of(new StartMemo(memo.terrain(), memo.foundation())).stilts());
|
||||
assertNull(NativeStructureFit.of(new StartMemo(memo.text())).stilts());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bundlesWrittenUnderAnOlderSchemaRevisionFailClosed() throws Exception {
|
||||
NativeStructureOwnershipRecord record = record("nova_structures:tavern_oak", 4, -7, 71L);
|
||||
NativeStructureOwnershipRecord record = record("nova_structures:tavern_oak", 4, -7);
|
||||
NativeStructureOwnershipBundle bundle = NativeStructureOwnershipBundle.empty().with(record);
|
||||
ByteArrayOutputStream encoded = new ByteArrayOutputStream();
|
||||
bundle.write(new DataOutputStream(encoded));
|
||||
@@ -319,7 +309,6 @@ public class NativeStructureOwnershipRecordTest {
|
||||
NativeStructureOwnershipRecord.writeString(output, " ", 512, "structure key");
|
||||
output.writeInt(0);
|
||||
output.writeInt(0);
|
||||
output.writeLong(1L);
|
||||
output.writeInt(47);
|
||||
output.writeInt(0);
|
||||
output.writeInt(43);
|
||||
@@ -339,14 +328,12 @@ public class NativeStructureOwnershipRecordTest {
|
||||
new DataInputStream(new ByteArrayInputStream(encoded.toByteArray()))));
|
||||
}
|
||||
|
||||
private static NativeStructureOwnershipRecord record(String key, int originX, int originZ,
|
||||
long placementIdentity) {
|
||||
private static NativeStructureOwnershipRecord record(String key, int originX, int originZ) {
|
||||
return new NativeStructureOwnershipRecord(
|
||||
NativeStructureOwnershipRecord.CURRENT_SCHEMA,
|
||||
key,
|
||||
originX,
|
||||
originZ,
|
||||
placementIdentity,
|
||||
47,
|
||||
originX << 4,
|
||||
43,
|
||||
@@ -365,7 +352,6 @@ public class NativeStructureOwnershipRecordTest {
|
||||
}
|
||||
|
||||
private static NativeStructureOwnershipRecord.MemoSnapshot decision() {
|
||||
StartMemo memo = NativeStructureFit.NONE.memo();
|
||||
return NativeStructureOwnershipRecord.MemoSnapshot.of(new NativeStartMemo(memo.terrain(), memo.foundation()));
|
||||
return NativeStructureOwnershipRecord.MemoSnapshot.of(new NativeStartMemo(NativeStructureFit.NONE.memo().text()));
|
||||
}
|
||||
}
|
||||
+12
-11
@@ -60,7 +60,7 @@ public class NativeStructureOwnershipStoreTest {
|
||||
3, 4, current.structureKey(), 2, 3);
|
||||
|
||||
assertEquals(current, resolved);
|
||||
assertEquals(terrain(9), resolved.restoredMemo().terrain());
|
||||
assertEquals(memoText(terrain(9), 11L), resolved.restoredMemo().text());
|
||||
assertEquals(stale.contentFingerprint(), resolved.contentFingerprint());
|
||||
assertEquals(stale, storage.find(target, stale));
|
||||
}
|
||||
@@ -404,19 +404,17 @@ public class NativeStructureOwnershipStoreTest {
|
||||
return engine;
|
||||
}
|
||||
|
||||
private static NativeStructureOwnershipRecord record(String key, int originX, int originZ,
|
||||
long placementIdentity) {
|
||||
return record(key, originX, originZ, placementIdentity, "{}", 8);
|
||||
/** {@code variant} goes into the record's memo, telling apart records that are otherwise alike. */
|
||||
private static NativeStructureOwnershipRecord record(String key, int originX, int originZ, long variant) {
|
||||
return record(key, originX, originZ, variant, "{}", 8);
|
||||
}
|
||||
|
||||
private static NativeStructureOwnershipRecord record(String key, int originX, int originZ,
|
||||
long placementIdentity,
|
||||
private static NativeStructureOwnershipRecord record(String key, int originX, int originZ, long variant,
|
||||
int referenceRadius) {
|
||||
return record(key, originX, originZ, placementIdentity, "{}", referenceRadius);
|
||||
return record(key, originX, originZ, variant, "{}", referenceRadius);
|
||||
}
|
||||
|
||||
private static NativeStructureOwnershipRecord record(String key, int originX, int originZ,
|
||||
long placementIdentity,
|
||||
private static NativeStructureOwnershipRecord record(String key, int originX, int originZ, long variant,
|
||||
String terrain,
|
||||
int referenceRadius) {
|
||||
return new NativeStructureOwnershipRecord(
|
||||
@@ -424,7 +422,6 @@ public class NativeStructureOwnershipStoreTest {
|
||||
key,
|
||||
originX,
|
||||
originZ,
|
||||
placementIdentity,
|
||||
47,
|
||||
originX << 4,
|
||||
43,
|
||||
@@ -438,10 +435,14 @@ public class NativeStructureOwnershipStoreTest {
|
||||
originZ - referenceRadius,
|
||||
originZ + referenceRadius,
|
||||
FINGERPRINT,
|
||||
new NativeStructureOwnershipRecord.MemoSnapshot("null", terrain)
|
||||
new NativeStructureOwnershipRecord.MemoSnapshot(memoText(terrain, variant))
|
||||
);
|
||||
}
|
||||
|
||||
private static String memoText(String terrain, long variant) {
|
||||
return "{\"terrain\":" + terrain + ",\"variant\":" + variant + "}";
|
||||
}
|
||||
|
||||
private static String terrain(int horizontalPadding) {
|
||||
return "{\"horizontalPadding\":" + horizontalPadding + "}";
|
||||
}
|
||||
|
||||
+70
-64
@@ -7,6 +7,7 @@ import art.arcane.iris.builtin.structure.StructureTerrain;
|
||||
import art.arcane.iris.builtin.structure.StructurePlacement;
|
||||
import art.arcane.iris.builtin.structure.StructureDistribution;
|
||||
import art.arcane.iris.builtin.structure.NativeStructureSource;
|
||||
import art.arcane.iris.engine.framework.structure.NativeStartPlanner;
|
||||
import art.arcane.iris.engine.object.TestSettings;
|
||||
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
@@ -35,8 +36,8 @@ import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
* The starts the pack's nativeStructures placements make, now through iris:structure's vanilla structure hook, are the
|
||||
* ones the core planner made before the move: the same chunks, structures, base heights and placement identities for
|
||||
* a fixed seed (pinned from the planner), and fits whose persisted JSON is unchanged.
|
||||
* ones the core planner made before the move: the same chunks, structures, base heights and placements for a
|
||||
* fixed seed (pinned from the planner), and fits whose persisted terrain and stilts JSON is unchanged.
|
||||
*/
|
||||
public class NativeStructureStartsTest {
|
||||
private static final long SEED = 1337L;
|
||||
@@ -44,60 +45,64 @@ public class NativeStructureStartsTest {
|
||||
private static final int GRID_RADIUS_CHUNKS = 6;
|
||||
private static final Gson GSON = new Gson();
|
||||
|
||||
/** chunkX chunkZ structure baseY placement identity, as NativeStructurePlacementPlanner.plansAt returned them. */
|
||||
/**
|
||||
* chunkX chunkZ structure baseY placement, as NativeStructurePlacementPlanner.plansAt returned them. Batch 6 dropped
|
||||
* the trailing placement identity column (one value per placement: villages -2304053147360248982, cities
|
||||
* 7830921123394837354, outposts 3980124831785354812) when starts stopped carrying it; the other columns are unchanged.
|
||||
*/
|
||||
private static final List<String> PLANNER_STARTS = List.of(
|
||||
"-6 -4 minecraft:village_plains 72 villages -2304053147360248982",
|
||||
"-6 0 minecraft:ancient_city -11 cities 7830921123394837354",
|
||||
"-6 1 minecraft:pillager_outpost 92 outposts 3980124831785354812",
|
||||
"-6 3 minecraft:village_plains 88 villages -2304053147360248982",
|
||||
"-6 3 minecraft:ancient_city -14 cities 7830921123394837354",
|
||||
"-5 -4 minecraft:pillager_outpost 64 outposts 3980124831785354812",
|
||||
"-5 -3 minecraft:ancient_city -40 cities 7830921123394837354",
|
||||
"-5 5 minecraft:pillager_outpost 76 outposts 3980124831785354812",
|
||||
"-4 -5 minecraft:pillager_outpost 88 outposts 3980124831785354812",
|
||||
"-4 -1 minecraft:village_plains 80 villages -2304053147360248982",
|
||||
"-4 -1 minecraft:pillager_outpost 80 outposts 3980124831785354812",
|
||||
"-4 1 minecraft:village_plains 76 villages -2304053147360248982",
|
||||
"-4 1 minecraft:pillager_outpost 76 outposts 3980124831785354812",
|
||||
"-3 -1 minecraft:village_plains 72 villages -2304053147360248982",
|
||||
"-3 1 minecraft:pillager_outpost 68 outposts 3980124831785354812",
|
||||
"-3 6 minecraft:village_plains 88 villages -2304053147360248982",
|
||||
"-2 0 minecraft:village_plains 92 villages -2304053147360248982",
|
||||
"-2 6 minecraft:pillager_outpost 80 outposts 3980124831785354812",
|
||||
"-1 -4 minecraft:village_plains 92 villages -2304053147360248982",
|
||||
"-1 4 minecraft:ancient_city -12 cities 7830921123394837354",
|
||||
"-1 6 minecraft:ancient_city -23 cities 7830921123394837354",
|
||||
"0 -6 minecraft:village_plains 88 villages -2304053147360248982",
|
||||
"0 -2 minecraft:village_plains 80 villages -2304053147360248982",
|
||||
"0 4 minecraft:pillager_outpost 68 outposts 3980124831785354812",
|
||||
"0 6 minecraft:village_plains 64 villages -2304053147360248982",
|
||||
"1 -6 minecraft:ancient_city -32 cities 7830921123394837354",
|
||||
"1 -4 minecraft:pillager_outpost 76 outposts 3980124831785354812",
|
||||
"1 0 minecraft:ancient_city -37 cities 7830921123394837354",
|
||||
"1 2 minecraft:pillager_outpost 64 outposts 3980124831785354812",
|
||||
"1 3 minecraft:ancient_city -38 cities 7830921123394837354",
|
||||
"1 5 minecraft:ancient_city -12 cities 7830921123394837354",
|
||||
"2 -2 minecraft:pillager_outpost 64 villages -2304053147360248982",
|
||||
"2 5 minecraft:village_plains 80 villages -2304053147360248982",
|
||||
"2 5 minecraft:pillager_outpost 80 outposts 3980124831785354812",
|
||||
"3 -5 minecraft:village_plains 92 villages -2304053147360248982",
|
||||
"3 1 minecraft:village_plains 80 villages -2304053147360248982",
|
||||
"3 5 minecraft:pillager_outpost 72 villages -2304053147360248982",
|
||||
"4 1 minecraft:ancient_city -16 cities 7830921123394837354",
|
||||
"4 1 minecraft:pillager_outpost 72 outposts 3980124831785354812",
|
||||
"4 3 minecraft:pillager_outpost 68 outposts 3980124831785354812",
|
||||
"4 5 minecraft:pillager_outpost 64 outposts 3980124831785354812",
|
||||
"4 6 minecraft:ancient_city -18 cities 7830921123394837354",
|
||||
"5 -5 minecraft:village_plains 76 villages -2304053147360248982",
|
||||
"5 -5 minecraft:ancient_city -24 cities 7830921123394837354",
|
||||
"5 1 minecraft:pillager_outpost 64 outposts 3980124831785354812",
|
||||
"5 2 minecraft:ancient_city -33 cities 7830921123394837354",
|
||||
"5 4 minecraft:village_plains 88 villages -2304053147360248982",
|
||||
"5 6 minecraft:village_plains 84 villages -2304053147360248982",
|
||||
"6 -5 minecraft:pillager_outpost 68 outposts 3980124831785354812",
|
||||
"6 -3 minecraft:village_plains 64 villages -2304053147360248982",
|
||||
"6 -2 minecraft:pillager_outpost 92 outposts 3980124831785354812",
|
||||
"6 2 minecraft:ancient_city -18 cities 7830921123394837354");
|
||||
"-6 -4 minecraft:village_plains 72 villages",
|
||||
"-6 0 minecraft:ancient_city -11 cities",
|
||||
"-6 1 minecraft:pillager_outpost 92 outposts",
|
||||
"-6 3 minecraft:village_plains 88 villages",
|
||||
"-6 3 minecraft:ancient_city -14 cities",
|
||||
"-5 -4 minecraft:pillager_outpost 64 outposts",
|
||||
"-5 -3 minecraft:ancient_city -40 cities",
|
||||
"-5 5 minecraft:pillager_outpost 76 outposts",
|
||||
"-4 -5 minecraft:pillager_outpost 88 outposts",
|
||||
"-4 -1 minecraft:village_plains 80 villages",
|
||||
"-4 -1 minecraft:pillager_outpost 80 outposts",
|
||||
"-4 1 minecraft:village_plains 76 villages",
|
||||
"-4 1 minecraft:pillager_outpost 76 outposts",
|
||||
"-3 -1 minecraft:village_plains 72 villages",
|
||||
"-3 1 minecraft:pillager_outpost 68 outposts",
|
||||
"-3 6 minecraft:village_plains 88 villages",
|
||||
"-2 0 minecraft:village_plains 92 villages",
|
||||
"-2 6 minecraft:pillager_outpost 80 outposts",
|
||||
"-1 -4 minecraft:village_plains 92 villages",
|
||||
"-1 4 minecraft:ancient_city -12 cities",
|
||||
"-1 6 minecraft:ancient_city -23 cities",
|
||||
"0 -6 minecraft:village_plains 88 villages",
|
||||
"0 -2 minecraft:village_plains 80 villages",
|
||||
"0 4 minecraft:pillager_outpost 68 outposts",
|
||||
"0 6 minecraft:village_plains 64 villages",
|
||||
"1 -6 minecraft:ancient_city -32 cities",
|
||||
"1 -4 minecraft:pillager_outpost 76 outposts",
|
||||
"1 0 minecraft:ancient_city -37 cities",
|
||||
"1 2 minecraft:pillager_outpost 64 outposts",
|
||||
"1 3 minecraft:ancient_city -38 cities",
|
||||
"1 5 minecraft:ancient_city -12 cities",
|
||||
"2 -2 minecraft:pillager_outpost 64 villages",
|
||||
"2 5 minecraft:village_plains 80 villages",
|
||||
"2 5 minecraft:pillager_outpost 80 outposts",
|
||||
"3 -5 minecraft:village_plains 92 villages",
|
||||
"3 1 minecraft:village_plains 80 villages",
|
||||
"3 5 minecraft:pillager_outpost 72 villages",
|
||||
"4 1 minecraft:ancient_city -16 cities",
|
||||
"4 1 minecraft:pillager_outpost 72 outposts",
|
||||
"4 3 minecraft:pillager_outpost 68 outposts",
|
||||
"4 5 minecraft:pillager_outpost 64 outposts",
|
||||
"4 6 minecraft:ancient_city -18 cities",
|
||||
"5 -5 minecraft:village_plains 76 villages",
|
||||
"5 -5 minecraft:ancient_city -24 cities",
|
||||
"5 1 minecraft:pillager_outpost 64 outposts",
|
||||
"5 2 minecraft:ancient_city -33 cities",
|
||||
"5 4 minecraft:village_plains 88 villages",
|
||||
"5 6 minecraft:village_plains 84 villages",
|
||||
"6 -5 minecraft:pillager_outpost 68 outposts",
|
||||
"6 -3 minecraft:village_plains 64 villages",
|
||||
"6 -2 minecraft:pillager_outpost 92 outposts",
|
||||
"6 2 minecraft:ancient_city -18 cities");
|
||||
|
||||
@Rule
|
||||
public TemporaryFolder folder = new TemporaryFolder();
|
||||
@@ -121,9 +126,15 @@ public class NativeStructureStartsTest {
|
||||
List<String> starts = new ArrayList<>();
|
||||
for (int chunkX = -GRID_RADIUS_CHUNKS; chunkX <= GRID_RADIUS_CHUNKS; chunkX++) {
|
||||
for (int chunkZ = -GRID_RADIUS_CHUNKS; chunkZ <= GRID_RADIUS_CHUNKS; chunkZ++) {
|
||||
for (NativeStructureStartPlan plan : NativeStructureStarts.plansAt(engine, chunkX, chunkZ)) {
|
||||
List<NativeStructureStartPlan> plans = NativeStructureStarts.plansAt(engine, chunkX, chunkZ);
|
||||
List<NativeStartPlanner.Plan> modulePlans = NativeStartPlanner.plansAt(engine, chunkX, chunkZ);
|
||||
assertEquals(modulePlans.size(), plans.size());
|
||||
for (int index = 0; index < plans.size(); index++) {
|
||||
NativeStructureStartPlan plan = plans.get(index);
|
||||
NativeStartPlanner.Plan modulePlan = modulePlans.get(index);
|
||||
assertEquals(modulePlan.source().structure(), plan.structureKey());
|
||||
starts.add(plan.chunkX() + " " + plan.chunkZ() + " " + plan.structureKey() + " " + plan.baseY() + " "
|
||||
+ placementId(placements, plan.placementIdentity()) + " " + plan.placementIdentity());
|
||||
+ modulePlan.placement().placementId());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -148,10 +159,10 @@ public class NativeStructureStartsTest {
|
||||
|
||||
NativeStructureStartPlan plan = NativeStructureStarts.matchingPlan(engine, "MINECRAFT:ANCIENT_CITY", 0, 0);
|
||||
|
||||
assertEquals(new NativeStartMemo(GSON.toJson(terrain), GSON.toJson(stilt)), plan.memo());
|
||||
assertEquals(new NativeStartMemo("{\"terrain\":" + GSON.toJson(terrain) + ",\"stilts\":" + GSON.toJson(stilt) + "}"),
|
||||
plan.memo());
|
||||
assertEquals(new NativeJigsawOverrides("minecraft:village/plains/town_centers", "", 5, null, null, false,
|
||||
"OCEAN_FLOOR_WG", null, null, NativeJigsawOverrides.SOURCE), plan.jigsaw());
|
||||
assertEquals(StructurePlacementGrid.placementIdentity(fitted), plan.placementIdentity());
|
||||
assertNull(NativeStructureStarts.matchingPlan(engine, "minecraft:stronghold", 0, 0));
|
||||
}
|
||||
|
||||
@@ -168,11 +179,6 @@ public class NativeStructureStartsTest {
|
||||
return placement;
|
||||
}
|
||||
|
||||
private static String placementId(KList<StructurePlacement> placements, long identity) {
|
||||
return placements.stream().filter(placement -> StructurePlacementGrid.placementIdentity(placement) == identity)
|
||||
.findFirst().orElseThrow().placementId();
|
||||
}
|
||||
|
||||
/** An engine whose pack serves the built-in modules, with terrain heights that vary per column and a high sea. */
|
||||
private Engine engine(KList<StructurePlacement> placements) throws IOException {
|
||||
IrisData data = mock(IrisData.class);
|
||||
|
||||
-1
@@ -95,7 +95,6 @@ public class NativeStartPlannerTest {
|
||||
assertEquals(34, start.y());
|
||||
assertTrue(start.isUnderground());
|
||||
assertTrue(start.replacesPlatformStart());
|
||||
assertEquals(StructurePlacementGrid.placementIdentity(placement), start.identity());
|
||||
NativeStructureFit fit = NativeStructureFit.of(start.memo().orElseThrow());
|
||||
assertEquals(StructureTerrainMode.FORCE_CARVE, fit.terrain().resolvedMode());
|
||||
assertEquals(24, fit.terrain().horizontalPadding());
|
||||
|
||||
@@ -248,7 +248,7 @@ final class FitFixture {
|
||||
|
||||
static FitStart start(String terrainJson, String stiltsJson, TerrainAdaptation adaptation, DecorationStep step,
|
||||
Piece... pieces) {
|
||||
StartMemo memo = new StartMemo(terrainJson, stiltsJson);
|
||||
StartMemo memo = new StartMemo("{\"terrain\":" + terrainJson + ",\"stilts\":" + stiltsJson + "}");
|
||||
StructureFit.Start start = new StructureFit.Start() {
|
||||
private final StartKey key = StartKey.create();
|
||||
|
||||
|
||||
+1
-1
@@ -185,7 +185,7 @@ public class TerrainIntegrationTest {
|
||||
public void omittedTerrainRetainsSourceSemanticsAndAnExplicitTerrainWins() {
|
||||
assertEquals(StructureTerrainMode.SOURCE, NativeStructureFit.NONE.resolvedTerrain().resolvedMode());
|
||||
assertEquals(StructureTerrainMode.PRESERVE,
|
||||
NativeStructureFit.of(new StartMemo("{\"mode\":\"PRESERVE\"}", "null")).resolvedTerrain().resolvedMode());
|
||||
NativeStructureFit.of(new StartMemo("{\"terrain\":{\"mode\":\"PRESERVE\"}}")).resolvedTerrain().resolvedMode());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+4
@@ -15,6 +15,9 @@ import static org.junit.Assert.assertNull;
|
||||
/** The settings of {@code iris:objects} describe the same JSON an Iris object placement reads, and keep it for Iris to read. */
|
||||
public class ObjectPlacementMirrorTest {
|
||||
private static final Gson GSON = new Gson();
|
||||
private static final String WARP_OPTION = "warp";
|
||||
/** Iris's own cache size knob, which IrisApi's NoiseStyle leaves out; a placement's JSON still carries it to Iris. */
|
||||
private static final String IRIS_ONLY_STYLE_OPTION = "cacheSize";
|
||||
|
||||
@Test
|
||||
public void theSettingsDeclareEveryOptionOfIrisObjectPlacementAndNoOther() {
|
||||
@@ -29,6 +32,7 @@ public class ObjectPlacementMirrorTest {
|
||||
JsonObject host = GSON.toJsonTree(new IrisObjectPlacement()).getAsJsonObject();
|
||||
JsonObject settings = GSON.toJsonTree(TestSettings.of(ObjectPlacement.class, "{}")).getAsJsonObject();
|
||||
|
||||
host.getAsJsonObject(WARP_OPTION).remove(IRIS_ONLY_STYLE_OPTION);
|
||||
for (String option : host.keySet()) {
|
||||
assertEquals("default of " + option, host.get(option), settings.get(option));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user