mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-10-22 08:07:42 +00:00
Temp vag
This commit is contained in:
1 parent
a66cba6418
commit
70d355621c
26 files changed
+1719
-35
No files matched your search
@@ -1714,6 +1714,41 @@ public class DatapackIngestServiceTest {
|
||||
assertFalse(scratch.exists());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void recoveryRemovesFinderMetadataFromInstallScratch() throws Exception {
|
||||
File root = temporaryFolder.newFolder("orphan-install-finder-metadata-root");
|
||||
File scratch = new File(root, ".iris-datapack-install");
|
||||
assertTrue(scratch.mkdirs());
|
||||
File pending = new File(scratch, "managed-" + UUID.randomUUID());
|
||||
assertTrue(pending.mkdirs());
|
||||
Files.writeString(new File(pending, "partial.dat").toPath(), "partial", StandardCharsets.UTF_8);
|
||||
File metadata = new File(scratch, ".DS_Store");
|
||||
Files.writeString(metadata.toPath(), "finder", StandardCharsets.UTF_8);
|
||||
|
||||
DatapackIngestService.recoverTransactions(root, List.of());
|
||||
|
||||
assertFalse(metadata.exists());
|
||||
assertFalse(pending.exists());
|
||||
assertFalse(scratch.exists());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void recoveryRejectsFinderMetadataDirectoryInInstallScratch() throws Exception {
|
||||
File root = temporaryFolder.newFolder("orphan-install-finder-directory-root");
|
||||
File scratch = new File(root, ".iris-datapack-install");
|
||||
assertTrue(scratch.mkdirs());
|
||||
File metadata = new File(scratch, ".DS_Store");
|
||||
assertTrue(metadata.mkdirs());
|
||||
|
||||
try {
|
||||
DatapackIngestService.recoverTransactions(root, List.of());
|
||||
fail("Expected suspicious Finder metadata to block recovery");
|
||||
} catch (IOException expected) {
|
||||
assertTrue(expected.getMessage().contains("Suspicious datapack recovery artifact"));
|
||||
}
|
||||
assertTrue(metadata.isDirectory());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void recoveryPreservesAndBlocksOnAnUnjournaledInstallBackup() throws Exception {
|
||||
File root = temporaryFolder.newFolder("orphan-install-backup-root");
|
||||
|
||||
+111
@@ -0,0 +1,111 @@
|
||||
package art.arcane.iris.core.pack;
|
||||
|
||||
import art.arcane.volmlib.util.json.JSONArray;
|
||||
import art.arcane.volmlib.util.json.JSONObject;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class PackValidatorStructureTerrainBackendTest {
|
||||
@Rule
|
||||
public TemporaryFolder temporaryFolder = new TemporaryFolder();
|
||||
|
||||
@Test
|
||||
public void rejectsNativeOnlyTerrainModesForEditablePlacementsAcrossEveryHost() throws Exception {
|
||||
for (String mode : List.of("VACUUM", "ENCASE")) {
|
||||
String folderName = "editable-" + mode.toLowerCase(Locale.ROOT);
|
||||
File pack = temporaryFolder.newFolder(folderName);
|
||||
writePlacement(pack, "dimensions/main.json", "dimension-" + folderName,
|
||||
"dimension_city", false, mode);
|
||||
writePlacement(pack, "regions/forest.json", "region-" + folderName,
|
||||
"forest_tower", false, mode);
|
||||
writePlacement(pack, "biomes/plains.json", "biome-" + folderName,
|
||||
"plains_farm", false, mode);
|
||||
List<String> errors = new ArrayList<>();
|
||||
|
||||
PackStructurePlacementValidator.validateStructurePlacements(
|
||||
pack, Set.of("dimension_city", "forest_tower", "plains_farm"), false, errors);
|
||||
|
||||
String suffix = ".terrain.mode " + mode + " cannot target editable Iris structures; "
|
||||
+ "use nativeStructures or importedStructures.adjustments for native terrain preparation.";
|
||||
assertEquals(List.of(
|
||||
"Dimension 'main' structures[0]" + suffix,
|
||||
"Region 'forest' structures[0]" + suffix,
|
||||
"Biome 'plains' structures[0]" + suffix
|
||||
), errors);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void acceptsNativeOnlyTerrainModesForNativeStructurePlacements() throws Exception {
|
||||
for (String mode : List.of("VACUUM", "ENCASE")) {
|
||||
File pack = temporaryFolder.newFolder("native-" + mode.toLowerCase(Locale.ROOT));
|
||||
writePlacement(pack, "dimensions/main.json", "native-" + mode,
|
||||
"minecraft:village_plains", true, mode);
|
||||
List<String> errors = new ArrayList<>();
|
||||
|
||||
PackStructurePlacementValidator.validateStructurePlacements(pack, Set.of(), false, errors);
|
||||
|
||||
assertTrue(mode + ": " + errors, errors.isEmpty());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void acceptsSupportedTerrainModesForEditablePlacements() throws Exception {
|
||||
for (String mode : List.of("SOURCE", "PRESERVE", "BORE", "FORCE_CARVE")) {
|
||||
File pack = temporaryFolder.newFolder("editable-" + mode.toLowerCase(Locale.ROOT));
|
||||
writePlacement(pack, "dimensions/main.json", "editable-" + mode,
|
||||
"dimension_city", false, mode);
|
||||
List<String> errors = new ArrayList<>();
|
||||
|
||||
PackStructurePlacementValidator.validateStructurePlacements(
|
||||
pack, Set.of("dimension_city"), false, errors);
|
||||
|
||||
assertTrue(mode + ": " + errors, errors.isEmpty());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void acceptsNativeOnlyTerrainModesForImportedStructureAdjustments() {
|
||||
for (String mode : List.of("VACUUM", "ENCASE")) {
|
||||
JSONObject policy = new JSONObject().put("adjustments", new JSONArray().put(
|
||||
new JSONObject()
|
||||
.put("match", new JSONArray().put("towns_and_towers:"))
|
||||
.put("terrain", new JSONObject().put("mode", mode))));
|
||||
List<String> errors = new ArrayList<>();
|
||||
|
||||
PackDimensionValidator.validateImportedStructurePolicy(
|
||||
"overworld", new JSONObject().put("importedStructures", policy), errors);
|
||||
|
||||
assertTrue(mode + ": " + errors, errors.isEmpty());
|
||||
}
|
||||
}
|
||||
|
||||
private void writePlacement(File pack, String relativePath, String placementId,
|
||||
String structureKey, boolean nativeStructure,
|
||||
String terrainMode) throws Exception {
|
||||
String source = nativeStructure
|
||||
? "\"nativeStructures\":[{\"structure\":\"" + structureKey + "\"}]"
|
||||
: "\"structures\":[\"" + structureKey + "\"]";
|
||||
write(pack, relativePath, "{\"structures\":[{\"placementId\":\"" + placementId
|
||||
+ "\"," + source + ",\"terrain\":{\"mode\":\"" + terrainMode + "\"}}]}");
|
||||
}
|
||||
|
||||
private void write(File root, String relativePath, String content) throws Exception {
|
||||
Path path = root.toPath().resolve(relativePath);
|
||||
Files.createDirectories(path.getParent());
|
||||
Files.writeString(path, content, StandardCharsets.UTF_8);
|
||||
}
|
||||
}
|
||||
@@ -156,6 +156,7 @@ public class SchemaBuilderParityTest {
|
||||
JSONObject terrainDefinition = schema.getJSONObject("definitions")
|
||||
.getJSONObject(terrain.getString("$ref").substring("#/definitions/".length()));
|
||||
JSONObject terrainProperties = terrainDefinition.getJSONObject("properties");
|
||||
JSONObject terrainMode = terrainProperties.getJSONObject("mode");
|
||||
JSONObject carveShape = terrainProperties.getJSONObject("shape");
|
||||
JSONObject erosionStrength = terrainProperties.getJSONObject("erosionStrength");
|
||||
JSONObject erosionFrequency = terrainProperties.getJSONObject("erosionFrequency");
|
||||
@@ -163,10 +164,17 @@ public class SchemaBuilderParityTest {
|
||||
JSONObject lobeStrength = terrainProperties.getJSONObject("lobeStrength");
|
||||
String carveShapeDefinition = carveShape.getString("$ref")
|
||||
.substring("#/definitions/".length());
|
||||
String terrainModeDefinition = terrainMode.getString("$ref")
|
||||
.substring("#/definitions/".length());
|
||||
|
||||
assertTrue(properties.has("structures"));
|
||||
assertTrue(properties.has("nativeStructures"));
|
||||
assertTrue(properties.has("distribution"));
|
||||
assertTrue(terrain.getString("description").contains(
|
||||
"The editable structures backend supports SOURCE, PRESERVE, BORE, and FORCE_CARVE. "
|
||||
+ "The nativeStructures backend supports every terrain mode."));
|
||||
assertEquals(List.of("SOURCE", "PRESERVE", "BORE", "FORCE_CARVE", "VACUUM", "ENCASE"),
|
||||
oneOfValues(schema.getJSONObject("definitions"), terrainModeDefinition));
|
||||
assertEquals(List.of("BOX", "ROUNDED", "ERODED"), oneOfValues(
|
||||
schema.getJSONObject("definitions"), carveShapeDefinition));
|
||||
assertEquals(0D, erosionStrength.getDouble("minimum"), 0D);
|
||||
|
||||
+27
@@ -100,6 +100,33 @@ public class NativeStructureOwnershipRecordTest {
|
||||
assertEquals(83L, record.placementIdentity());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void referenceEnvelopeRefreshPreservesPersistedAuthority() {
|
||||
NativeStructureOwnershipRecord original = record(
|
||||
"nova_structures:tavern_oak", -3, 9, 83L);
|
||||
|
||||
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());
|
||||
assertEquals(original.contentMinZ(), refreshed.contentMinZ());
|
||||
assertEquals(original.contentMaxX(), refreshed.contentMaxX());
|
||||
assertEquals(original.contentMaxY(), refreshed.contentMaxY());
|
||||
assertEquals(original.contentMaxZ(), refreshed.contentMaxZ());
|
||||
assertEquals(original.locatorY(), refreshed.locatorY());
|
||||
assertEquals(original.contentFingerprint(), refreshed.contentFingerprint());
|
||||
assertEquals(original.decision(), refreshed.decision());
|
||||
assertEquals(-6, refreshed.referenceMinChunkX());
|
||||
assertEquals(0, refreshed.referenceMaxChunkX());
|
||||
assertEquals(6, refreshed.referenceMinChunkZ());
|
||||
assertEquals(12, refreshed.referenceMaxChunkZ());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void ownershipRoundTripPreservesExactBoundsAndPriority() throws Exception {
|
||||
NativeStructureOwnershipRecord ownership = record(
|
||||
|
||||
+29
@@ -202,6 +202,35 @@ public class IrisImportedStructureControlTest {
|
||||
assertNull(control.resolve("minecraft:trial_chambers", true).yBand());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void namespaceVacuumCanPreserveSpecificStructuresLater() {
|
||||
IrisVanillaStructureAdjustment namespace = new IrisVanillaStructureAdjustment()
|
||||
.setMatch(keys("towns_and_towers:"))
|
||||
.setTerrain(new IrisStructureTerrain().setMode(IrisStructureTerrainMode.VACUUM));
|
||||
IrisVanillaStructureAdjustment preserveShips = new IrisVanillaStructureAdjustment()
|
||||
.setMatch(keys(
|
||||
"towns_and_towers:mimic_desert",
|
||||
"towns_and_towers:pillager_outpost_ocean",
|
||||
"towns_and_towers:village_ocean",
|
||||
"towns_and_towers:wreckage_ocean"))
|
||||
.setTerrain(new IrisStructureTerrain().setMode(IrisStructureTerrainMode.PRESERVE));
|
||||
KList<IrisVanillaStructureAdjustment> adjustments = new KList<>();
|
||||
adjustments.add(namespace);
|
||||
adjustments.add(preserveShips);
|
||||
IrisImportedStructureControl control = new IrisImportedStructureControl()
|
||||
.setAdjustments(adjustments);
|
||||
|
||||
assertEquals(IrisStructureTerrainMode.VACUUM,
|
||||
control.resolve("towns_and_towers:village_forest", false)
|
||||
.terrain().resolvedMode());
|
||||
assertEquals(IrisStructureTerrainMode.PRESERVE,
|
||||
control.resolve("towns_and_towers:village_ocean", false)
|
||||
.terrain().resolvedMode());
|
||||
assertEquals(IrisStructureTerrainMode.PRESERVE,
|
||||
control.resolve("towns_and_towers:mimic_desert", true)
|
||||
.terrain().resolvedMode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void preserveSourceYMatchesTheStructureFamilyAndKeepsExplicitShifts() {
|
||||
IrisVanillaStructureAdjustment adjustment = new IrisVanillaStructureAdjustment()
|
||||
|
||||
Reference in new issue
Block a user