mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-12-03 19:51:49 +00:00
Core reads structure placements from settings; package exports leave structures to their own closure
ModuleResourceClosure.exportingElsewhere(type) names the resources of a kind another exporter writes: IrisPackageCompiler and the modded studio export take the placed structure keys from it, and StructurePackageClosure still copies structures with their pools, pieces and loot. SchemaBuilder loses the RegistryListStructure branches and StructureSchemaKeys. Tests build placements as packs write them (StructurePlacementFixtures); a decoding test pins the overworld's ancient city placement and an anonymous cave placement to the identities and starts the old classes gave.
This commit is contained in:
1 parent
7d9fd3faa6
commit
57d5a65c57
26 files changed
+770
-711
No files matched your search
+11
-2
@@ -3,7 +3,9 @@ package art.arcane.iris.nativegen;
|
|||||||
import art.arcane.iris.engine.framework.NativeStructureOwnershipRecord;
|
import art.arcane.iris.engine.framework.NativeStructureOwnershipRecord;
|
||||||
import art.arcane.iris.engine.framework.NativeStructureStartPlan;
|
import art.arcane.iris.engine.framework.NativeStructureStartPlan;
|
||||||
import art.arcane.iris.engine.framework.StructurePlacementGrid;
|
import art.arcane.iris.engine.framework.StructurePlacementGrid;
|
||||||
import art.arcane.iris.engine.object.structure.IrisStructurePlacement;
|
import art.arcane.iris.builtin.structure.StructurePlacement;
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
import art.arcane.iris.engine.framework.NativeStartMemo;
|
import art.arcane.iris.engine.framework.NativeStartMemo;
|
||||||
import art.arcane.iris.engine.framework.NativeStructureReach;
|
import art.arcane.iris.engine.framework.NativeStructureReach;
|
||||||
import net.minecraft.SharedConstants;
|
import net.minecraft.SharedConstants;
|
||||||
@@ -242,7 +244,7 @@ public class NativeStructureOwnershipFingerprintTest {
|
|||||||
|
|
||||||
private static NativeStructureStartPlan plan(ChunkPos origin, int baseY) {
|
private static NativeStructureStartPlan plan(ChunkPos origin, int baseY) {
|
||||||
return new NativeStructureStartPlan("minecraft:monument", origin.x(), origin.z(), baseY, false, false,
|
return new NativeStructureStartPlan("minecraft:monument", origin.x(), origin.z(), baseY, false, false,
|
||||||
StructurePlacementGrid.placementIdentity(new IrisStructurePlacement().setPlacementId("monument-test")),
|
StructurePlacementGrid.placementIdentity(placementWithId("monument-test")),
|
||||||
null, new NativeStartMemo("{\"mode\":\"SOURCE\"}", "null"));
|
null, new NativeStartMemo("{\"mode\":\"SOURCE\"}", "null"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -328,4 +330,11 @@ public class NativeStructureOwnershipFingerprintTest {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** A structure placement as a pack writing only its {@code placementId} has it. */
|
||||||
|
private static StructurePlacement placementWithId(String placementId) {
|
||||||
|
JsonObject json = new JsonObject();
|
||||||
|
json.addProperty("placementId", placementId);
|
||||||
|
return new Gson().fromJson(json, StructurePlacement.class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+11
-2
@@ -5,7 +5,9 @@ import art.arcane.iris.engine.framework.NativeStructureStartPlan;
|
|||||||
import art.arcane.iris.engine.framework.StructurePlacementGrid;
|
import art.arcane.iris.engine.framework.StructurePlacementGrid;
|
||||||
import art.arcane.iris.engine.framework.NativeStartMemo;
|
import art.arcane.iris.engine.framework.NativeStartMemo;
|
||||||
import art.arcane.iris.engine.framework.NativeStructureReach;
|
import art.arcane.iris.engine.framework.NativeStructureReach;
|
||||||
import art.arcane.iris.engine.object.structure.IrisStructurePlacement;
|
import art.arcane.iris.builtin.structure.StructurePlacement;
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
import net.minecraft.SharedConstants;
|
import net.minecraft.SharedConstants;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.core.HolderSet;
|
import net.minecraft.core.HolderSet;
|
||||||
@@ -295,7 +297,7 @@ public class NativeStructureOwnershipRecoveryTest {
|
|||||||
monumentStart(structure(), origin, 1L)).minY(),
|
monumentStart(structure(), origin, 1L)).minY(),
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
StructurePlacementGrid.placementIdentity(new IrisStructurePlacement().setPlacementId(placementId)),
|
StructurePlacementGrid.placementIdentity(placementWithId(placementId)),
|
||||||
null,
|
null,
|
||||||
new NativeStartMemo(terrain, "null")
|
new NativeStartMemo(terrain, "null")
|
||||||
);
|
);
|
||||||
@@ -322,4 +324,11 @@ public class NativeStructureOwnershipRecoveryTest {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** A structure placement as a pack writing only its {@code placementId} has it. */
|
||||||
|
private static StructurePlacement placementWithId(String placementId) {
|
||||||
|
JsonObject json = new JsonObject();
|
||||||
|
json.addProperty("placementId", placementId);
|
||||||
|
return new Gson().fromJson(json, StructurePlacement.class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+3
-20
@@ -38,7 +38,7 @@ import art.arcane.iris.engine.object.terrain.IrisGenerator;
|
|||||||
import art.arcane.iris.core.pack.ModuleResourceClosure;
|
import art.arcane.iris.core.pack.ModuleResourceClosure;
|
||||||
import art.arcane.iris.core.pack.PackExportClosure;
|
import art.arcane.iris.core.pack.PackExportClosure;
|
||||||
import art.arcane.iris.engine.object.world.region.IrisRegion;
|
import art.arcane.iris.engine.object.world.region.IrisRegion;
|
||||||
import art.arcane.iris.engine.object.structure.IrisStructurePlacement;
|
import art.arcane.iris.engine.object.structure.IrisStructure;
|
||||||
import art.arcane.iris.modded.ModdedDimensionManager;
|
import art.arcane.iris.modded.ModdedDimensionManager;
|
||||||
import art.arcane.iris.modded.ModdedEngineBootstrap;
|
import art.arcane.iris.modded.ModdedEngineBootstrap;
|
||||||
import art.arcane.iris.modded.ModdedScheduler;
|
import art.arcane.iris.modded.ModdedScheduler;
|
||||||
@@ -881,9 +881,8 @@ public final class ModdedStudioCommands {
|
|||||||
LinkedHashSet<String> regionKeys = new LinkedHashSet<>();
|
LinkedHashSet<String> regionKeys = new LinkedHashSet<>();
|
||||||
LinkedHashSet<String> biomeKeys = new LinkedHashSet<>();
|
LinkedHashSet<String> biomeKeys = new LinkedHashSet<>();
|
||||||
LinkedHashSet<String> generatorKeys = new LinkedHashSet<>();
|
LinkedHashSet<String> generatorKeys = new LinkedHashSet<>();
|
||||||
ModuleResourceClosure moduleResources = new ModuleResourceClosure(dm);
|
ModuleResourceClosure moduleResources = new ModuleResourceClosure(dm).exportingElsewhere(IrisStructure.class);
|
||||||
LinkedHashSet<String> objectKeys = new LinkedHashSet<>();
|
LinkedHashSet<String> objectKeys = new LinkedHashSet<>();
|
||||||
LinkedHashSet<String> structureKeys = new LinkedHashSet<>();
|
|
||||||
|
|
||||||
dimension.getAllRegions(() -> dm).forEach((IrisRegion region) -> {
|
dimension.getAllRegions(() -> dm).forEach((IrisRegion region) -> {
|
||||||
if (region != null && region.getLoadKey() != null) {
|
if (region != null && region.getLoadKey() != null) {
|
||||||
@@ -896,7 +895,6 @@ public final class ModdedStudioCommands {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
moduleResources.followSettingsOf(dimension);
|
moduleResources.followSettingsOf(dimension);
|
||||||
collectStructureKeys(structureKeys, dimension.getStructures());
|
|
||||||
|
|
||||||
for (String regionKey : regionKeys) {
|
for (String regionKey : regionKeys) {
|
||||||
IrisRegion region = dm.getRegionLoader().load(regionKey);
|
IrisRegion region = dm.getRegionLoader().load(regionKey);
|
||||||
@@ -910,7 +908,6 @@ public final class ModdedStudioCommands {
|
|||||||
});
|
});
|
||||||
moduleResources.followSettingsOf(region);
|
moduleResources.followSettingsOf(region);
|
||||||
moduleResources.follow(region.getObjects());
|
moduleResources.follow(region.getObjects());
|
||||||
collectStructureKeys(structureKeys, region.getStructures());
|
|
||||||
objectKeys.addAll(PackExportClosure.collectObjectKeys(region.getObjects()));
|
objectKeys.addAll(PackExportClosure.collectObjectKeys(region.getObjects()));
|
||||||
}
|
}
|
||||||
for (String biomeKey : biomeKeys) {
|
for (String biomeKey : biomeKeys) {
|
||||||
@@ -921,11 +918,11 @@ public final class ModdedStudioCommands {
|
|||||||
biome.getGenerators().forEach((IrisBiomeGeneratorLink link) -> generatorKeys.add(link.getGenerator()));
|
biome.getGenerators().forEach((IrisBiomeGeneratorLink link) -> generatorKeys.add(link.getGenerator()));
|
||||||
moduleResources.followSettingsOf(biome);
|
moduleResources.followSettingsOf(biome);
|
||||||
moduleResources.follow(biome.getObjects());
|
moduleResources.follow(biome.getObjects());
|
||||||
collectStructureKeys(structureKeys, biome.getStructures());
|
|
||||||
objectKeys.addAll(PackExportClosure.collectObjectKeys(biome.getObjects()));
|
objectKeys.addAll(PackExportClosure.collectObjectKeys(biome.getObjects()));
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuilder hashes = new StringBuilder();
|
StringBuilder hashes = new StringBuilder();
|
||||||
|
List<String> structureKeys = moduleResources.keysOf(IrisStructure.class);
|
||||||
StructurePackageClosure structureClosure = StructurePackageClosure.collect(packFolder, structureKeys);
|
StructurePackageClosure structureClosure = StructurePackageClosure.collect(packFolder, structureKeys);
|
||||||
if (!structureClosure.isValid()) {
|
if (!structureClosure.isValid()) {
|
||||||
throw new IOException("Structure package closure is invalid: " + String.join("; ", structureClosure.errors()));
|
throw new IOException("Structure package closure is invalid: " + String.join("; ", structureClosure.errors()));
|
||||||
@@ -969,20 +966,6 @@ public final class ModdedStudioCommands {
|
|||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void collectStructureKeys(LinkedHashSet<String> keys, List<IrisStructurePlacement> placements) {
|
|
||||||
if (placements == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
for (IrisStructurePlacement placement : placements) {
|
|
||||||
if (placement == null || placement.getStructures() == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
for (String structureKey : placement.getStructures()) {
|
|
||||||
keys.add(structureKey);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String copyJson(File folder, String category, String key, File file) {
|
private static String copyJson(File folder, String category, String key, File file) {
|
||||||
if (file == null || !file.isFile()) {
|
if (file == null || !file.isFile()) {
|
||||||
return "";
|
return "";
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
|
import java.util.TreeSet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The resources of the pack's module resource kinds that a pack export has to carry: what the settings of the
|
* The resources of the pack's module resource kinds that a pack export has to carry: what the settings of the
|
||||||
@@ -59,6 +60,7 @@ public final class ModuleResourceClosure {
|
|||||||
private final Map<Class<?>, ResourceKind<?>> kindsByType = new HashMap<>();
|
private final Map<Class<?>, ResourceKind<?>> kindsByType = new HashMap<>();
|
||||||
private final Map<ResourceKind<?>, Map<String, Object>> found = new LinkedHashMap<>();
|
private final Map<ResourceKind<?>, Map<String, Object>> found = new LinkedHashMap<>();
|
||||||
private final Set<Object> visited = java.util.Collections.newSetFromMap(new IdentityHashMap<>());
|
private final Set<Object> visited = java.util.Collections.newSetFromMap(new IdentityHashMap<>());
|
||||||
|
private final Map<Class<?>, Set<String>> exportedElsewhere = new HashMap<>();
|
||||||
|
|
||||||
public ModuleResourceClosure(IrisData data) {
|
public ModuleResourceClosure(IrisData data) {
|
||||||
this.data = data;
|
this.data = data;
|
||||||
@@ -67,6 +69,16 @@ public final class ModuleResourceClosure {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Leaves the resources that read into {@code type} to another exporter, such as Iris's structure closure that
|
||||||
|
* copies structures with their pools, pieces and loot: {@link #keysOf} names the ones referenced, but they are
|
||||||
|
* not loaded, followed or written. Call before following anything.
|
||||||
|
*/
|
||||||
|
public ModuleResourceClosure exportingElsewhere(Class<?> type) {
|
||||||
|
exportedElsewhere.putIfAbsent(type, new TreeSet<>());
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/** Adds the resources that the module settings of {@code owner} reference, and those they reference. */
|
/** Adds the resources that the module settings of {@code owner} reference, and those they reference. */
|
||||||
public void followSettingsOf(IrisRegistrant owner) {
|
public void followSettingsOf(IrisRegistrant owner) {
|
||||||
owner.getModuleSettings().values().forEach(this::follow);
|
owner.getModuleSettings().values().forEach(this::follow);
|
||||||
@@ -108,6 +120,9 @@ public final class ModuleResourceClosure {
|
|||||||
|
|
||||||
/** The keys of the resources found of the kind that reads into {@code type}, in key order. */
|
/** The keys of the resources found of the kind that reads into {@code type}, in key order. */
|
||||||
public List<String> keysOf(Class<?> type) {
|
public List<String> keysOf(Class<?> type) {
|
||||||
|
if (exportedElsewhere.containsKey(type)) {
|
||||||
|
return new ArrayList<>(exportedElsewhere.get(type));
|
||||||
|
}
|
||||||
ResourceKind<?> kind = kindsByType.get(type);
|
ResourceKind<?> kind = kindsByType.get(type);
|
||||||
return kind == null || !found.containsKey(kind) ? List.of() : new ArrayList<>(new TreeMap<>(found.get(kind)).keySet());
|
return kind == null || !found.containsKey(kind) ? List.of() : new ArrayList<>(new TreeMap<>(found.get(kind)).keySet());
|
||||||
}
|
}
|
||||||
@@ -175,6 +190,11 @@ public final class ModuleResourceClosure {
|
|||||||
if (kind == null || key == null || key.isBlank()) {
|
if (kind == null || key == null || key.isBlank()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Set<String> elsewhere = exportedElsewhere.get(type);
|
||||||
|
if (elsewhere != null) {
|
||||||
|
elsewhere.add(key);
|
||||||
|
return;
|
||||||
|
}
|
||||||
Map<String, Object> ofKind = found.computeIfAbsent(kind, ignored -> new LinkedHashMap<>());
|
Map<String, Object> ofKind = found.computeIfAbsent(kind, ignored -> new LinkedHashMap<>());
|
||||||
if (ofKind.containsKey(key)) {
|
if (ofKind.containsKey(key)) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ import art.arcane.iris.engine.object.material.IrisBlockData;
|
|||||||
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
||||||
import art.arcane.iris.engine.object.terrain.IrisGenerator;
|
import art.arcane.iris.engine.object.terrain.IrisGenerator;
|
||||||
import art.arcane.iris.engine.object.world.region.IrisRegion;
|
import art.arcane.iris.engine.object.world.region.IrisRegion;
|
||||||
import art.arcane.iris.engine.object.structure.IrisStructurePlacement;
|
import art.arcane.iris.engine.object.structure.IrisStructure;
|
||||||
import art.arcane.iris.spi.IrisLogging;
|
import art.arcane.iris.spi.IrisLogging;
|
||||||
import art.arcane.iris.spi.IrisPlatforms;
|
import art.arcane.iris.spi.IrisPlatforms;
|
||||||
import art.arcane.iris.util.common.plugin.VolmitSender;
|
import art.arcane.iris.util.common.plugin.VolmitSender;
|
||||||
@@ -52,8 +52,7 @@ import org.zeroturnaround.zip.ZipUtil;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.List;
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@SuppressWarnings("ALL")
|
@SuppressWarnings("ALL")
|
||||||
@@ -105,7 +104,7 @@ public class IrisPackageCompiler {
|
|||||||
KSet<IrisRegion> regions = new KSet<>();
|
KSet<IrisRegion> regions = new KSet<>();
|
||||||
KSet<IrisBiome> biomes = new KSet<>();
|
KSet<IrisBiome> biomes = new KSet<>();
|
||||||
KSet<IrisGenerator> generators = new KSet<>();
|
KSet<IrisGenerator> generators = new KSet<>();
|
||||||
ModuleResourceClosure moduleResources = new ModuleResourceClosure(dm);
|
ModuleResourceClosure moduleResources = new ModuleResourceClosure(dm).exportingElsewhere(IrisStructure.class);
|
||||||
KSet<IrisBlockData> blocks = new KSet<>();
|
KSet<IrisBlockData> blocks = new KSet<>();
|
||||||
|
|
||||||
// KSet is ConcurrentHashMap-backed: both add(null) and remove(null) throw NPE, so a
|
// KSet is ConcurrentHashMap-backed: both add(null) and remove(null) throw NPE, so a
|
||||||
@@ -125,10 +124,7 @@ public class IrisPackageCompiler {
|
|||||||
regions.forEach((r) -> allPlacements.addAll(r.getObjects()));
|
regions.forEach((r) -> allPlacements.addAll(r.getObjects()));
|
||||||
biomes.forEach((i) -> allPlacements.addAll(i.getObjects()));
|
biomes.forEach((i) -> allPlacements.addAll(i.getObjects()));
|
||||||
moduleResources.follow(allPlacements);
|
moduleResources.follow(allPlacements);
|
||||||
Set<String> structureKeys = new LinkedHashSet<>();
|
List<String> structureKeys = moduleResources.keysOf(IrisStructure.class);
|
||||||
collectStructureKeys(structureKeys, dimension.getStructures());
|
|
||||||
regions.forEach((region) -> collectStructureKeys(structureKeys, region.getStructures()));
|
|
||||||
biomes.forEach((biome) -> collectStructureKeys(structureKeys, biome.getStructures()));
|
|
||||||
KMap<String, String> renameObjects = new KMap<>();
|
KMap<String, String> renameObjects = new KMap<>();
|
||||||
String a;
|
String a;
|
||||||
StringBuilder b = new StringBuilder();
|
StringBuilder b = new StringBuilder();
|
||||||
@@ -265,18 +261,4 @@ public class IrisPackageCompiler {
|
|||||||
settings.keySet().forEach(key -> json.put(key, settings.get(key)));
|
settings.keySet().forEach(key -> json.put(key, settings.get(key)));
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void collectStructureKeys(Set<String> keys, KList<IrisStructurePlacement> placements) {
|
|
||||||
if (placements == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
for (IrisStructurePlacement placement : placements) {
|
|
||||||
if (placement == null || placement.getStructures() == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
for (String structureKey : placement.getStructures()) {
|
|
||||||
keys.add(structureKey);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -28,14 +28,12 @@ import art.arcane.iris.core.loader.ResourceLoader;
|
|||||||
import art.arcane.iris.core.modules.IrisValues;
|
import art.arcane.iris.core.modules.IrisValues;
|
||||||
import art.arcane.iris.core.modules.ModuleResourceFiles;
|
import art.arcane.iris.core.modules.ModuleResourceFiles;
|
||||||
import art.arcane.iris.core.modules.ModuleTargets;
|
import art.arcane.iris.core.modules.ModuleTargets;
|
||||||
import art.arcane.iris.engine.framework.structure.StructureResources;
|
|
||||||
import art.arcane.iris.engine.object.image.IrisImageMap;
|
import art.arcane.iris.engine.object.image.IrisImageMap;
|
||||||
import art.arcane.iris.engine.object.noise.NoiseStyle;
|
import art.arcane.iris.engine.object.noise.NoiseStyle;
|
||||||
import art.arcane.iris.engine.object.noise.expression.IrisExpression;
|
import art.arcane.iris.engine.object.noise.expression.IrisExpression;
|
||||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||||
import art.arcane.iris.engine.object.world.region.IrisRegion;
|
import art.arcane.iris.engine.object.world.region.IrisRegion;
|
||||||
import art.arcane.iris.core.structure.StructureSchemaKeys;
|
|
||||||
import art.arcane.iris.engine.framework.ListFunction;
|
import art.arcane.iris.engine.framework.ListFunction;
|
||||||
import art.arcane.iris.engine.object.annotations.ArrayType;
|
import art.arcane.iris.engine.object.annotations.ArrayType;
|
||||||
import art.arcane.iris.engine.object.annotations.Desc;
|
import art.arcane.iris.engine.object.annotations.Desc;
|
||||||
@@ -51,7 +49,6 @@ import art.arcane.iris.engine.object.annotations.RegistryListItemType;
|
|||||||
import art.arcane.iris.engine.object.annotations.RegistryListPotionEffect;
|
import art.arcane.iris.engine.object.annotations.RegistryListPotionEffect;
|
||||||
import art.arcane.iris.engine.object.annotations.RegistryListResource;
|
import art.arcane.iris.engine.object.annotations.RegistryListResource;
|
||||||
import art.arcane.iris.engine.object.annotations.RegistryListSpecialEntity;
|
import art.arcane.iris.engine.object.annotations.RegistryListSpecialEntity;
|
||||||
import art.arcane.iris.engine.object.annotations.RegistryListStructure;
|
|
||||||
import art.arcane.iris.engine.object.annotations.RegistryListVanillaStructure;
|
import art.arcane.iris.engine.object.annotations.RegistryListVanillaStructure;
|
||||||
import art.arcane.iris.engine.object.annotations.RegistryMapBlockState;
|
import art.arcane.iris.engine.object.annotations.RegistryMapBlockState;
|
||||||
import art.arcane.iris.engine.object.annotations.Required;
|
import art.arcane.iris.engine.object.annotations.Required;
|
||||||
@@ -595,21 +592,6 @@ public class SchemaBuilder {
|
|||||||
} else {
|
} else {
|
||||||
IrisLogging.error("Cannot find Registry Loader for type " + rr.value() + " used in " + k.getDeclaringClass().getCanonicalName() + " in field " + k.getName());
|
IrisLogging.error("Cannot find Registry Loader for type " + rr.value() + " used in " + k.getDeclaringClass().getCanonicalName() + " in field " + k.getName());
|
||||||
}
|
}
|
||||||
} else if (k.isAnnotationPresent(RegistryListStructure.class)) {
|
|
||||||
String key = "enum-iris-structure-placement";
|
|
||||||
|
|
||||||
if (!definitions.containsKey(key)) {
|
|
||||||
JSONObject j = new JSONObject();
|
|
||||||
j.put("enum", new JSONArray(StructureSchemaKeys.collect(
|
|
||||||
StructureResources.structureKeys(data),
|
|
||||||
StructureResources.pieceKeys(data)).toArray(new String[0])));
|
|
||||||
definitions.put(key, j);
|
|
||||||
}
|
|
||||||
|
|
||||||
fancyType = "Structure";
|
|
||||||
prop.put("$ref", "#/definitions/" + key);
|
|
||||||
description.add(SYMBOL_TYPE__N + " Must be a valid vanilla, datapack, or imported Iris structure (use ctrl+space for auto complete!)");
|
|
||||||
|
|
||||||
} else if (k.isAnnotationPresent(RegistryListBlockType.class)) {
|
} else if (k.isAnnotationPresent(RegistryListBlockType.class)) {
|
||||||
fancyType = "Block Type";
|
fancyType = "Block Type";
|
||||||
putRegistryEnumRef(prop, "enum-block-type", this::blockTypes);
|
putRegistryEnumRef(prop, "enum-block-type", this::blockTypes);
|
||||||
@@ -771,22 +753,6 @@ public class SchemaBuilder {
|
|||||||
} else {
|
} else {
|
||||||
IrisLogging.error("Cannot find Registry Loader for type (list schema) " + rr.value() + " used in " + k.getDeclaringClass().getCanonicalName() + " in field " + k.getName());
|
IrisLogging.error("Cannot find Registry Loader for type (list schema) " + rr.value() + " used in " + k.getDeclaringClass().getCanonicalName() + " in field " + k.getName());
|
||||||
}
|
}
|
||||||
} else if (k.isAnnotationPresent(RegistryListStructure.class)) {
|
|
||||||
fancyType = "List<Structure>";
|
|
||||||
String key = "enum-iris-structure-placement";
|
|
||||||
|
|
||||||
if (!definitions.containsKey(key)) {
|
|
||||||
JSONObject j = new JSONObject();
|
|
||||||
j.put("enum", new JSONArray(StructureSchemaKeys.collect(
|
|
||||||
StructureResources.structureKeys(data),
|
|
||||||
StructureResources.pieceKeys(data)).toArray(new String[0])));
|
|
||||||
definitions.put(key, j);
|
|
||||||
}
|
|
||||||
|
|
||||||
JSONObject items = new JSONObject();
|
|
||||||
items.put("$ref", "#/definitions/" + key);
|
|
||||||
prop.put("items", items);
|
|
||||||
description.add(SYMBOL_TYPE__N + " Must be a valid vanilla, datapack, or imported Iris structure (use ctrl+space for auto complete!)");
|
|
||||||
} else if (k.isAnnotationPresent(RegistryListVanillaStructure.class)) {
|
} else if (k.isAnnotationPresent(RegistryListVanillaStructure.class)) {
|
||||||
fancyType = "List<Vanilla Structure>";
|
fancyType = "List<Vanilla Structure>";
|
||||||
putRegistryEnumItems(prop, "enum-vanilla-structure", this::vanillaStructures);
|
putRegistryEnumItems(prop, "enum-vanilla-structure", this::vanillaStructures);
|
||||||
|
|||||||
@@ -1,57 +0,0 @@
|
|||||||
/*
|
|
||||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
|
||||||
* Copyright (c) 2022 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.structure;
|
|
||||||
|
|
||||||
import art.arcane.volmlib.util.collection.KList;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.TreeSet;
|
|
||||||
|
|
||||||
public final class StructureSchemaKeys {
|
|
||||||
private StructureSchemaKeys() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public static KList<String> collect(Collection<String> structureKeys, Collection<String> jigsawPieceKeys) {
|
|
||||||
Set<String> pieces = new HashSet<>();
|
|
||||||
if (jigsawPieceKeys != null) {
|
|
||||||
for (String piece : jigsawPieceKeys) {
|
|
||||||
if (piece != null && !piece.isBlank()) {
|
|
||||||
pieces.add(piece);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
TreeSet<String> merged = new TreeSet<>();
|
|
||||||
if (structureKeys != null) {
|
|
||||||
for (String key : structureKeys) {
|
|
||||||
if (key == null || key.isBlank()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (pieces.contains(key)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
merged.add(key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return new KList<>(merged);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+18
@@ -0,0 +1,18 @@
|
|||||||
|
package art.arcane.iris.builtin.structure;
|
||||||
|
|
||||||
|
import com.volmit.config.Desc;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
public class NativeStructureSuppressionDescTest {
|
||||||
|
@Test
|
||||||
|
public void suppressionTypeAndValuesKeepTheirStudioDescriptions() throws NoSuchFieldException {
|
||||||
|
assertEquals("Controls whether an Iris structure placement suppresses its imported native source.",
|
||||||
|
NativeStructureSuppression.class.getAnnotation(Desc.class).value());
|
||||||
|
assertEquals("Leaves native generation enabled alongside this Iris structure placement.",
|
||||||
|
NativeStructureSuppression.class.getField("NONE").getAnnotation(Desc.class).value());
|
||||||
|
assertEquals("Suppresses the structure's vanillaSource when used by a validated dimension-level replacement placement.",
|
||||||
|
NativeStructureSuppression.class.getField("REPLACE_SOURCE").getAnnotation(Desc.class).value());
|
||||||
|
}
|
||||||
|
}
|
||||||
+38
@@ -0,0 +1,38 @@
|
|||||||
|
package art.arcane.iris.builtin.structure;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static art.arcane.iris.engine.framework.StructurePlacementFixtures.placement;
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
public class StructurePlacementAnchorTest {
|
||||||
|
@Test
|
||||||
|
public void legacyPreservesUndergroundBehavior() {
|
||||||
|
StructurePlacement surface = new StructurePlacement();
|
||||||
|
StructurePlacement underground = placement("underground", true);
|
||||||
|
|
||||||
|
assertEquals(StructureAnchorMode.SURFACE, surface.resolvedAnchor());
|
||||||
|
assertEquals(StructureAnchorMode.HEIGHT_BAND, underground.resolvedAnchor());
|
||||||
|
assertFalse(surface.isAnchoredUnderground());
|
||||||
|
assertTrue(underground.isAnchoredUnderground());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void explicitAnchorOverridesLegacyBoolean() {
|
||||||
|
StructurePlacement floor = placement("underground", false, "anchor", StructureAnchorMode.CAVE_FLOOR);
|
||||||
|
StructurePlacement surface = placement("underground", true, "anchor", StructureAnchorMode.SURFACE);
|
||||||
|
|
||||||
|
assertTrue(floor.isAnchoredUnderground());
|
||||||
|
assertFalse(surface.isAnchoredUnderground());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void aMissingAnchorIsLegacy() {
|
||||||
|
StructurePlacement placement = placement("anchor", null, "underground", true);
|
||||||
|
|
||||||
|
assertEquals(StructureAnchorMode.LEGACY, placement.anchor());
|
||||||
|
assertEquals(StructureAnchorMode.HEIGHT_BAND, placement.resolvedAnchor());
|
||||||
|
}
|
||||||
|
}
|
||||||
+202
@@ -0,0 +1,202 @@
|
|||||||
|
/*
|
||||||
|
* 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.builtin.structure.NativeStructureSource;
|
||||||
|
import art.arcane.iris.builtin.structure.NativeStructureSuppression;
|
||||||
|
import art.arcane.iris.builtin.structure.StructureAnchorMode;
|
||||||
|
import art.arcane.iris.builtin.structure.StructureDistribution;
|
||||||
|
import art.arcane.iris.builtin.structure.StructurePlacement;
|
||||||
|
import art.arcane.iris.builtin.structure.StructurePlacementSettings;
|
||||||
|
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.host.LoadedPack;
|
||||||
|
import com.volmit.host.ModuleHost;
|
||||||
|
import org.junit.After;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Rule;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.rules.TemporaryFolder;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The {@code "structures"} of dimensions, regions and biomes as packs have always written them, read into
|
||||||
|
* {@link StructurePlacementSettings}. The pins are what the old host placement class gave for the same JSON.
|
||||||
|
*/
|
||||||
|
public class StructurePlacementSettingsDecodingTest {
|
||||||
|
/** The overworld's ancient city placement, as the pack wrote it before the move. */
|
||||||
|
private static final String OVERWORLD = """
|
||||||
|
{
|
||||||
|
"structures": [
|
||||||
|
{
|
||||||
|
"nativeStructures": [
|
||||||
|
{
|
||||||
|
"structure": "minecraft:ancient_city"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"placementId": "ancient-city-native",
|
||||||
|
"nativeSuppression": "REPLACE_SOURCE",
|
||||||
|
"underground": true,
|
||||||
|
"terrain": {
|
||||||
|
"mode": "FORCE_CARVE",
|
||||||
|
"horizontalPadding": 14,
|
||||||
|
"ceilingPadding": 12,
|
||||||
|
"floorPadding": 0,
|
||||||
|
"shape": "ERODED",
|
||||||
|
"erosionStrength": 1.0,
|
||||||
|
"erosionFrequency": 0.05
|
||||||
|
},
|
||||||
|
"stilt": {
|
||||||
|
"maxDepth": 768,
|
||||||
|
"spacing": 1,
|
||||||
|
"palette": {
|
||||||
|
"style": {
|
||||||
|
"style": "STATIC"
|
||||||
|
},
|
||||||
|
"palette": [
|
||||||
|
{
|
||||||
|
"block": "minecraft:deepslate_bricks",
|
||||||
|
"weight": 6
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"block": "minecraft:cracked_deepslate_bricks",
|
||||||
|
"weight": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"block": "minecraft:deepslate_tiles",
|
||||||
|
"weight": 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"block": "minecraft:cracked_deepslate_tiles",
|
||||||
|
"weight": 1
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"minHeight": -220,
|
||||||
|
"maxHeight": -220,
|
||||||
|
"distribution": "RANDOM_SPREAD",
|
||||||
|
"spacing": 64,
|
||||||
|
"separation": 5,
|
||||||
|
"salt": 42069
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
""";
|
||||||
|
/** The same placement without its id, a second source, a cave anchor and density starts. */
|
||||||
|
private static final String ANONYMOUS = """
|
||||||
|
{"structures": [{"nativeStructures": [{"structure": "minecraft:ancient_city"}, {"structure": "minecraft:trial_chambers", "weight": 3}], "nativeSuppression": "REPLACE_SOURCE", "underground": true, "terrain": {"mode": "FORCE_CARVE", "horizontalPadding": 14, "ceilingPadding": 12, "floorPadding": 0, "shape": "ERODED", "erosionStrength": 1.0, "erosionFrequency": 0.05}, "stilt": {"maxDepth": 768, "spacing": 1, "palette": {"style": {"style": "STATIC"}, "palette": [{"block": "minecraft:deepslate_bricks", "weight": 6}, {"block": "minecraft:cracked_deepslate_bricks", "weight": 1}, {"block": "minecraft:deepslate_tiles", "weight": 2}, {"block": "minecraft:cracked_deepslate_tiles", "weight": 1}]}}, "minHeight": -220, "maxHeight": -220, "distribution": "DENSITY", "spacing": 64, "separation": 5, "salt": 42069, "anchor": "CAVE_FLOOR", "caveBiomes": ["Deep", " crystal"], "density": 0.4}]}
|
||||||
|
""";
|
||||||
|
private static final long WORLD_SEED = 1337L;
|
||||||
|
private static final int SCANNED_CHUNKS_FROM = -32;
|
||||||
|
private static final int SCANNED_CHUNKS_TO = 32;
|
||||||
|
|
||||||
|
@Rule
|
||||||
|
public TemporaryFolder folder = new TemporaryFolder();
|
||||||
|
|
||||||
|
private LoadedPack pack;
|
||||||
|
private ModuleSettingsDecoder decoder;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void loadBuiltIns() throws IOException {
|
||||||
|
Path packFolder = folder.newFolder("pack").toPath();
|
||||||
|
pack = LoadedPack.load(packFolder, ModuleHost.of(BuiltInPack.allBuiltIns())
|
||||||
|
.describingHostTypesIn(IrisModuleHost.HOST_TYPE_PACKAGE).copyingJarsTo(folder.newFolder("copies").toPath()));
|
||||||
|
decoder = new ModuleSettingsDecoder(pack.catalog(), packFolder, Gson::new);
|
||||||
|
}
|
||||||
|
|
||||||
|
@After
|
||||||
|
public void closePack() {
|
||||||
|
pack.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void theOverworldPlacementReadsAsThePackWroteIt() {
|
||||||
|
StructurePlacement placement = placements(Target.DIMENSION, OVERWORLD).getFirst();
|
||||||
|
|
||||||
|
assertEquals(List.of("minecraft:ancient_city"), placement.nativeStructures().stream().map(NativeStructureSource::structure).toList());
|
||||||
|
assertEquals(1, placement.nativeStructures().getFirst().weight());
|
||||||
|
assertTrue(placement.nativeStructures().getFirst().jigsaw().isEmpty());
|
||||||
|
assertEquals(List.of(), placement.structures());
|
||||||
|
assertEquals("ancient-city-native", placement.placementId());
|
||||||
|
assertEquals(NativeStructureSuppression.REPLACE_SOURCE, placement.nativeSuppression());
|
||||||
|
assertTrue(placement.underground());
|
||||||
|
assertEquals(StructureTerrainMode.FORCE_CARVE, placement.resolvedTerrain().resolvedMode());
|
||||||
|
assertEquals(14, placement.resolvedTerrain().horizontalPadding());
|
||||||
|
assertEquals(768, placement.stilt().orElseThrow().maxDepth());
|
||||||
|
assertEquals(-220, placement.minHeight());
|
||||||
|
assertEquals(-220, placement.maxHeight());
|
||||||
|
assertEquals(StructureDistribution.RANDOM_SPREAD, placement.distribution());
|
||||||
|
assertEquals(64, placement.spacing());
|
||||||
|
assertEquals(5, placement.separation());
|
||||||
|
assertEquals(42069, placement.salt());
|
||||||
|
assertEquals(StructureAnchorMode.HEIGHT_BAND, placement.resolvedAnchor());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void placementsKeepTheirIdentityAndStarts() {
|
||||||
|
StructurePlacement overworld = placements(Target.DIMENSION, OVERWORLD).getFirst();
|
||||||
|
StructurePlacement anonymous = placements(Target.BIOME, ANONYMOUS).getFirst();
|
||||||
|
|
||||||
|
assertEquals(-5401497891314909808L, StructurePlacementGrid.placementIdentity(overworld));
|
||||||
|
assertEquals(-2165116524116229836L, StructurePlacementGrid.placementRng(overworld, 7, -11, 123L).getSeed());
|
||||||
|
assertEquals(new Starts(2, -939), starts(overworld));
|
||||||
|
assertEquals(-5867838400029675033L, StructurePlacementGrid.placementIdentity(anonymous));
|
||||||
|
assertEquals(-4577893773733009372L, StructurePlacementGrid.placementRng(anonymous, 7, -11, 123L).getSeed());
|
||||||
|
assertEquals(new Starts(1585, 865), starts(anonymous));
|
||||||
|
}
|
||||||
|
|
||||||
|
@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());
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<StructurePlacement> placements(Target target, String json) {
|
||||||
|
return decoder.decode(target, new JSONObject(json), "test resource")
|
||||||
|
.find(StructurePlacementSettings.class).orElseThrow().placements();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Starts starts(StructurePlacement placement) {
|
||||||
|
int count = 0;
|
||||||
|
long checksum = 0;
|
||||||
|
for (int chunkX = SCANNED_CHUNKS_FROM; chunkX < SCANNED_CHUNKS_TO; chunkX++) {
|
||||||
|
for (int chunkZ = SCANNED_CHUNKS_FROM; chunkZ < SCANNED_CHUNKS_TO; chunkZ++) {
|
||||||
|
if (StructurePlacementGrid.startsInChunk(placement, chunkX, chunkZ, WORLD_SEED)) {
|
||||||
|
count++;
|
||||||
|
checksum += chunkX * 31L + chunkZ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new Starts(count, checksum);
|
||||||
|
}
|
||||||
|
|
||||||
|
private record Starts(int count, long checksum) {
|
||||||
|
}
|
||||||
|
}
|
||||||
-39
@@ -1,39 +0,0 @@
|
|||||||
package art.arcane.iris.core.project;
|
|
||||||
|
|
||||||
import art.arcane.iris.engine.object.structure.vanilla.NativeStructureSuppression;
|
|
||||||
import art.arcane.iris.engine.object.annotations.Desc;
|
|
||||||
import art.arcane.volmlib.util.json.JSONArray;
|
|
||||||
import art.arcane.volmlib.util.json.JSONObject;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.assertNotNull;
|
|
||||||
|
|
||||||
public class NativeStructureSuppressionSchemaTest {
|
|
||||||
@Test
|
|
||||||
public void suppressionTypeAndValuesAreSchemaDescribed() throws NoSuchFieldException {
|
|
||||||
assertNotNull(NativeStructureSuppression.class.getAnnotation(Desc.class));
|
|
||||||
assertNotNull(NativeStructureSuppression.class.getField("NONE").getAnnotation(Desc.class));
|
|
||||||
assertNotNull(NativeStructureSuppression.class.getField("REPLACE_SOURCE").getAnnotation(Desc.class));
|
|
||||||
|
|
||||||
JSONObject schema = new SchemaBuilder(SuppressionModel.class, null).construct();
|
|
||||||
JSONObject suppression = schema.getJSONObject("properties").getJSONObject("suppression");
|
|
||||||
String definitionKey = suppression.getString("$ref").substring("#/definitions/".length());
|
|
||||||
JSONArray values = schema.getJSONObject("definitions")
|
|
||||||
.getJSONObject(definitionKey)
|
|
||||||
.getJSONArray("oneOf");
|
|
||||||
|
|
||||||
assertEquals("NONE", values.getJSONObject(0).getString("const"));
|
|
||||||
assertEquals("Leaves native generation enabled alongside this Iris structure placement.",
|
|
||||||
values.getJSONObject(0).getString("description"));
|
|
||||||
assertEquals("REPLACE_SOURCE", values.getJSONObject(1).getString("const"));
|
|
||||||
assertEquals("Suppresses the structure's vanillaSource when used by a validated dimension-level replacement placement.",
|
|
||||||
values.getJSONObject(1).getString("description"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Desc("Schema model for native structure suppression.")
|
|
||||||
public static class SuppressionModel {
|
|
||||||
@Desc("Native structure suppression behavior.")
|
|
||||||
private NativeStructureSuppression suppression = NativeStructureSuppression.NONE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -29,7 +29,6 @@ import art.arcane.iris.engine.object.noise.expression.IrisExpression;
|
|||||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
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.dimension.IrisDimension;
|
||||||
import art.arcane.iris.engine.object.structure.IrisStructure;
|
import art.arcane.iris.engine.object.structure.IrisStructure;
|
||||||
import art.arcane.iris.engine.object.structure.IrisStructurePlacement;
|
|
||||||
import art.arcane.iris.engine.object.annotations.ArrayType;
|
import art.arcane.iris.engine.object.annotations.ArrayType;
|
||||||
import art.arcane.iris.engine.object.annotations.Desc;
|
import art.arcane.iris.engine.object.annotations.Desc;
|
||||||
import art.arcane.iris.engine.object.annotations.MaxNumber;
|
import art.arcane.iris.engine.object.annotations.MaxNumber;
|
||||||
@@ -44,7 +43,6 @@ import art.arcane.iris.engine.object.annotations.RegistryListSpecialEntity;
|
|||||||
import art.arcane.iris.engine.object.annotations.RegistryListVanillaStructure;
|
import art.arcane.iris.engine.object.annotations.RegistryListVanillaStructure;
|
||||||
import art.arcane.iris.engine.object.annotations.functions.LootTableKeyFunction;
|
import art.arcane.iris.engine.object.annotations.functions.LootTableKeyFunction;
|
||||||
import art.arcane.iris.spi.IrisPlatform;
|
import art.arcane.iris.spi.IrisPlatform;
|
||||||
import art.arcane.iris.engine.object.structure.vanilla.IrisNativeStructure;
|
|
||||||
import art.arcane.iris.spi.IrisPlatforms;
|
import art.arcane.iris.spi.IrisPlatforms;
|
||||||
import art.arcane.iris.spi.LogLevel;
|
import art.arcane.iris.spi.LogLevel;
|
||||||
import art.arcane.iris.spi.PlatformBiome;
|
import art.arcane.iris.spi.PlatformBiome;
|
||||||
@@ -171,8 +169,10 @@ public class SchemaBuilderParityTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void structurePlacementSchemaIncludesFoundationSettingsAndOmitsUnsupportedTransforms() {
|
public void structurePlacementSchemaIncludesFoundationSettingsAndOmitsUnsupportedTransforms() {
|
||||||
JSONObject schema = new SchemaBuilder(IrisStructurePlacement.class, structureSchemaData()).construct();
|
JSONObject schema = new SchemaBuilder(IrisBiome.class, structureSchemaData()).construct();
|
||||||
JSONObject properties = schema.getJSONObject("properties");
|
JSONObject structures = rootProperties(schema).getJSONObject("structures");
|
||||||
|
JSONObject properties = schema.getJSONObject("definitions")
|
||||||
|
.getJSONObject(definitionKey(structures.getJSONObject("items"))).getJSONObject("properties");
|
||||||
JSONObject stilt = properties.getJSONObject("stilt");
|
JSONObject stilt = properties.getJSONObject("stilt");
|
||||||
JSONObject stiltDefinition = schema.getJSONObject("definitions")
|
JSONObject stiltDefinition = schema.getJSONObject("definitions")
|
||||||
.getJSONObject(stilt.getString("$ref").substring("#/definitions/".length()));
|
.getJSONObject(stilt.getString("$ref").substring("#/definitions/".length()));
|
||||||
@@ -206,7 +206,7 @@ public class SchemaBuilderParityTest {
|
|||||||
assertEquals(1D, lobeFrequency.getDouble("maximum"), 0D);
|
assertEquals(1D, lobeFrequency.getDouble("maximum"), 0D);
|
||||||
assertEquals(0D, lobeStrength.getDouble("minimum"), 0D);
|
assertEquals(0D, lobeStrength.getDouble("minimum"), 0D);
|
||||||
assertEquals(1D, lobeStrength.getDouble("maximum"), 0D);
|
assertEquals(1D, lobeStrength.getDouble("maximum"), 0D);
|
||||||
assertEquals("object", stilt.getString("type"));
|
assertEquals("module-art-arcane-iris-builtin-structure-structurestilts", definitionKey(stilt));
|
||||||
assertTrue(stiltProperties.has("palette"));
|
assertTrue(stiltProperties.has("palette"));
|
||||||
assertTrue(stiltProperties.has("supportNonOccluding"));
|
assertTrue(stiltProperties.has("supportNonOccluding"));
|
||||||
assertEquals(1, maxDepth.getInt("minimum"));
|
assertEquals(1, maxDepth.getInt("minimum"));
|
||||||
@@ -268,9 +268,13 @@ public class SchemaBuilderParityTest {
|
|||||||
IrisPlatforms.unbind();
|
IrisPlatforms.unbind();
|
||||||
IrisPlatforms.bind(new FakePlatform(hooks));
|
IrisPlatforms.bind(new FakePlatform(hooks));
|
||||||
|
|
||||||
JSONObject schema = new SchemaBuilder(IrisNativeStructure.class, structureSchemaData()).construct();
|
JSONObject schema = new SchemaBuilder(IrisDimension.class, structureSchemaData()).construct();
|
||||||
JSONObject definitions = schema.getJSONObject("definitions");
|
JSONObject definitions = schema.getJSONObject("definitions");
|
||||||
JSONObject jigsaw = definitions.getJSONObject(definitionKey(schema.getJSONObject("properties").getJSONObject("jigsaw")))
|
JSONObject placement = definitions.getJSONObject(definitionKey(rootProperties(schema).getJSONObject("structures")
|
||||||
|
.getJSONObject("items"))).getJSONObject("properties");
|
||||||
|
JSONObject source = definitions.getJSONObject(definitionKey(placement.getJSONObject("nativeStructures")
|
||||||
|
.getJSONObject("items"))).getJSONObject("properties");
|
||||||
|
JSONObject jigsaw = definitions.getJSONObject(definitionKey(source.getJSONObject("jigsaw")))
|
||||||
.getJSONObject("properties");
|
.getJSONObject("properties");
|
||||||
|
|
||||||
assertEquals("enum-native-jigsaw-pool", definitionKey(jigsaw.getJSONObject("startPool")));
|
assertEquals("enum-native-jigsaw-pool", definitionKey(jigsaw.getJSONObject("startPool")));
|
||||||
|
|||||||
@@ -1,71 +0,0 @@
|
|||||||
package art.arcane.iris.core.structure;
|
|
||||||
|
|
||||||
import art.arcane.volmlib.util.collection.KList;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.assertFalse;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
public class StructureSchemaKeysTest {
|
|
||||||
@Test
|
|
||||||
public void exposesOnlyExistingIrisStructureResources() {
|
|
||||||
KList<String> result = StructureSchemaKeys.collect(
|
|
||||||
Arrays.asList("minecraft_stronghold", "custom/cool_tower"),
|
|
||||||
Collections.emptyList());
|
|
||||||
|
|
||||||
assertEquals(Arrays.asList("custom/cool_tower", "minecraft_stronghold"), result);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void nativeRegistryKeysAreNotSynthesized() {
|
|
||||||
KList<String> result = StructureSchemaKeys.collect(
|
|
||||||
Collections.singletonList("custom/castle"),
|
|
||||||
Collections.emptyList());
|
|
||||||
|
|
||||||
assertFalse(result.contains("minecraft_stronghold"));
|
|
||||||
assertFalse(result.contains("minecraft:stronghold"));
|
|
||||||
assertTrue(result.contains("custom/castle"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void jigsawComponentPiecesAreExcluded() {
|
|
||||||
List<String> pieces = Arrays.asList(
|
|
||||||
"village/taiga/houses/taiga_small_house_5",
|
|
||||||
"trial_chambers/corridor/straight_1");
|
|
||||||
|
|
||||||
KList<String> result = StructureSchemaKeys.collect(
|
|
||||||
Arrays.asList("village/taiga/houses/taiga_small_house_5", "custom/castle"),
|
|
||||||
pieces);
|
|
||||||
|
|
||||||
assertFalse(result.contains("village/taiga/houses/taiga_small_house_5"));
|
|
||||||
assertTrue(result.contains("custom/castle"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void resultIsSortedAndDeduplicated() {
|
|
||||||
KList<String> result = StructureSchemaKeys.collect(
|
|
||||||
Arrays.asList("zeta", "alpha", "zeta"),
|
|
||||||
Collections.emptyList());
|
|
||||||
|
|
||||||
assertEquals(Arrays.asList("alpha", "zeta"), result);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void nullCollectionsAreHandled() {
|
|
||||||
assertTrue(StructureSchemaKeys.collect(null, null).isEmpty());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void blankAndNullEntriesAreIgnored() {
|
|
||||||
KList<String> result = StructureSchemaKeys.collect(
|
|
||||||
Arrays.asList("custom_one", "", null, " "),
|
|
||||||
Arrays.asList("", null));
|
|
||||||
|
|
||||||
assertEquals(Collections.singletonList("custom_one"), result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+102
-112
@@ -32,22 +32,27 @@ import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawConnector;
|
|||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPiece;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPiece;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPieceEntry;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPieceEntry;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPool;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPool;
|
||||||
import art.arcane.iris.engine.object.structure.vanilla.IrisNativeStructure;
|
import art.arcane.iris.builtin.structure.NativeStructureSource;
|
||||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||||
import art.arcane.iris.engine.object.value.IrisPosition;
|
import art.arcane.iris.engine.object.value.IrisPosition;
|
||||||
import art.arcane.iris.engine.object.world.region.IrisRegion;
|
import art.arcane.iris.engine.object.world.region.IrisRegion;
|
||||||
import art.arcane.iris.engine.object.structure.IrisStructure;
|
import art.arcane.iris.engine.object.structure.IrisStructure;
|
||||||
import art.arcane.iris.engine.object.structure.IrisStructureAnchorMode;
|
import art.arcane.iris.builtin.structure.StructureAnchorMode;
|
||||||
import art.arcane.iris.engine.object.structure.IrisStructurePlacement;
|
import art.arcane.iris.builtin.structure.StructurePlacement;
|
||||||
import art.arcane.iris.engine.object.structure.vanilla.NativeStructureSuppression;
|
import art.arcane.iris.builtin.structure.NativeStructureSuppression;
|
||||||
import art.arcane.iris.engine.object.structure.StructureDistribution;
|
import art.arcane.iris.builtin.structure.StructureDistribution;
|
||||||
import art.arcane.volmlib.util.collection.KList;
|
import art.arcane.volmlib.util.collection.KList;
|
||||||
import art.arcane.volmlib.util.math.RNG;
|
import art.arcane.volmlib.util.math.RNG;
|
||||||
import com.volmit.host.ModuleLogs;
|
import com.volmit.host.ModuleLogs;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import art.arcane.iris.engine.object.TestSettings;
|
||||||
|
|
||||||
|
import static art.arcane.iris.engine.framework.StructurePlacementFixtures.placement;
|
||||||
|
import static art.arcane.iris.engine.framework.StructurePlacementFixtures.nativeSource;
|
||||||
|
import static art.arcane.iris.engine.framework.StructurePlacementFixtures.declaring;
|
||||||
|
import static art.arcane.iris.engine.framework.StructurePlacementFixtures.withAdded;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
@@ -100,11 +105,11 @@ public class IrisStructureLocatorContractTest {
|
|||||||
@Test
|
@Test
|
||||||
public void locatablePlacementsExcludeEveryDistributionOutsideWorldHeight() {
|
public void locatablePlacementsExcludeEveryDistributionOutsideWorldHeight() {
|
||||||
Engine randomSpread = densityEngine(1.0, false, -64, 384, 400, 500);
|
Engine randomSpread = densityEngine(1.0, false, -64, 384, 400, 500);
|
||||||
randomSpread.getDimension().getStructures().get(0)
|
TestSettings.with(StructurePlacementScope.placementsOf(randomSpread.getDimension()).get(0),
|
||||||
.setDistribution(StructureDistribution.RANDOM_SPREAD);
|
"distribution", StructureDistribution.RANDOM_SPREAD);
|
||||||
Engine concentricRings = densityEngine(1.0, false, -64, 384, 400, 500);
|
Engine concentricRings = densityEngine(1.0, false, -64, 384, 400, 500);
|
||||||
concentricRings.getDimension().getStructures().get(0)
|
TestSettings.with(StructurePlacementScope.placementsOf(concentricRings.getDimension()).get(0),
|
||||||
.setDistribution(StructureDistribution.CONCENTRIC_RINGS);
|
"distribution", StructureDistribution.CONCENTRIC_RINGS);
|
||||||
|
|
||||||
assertFalse(IrisStructureLocator.hasLocatablePlacement(randomSpread, "test:density"));
|
assertFalse(IrisStructureLocator.hasLocatablePlacement(randomSpread, "test:density"));
|
||||||
assertFalse(IrisStructureLocator.hasLocatablePlacement(concentricRings, "test:density"));
|
assertFalse(IrisStructureLocator.hasLocatablePlacement(concentricRings, "test:density"));
|
||||||
@@ -118,13 +123,12 @@ public class IrisStructureLocatorContractTest {
|
|||||||
structure.setVanillaSource("source:city");
|
structure.setVanillaSource("source:city");
|
||||||
ModuleResourceFixture.of(data).resource(StructureResources.STRUCTURES, "test:city_definition", structure);
|
ModuleResourceFixture.of(data).resource(StructureResources.STRUCTURES, "test:city_definition", structure);
|
||||||
|
|
||||||
IrisStructurePlacement editable = new IrisStructurePlacement();
|
StructurePlacement editable = new StructurePlacement();
|
||||||
editable.getStructures().add("test:city_definition");
|
withAdded(editable, "structures", "test:city_definition");
|
||||||
IrisStructurePlacement nativePlacement = new IrisStructurePlacement();
|
StructurePlacement nativePlacement = new StructurePlacement();
|
||||||
nativePlacement.getNativeStructures().add(new IrisNativeStructure()
|
withAdded(nativePlacement, "nativeStructures", nativeSource("source:native_city"));
|
||||||
.setStructure("source:native_city"));
|
|
||||||
IrisDimension dimension = mock(IrisDimension.class);
|
IrisDimension dimension = mock(IrisDimension.class);
|
||||||
KList<IrisStructurePlacement> placements = new KList<>();
|
KList<StructurePlacement> placements = new KList<>();
|
||||||
placements.add(editable);
|
placements.add(editable);
|
||||||
placements.add(nativePlacement);
|
placements.add(nativePlacement);
|
||||||
Engine engine = mock(Engine.class);
|
Engine engine = mock(Engine.class);
|
||||||
@@ -133,7 +137,7 @@ public class IrisStructureLocatorContractTest {
|
|||||||
when(engine.getDimension()).thenReturn(dimension);
|
when(engine.getDimension()).thenReturn(dimension);
|
||||||
when(engine.getMinHeight()).thenReturn(-64);
|
when(engine.getMinHeight()).thenReturn(-64);
|
||||||
when(engine.getHeight()).thenReturn(384);
|
when(engine.getHeight()).thenReturn(384);
|
||||||
when(dimension.getStructures()).thenReturn(placements);
|
when(dimension.getModuleSettings()).thenReturn(declaring(placements));
|
||||||
when(dimension.getAllRegions(engine)).thenReturn(new KList<>());
|
when(dimension.getAllRegions(engine)).thenReturn(new KList<>());
|
||||||
when(dimension.getReachableBiomes(engine)).thenReturn(new KList<>());
|
when(dimension.getReachableBiomes(engine)).thenReturn(new KList<>());
|
||||||
|
|
||||||
@@ -159,15 +163,13 @@ public class IrisStructureLocatorContractTest {
|
|||||||
Engine engine = mock(Engine.class);
|
Engine engine = mock(Engine.class);
|
||||||
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
|
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
|
||||||
IrisDimension dimension = mock(IrisDimension.class);
|
IrisDimension dimension = mock(IrisDimension.class);
|
||||||
IrisStructurePlacement placement = new IrisStructurePlacement()
|
StructurePlacement placement = placement("nativeSuppression", NativeStructureSuppression.REPLACE_SOURCE);
|
||||||
.setNativeSuppression(NativeStructureSuppression.REPLACE_SOURCE);
|
withAdded(placement, "nativeStructures", nativeSource("minecraft:ancient_city"));
|
||||||
placement.getNativeStructures().add(new IrisNativeStructure()
|
KList<StructurePlacement> placements = new KList<>();
|
||||||
.setStructure("minecraft:ancient_city"));
|
|
||||||
KList<IrisStructurePlacement> placements = new KList<>();
|
|
||||||
placements.add(placement);
|
placements.add(placement);
|
||||||
when(engine.getData()).thenReturn(data);
|
when(engine.getData()).thenReturn(data);
|
||||||
when(engine.getDimension()).thenReturn(dimension);
|
when(engine.getDimension()).thenReturn(dimension);
|
||||||
when(dimension.getStructures()).thenReturn(placements);
|
when(dimension.getModuleSettings()).thenReturn(declaring(placements));
|
||||||
when(dimension.getAllRegions(engine)).thenReturn(new KList<>());
|
when(dimension.getAllRegions(engine)).thenReturn(new KList<>());
|
||||||
when(dimension.getReachableBiomes(engine)).thenReturn(new KList<>());
|
when(dimension.getReachableBiomes(engine)).thenReturn(new KList<>());
|
||||||
|
|
||||||
@@ -193,12 +195,12 @@ public class IrisStructureLocatorContractTest {
|
|||||||
ModuleResourceFixture.of(data).resource(StructureResources.STRUCTURES, "test:city", structure);
|
ModuleResourceFixture.of(data).resource(StructureResources.STRUCTURES, "test:city", structure);
|
||||||
registerSinglePieceGraph(data, structure, "test:city");
|
registerSinglePieceGraph(data, structure, "test:city");
|
||||||
|
|
||||||
IrisStructurePlacement placement = new IrisStructurePlacement();
|
StructurePlacement placement = new StructurePlacement();
|
||||||
placement.getStructures().add("test:city");
|
withAdded(placement, "structures", "test:city");
|
||||||
IrisDimension dimension = mock(IrisDimension.class);
|
IrisDimension dimension = mock(IrisDimension.class);
|
||||||
KList<IrisStructurePlacement> placements = new KList<>();
|
KList<StructurePlacement> placements = new KList<>();
|
||||||
placements.add(placement);
|
placements.add(placement);
|
||||||
when(dimension.getStructures()).thenReturn(placements);
|
when(dimension.getModuleSettings()).thenReturn(declaring(placements));
|
||||||
when(dimension.getAllRegions(any())).thenReturn(new KList<>());
|
when(dimension.getAllRegions(any())).thenReturn(new KList<>());
|
||||||
when(dimension.getReachableBiomes(any())).thenReturn(new KList<>());
|
when(dimension.getReachableBiomes(any())).thenReturn(new KList<>());
|
||||||
|
|
||||||
@@ -210,7 +212,7 @@ public class IrisStructureLocatorContractTest {
|
|||||||
|
|
||||||
assertTrue(IrisStructureLocator.isPlaced(engine, "minecraft:ancient_city"));
|
assertTrue(IrisStructureLocator.isPlaced(engine, "minecraft:ancient_city"));
|
||||||
assertFalse(IrisStructureLocator.suppressesVanilla(engine, "minecraft:ancient_city"));
|
assertFalse(IrisStructureLocator.suppressesVanilla(engine, "minecraft:ancient_city"));
|
||||||
placement.setNativeSuppression(NativeStructureSuppression.REPLACE_SOURCE);
|
TestSettings.with(placement, "nativeSuppression", NativeStructureSuppression.REPLACE_SOURCE);
|
||||||
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
|
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
|
||||||
assertTrue(IrisStructureLocator.suppressesVanilla(engine, "minecraft:ancient_city"));
|
assertTrue(IrisStructureLocator.suppressesVanilla(engine, "minecraft:ancient_city"));
|
||||||
}
|
}
|
||||||
@@ -224,13 +226,13 @@ public class IrisStructureLocatorContractTest {
|
|||||||
ModuleResourceFixture.of(data).resource(StructureResources.STRUCTURES, "test:city", structure);
|
ModuleResourceFixture.of(data).resource(StructureResources.STRUCTURES, "test:city", structure);
|
||||||
registerSinglePieceGraph(data, structure, "test:city");
|
registerSinglePieceGraph(data, structure, "test:city");
|
||||||
|
|
||||||
IrisStructurePlacement placement = new IrisStructurePlacement();
|
StructurePlacement placement = new StructurePlacement();
|
||||||
placement.getStructures().add("test:city");
|
withAdded(placement, "structures", "test:city");
|
||||||
placement.setNativeSuppression(NativeStructureSuppression.REPLACE_SOURCE);
|
TestSettings.with(placement, "nativeSuppression", NativeStructureSuppression.REPLACE_SOURCE);
|
||||||
IrisRegion region = mock(IrisRegion.class);
|
IrisRegion region = mock(IrisRegion.class);
|
||||||
when(region.getStructures()).thenReturn(new KList<IrisStructurePlacement>().qadd(placement));
|
when(region.getModuleSettings()).thenReturn(declaring(new KList<StructurePlacement>().qadd(placement)));
|
||||||
IrisDimension dimension = mock(IrisDimension.class);
|
IrisDimension dimension = mock(IrisDimension.class);
|
||||||
when(dimension.getStructures()).thenReturn(new KList<>());
|
when(dimension.getModuleSettings()).thenReturn(declaring(new KList<>()));
|
||||||
when(dimension.getAllRegions(any())).thenReturn(new KList<IrisRegion>().qadd(region));
|
when(dimension.getAllRegions(any())).thenReturn(new KList<IrisRegion>().qadd(region));
|
||||||
when(dimension.getReachableBiomes(any())).thenReturn(new KList<>());
|
when(dimension.getReachableBiomes(any())).thenReturn(new KList<>());
|
||||||
|
|
||||||
@@ -291,11 +293,10 @@ public class IrisStructureLocatorContractTest {
|
|||||||
when(data.load(IrisObject.class, "test:target-object", false)).thenReturn(targetObject);
|
when(data.load(IrisObject.class, "test:target-object", false)).thenReturn(targetObject);
|
||||||
assertFalse(StructureGraphCatalog.compile(data, structure, ModuleLogs.discarding()).isAssemblyViable());
|
assertFalse(StructureGraphCatalog.compile(data, structure, ModuleLogs.discarding()).isAssemblyViable());
|
||||||
|
|
||||||
IrisStructurePlacement placement = new IrisStructurePlacement()
|
StructurePlacement placement = placement("nativeSuppression", NativeStructureSuppression.REPLACE_SOURCE);
|
||||||
.setNativeSuppression(NativeStructureSuppression.REPLACE_SOURCE);
|
withAdded(placement, "structures", "test:city");
|
||||||
placement.getStructures().add("test:city");
|
|
||||||
IrisDimension dimension = mock(IrisDimension.class);
|
IrisDimension dimension = mock(IrisDimension.class);
|
||||||
when(dimension.getStructures()).thenReturn(new KList<IrisStructurePlacement>().qadd(placement));
|
when(dimension.getModuleSettings()).thenReturn(declaring(new KList<StructurePlacement>().qadd(placement)));
|
||||||
when(dimension.getAllRegions(any())).thenReturn(new KList<>());
|
when(dimension.getAllRegions(any())).thenReturn(new KList<>());
|
||||||
when(dimension.getReachableBiomes(any())).thenReturn(new KList<>());
|
when(dimension.getReachableBiomes(any())).thenReturn(new KList<>());
|
||||||
Engine engine = mock(Engine.class);
|
Engine engine = mock(Engine.class);
|
||||||
@@ -315,11 +316,10 @@ public class IrisStructureLocatorContractTest {
|
|||||||
structure.setLoadKey("test:city");
|
structure.setLoadKey("test:city");
|
||||||
ModuleResourceFixture.of(data).resource(StructureResources.STRUCTURES, "test:city", structure);
|
ModuleResourceFixture.of(data).resource(StructureResources.STRUCTURES, "test:city", structure);
|
||||||
registerSinglePieceGraph(data, structure, "test:city");
|
registerSinglePieceGraph(data, structure, "test:city");
|
||||||
IrisStructurePlacement placement = new IrisStructurePlacement()
|
StructurePlacement placement = placement("nativeSuppression", NativeStructureSuppression.REPLACE_SOURCE);
|
||||||
.setNativeSuppression(NativeStructureSuppression.REPLACE_SOURCE);
|
withAdded(placement, "structures", "test:city");
|
||||||
placement.getStructures().add("test:city");
|
|
||||||
IrisDimension dimension = mock(IrisDimension.class);
|
IrisDimension dimension = mock(IrisDimension.class);
|
||||||
when(dimension.getStructures()).thenReturn(new KList<IrisStructurePlacement>().qadd(placement));
|
when(dimension.getModuleSettings()).thenReturn(declaring(new KList<StructurePlacement>().qadd(placement)));
|
||||||
when(dimension.getAllRegions(any())).thenReturn(new KList<>());
|
when(dimension.getAllRegions(any())).thenReturn(new KList<>());
|
||||||
when(dimension.getReachableBiomes(any())).thenReturn(new KList<>());
|
when(dimension.getReachableBiomes(any())).thenReturn(new KList<>());
|
||||||
Engine engine = mock(Engine.class);
|
Engine engine = mock(Engine.class);
|
||||||
@@ -336,10 +336,10 @@ public class IrisStructureLocatorContractTest {
|
|||||||
public void missingNonReplacementStructureFailsInsteadOfBeingSkipped() {
|
public void missingNonReplacementStructureFailsInsteadOfBeingSkipped() {
|
||||||
IrisData data = mock(IrisData.class);
|
IrisData data = mock(IrisData.class);
|
||||||
ModuleResourceFixture.serve(data);
|
ModuleResourceFixture.serve(data);
|
||||||
IrisStructurePlacement placement = new IrisStructurePlacement();
|
StructurePlacement placement = new StructurePlacement();
|
||||||
placement.getStructures().add("test:missing");
|
withAdded(placement, "structures", "test:missing");
|
||||||
IrisDimension dimension = mock(IrisDimension.class);
|
IrisDimension dimension = mock(IrisDimension.class);
|
||||||
when(dimension.getStructures()).thenReturn(new KList<IrisStructurePlacement>().qadd(placement));
|
when(dimension.getModuleSettings()).thenReturn(declaring(new KList<StructurePlacement>().qadd(placement)));
|
||||||
when(dimension.getAllRegions(any())).thenReturn(new KList<>());
|
when(dimension.getAllRegions(any())).thenReturn(new KList<>());
|
||||||
when(dimension.getReachableBiomes(any())).thenReturn(new KList<>());
|
when(dimension.getReachableBiomes(any())).thenReturn(new KList<>());
|
||||||
Engine engine = mock(Engine.class);
|
Engine engine = mock(Engine.class);
|
||||||
@@ -355,15 +355,14 @@ public class IrisStructureLocatorContractTest {
|
|||||||
@Test
|
@Test
|
||||||
public void placementResolutionRejectsAnUnboundEngine() {
|
public void placementResolutionRejectsAnUnboundEngine() {
|
||||||
assertReplacementFailure(
|
assertReplacementFailure(
|
||||||
() -> IrisStructureLocator.resolvePlacement(null, new IrisStructurePlacement(), 0, 0),
|
() -> IrisStructureLocator.resolvePlacement(null, new StructurePlacement(), 0, 0),
|
||||||
"fully bound engine");
|
"fully bound engine");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void replacementOutputFailureIncludesStructureAndChunkContext() {
|
public void replacementOutputFailureIncludesStructureAndChunkContext() {
|
||||||
IrisStructurePlacement placement = new IrisStructurePlacement()
|
StructurePlacement placement = placement("nativeSuppression", NativeStructureSuppression.REPLACE_SOURCE);
|
||||||
.setNativeSuppression(NativeStructureSuppression.REPLACE_SOURCE);
|
withAdded(placement, "structures", "test:city");
|
||||||
placement.getStructures().add("test:city");
|
|
||||||
|
|
||||||
assertReplacementFailure(
|
assertReplacementFailure(
|
||||||
() -> IrisStructureLocator.requirePlacementOutput(
|
() -> IrisStructureLocator.requirePlacementOutput(
|
||||||
@@ -373,8 +372,8 @@ public class IrisStructureLocatorContractTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void nonReplacementOutputAbsenceRemainsSkippable() {
|
public void nonReplacementOutputAbsenceRemainsSkippable() {
|
||||||
IrisStructurePlacement placement = new IrisStructurePlacement();
|
StructurePlacement placement = new StructurePlacement();
|
||||||
placement.getStructures().add("test:city");
|
withAdded(placement, "structures", "test:city");
|
||||||
|
|
||||||
assertFalse(IrisStructureLocator.requirePlacementOutput(
|
assertFalse(IrisStructureLocator.requirePlacementOutput(
|
||||||
placement, "test:city", 12, -7, false, "runtime assembly produced no pieces"));
|
placement, "test:city", 12, -7, false, "runtime assembly produced no pieces"));
|
||||||
@@ -466,7 +465,7 @@ public class IrisStructureLocatorContractTest {
|
|||||||
Engine engine = densityEngine(1.0, false, -64, 384, -2032, 2032);
|
Engine engine = densityEngine(1.0, false, -64, 384, -2032, 2032);
|
||||||
when(engine.getHeight(anyInt(), anyInt(), eq(true))).thenReturn(128);
|
when(engine.getHeight(anyInt(), anyInt(), eq(true))).thenReturn(128);
|
||||||
when(engine.getDimension().getFluidHeight()).thenReturn(63);
|
when(engine.getDimension().getFluidHeight()).thenReturn(63);
|
||||||
IrisStructurePlacement placement = engine.getDimension().getStructures().get(0);
|
StructurePlacement placement = StructurePlacementScope.placementsOf(engine.getDimension()).get(0);
|
||||||
NearestScenario scenario = nearestEqualChunkDistanceScenario(engine, placement);
|
NearestScenario scenario = nearestEqualChunkDistanceScenario(engine, placement);
|
||||||
assertNotNull(scenario);
|
assertNotNull(scenario);
|
||||||
|
|
||||||
@@ -494,19 +493,19 @@ public class IrisStructureLocatorContractTest {
|
|||||||
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
|
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
|
||||||
when(engine.getMinHeight()).thenReturn(-64);
|
when(engine.getMinHeight()).thenReturn(-64);
|
||||||
when(engine.getHeight()).thenReturn(384);
|
when(engine.getHeight()).thenReturn(384);
|
||||||
IrisStructurePlacement placement = new IrisStructurePlacement();
|
StructurePlacement placement = new StructurePlacement();
|
||||||
placement.setDistribution(StructureDistribution.DENSITY);
|
TestSettings.with(placement, "distribution", StructureDistribution.DENSITY);
|
||||||
placement.setMinHeight(-32);
|
TestSettings.with(placement, "minHeight", -32);
|
||||||
placement.setMaxHeight(128);
|
TestSettings.with(placement, "maxHeight", 128);
|
||||||
|
|
||||||
placement.setDensity(Double.NaN);
|
TestSettings.with(placement, "density", Double.NaN);
|
||||||
assertFalse(IrisStructureLocator.isSearchableDensityPlacement(engine, placement));
|
assertFalse(IrisStructureLocator.isSearchableDensityPlacement(engine, placement));
|
||||||
placement.setDensity(0.0);
|
TestSettings.with(placement, "density", 0.0);
|
||||||
assertFalse(IrisStructureLocator.isSearchableDensityPlacement(engine, placement));
|
assertFalse(IrisStructureLocator.isSearchableDensityPlacement(engine, placement));
|
||||||
placement.setDensity(0.01);
|
TestSettings.with(placement, "density", 0.01);
|
||||||
assertTrue(IrisStructureLocator.isSearchableDensityPlacement(engine, placement));
|
assertTrue(IrisStructureLocator.isSearchableDensityPlacement(engine, placement));
|
||||||
placement.setMinHeight(400);
|
TestSettings.with(placement, "minHeight", 400);
|
||||||
placement.setMaxHeight(500);
|
TestSettings.with(placement, "maxHeight", 500);
|
||||||
assertFalse(IrisStructureLocator.isSearchableDensityPlacement(engine, placement));
|
assertFalse(IrisStructureLocator.isSearchableDensityPlacement(engine, placement));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -545,9 +544,9 @@ public class IrisStructureLocatorContractTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void selectedStructureKeyDoesNotMatchUnselectedPlacementMember() {
|
public void selectedStructureKeyDoesNotMatchUnselectedPlacementMember() {
|
||||||
IrisStructurePlacement placement = new IrisStructurePlacement();
|
StructurePlacement placement = new StructurePlacement();
|
||||||
placement.getStructures().add("test:first");
|
withAdded(placement, "structures", "test:first");
|
||||||
placement.getStructures().add("test:second");
|
withAdded(placement, "structures", "test:second");
|
||||||
RNG selectsLast = new RNG(1L) {
|
RNG selectsLast = new RNG(1L) {
|
||||||
@Override
|
@Override
|
||||||
public int nextInt(int bound) {
|
public int nextInt(int bound) {
|
||||||
@@ -569,10 +568,10 @@ public class IrisStructureLocatorContractTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void undergroundAssemblyIsShiftedToFitOrRejectedWhole() {
|
public void undergroundAssemblyIsShiftedToFitOrRejectedWhole() {
|
||||||
IrisStructurePlacement placement = new IrisStructurePlacement();
|
StructurePlacement placement = new StructurePlacement();
|
||||||
placement.setUnderground(true);
|
TestSettings.with(placement, "underground", true);
|
||||||
placement.setMinHeight(-10);
|
TestSettings.with(placement, "minHeight", -10);
|
||||||
placement.setMaxHeight(10);
|
TestSettings.with(placement, "maxHeight", 10);
|
||||||
|
|
||||||
KList<PlacedStructurePiece> movable = new KList<>();
|
KList<PlacedStructurePiece> movable = new KList<>();
|
||||||
movable.add(piece(-4, -10, -4, 4, 5, 4));
|
movable.add(piece(-4, -10, -4, 4, 5, 4));
|
||||||
@@ -582,7 +581,7 @@ public class IrisStructureLocatorContractTest {
|
|||||||
tooTall.add(piece(-4, -100, -4, 4, 400, 4));
|
tooTall.add(piece(-4, -100, -4, 4, 400, 4));
|
||||||
assertNull(IrisStructureLocator.resolveVerticalShift(tooTall, placement, 0, 0, 319));
|
assertNull(IrisStructureLocator.resolveVerticalShift(tooTall, placement, 0, 0, 319));
|
||||||
|
|
||||||
placement.setUnderground(false);
|
TestSettings.with(placement, "underground", false);
|
||||||
KList<PlacedStructurePiece> clippedSurface = new KList<>();
|
KList<PlacedStructurePiece> clippedSurface = new KList<>();
|
||||||
clippedSurface.add(piece(-4, 300, -4, 4, 330, 4));
|
clippedSurface.add(piece(-4, 300, -4, 4, 330, 4));
|
||||||
assertNull(IrisStructureLocator.resolveVerticalShift(clippedSurface, placement, 300, -64, 319));
|
assertNull(IrisStructureLocator.resolveVerticalShift(clippedSurface, placement, 300, -64, 319));
|
||||||
@@ -592,19 +591,19 @@ public class IrisStructureLocatorContractTest {
|
|||||||
public void caveAssemblyBoundsAlignToTheRequestedAnchorFace() {
|
public void caveAssemblyBoundsAlignToTheRequestedAnchorFace() {
|
||||||
KList<PlacedStructurePiece> pieces = new KList<>();
|
KList<PlacedStructurePiece> pieces = new KList<>();
|
||||||
pieces.add(piece(-2, 10, -2, 2, 14, 2));
|
pieces.add(piece(-2, 10, -2, 2, 14, 2));
|
||||||
IrisStructurePlacement placement = new IrisStructurePlacement();
|
StructurePlacement placement = new StructurePlacement();
|
||||||
|
|
||||||
placement.setAnchor(IrisStructureAnchorMode.CAVE_FLOOR);
|
TestSettings.with(placement, "anchor", StructureAnchorMode.CAVE_FLOOR);
|
||||||
KList<PlacedStructurePiece> floor = IrisStructureLocator.alignCavePieces(pieces, placement, 40);
|
KList<PlacedStructurePiece> floor = IrisStructureLocator.alignCavePieces(pieces, placement, 40);
|
||||||
assertEquals(40, floor.getFirst().getMinY());
|
assertEquals(40, floor.getFirst().getMinY());
|
||||||
assertEquals(44, floor.getFirst().getMaxY());
|
assertEquals(44, floor.getFirst().getMaxY());
|
||||||
|
|
||||||
placement.setAnchor(IrisStructureAnchorMode.CAVE_CEILING);
|
TestSettings.with(placement, "anchor", StructureAnchorMode.CAVE_CEILING);
|
||||||
KList<PlacedStructurePiece> ceiling = IrisStructureLocator.alignCavePieces(pieces, placement, 40);
|
KList<PlacedStructurePiece> ceiling = IrisStructureLocator.alignCavePieces(pieces, placement, 40);
|
||||||
assertEquals(36, ceiling.getFirst().getMinY());
|
assertEquals(36, ceiling.getFirst().getMinY());
|
||||||
assertEquals(40, ceiling.getFirst().getMaxY());
|
assertEquals(40, ceiling.getFirst().getMaxY());
|
||||||
|
|
||||||
placement.setAnchor(IrisStructureAnchorMode.CAVE_CENTER);
|
TestSettings.with(placement, "anchor", StructureAnchorMode.CAVE_CENTER);
|
||||||
KList<PlacedStructurePiece> center = IrisStructureLocator.alignCavePieces(pieces, placement, 40);
|
KList<PlacedStructurePiece> center = IrisStructureLocator.alignCavePieces(pieces, placement, 40);
|
||||||
assertEquals(38, center.getFirst().getMinY());
|
assertEquals(38, center.getFirst().getMinY());
|
||||||
assertEquals(42, center.getFirst().getMaxY());
|
assertEquals(42, center.getFirst().getMaxY());
|
||||||
@@ -616,19 +615,14 @@ public class IrisStructureLocatorContractTest {
|
|||||||
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
|
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
|
||||||
when(engine.getMinHeight()).thenReturn(-64);
|
when(engine.getMinHeight()).thenReturn(-64);
|
||||||
when(engine.getHeight()).thenReturn(384);
|
when(engine.getHeight()).thenReturn(384);
|
||||||
IrisStructurePlacement placement = new IrisStructurePlacement()
|
StructurePlacement placement = placement("distribution", StructureDistribution.DENSITY, "density", 1D, "anchor", StructureAnchorMode.CAVE_FLOOR, "minHeight", 319, "maxHeight", 319);
|
||||||
.setDistribution(StructureDistribution.DENSITY)
|
|
||||||
.setDensity(1D)
|
|
||||||
.setAnchor(IrisStructureAnchorMode.CAVE_FLOOR)
|
|
||||||
.setMinHeight(319)
|
|
||||||
.setMaxHeight(319);
|
|
||||||
|
|
||||||
assertFalse(IrisStructureLocator.isSearchableDensityPlacement(engine, placement));
|
assertFalse(IrisStructureLocator.isSearchableDensityPlacement(engine, placement));
|
||||||
placement.setMinHeight(318).setMaxHeight(318);
|
TestSettings.with(placement, "minHeight", 318, "maxHeight", 318);
|
||||||
assertTrue(IrisStructureLocator.isSearchableDensityPlacement(engine, placement));
|
assertTrue(IrisStructureLocator.isSearchableDensityPlacement(engine, placement));
|
||||||
|
|
||||||
when(engine.getHeight()).thenReturn(2);
|
when(engine.getHeight()).thenReturn(2);
|
||||||
placement.setMinHeight(-2032).setMaxHeight(2032);
|
TestSettings.with(placement, "minHeight", -2032, "maxHeight", 2032);
|
||||||
assertFalse(IrisStructureLocator.isSearchableDensityPlacement(engine, placement));
|
assertFalse(IrisStructureLocator.isSearchableDensityPlacement(engine, placement));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -639,18 +633,18 @@ public class IrisStructureLocatorContractTest {
|
|||||||
when(engine.getMinHeight()).thenReturn(-64);
|
when(engine.getMinHeight()).thenReturn(-64);
|
||||||
when(engine.getHeight(anyInt(), anyInt(), eq(true)))
|
when(engine.getHeight(anyInt(), anyInt(), eq(true)))
|
||||||
.thenAnswer(invocation -> invocation.<Integer>getArgument(0) == 1 ? 140 : 164);
|
.thenAnswer(invocation -> invocation.<Integer>getArgument(0) == 1 ? 140 : 164);
|
||||||
IrisStructurePlacement placement = new IrisStructurePlacement();
|
StructurePlacement placement = new StructurePlacement();
|
||||||
placement.setUnderground(true);
|
TestSettings.with(placement, "underground", true);
|
||||||
placement.setMinHeight(-64);
|
TestSettings.with(placement, "minHeight", -64);
|
||||||
placement.setMaxHeight(100);
|
TestSettings.with(placement, "maxHeight", 100);
|
||||||
KList<PlacedStructurePiece> pieces = new KList<>();
|
KList<PlacedStructurePiece> pieces = new KList<>();
|
||||||
pieces.add(piece(0, 60, 0, 1, 80, 0));
|
pieces.add(piece(0, 60, 0, 1, 80, 0));
|
||||||
|
|
||||||
assertEquals(Integer.valueOf(-5), IrisStructureLocator.resolveUndergroundBurialShift(
|
assertEquals(Integer.valueOf(-5), IrisStructureLocator.resolveUndergroundBurialShift(
|
||||||
engine, pieces, placement, 60, -63, 319));
|
engine, pieces, placement, 60, -63, 319));
|
||||||
|
|
||||||
placement.setMinHeight(60);
|
TestSettings.with(placement, "minHeight", 60);
|
||||||
placement.setMaxHeight(60);
|
TestSettings.with(placement, "maxHeight", 60);
|
||||||
assertNull(IrisStructureLocator.resolveUndergroundBurialShift(
|
assertNull(IrisStructureLocator.resolveUndergroundBurialShift(
|
||||||
engine, pieces, placement, 60, -63, 319));
|
engine, pieces, placement, 60, -63, 319));
|
||||||
}
|
}
|
||||||
@@ -661,26 +655,26 @@ public class IrisStructureLocatorContractTest {
|
|||||||
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
|
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
|
||||||
when(engine.getMinHeight()).thenReturn(-64);
|
when(engine.getMinHeight()).thenReturn(-64);
|
||||||
when(engine.getHeight(anyInt(), anyInt(), eq(true))).thenReturn(164);
|
when(engine.getHeight(anyInt(), anyInt(), eq(true))).thenReturn(164);
|
||||||
IrisStructurePlacement placement = new IrisStructurePlacement();
|
StructurePlacement placement = new StructurePlacement();
|
||||||
placement.setUnderground(true);
|
TestSettings.with(placement, "underground", true);
|
||||||
placement.setMinHeight(-64);
|
TestSettings.with(placement, "minHeight", -64);
|
||||||
placement.setMaxHeight(100);
|
TestSettings.with(placement, "maxHeight", 100);
|
||||||
placement.setTerrain(forceCarve("\"horizontalPadding\":2,\"ceilingPadding\":20,\"shape\":\"ERODED\""));
|
TestSettings.with(placement, "terrain", forceCarve("\"horizontalPadding\":2,\"ceilingPadding\":20,\"shape\":\"ERODED\""));
|
||||||
KList<PlacedStructurePiece> pieces = new KList<>();
|
KList<PlacedStructurePiece> pieces = new KList<>();
|
||||||
pieces.add(piece(0, 60, 0, 1, 80, 1));
|
pieces.add(piece(0, 60, 0, 1, 80, 1));
|
||||||
|
|
||||||
assertEquals(Integer.valueOf(-14), IrisStructureLocator.resolveUndergroundBurialShift(
|
assertEquals(Integer.valueOf(-14), IrisStructureLocator.resolveUndergroundBurialShift(
|
||||||
engine, pieces, placement, 60, -63, 319));
|
engine, pieces, placement, 60, -63, 319));
|
||||||
|
|
||||||
placement.setTerrain(forceCarve("\"horizontalPadding\":2,\"ceilingPadding\":20,\"shape\":\"ERODED\",\"erosionStrength\":0"));
|
TestSettings.with(placement, "terrain", forceCarve("\"horizontalPadding\":2,\"ceilingPadding\":20,\"shape\":\"ERODED\",\"erosionStrength\":0"));
|
||||||
assertEquals(Integer.valueOf(-1), IrisStructureLocator.resolveUndergroundBurialShift(
|
assertEquals(Integer.valueOf(-1), IrisStructureLocator.resolveUndergroundBurialShift(
|
||||||
engine, pieces, placement, 60, -63, 319));
|
engine, pieces, placement, 60, -63, 319));
|
||||||
|
|
||||||
placement.setTerrain(forceCarve("\"horizontalPadding\":2,\"ceilingPadding\":20,\"shape\":\"ROUNDED\",\"erosionStrength\":0"));
|
TestSettings.with(placement, "terrain", forceCarve("\"horizontalPadding\":2,\"ceilingPadding\":20,\"shape\":\"ROUNDED\",\"erosionStrength\":0"));
|
||||||
assertEquals(Integer.valueOf(-1), IrisStructureLocator.resolveUndergroundBurialShift(
|
assertEquals(Integer.valueOf(-1), IrisStructureLocator.resolveUndergroundBurialShift(
|
||||||
engine, pieces, placement, 60, -63, 319));
|
engine, pieces, placement, 60, -63, 319));
|
||||||
|
|
||||||
placement.setTerrain(forceCarve("\"horizontalPadding\":2,\"ceilingPadding\":0,\"shape\":\"ROUNDED\",\"erosionStrength\":0"));
|
TestSettings.with(placement, "terrain", forceCarve("\"horizontalPadding\":2,\"ceilingPadding\":0,\"shape\":\"ROUNDED\",\"erosionStrength\":0"));
|
||||||
assertEquals(Integer.valueOf(0), IrisStructureLocator.resolveUndergroundBurialShift(
|
assertEquals(Integer.valueOf(0), IrisStructureLocator.resolveUndergroundBurialShift(
|
||||||
engine, pieces, placement, 60, -63, 319));
|
engine, pieces, placement, 60, -63, 319));
|
||||||
}
|
}
|
||||||
@@ -691,11 +685,7 @@ public class IrisStructureLocatorContractTest {
|
|||||||
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
|
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
|
||||||
when(engine.getMinHeight()).thenReturn(-64);
|
when(engine.getMinHeight()).thenReturn(-64);
|
||||||
when(engine.getHeight(anyInt(), anyInt(), eq(true))).thenReturn(164);
|
when(engine.getHeight(anyInt(), anyInt(), eq(true))).thenReturn(164);
|
||||||
IrisStructurePlacement placement = new IrisStructurePlacement()
|
StructurePlacement placement = placement("underground", true, "minHeight", -64, "maxHeight", 100, "terrain", forceCarve("\"shape\":\"ROUNDED\",\"horizontalPadding\":0,\"ceilingPadding\":0"));
|
||||||
.setUnderground(true)
|
|
||||||
.setMinHeight(-64)
|
|
||||||
.setMaxHeight(100)
|
|
||||||
.setTerrain(forceCarve("\"shape\":\"ROUNDED\",\"horizontalPadding\":0,\"ceilingPadding\":0"));
|
|
||||||
KList<PlacedStructurePiece> pieces = new KList<>();
|
KList<PlacedStructurePiece> pieces = new KList<>();
|
||||||
pieces.add(piece(4, 60, 7, 4, 80, 7));
|
pieces.add(piece(4, 60, 7, 4, 80, 7));
|
||||||
|
|
||||||
@@ -706,7 +696,7 @@ public class IrisStructureLocatorContractTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void exactYOnlyCoversPlacementPathsWithResolvedAbsoluteAnchors() {
|
public void exactYOnlyCoversPlacementPathsWithResolvedAbsoluteAnchors() {
|
||||||
IrisStructurePlacement placement = new IrisStructurePlacement();
|
StructurePlacement placement = new StructurePlacement();
|
||||||
IrisStructure structure = new IrisStructure();
|
IrisStructure structure = new IrisStructure();
|
||||||
structure.setPlaceMode(ObjectPlaceMode.CENTER_HEIGHT);
|
structure.setPlaceMode(ObjectPlaceMode.CENTER_HEIGHT);
|
||||||
KList<PlacedStructurePiece> onePiece = new KList<>();
|
KList<PlacedStructurePiece> onePiece = new KList<>();
|
||||||
@@ -717,10 +707,10 @@ public class IrisStructureLocatorContractTest {
|
|||||||
assertTrue(IrisStructureLocator.hasExactY(placement, structure, onePiece));
|
assertTrue(IrisStructureLocator.hasExactY(placement, structure, onePiece));
|
||||||
|
|
||||||
structure.setPlaceMode(ObjectPlaceMode.CENTER_HEIGHT);
|
structure.setPlaceMode(ObjectPlaceMode.CENTER_HEIGHT);
|
||||||
placement.setUnderground(true);
|
TestSettings.with(placement, "underground", true);
|
||||||
assertTrue(IrisStructureLocator.hasExactY(placement, structure, onePiece));
|
assertTrue(IrisStructureLocator.hasExactY(placement, structure, onePiece));
|
||||||
|
|
||||||
placement.setUnderground(false);
|
TestSettings.with(placement, "underground", false);
|
||||||
KList<PlacedStructurePiece> multiplePieces = new KList<>(onePiece);
|
KList<PlacedStructurePiece> multiplePieces = new KList<>(onePiece);
|
||||||
multiplePieces.add(piece(5, 1, -4, 12, 20, 4));
|
multiplePieces.add(piece(5, 1, -4, 12, 20, 4));
|
||||||
assertTrue(IrisStructureLocator.hasExactY(placement, structure, multiplePieces));
|
assertTrue(IrisStructureLocator.hasExactY(placement, structure, multiplePieces));
|
||||||
@@ -743,7 +733,7 @@ public class IrisStructureLocatorContractTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private NearestScenario nearestEqualChunkDistanceScenario(
|
private NearestScenario nearestEqualChunkDistanceScenario(
|
||||||
Engine engine, IrisStructurePlacement placement) {
|
Engine engine, StructurePlacement placement) {
|
||||||
int[][] chunks = {
|
int[][] chunks = {
|
||||||
{-1, -1}, {-1, 0}, {-1, 1}, {0, -1},
|
{-1, -1}, {-1, 0}, {-1, 1}, {0, -1},
|
||||||
{0, 1}, {1, -1}, {1, 0}, {1, 1}
|
{0, 1}, {1, -1}, {1, 0}, {1, 1}
|
||||||
@@ -798,7 +788,7 @@ public class IrisStructureLocatorContractTest {
|
|||||||
IrisDimension dimension = mock(IrisDimension.class);
|
IrisDimension dimension = mock(IrisDimension.class);
|
||||||
when(engine.getData()).thenReturn(data);
|
when(engine.getData()).thenReturn(data);
|
||||||
when(engine.getDimension()).thenReturn(dimension);
|
when(engine.getDimension()).thenReturn(dimension);
|
||||||
when(dimension.getStructures()).thenReturn(new KList<>());
|
when(dimension.getModuleSettings()).thenReturn(declaring(new KList<>()));
|
||||||
when(dimension.getAllRegions(engine)).thenReturn(new KList<>());
|
when(dimension.getAllRegions(engine)).thenReturn(new KList<>());
|
||||||
when(dimension.getReachableBiomes(engine)).thenReturn(new KList<>());
|
when(dimension.getReachableBiomes(engine)).thenReturn(new KList<>());
|
||||||
return engine;
|
return engine;
|
||||||
@@ -812,26 +802,26 @@ public class IrisStructureLocatorContractTest {
|
|||||||
ModuleResourceFixture.of(data).resource(StructureResources.STRUCTURES, "test:density", structure);
|
ModuleResourceFixture.of(data).resource(StructureResources.STRUCTURES, "test:density", structure);
|
||||||
registerSinglePieceGraph(data, structure, "test:density");
|
registerSinglePieceGraph(data, structure, "test:density");
|
||||||
|
|
||||||
IrisStructurePlacement placement = new IrisStructurePlacement();
|
StructurePlacement placement = new StructurePlacement();
|
||||||
placement.getStructures().add("test:density");
|
withAdded(placement, "structures", "test:density");
|
||||||
placement.setDistribution(StructureDistribution.DENSITY);
|
TestSettings.with(placement, "distribution", StructureDistribution.DENSITY);
|
||||||
placement.setDensity(density);
|
TestSettings.with(placement, "density", density);
|
||||||
placement.setUnderground(underground);
|
TestSettings.with(placement, "underground", underground);
|
||||||
placement.setMinHeight(placementMin);
|
TestSettings.with(placement, "minHeight", placementMin);
|
||||||
placement.setMaxHeight(placementMax);
|
TestSettings.with(placement, "maxHeight", placementMax);
|
||||||
|
|
||||||
Engine engine = mock(Engine.class);
|
Engine engine = mock(Engine.class);
|
||||||
|
|
||||||
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
|
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
|
||||||
IrisDimension dimension = mock(IrisDimension.class);
|
IrisDimension dimension = mock(IrisDimension.class);
|
||||||
KList<IrisStructurePlacement> placements = new KList<>();
|
KList<StructurePlacement> placements = new KList<>();
|
||||||
placements.add(placement);
|
placements.add(placement);
|
||||||
when(engine.getData()).thenReturn(data);
|
when(engine.getData()).thenReturn(data);
|
||||||
when(engine.getDimension()).thenReturn(dimension);
|
when(engine.getDimension()).thenReturn(dimension);
|
||||||
when(engine.getSeedManager()).thenReturn(new SeedManager(77L));
|
when(engine.getSeedManager()).thenReturn(new SeedManager(77L));
|
||||||
when(engine.getMinHeight()).thenReturn(worldMin);
|
when(engine.getMinHeight()).thenReturn(worldMin);
|
||||||
when(engine.getHeight()).thenReturn(worldHeight);
|
when(engine.getHeight()).thenReturn(worldHeight);
|
||||||
when(dimension.getStructures()).thenReturn(placements);
|
when(dimension.getModuleSettings()).thenReturn(declaring(placements));
|
||||||
when(dimension.getAllRegions(engine)).thenReturn(new KList<>());
|
when(dimension.getAllRegions(engine)).thenReturn(new KList<>());
|
||||||
when(dimension.getReachableBiomes(engine)).thenReturn(new KList<>());
|
when(dimension.getReachableBiomes(engine)).thenReturn(new KList<>());
|
||||||
return engine;
|
return engine;
|
||||||
|
|||||||
+33
-51
@@ -2,14 +2,18 @@ package art.arcane.iris.engine.framework;
|
|||||||
|
|
||||||
import art.arcane.iris.core.loader.IrisData;
|
import art.arcane.iris.core.loader.IrisData;
|
||||||
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
||||||
import art.arcane.iris.engine.object.structure.vanilla.IrisNativeStructure;
|
import art.arcane.iris.builtin.structure.NativeStructureSource;
|
||||||
import art.arcane.iris.engine.object.structure.IrisStructurePlacement;
|
import art.arcane.iris.builtin.structure.StructurePlacement;
|
||||||
import art.arcane.iris.engine.object.structure.StructureDistribution;
|
import art.arcane.iris.builtin.structure.StructureDistribution;
|
||||||
import art.arcane.volmlib.util.collection.KList;
|
import art.arcane.volmlib.util.collection.KList;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
|
import static art.arcane.iris.engine.framework.StructurePlacementFixtures.placement;
|
||||||
|
import static art.arcane.iris.engine.framework.StructurePlacementFixtures.nativeSource;
|
||||||
|
import static art.arcane.iris.engine.framework.StructurePlacementFixtures.declaring;
|
||||||
|
import static art.arcane.iris.engine.framework.StructurePlacementFixtures.withAdded;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
@@ -23,11 +27,11 @@ public class IrisStructurePlacementRingLocatorTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void zeroVanillaRingSearchesTheOriginPlacementCell() {
|
public void zeroVanillaRingSearchesTheOriginPlacementCell() {
|
||||||
IrisStructurePlacement placement = randomPlacement("origin-cell", 24, 6);
|
StructurePlacement placement = randomPlacement("origin-cell", 24, 6);
|
||||||
Engine engine = engine(placement);
|
Engine engine = engine(placement);
|
||||||
long seed = engine.getSeedManager().getMantle();
|
long seed = engine.getSeedManager().getMantle();
|
||||||
int[] expected = StructurePlacementGrid.randomSpreadCellChunk(
|
int[] expected = StructurePlacementGrid.randomSpreadCellChunk(
|
||||||
0, 0, placement.getSpacing(), placement.getSeparation(),
|
0, 0, placement.spacing(), placement.separation(),
|
||||||
StructurePlacementGrid.placementSalt(placement), seed);
|
StructurePlacementGrid.placementSalt(placement), seed);
|
||||||
assertTrue(expected[0] != 0 || expected[1] != 0);
|
assertTrue(expected[0] != 0 || expected[1] != 0);
|
||||||
|
|
||||||
@@ -45,8 +49,8 @@ public class IrisStructurePlacementRingLocatorTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void mixedSpacingPlacementsShareTheSameVanillaRingIndex() {
|
public void mixedSpacingPlacementsShareTheSameVanillaRingIndex() {
|
||||||
IrisStructurePlacement small = randomPlacement("small-grid", 8, 2);
|
StructurePlacement small = randomPlacement("small-grid", 8, 2);
|
||||||
IrisStructurePlacement large = randomPlacement("large-grid", 40, 10);
|
StructurePlacement large = randomPlacement("large-grid", 40, 10);
|
||||||
Engine engine = engine(small, large);
|
Engine engine = engine(small, large);
|
||||||
long seed = engine.getSeedManager().getMantle();
|
long seed = engine.getSeedManager().getMantle();
|
||||||
int[] smallRingZero = candidate(small, seed, 0, 0);
|
int[] smallRingZero = candidate(small, seed, 0, 0);
|
||||||
@@ -74,14 +78,9 @@ public class IrisStructurePlacementRingLocatorTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void concentricPlacementsIgnoreTheRandomSpreadRingRadius() {
|
public void concentricPlacementsIgnoreTheRandomSpreadRingRadius() {
|
||||||
IrisStructurePlacement placement = new IrisStructurePlacement()
|
StructurePlacement placement = placement("placementId", "concentric", "distribution", StructureDistribution.CONCENTRIC_RINGS, "ringCount", 1, "ringDistance", 32, "ringSpread", 1);
|
||||||
.setPlacementId("concentric")
|
withAdded(placement, "nativeStructures",
|
||||||
.setDistribution(StructureDistribution.CONCENTRIC_RINGS)
|
nativeSource(STRUCTURE_KEY));
|
||||||
.setRingCount(1)
|
|
||||||
.setRingDistance(32)
|
|
||||||
.setRingSpread(1);
|
|
||||||
placement.getNativeStructures().add(
|
|
||||||
new IrisNativeStructure().setStructure(STRUCTURE_KEY));
|
|
||||||
Engine engine = engine(placement);
|
Engine engine = engine(placement);
|
||||||
|
|
||||||
IrisStructureLocator.LocateResult result =
|
IrisStructureLocator.LocateResult result =
|
||||||
@@ -96,12 +95,9 @@ public class IrisStructurePlacementRingLocatorTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void sparseDensityPlacementRingSearchStopsAtTheCandidateBudget() {
|
public void sparseDensityPlacementRingSearchStopsAtTheCandidateBudget() {
|
||||||
IrisStructurePlacement placement = new IrisStructurePlacement()
|
StructurePlacement placement = placement("placementId", "density", "distribution", StructureDistribution.DENSITY, "density", 1.0);
|
||||||
.setPlacementId("density")
|
withAdded(placement, "nativeStructures",
|
||||||
.setDistribution(StructureDistribution.DENSITY)
|
nativeSource(STRUCTURE_KEY));
|
||||||
.setDensity(1.0);
|
|
||||||
placement.getNativeStructures().add(
|
|
||||||
new IrisNativeStructure().setStructure(STRUCTURE_KEY));
|
|
||||||
Engine engine = engine(placement);
|
Engine engine = engine(placement);
|
||||||
|
|
||||||
IrisStructureLocator.LocateResult result =
|
IrisStructureLocator.LocateResult result =
|
||||||
@@ -114,14 +110,9 @@ public class IrisStructurePlacementRingLocatorTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void concentricPlacementRingSearchStopsAtTheSharedCandidateBudget() {
|
public void concentricPlacementRingSearchStopsAtTheSharedCandidateBudget() {
|
||||||
IrisStructurePlacement placement = new IrisStructurePlacement()
|
StructurePlacement placement = placement("placementId", "unbounded-concentric-rings", "distribution", StructureDistribution.CONCENTRIC_RINGS, "ringCount", Integer.MAX_VALUE, "ringDistance", 32, "ringSpread", 1);
|
||||||
.setPlacementId("unbounded-concentric-rings")
|
withAdded(placement, "nativeStructures",
|
||||||
.setDistribution(StructureDistribution.CONCENTRIC_RINGS)
|
nativeSource(STRUCTURE_KEY));
|
||||||
.setRingCount(Integer.MAX_VALUE)
|
|
||||||
.setRingDistance(32)
|
|
||||||
.setRingSpread(1);
|
|
||||||
placement.getNativeStructures().add(
|
|
||||||
new IrisNativeStructure().setStructure(STRUCTURE_KEY));
|
|
||||||
Engine engine = engine(placement);
|
Engine engine = engine(placement);
|
||||||
|
|
||||||
IrisStructureLocator.LocateResult result = IrisStructureLocator.locateInPlacementRings(
|
IrisStructureLocator.LocateResult result = IrisStructureLocator.locateInPlacementRings(
|
||||||
@@ -132,14 +123,9 @@ public class IrisStructurePlacementRingLocatorTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void concentricChunkRadiusSearchStopsAtTheSharedCandidateBudget() {
|
public void concentricChunkRadiusSearchStopsAtTheSharedCandidateBudget() {
|
||||||
IrisStructurePlacement placement = new IrisStructurePlacement()
|
StructurePlacement placement = placement("placementId", "unbounded-concentric-chunks", "distribution", StructureDistribution.CONCENTRIC_RINGS, "ringCount", Integer.MAX_VALUE, "ringDistance", 32, "ringSpread", 1);
|
||||||
.setPlacementId("unbounded-concentric-chunks")
|
withAdded(placement, "nativeStructures",
|
||||||
.setDistribution(StructureDistribution.CONCENTRIC_RINGS)
|
nativeSource(STRUCTURE_KEY));
|
||||||
.setRingCount(Integer.MAX_VALUE)
|
|
||||||
.setRingDistance(32)
|
|
||||||
.setRingSpread(1);
|
|
||||||
placement.getNativeStructures().add(
|
|
||||||
new IrisNativeStructure().setStructure(STRUCTURE_KEY));
|
|
||||||
Engine engine = engine(placement);
|
Engine engine = engine(placement);
|
||||||
|
|
||||||
IrisStructureLocator.LocateResult result = IrisStructureLocator.locate(
|
IrisStructureLocator.LocateResult result = IrisStructureLocator.locate(
|
||||||
@@ -149,31 +135,27 @@ public class IrisStructurePlacementRingLocatorTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static int[] candidate(
|
private static int[] candidate(
|
||||||
IrisStructurePlacement placement, long seed, int cellX, int cellZ) {
|
StructurePlacement placement, long seed, int cellX, int cellZ) {
|
||||||
return StructurePlacementGrid.randomSpreadCellChunk(
|
return StructurePlacementGrid.randomSpreadCellChunk(
|
||||||
cellX, cellZ, placement.getSpacing(), placement.getSeparation(),
|
cellX, cellZ, placement.spacing(), placement.separation(),
|
||||||
StructurePlacementGrid.placementSalt(placement), seed);
|
StructurePlacementGrid.placementSalt(placement), seed);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IrisStructurePlacement randomPlacement(
|
private static StructurePlacement randomPlacement(
|
||||||
String placementId, int spacing, int separation) {
|
String placementId, int spacing, int separation) {
|
||||||
IrisStructurePlacement placement = new IrisStructurePlacement()
|
StructurePlacement placement = placement("placementId", placementId, "distribution", StructureDistribution.RANDOM_SPREAD, "spacing", spacing, "separation", separation);
|
||||||
.setPlacementId(placementId)
|
withAdded(placement, "nativeStructures",
|
||||||
.setDistribution(StructureDistribution.RANDOM_SPREAD)
|
nativeSource(STRUCTURE_KEY));
|
||||||
.setSpacing(spacing)
|
|
||||||
.setSeparation(separation);
|
|
||||||
placement.getNativeStructures().add(
|
|
||||||
new IrisNativeStructure().setStructure(STRUCTURE_KEY));
|
|
||||||
return placement;
|
return placement;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Engine engine(IrisStructurePlacement... placements) {
|
private static Engine engine(StructurePlacement... placements) {
|
||||||
IrisData data = mock(IrisData.class);
|
IrisData data = mock(IrisData.class);
|
||||||
IrisDimension dimension = mock(IrisDimension.class);
|
IrisDimension dimension = mock(IrisDimension.class);
|
||||||
Engine engine = mock(Engine.class);
|
Engine engine = mock(Engine.class);
|
||||||
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
|
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
|
||||||
KList<IrisStructurePlacement> configured = new KList<>();
|
KList<StructurePlacement> configured = new KList<>();
|
||||||
for (IrisStructurePlacement placement : placements) {
|
for (StructurePlacement placement : placements) {
|
||||||
configured.add(placement);
|
configured.add(placement);
|
||||||
}
|
}
|
||||||
when(engine.getData()).thenReturn(data);
|
when(engine.getData()).thenReturn(data);
|
||||||
@@ -184,7 +166,7 @@ public class IrisStructurePlacementRingLocatorTest {
|
|||||||
when(engine.getHeight()).thenReturn(384);
|
when(engine.getHeight()).thenReturn(384);
|
||||||
when(engine.getHeight(anyInt(), anyInt(), anyBoolean())).thenReturn(128);
|
when(engine.getHeight(anyInt(), anyInt(), anyBoolean())).thenReturn(128);
|
||||||
when(dimension.getFluidHeight()).thenReturn(63);
|
when(dimension.getFluidHeight()).thenReturn(63);
|
||||||
when(dimension.getStructures()).thenReturn(configured);
|
when(dimension.getModuleSettings()).thenReturn(declaring(configured));
|
||||||
when(dimension.getAllRegions(engine)).thenReturn(new KList<>());
|
when(dimension.getAllRegions(engine)).thenReturn(new KList<>());
|
||||||
when(dimension.getReachableBiomes(engine)).thenReturn(new KList<>());
|
when(dimension.getReachableBiomes(engine)).thenReturn(new KList<>());
|
||||||
return engine;
|
return engine;
|
||||||
|
|||||||
+18
-17
@@ -4,13 +4,12 @@ import art.arcane.iris.core.loader.IrisData;
|
|||||||
import art.arcane.iris.builtin.structure.StructureAdjustment;
|
import art.arcane.iris.builtin.structure.StructureAdjustment;
|
||||||
import art.arcane.iris.builtin.structure.StructureSettings;
|
import art.arcane.iris.builtin.structure.StructureSettings;
|
||||||
import art.arcane.iris.core.modules.BuiltInPack;
|
import art.arcane.iris.core.modules.BuiltInPack;
|
||||||
import art.arcane.iris.core.modules.ModuleSettings;
|
|
||||||
import art.arcane.iris.core.modules.IrisPackResources;
|
import art.arcane.iris.core.modules.IrisPackResources;
|
||||||
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
||||||
import art.arcane.iris.engine.object.structure.vanilla.IrisNativeStructure;
|
import art.arcane.iris.builtin.structure.NativeStructureSource;
|
||||||
import art.arcane.iris.engine.object.world.region.IrisRegion;
|
import art.arcane.iris.engine.object.world.region.IrisRegion;
|
||||||
import art.arcane.iris.engine.object.structure.IrisStructurePlacement;
|
import art.arcane.iris.builtin.structure.StructurePlacement;
|
||||||
import art.arcane.iris.engine.object.structure.vanilla.NativeStructureSuppression;
|
import art.arcane.iris.builtin.structure.NativeStructureSuppression;
|
||||||
import art.arcane.volmlib.util.collection.KList;
|
import art.arcane.volmlib.util.collection.KList;
|
||||||
import com.volmit.FeatureRegistry;
|
import com.volmit.FeatureRegistry;
|
||||||
import com.volmit.IrisModule;
|
import com.volmit.IrisModule;
|
||||||
@@ -38,6 +37,10 @@ import java.util.List;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
|
import static art.arcane.iris.engine.framework.StructurePlacementFixtures.nativeSource;
|
||||||
|
import static art.arcane.iris.engine.framework.StructurePlacementFixtures.placementSettings;
|
||||||
|
import static art.arcane.iris.engine.framework.StructurePlacementFixtures.declaring;
|
||||||
|
import static art.arcane.iris.engine.framework.StructurePlacementFixtures.withAdded;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertThrows;
|
import static org.junit.Assert.assertThrows;
|
||||||
@@ -106,9 +109,9 @@ public class NativeStructureGenerationPolicyTest {
|
|||||||
/** Suppression comes from the iris:structure module's rule. */
|
/** Suppression comes from the iris:structure module's rule. */
|
||||||
@Test
|
@Test
|
||||||
public void aStructureAnIrisPlacementReplacesIsBlockedByTheStructureModule() throws IOException {
|
public void aStructureAnIrisPlacementReplacesIsBlockedByTheStructureModule() throws IOException {
|
||||||
IrisStructurePlacement replacement = new IrisStructurePlacement().setNativeSuppression(NativeStructureSuppression.REPLACE_SOURCE);
|
StructurePlacement replacement = StructurePlacementFixtures.placement("nativeSuppression", NativeStructureSuppression.REPLACE_SOURCE);
|
||||||
replacement.getNativeStructures().add(new IrisNativeStructure().setStructure("minecraft:village_plains"));
|
withAdded(replacement, "nativeStructures", nativeSource("minecraft:village_plains"));
|
||||||
KList<IrisStructurePlacement> dimensionPlacements = new KList<>();
|
KList<StructurePlacement> dimensionPlacements = new KList<>();
|
||||||
dimensionPlacements.add(replacement);
|
dimensionPlacements.add(replacement);
|
||||||
Engine engine = engine(allowingEverything(), new KList<>(), dimensionPlacements, List.of());
|
Engine engine = engine(allowingEverything(), new KList<>(), dimensionPlacements, List.of());
|
||||||
|
|
||||||
@@ -223,32 +226,30 @@ public class NativeStructureGenerationPolicyTest {
|
|||||||
return new StructureSettings();
|
return new StructureSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static KList<IrisStructurePlacement> regionPlacement(String placedKey) {
|
private static KList<StructurePlacement> regionPlacement(String placedKey) {
|
||||||
IrisStructurePlacement placement = new IrisStructurePlacement();
|
StructurePlacement placement = new StructurePlacement();
|
||||||
placement.getNativeStructures().add(new IrisNativeStructure().setStructure(placedKey));
|
withAdded(placement, "nativeStructures", nativeSource(placedKey));
|
||||||
KList<IrisStructurePlacement> placements = new KList<>();
|
KList<StructurePlacement> placements = new KList<>();
|
||||||
placements.add(placement);
|
placements.add(placement);
|
||||||
return placements;
|
return placements;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** An engine whose pack serves Iris's built-in modules and {@code packModules}, with the given structure placements. */
|
/** An engine whose pack serves Iris's built-in modules and {@code packModules}, with the given structure placements. */
|
||||||
private Engine engine(StructureSettings settings, KList<IrisStructurePlacement> regionPlacements,
|
private Engine engine(StructureSettings settings, KList<StructurePlacement> regionPlacements,
|
||||||
KList<IrisStructurePlacement> dimensionPlacements, List<IrisModule> packModules) throws IOException {
|
KList<StructurePlacement> dimensionPlacements, List<IrisModule> packModules) throws IOException {
|
||||||
IrisData data = mock(IrisData.class);
|
IrisData data = mock(IrisData.class);
|
||||||
Engine engine = mock(Engine.class);
|
Engine engine = mock(Engine.class);
|
||||||
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
|
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
|
||||||
IrisDimension dimension = mock(IrisDimension.class);
|
IrisDimension dimension = mock(IrisDimension.class);
|
||||||
IrisRegion region = mock(IrisRegion.class);
|
IrisRegion region = mock(IrisRegion.class);
|
||||||
when(region.getStructures()).thenReturn(regionPlacements);
|
when(region.getModuleSettings()).thenReturn(declaring(regionPlacements));
|
||||||
when(region.getModuleSettings()).thenReturn(ModuleSettings.NONE);
|
|
||||||
KList<IrisRegion> regions = new KList<>();
|
KList<IrisRegion> regions = new KList<>();
|
||||||
regions.add(region);
|
regions.add(region);
|
||||||
|
|
||||||
packs.add(BuiltInPack.serveWithResources(data, folder, packModules));
|
packs.add(BuiltInPack.serveWithResources(data, folder, packModules));
|
||||||
when(engine.getData()).thenReturn(data);
|
when(engine.getData()).thenReturn(data);
|
||||||
when(engine.getDimension()).thenReturn(dimension);
|
when(engine.getDimension()).thenReturn(dimension);
|
||||||
when(dimension.getModuleSettings()).thenReturn(BuiltInPack.settings(settings));
|
when(dimension.getModuleSettings()).thenReturn(BuiltInPack.settings(settings, placementSettings(dimensionPlacements)));
|
||||||
when(dimension.getStructures()).thenReturn(dimensionPlacements);
|
|
||||||
when(dimension.getAllRegions(engine)).thenReturn(regions);
|
when(dimension.getAllRegions(engine)).thenReturn(regions);
|
||||||
when(dimension.getReachableBiomes(engine)).thenReturn(new KList<>());
|
when(dimension.getReachableBiomes(engine)).thenReturn(new KList<>());
|
||||||
return engine;
|
return engine;
|
||||||
|
|||||||
+22
-22
@@ -2,12 +2,12 @@ package art.arcane.iris.engine.framework;
|
|||||||
|
|
||||||
import art.arcane.iris.core.loader.IrisData;
|
import art.arcane.iris.core.loader.IrisData;
|
||||||
import art.arcane.iris.core.modules.BuiltInPack;
|
import art.arcane.iris.core.modules.BuiltInPack;
|
||||||
import art.arcane.iris.core.modules.ModuleSettings;
|
|
||||||
import art.arcane.iris.builtin.structure.StructureStilts;
|
import art.arcane.iris.builtin.structure.StructureStilts;
|
||||||
import art.arcane.iris.builtin.structure.StructureTerrain;
|
import art.arcane.iris.builtin.structure.StructureTerrain;
|
||||||
import art.arcane.iris.engine.object.structure.IrisStructurePlacement;
|
import art.arcane.iris.builtin.structure.StructurePlacement;
|
||||||
import art.arcane.iris.engine.object.structure.StructureDistribution;
|
import art.arcane.iris.builtin.structure.StructureDistribution;
|
||||||
import art.arcane.iris.engine.object.structure.vanilla.IrisNativeStructure;
|
import art.arcane.iris.builtin.structure.NativeStructureSource;
|
||||||
|
import art.arcane.iris.engine.object.TestSettings;
|
||||||
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
||||||
import art.arcane.volmlib.util.collection.KList;
|
import art.arcane.volmlib.util.collection.KList;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
@@ -22,6 +22,9 @@ import java.io.IOException;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static art.arcane.iris.engine.framework.StructurePlacementFixtures.nativeSource;
|
||||||
|
import static art.arcane.iris.engine.framework.StructurePlacementFixtures.declaring;
|
||||||
|
import static art.arcane.iris.engine.framework.StructurePlacementFixtures.withAdded;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.Assert.assertNull;
|
||||||
import static org.mockito.ArgumentMatchers.anyInt;
|
import static org.mockito.ArgumentMatchers.anyInt;
|
||||||
@@ -107,7 +110,7 @@ public class NativeStructureStartsTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void startsMatchThePlannersForAFixedSeed() throws IOException {
|
public void startsMatchThePlannersForAFixedSeed() throws IOException {
|
||||||
KList<IrisStructurePlacement> placements = new KList<>();
|
KList<StructurePlacement> placements = new KList<>();
|
||||||
placements.add(placement("villages", false, -64, 320, 0.2D, source("minecraft:village_plains", 3),
|
placements.add(placement("villages", false, -64, 320, 0.2D, source("minecraft:village_plains", 3),
|
||||||
source("minecraft:pillager_outpost", 1)));
|
source("minecraft:pillager_outpost", 1)));
|
||||||
placements.add(placement("cities", true, -50, -10, 0.15D, source("minecraft:ancient_city", 1)));
|
placements.add(placement("cities", true, -50, -10, 0.15D, source("minecraft:ancient_city", 1)));
|
||||||
@@ -136,9 +139,9 @@ public class NativeStructureStartsTest {
|
|||||||
+ "\"palette\":{\"palette\":[{\"block\":\"minecraft:stone_bricks\"}]}}", StructureStilts.class);
|
+ "\"palette\":{\"palette\":[{\"block\":\"minecraft:stone_bricks\"}]}}", StructureStilts.class);
|
||||||
JigsawOverrides jigsaw = JigsawOverrides.none().withStartPool("minecraft:village/plains/town_centers")
|
JigsawOverrides jigsaw = JigsawOverrides.none().withStartPool("minecraft:village/plains/town_centers")
|
||||||
.withMaxDepth(5).withHeightmap(JigsawOverrides.Heightmap.OCEAN_FLOOR_WG).withExpansionHack(false);
|
.withMaxDepth(5).withHeightmap(JigsawOverrides.Heightmap.OCEAN_FLOOR_WG).withExpansionHack(false);
|
||||||
IrisStructurePlacement fitted = placement("fitted", true, -40, -20, 1D, source("minecraft:ancient_city", 1)
|
StructurePlacement fitted = TestSettings.with(placement("fitted", true, -40, -20, 1D,
|
||||||
.setJigsaw(jigsaw)).setTerrain(terrain).setStilt(stilt);
|
TestSettings.with(source("minecraft:ancient_city", 1), "jigsaw", jigsaw)), "terrain", terrain, "stilt", stilt);
|
||||||
KList<IrisStructurePlacement> placements = new KList<>();
|
KList<StructurePlacement> placements = new KList<>();
|
||||||
placements.add(fitted);
|
placements.add(fitted);
|
||||||
Engine engine = engine(placements);
|
Engine engine = engine(placements);
|
||||||
|
|
||||||
@@ -151,28 +154,26 @@ public class NativeStructureStartsTest {
|
|||||||
assertNull(NativeStructureStarts.matchingPlan(engine, "minecraft:stronghold", 0, 0));
|
assertNull(NativeStructureStarts.matchingPlan(engine, "minecraft:stronghold", 0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IrisNativeStructure source(String structure, int weight) {
|
private static NativeStructureSource source(String structure, int weight) {
|
||||||
return new IrisNativeStructure().setStructure(structure).setWeight(weight);
|
return nativeSource(structure, weight);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IrisStructurePlacement placement(String id, boolean underground, int minHeight, int maxHeight, double density,
|
private static StructurePlacement placement(String id, boolean underground, int minHeight, int maxHeight, double density,
|
||||||
IrisNativeStructure... sources) {
|
NativeStructureSource... sources) {
|
||||||
IrisStructurePlacement placement = new IrisStructurePlacement().setPlacementId(id)
|
StructurePlacement placement = StructurePlacementFixtures.placement("placementId", id, "distribution", StructureDistribution.DENSITY, "density", density, "underground", underground, "minHeight", minHeight, "maxHeight", maxHeight);
|
||||||
.setDistribution(StructureDistribution.DENSITY).setDensity(density)
|
for (NativeStructureSource source : sources) {
|
||||||
.setUnderground(underground).setMinHeight(minHeight).setMaxHeight(maxHeight);
|
withAdded(placement, "nativeStructures", source);
|
||||||
for (IrisNativeStructure source : sources) {
|
|
||||||
placement.getNativeStructures().add(source);
|
|
||||||
}
|
}
|
||||||
return placement;
|
return placement;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String placementId(KList<IrisStructurePlacement> placements, long identity) {
|
private static String placementId(KList<StructurePlacement> placements, long identity) {
|
||||||
return placements.stream().filter(placement -> StructurePlacementGrid.placementIdentity(placement) == identity)
|
return placements.stream().filter(placement -> StructurePlacementGrid.placementIdentity(placement) == identity)
|
||||||
.findFirst().orElseThrow().getPlacementId();
|
.findFirst().orElseThrow().placementId();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** An engine whose pack serves the built-in modules, with terrain heights that vary per column and a high sea. */
|
/** An engine whose pack serves the built-in modules, with terrain heights that vary per column and a high sea. */
|
||||||
private Engine engine(KList<IrisStructurePlacement> placements) throws IOException {
|
private Engine engine(KList<StructurePlacement> placements) throws IOException {
|
||||||
IrisData data = mock(IrisData.class);
|
IrisData data = mock(IrisData.class);
|
||||||
Engine engine = mock(Engine.class);
|
Engine engine = mock(Engine.class);
|
||||||
IrisDimension dimension = mock(IrisDimension.class);
|
IrisDimension dimension = mock(IrisDimension.class);
|
||||||
@@ -190,8 +191,7 @@ public class NativeStructureStartsTest {
|
|||||||
});
|
});
|
||||||
when(engine.getDimension()).thenReturn(dimension);
|
when(engine.getDimension()).thenReturn(dimension);
|
||||||
when(dimension.getFluidHeight()).thenReturn(127);
|
when(dimension.getFluidHeight()).thenReturn(127);
|
||||||
when(dimension.getModuleSettings()).thenReturn(ModuleSettings.NONE);
|
when(dimension.getModuleSettings()).thenReturn(declaring(placements));
|
||||||
when(dimension.getStructures()).thenReturn(placements);
|
|
||||||
when(dimension.getAllRegions(engine)).thenReturn(new KList<>());
|
when(dimension.getAllRegions(engine)).thenReturn(new KList<>());
|
||||||
when(dimension.getReachableBiomes(engine)).thenReturn(new KList<>());
|
when(dimension.getReachableBiomes(engine)).thenReturn(new KList<>());
|
||||||
return engine;
|
return engine;
|
||||||
|
|||||||
-1
@@ -63,7 +63,6 @@ public class NativeStructureVolumeSuppressionTest {
|
|||||||
when(engine.getData()).thenReturn(data);
|
when(engine.getData()).thenReturn(data);
|
||||||
when(engine.getDimension()).thenReturn(dimension);
|
when(engine.getDimension()).thenReturn(dimension);
|
||||||
when(dimension.getModuleSettings()).thenReturn(BuiltInPack.settings(settings));
|
when(dimension.getModuleSettings()).thenReturn(BuiltInPack.settings(settings));
|
||||||
when(dimension.getStructures()).thenReturn(new KList<>());
|
|
||||||
when(dimension.getAllRegions(engine)).thenReturn(new KList<>());
|
when(dimension.getAllRegions(engine)).thenReturn(new KList<>());
|
||||||
when(dimension.getReachableBiomes(engine)).thenReturn(new KList<>());
|
when(dimension.getReachableBiomes(engine)).thenReturn(new KList<>());
|
||||||
return engine;
|
return engine;
|
||||||
|
|||||||
+20
-26
@@ -1,7 +1,7 @@
|
|||||||
package art.arcane.iris.engine.framework;
|
package art.arcane.iris.engine.framework;
|
||||||
|
|
||||||
import art.arcane.iris.engine.object.structure.IrisStructureAnchorMode;
|
import art.arcane.iris.builtin.structure.StructureAnchorMode;
|
||||||
import art.arcane.iris.engine.object.structure.IrisStructurePlacement;
|
import art.arcane.iris.builtin.structure.StructurePlacement;
|
||||||
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
||||||
import art.arcane.iris.spi.IrisPlatform;
|
import art.arcane.iris.spi.IrisPlatform;
|
||||||
import art.arcane.iris.spi.IrisPlatforms;
|
import art.arcane.iris.spi.IrisPlatforms;
|
||||||
@@ -18,6 +18,7 @@ import java.util.HashSet;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.function.IntPredicate;
|
import java.util.function.IntPredicate;
|
||||||
|
|
||||||
|
import static art.arcane.iris.engine.framework.StructurePlacementFixtures.placement;
|
||||||
import static org.junit.Assert.assertArrayEquals;
|
import static org.junit.Assert.assertArrayEquals;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
@@ -55,11 +56,11 @@ public class StructureCaveAnchorResolverTest {
|
|||||||
IntPredicate carved = carvedAt(10, 11, 12, 13);
|
IntPredicate carved = carvedAt(10, 11, 12, 13);
|
||||||
|
|
||||||
assertTrue(StructureCaveAnchorResolver.matchesGeometry(
|
assertTrue(StructureCaveAnchorResolver.matchesGeometry(
|
||||||
carved, IrisStructureAnchorMode.CAVE_FLOOR, 10, 3));
|
carved, StructureAnchorMode.CAVE_FLOOR, 10, 3));
|
||||||
assertFalse(StructureCaveAnchorResolver.matchesGeometry(
|
assertFalse(StructureCaveAnchorResolver.matchesGeometry(
|
||||||
carved, IrisStructureAnchorMode.CAVE_FLOOR, 11, 3));
|
carved, StructureAnchorMode.CAVE_FLOOR, 11, 3));
|
||||||
assertFalse(StructureCaveAnchorResolver.matchesGeometry(
|
assertFalse(StructureCaveAnchorResolver.matchesGeometry(
|
||||||
carved, IrisStructureAnchorMode.CAVE_FLOOR, 10, 5));
|
carved, StructureAnchorMode.CAVE_FLOOR, 10, 5));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -67,9 +68,9 @@ public class StructureCaveAnchorResolverTest {
|
|||||||
IntPredicate carved = carvedAt(20, 21, 22, 23);
|
IntPredicate carved = carvedAt(20, 21, 22, 23);
|
||||||
|
|
||||||
assertTrue(StructureCaveAnchorResolver.matchesGeometry(
|
assertTrue(StructureCaveAnchorResolver.matchesGeometry(
|
||||||
carved, IrisStructureAnchorMode.CAVE_CEILING, 23, 4));
|
carved, StructureAnchorMode.CAVE_CEILING, 23, 4));
|
||||||
assertFalse(StructureCaveAnchorResolver.matchesGeometry(
|
assertFalse(StructureCaveAnchorResolver.matchesGeometry(
|
||||||
carved, IrisStructureAnchorMode.CAVE_CEILING, 22, 4));
|
carved, StructureAnchorMode.CAVE_CEILING, 22, 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -77,13 +78,13 @@ public class StructureCaveAnchorResolverTest {
|
|||||||
IntPredicate carved = carvedAt(30, 31, 32, 33, 34);
|
IntPredicate carved = carvedAt(30, 31, 32, 33, 34);
|
||||||
|
|
||||||
assertTrue(StructureCaveAnchorResolver.matchesGeometry(
|
assertTrue(StructureCaveAnchorResolver.matchesGeometry(
|
||||||
carved, IrisStructureAnchorMode.CAVE_CENTER, 32, 5));
|
carved, StructureAnchorMode.CAVE_CENTER, 32, 5));
|
||||||
assertFalse(StructureCaveAnchorResolver.matchesGeometry(
|
assertFalse(StructureCaveAnchorResolver.matchesGeometry(
|
||||||
carved, IrisStructureAnchorMode.CAVE_CENTER, 31, 3));
|
carved, StructureAnchorMode.CAVE_CENTER, 31, 3));
|
||||||
assertFalse(StructureCaveAnchorResolver.matchesGeometry(
|
assertFalse(StructureCaveAnchorResolver.matchesGeometry(
|
||||||
carved, IrisStructureAnchorMode.CAVE_CENTER, 33, 3));
|
carved, StructureAnchorMode.CAVE_CENTER, 33, 3));
|
||||||
assertFalse(StructureCaveAnchorResolver.matchesGeometry(
|
assertFalse(StructureCaveAnchorResolver.matchesGeometry(
|
||||||
carvedAt(32, 33, 34), IrisStructureAnchorMode.CAVE_CENTER, 32, 3));
|
carvedAt(32, 33, 34), StructureAnchorMode.CAVE_CENTER, 32, 3));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -91,21 +92,21 @@ public class StructureCaveAnchorResolverTest {
|
|||||||
IntPredicate carved = carvedAt(30, 31, 32, 33);
|
IntPredicate carved = carvedAt(30, 31, 32, 33);
|
||||||
|
|
||||||
assertTrue(StructureCaveAnchorResolver.matchesGeometry(
|
assertTrue(StructureCaveAnchorResolver.matchesGeometry(
|
||||||
carved, IrisStructureAnchorMode.CAVE_CENTER, 31, 4));
|
carved, StructureAnchorMode.CAVE_CENTER, 31, 4));
|
||||||
assertTrue(StructureCaveAnchorResolver.matchesGeometry(
|
assertTrue(StructureCaveAnchorResolver.matchesGeometry(
|
||||||
carved, IrisStructureAnchorMode.CAVE_CENTER, 32, 4));
|
carved, StructureAnchorMode.CAVE_CENTER, 32, 4));
|
||||||
assertFalse(StructureCaveAnchorResolver.matchesGeometry(
|
assertFalse(StructureCaveAnchorResolver.matchesGeometry(
|
||||||
carved, IrisStructureAnchorMode.CAVE_CENTER, 30, 4));
|
carved, StructureAnchorMode.CAVE_CENTER, 30, 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void anyRequiresClearanceAroundTheAlignedCenter() {
|
public void anyRequiresClearanceAroundTheAlignedCenter() {
|
||||||
assertTrue(StructureCaveAnchorResolver.matchesGeometry(
|
assertTrue(StructureCaveAnchorResolver.matchesGeometry(
|
||||||
carvedAt(39, 40, 41), IrisStructureAnchorMode.CAVE_ANY, 40, 3));
|
carvedAt(39, 40, 41), StructureAnchorMode.CAVE_ANY, 40, 3));
|
||||||
assertTrue(StructureCaveAnchorResolver.matchesGeometry(
|
assertTrue(StructureCaveAnchorResolver.matchesGeometry(
|
||||||
carvedAt(48, 49, 50, 51), IrisStructureAnchorMode.CAVE_ANY, 49, 4));
|
carvedAt(48, 49, 50, 51), StructureAnchorMode.CAVE_ANY, 49, 4));
|
||||||
assertFalse(StructureCaveAnchorResolver.matchesGeometry(
|
assertFalse(StructureCaveAnchorResolver.matchesGeometry(
|
||||||
carvedAt(60, 61, 62), IrisStructureAnchorMode.CAVE_ANY, 60, 3));
|
carvedAt(60, 61, 62), StructureAnchorMode.CAVE_ANY, 60, 3));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -200,15 +201,8 @@ public class StructureCaveAnchorResolverTest {
|
|||||||
return engine;
|
return engine;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IrisStructurePlacement floorPlacement(boolean underwater) {
|
private static StructurePlacement floorPlacement(boolean underwater) {
|
||||||
return new IrisStructurePlacement()
|
return placement("anchor", StructureAnchorMode.CAVE_FLOOR, "minHeight", -54, "maxHeight", -54, "caveAnchorAttempts", 1, "caveAnchorScanStep", 1, "caveMinimumClearance", 3, "underwater", underwater);
|
||||||
.setAnchor(IrisStructureAnchorMode.CAVE_FLOOR)
|
|
||||||
.setMinHeight(-54)
|
|
||||||
.setMaxHeight(-54)
|
|
||||||
.setCaveAnchorAttempts(1)
|
|
||||||
.setCaveAnchorScanStep(1)
|
|
||||||
.setCaveMinimumClearance(3)
|
|
||||||
.setUnderwater(underwater);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IntPredicate carvedAt(Integer... values) {
|
private static IntPredicate carvedAt(Integer... values) {
|
||||||
|
|||||||
@@ -0,0 +1,80 @@
|
|||||||
|
package art.arcane.iris.engine.framework;
|
||||||
|
|
||||||
|
import art.arcane.iris.builtin.structure.NativeStructureSource;
|
||||||
|
import art.arcane.iris.builtin.structure.StructurePlacement;
|
||||||
|
import art.arcane.iris.builtin.structure.StructurePlacementSettings;
|
||||||
|
import art.arcane.iris.core.loader.IrisRegistrant;
|
||||||
|
import art.arcane.iris.core.modules.BuiltInPack;
|
||||||
|
import art.arcane.iris.core.modules.ModuleSettings;
|
||||||
|
import art.arcane.iris.engine.object.TestSettings;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/** Structure placements as packs write them, for tests: {@code placement("structures", List.of("test:city"))}. */
|
||||||
|
public final class StructurePlacementFixtures {
|
||||||
|
private StructurePlacementFixtures() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A placement with the options {@code namesAndValues} set, the others at their defaults. */
|
||||||
|
public static StructurePlacement placement(Object... namesAndValues) {
|
||||||
|
return TestSettings.with(new StructurePlacement(), namesAndValues);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A placement that assembles the pack's structures {@code keys}. */
|
||||||
|
public static StructurePlacement assembling(String... keys) {
|
||||||
|
return placement("structures", new ArrayList<>(Arrays.asList(keys)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A placement that starts the platform's structures {@code sources} natively. */
|
||||||
|
public static StructurePlacement starting(NativeStructureSource... sources) {
|
||||||
|
return placement("nativeStructures", new ArrayList<>(Arrays.asList(sources)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static NativeStructureSource nativeSource(String structure) {
|
||||||
|
return TestSettings.with(new NativeStructureSource(), "structure", structure);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static NativeStructureSource nativeSource(String structure, int weight) {
|
||||||
|
return TestSettings.with(new NativeStructureSource(), "structure", structure, "weight", weight);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** {@code placement} with {@code value} appended to its list option {@code name}, as a pack listing one more would have it. */
|
||||||
|
public static StructurePlacement withAdded(StructurePlacement placement, String name, Object value) {
|
||||||
|
List<Object> values = new ArrayList<>(currentList(placement, name));
|
||||||
|
values.add(value);
|
||||||
|
return TestSettings.with(placement, name, values);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<?> currentList(StructurePlacement placement, String name) {
|
||||||
|
try {
|
||||||
|
java.lang.reflect.Field field = StructurePlacement.class.getDeclaredField(name);
|
||||||
|
field.setAccessible(true);
|
||||||
|
Object value = field.get(placement);
|
||||||
|
return value == null ? List.of() : (List<?>) value;
|
||||||
|
} catch (ReflectiveOperationException failure) {
|
||||||
|
throw new IllegalArgumentException("No list option " + name + " in a structure placement", failure);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The {@code "structures"} settings listing {@code placements}. */
|
||||||
|
public static StructurePlacementSettings placementSettings(List<StructurePlacement> placements) {
|
||||||
|
return TestSettings.with(new StructurePlacementSettings(), "placements", new ArrayList<>(placements));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The module settings of a dimension, region or biome whose {@code "structures"} are {@code placements}. */
|
||||||
|
public static ModuleSettings declaring(List<StructurePlacement> placements) {
|
||||||
|
return BuiltInPack.settings(placementSettings(placements));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ModuleSettings declaring(StructurePlacement... placements) {
|
||||||
|
return declaring(Arrays.asList(placements));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** {@code owner}, now declaring {@code placements} in its {@code "structures"}. */
|
||||||
|
public static <T extends IrisRegistrant> T declare(T owner, StructurePlacement... placements) {
|
||||||
|
owner.setModuleSettings(declaring(placements));
|
||||||
|
return owner;
|
||||||
|
}
|
||||||
|
}
|
||||||
+80
-88
@@ -18,11 +18,13 @@
|
|||||||
|
|
||||||
package art.arcane.iris.engine.framework;
|
package art.arcane.iris.engine.framework;
|
||||||
|
|
||||||
import art.arcane.iris.engine.object.structure.IrisStructurePlacement;
|
import art.arcane.iris.builtin.structure.StructurePlacement;
|
||||||
import art.arcane.iris.engine.object.structure.IrisStructureAnchorMode;
|
import art.arcane.iris.builtin.structure.StructureAnchorMode;
|
||||||
import art.arcane.iris.engine.object.structure.StructureDistribution;
|
import art.arcane.iris.builtin.structure.StructureDistribution;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import art.arcane.iris.engine.object.TestSettings;
|
||||||
|
|
||||||
|
import static art.arcane.iris.engine.framework.StructurePlacementFixtures.withAdded;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertNotEquals;
|
import static org.junit.Assert.assertNotEquals;
|
||||||
@@ -109,11 +111,11 @@ public class StructurePlacementGridTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void densityStartIsDeterministicAndPlacementIdScoped() {
|
public void densityStartIsDeterministicAndPlacementIdScoped() {
|
||||||
IrisStructurePlacement placement = placement(StructureDistribution.DENSITY);
|
StructurePlacement placement = placement(StructureDistribution.DENSITY);
|
||||||
placement.setDensity(0.35);
|
TestSettings.with(placement, "density", 0.35);
|
||||||
IrisStructurePlacement secondPlacement = placement(StructureDistribution.DENSITY);
|
StructurePlacement secondPlacement = placement(StructureDistribution.DENSITY);
|
||||||
secondPlacement.setDensity(0.35);
|
TestSettings.with(secondPlacement, "density", 0.35);
|
||||||
secondPlacement.setPlacementId("second");
|
TestSettings.with(secondPlacement, "placementId", "second");
|
||||||
boolean differsById = false;
|
boolean differsById = false;
|
||||||
for (int cx = -32; cx <= 32; cx++) {
|
for (int cx = -32; cx <= 32; cx++) {
|
||||||
for (int cz = -32; cz <= 32; cz++) {
|
for (int cz = -32; cz <= 32; cz++) {
|
||||||
@@ -129,22 +131,22 @@ public class StructurePlacementGridTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void densityBoundariesNeverAndAlwaysStart() {
|
public void densityBoundariesNeverAndAlwaysStart() {
|
||||||
IrisStructurePlacement placement = placement(StructureDistribution.DENSITY);
|
StructurePlacement placement = placement(StructureDistribution.DENSITY);
|
||||||
placement.setDensity(0.0);
|
TestSettings.with(placement, "density", 0.0);
|
||||||
assertFalse(StructurePlacementGrid.startsInChunk(placement, 4, -9, 77L));
|
assertFalse(StructurePlacementGrid.startsInChunk(placement, 4, -9, 77L));
|
||||||
placement.setDensity(1.0);
|
TestSettings.with(placement, "density", 1.0);
|
||||||
assertTrue(StructurePlacementGrid.startsInChunk(placement, 4, -9, 77L));
|
assertTrue(StructurePlacementGrid.startsInChunk(placement, 4, -9, 77L));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void concentricRingCountIsFiniteTotalPlacementCount() {
|
public void concentricRingCountIsFiniteTotalPlacementCount() {
|
||||||
IrisStructurePlacement placement = placement(StructureDistribution.CONCENTRIC_RINGS);
|
StructurePlacement placement = placement(StructureDistribution.CONCENTRIC_RINGS);
|
||||||
placement.setRingCount(10);
|
TestSettings.with(placement, "ringCount", 10);
|
||||||
placement.setRingSpread(3);
|
TestSettings.with(placement, "ringSpread", 3);
|
||||||
placement.setRingDistance(12);
|
TestSettings.with(placement, "ringDistance", 12);
|
||||||
long seed = 484848L;
|
long seed = 484848L;
|
||||||
int lastRing = Math.ceilDiv(placement.getRingCount(), placement.getRingSpread());
|
int lastRing = Math.ceilDiv(placement.ringCount(), placement.ringSpread());
|
||||||
int scanRadius = (lastRing + 2) * placement.getRingDistance();
|
int scanRadius = (lastRing + 2) * placement.ringDistance();
|
||||||
int starts = 0;
|
int starts = 0;
|
||||||
for (int cx = -scanRadius; cx <= scanRadius; cx++) {
|
for (int cx = -scanRadius; cx <= scanRadius; cx++) {
|
||||||
for (int cz = -scanRadius; cz <= scanRadius; cz++) {
|
for (int cz = -scanRadius; cz <= scanRadius; cz++) {
|
||||||
@@ -153,16 +155,16 @@ public class StructurePlacementGridTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assertEquals(placement.getRingCount(), starts);
|
assertEquals(placement.ringCount(), starts);
|
||||||
assertNull(StructurePlacementGrid.concentricRingChunk(placement, placement.getRingCount(), seed));
|
assertNull(StructurePlacementGrid.concentricRingChunk(placement, placement.ringCount(), seed));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void placementRngIsStableAndPlacementIdScoped() {
|
public void placementRngIsStableAndPlacementIdScoped() {
|
||||||
IrisStructurePlacement placement = placement(StructureDistribution.RANDOM_SPREAD);
|
StructurePlacement placement = placement(StructureDistribution.RANDOM_SPREAD);
|
||||||
long first = StructurePlacementGrid.placementRng(placement, 7, -11, 123L).getSeed();
|
long first = StructurePlacementGrid.placementRng(placement, 7, -11, 123L).getSeed();
|
||||||
long repeated = StructurePlacementGrid.placementRng(placement, 7, -11, 123L).getSeed();
|
long repeated = StructurePlacementGrid.placementRng(placement, 7, -11, 123L).getSeed();
|
||||||
placement.setPlacementId("second");
|
TestSettings.with(placement, "placementId", "second");
|
||||||
long secondPlacement = StructurePlacementGrid.placementRng(placement, 7, -11, 123L).getSeed();
|
long secondPlacement = StructurePlacementGrid.placementRng(placement, 7, -11, 123L).getSeed();
|
||||||
assertEquals(first, repeated);
|
assertEquals(first, repeated);
|
||||||
assertNotEquals(first, secondPlacement);
|
assertNotEquals(first, secondPlacement);
|
||||||
@@ -170,24 +172,24 @@ public class StructurePlacementGridTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void authoredPlacementIdSeparatesRandomSpreadStarts() {
|
public void authoredPlacementIdSeparatesRandomSpreadStarts() {
|
||||||
IrisStructurePlacement first = placement(StructureDistribution.RANDOM_SPREAD);
|
StructurePlacement first = placement(StructureDistribution.RANDOM_SPREAD);
|
||||||
first.setPlacementId("first");
|
TestSettings.with(first, "placementId", "first");
|
||||||
IrisStructurePlacement second = placement(StructureDistribution.RANDOM_SPREAD);
|
StructurePlacement second = placement(StructureDistribution.RANDOM_SPREAD);
|
||||||
second.setPlacementId("second");
|
TestSettings.with(second, "placementId", "second");
|
||||||
int[] firstStart = StructurePlacementGrid.randomSpreadCellChunk(
|
int[] firstStart = StructurePlacementGrid.randomSpreadCellChunk(
|
||||||
8, -3, first.getSpacing(), first.getSeparation(), StructurePlacementGrid.placementSalt(first), 31337L);
|
8, -3, first.spacing(), first.separation(), StructurePlacementGrid.placementSalt(first), 31337L);
|
||||||
int[] secondStart = StructurePlacementGrid.randomSpreadCellChunk(
|
int[] secondStart = StructurePlacementGrid.randomSpreadCellChunk(
|
||||||
8, -3, second.getSpacing(), second.getSeparation(), StructurePlacementGrid.placementSalt(second), 31337L);
|
8, -3, second.spacing(), second.separation(), StructurePlacementGrid.placementSalt(second), 31337L);
|
||||||
assertFalse(firstStart[0] == secondStart[0] && firstStart[1] == secondStart[1]);
|
assertFalse(firstStart[0] == secondStart[0] && firstStart[1] == secondStart[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void blankIdsDeriveDistinctStableRandomSpreadGridsFromContent() {
|
public void blankIdsDeriveDistinctStableRandomSpreadGridsFromContent() {
|
||||||
IrisStructurePlacement first = placement(StructureDistribution.RANDOM_SPREAD);
|
StructurePlacement first = placement(StructureDistribution.RANDOM_SPREAD);
|
||||||
IrisStructurePlacement recreatedFirst = placement(StructureDistribution.RANDOM_SPREAD);
|
StructurePlacement recreatedFirst = placement(StructureDistribution.RANDOM_SPREAD);
|
||||||
IrisStructurePlacement second = placement(StructureDistribution.RANDOM_SPREAD);
|
StructurePlacement second = placement(StructureDistribution.RANDOM_SPREAD);
|
||||||
second.getStructures().clear();
|
TestSettings.with(second, "structures", new java.util.ArrayList<>());
|
||||||
second.getStructures().add("test:other");
|
withAdded(second, "structures", "test:other");
|
||||||
|
|
||||||
assertEquals(StructurePlacementGrid.placementSalt(first),
|
assertEquals(StructurePlacementGrid.placementSalt(first),
|
||||||
StructurePlacementGrid.placementSalt(recreatedFirst));
|
StructurePlacementGrid.placementSalt(recreatedFirst));
|
||||||
@@ -196,10 +198,10 @@ public class StructurePlacementGridTest {
|
|||||||
boolean differs = false;
|
boolean differs = false;
|
||||||
for (int cell = -8; cell <= 8; cell++) {
|
for (int cell = -8; cell <= 8; cell++) {
|
||||||
int[] firstStart = StructurePlacementGrid.randomSpreadCellChunk(
|
int[] firstStart = StructurePlacementGrid.randomSpreadCellChunk(
|
||||||
cell, cell + 3, first.getSpacing(), first.getSeparation(),
|
cell, cell + 3, first.spacing(), first.separation(),
|
||||||
StructurePlacementGrid.placementSalt(first), 31337L);
|
StructurePlacementGrid.placementSalt(first), 31337L);
|
||||||
int[] secondStart = StructurePlacementGrid.randomSpreadCellChunk(
|
int[] secondStart = StructurePlacementGrid.randomSpreadCellChunk(
|
||||||
cell, cell + 3, second.getSpacing(), second.getSeparation(),
|
cell, cell + 3, second.spacing(), second.separation(),
|
||||||
StructurePlacementGrid.placementSalt(second), 31337L);
|
StructurePlacementGrid.placementSalt(second), 31337L);
|
||||||
differs |= firstStart[0] != secondStart[0] || firstStart[1] != secondStart[1];
|
differs |= firstStart[0] != secondStart[0] || firstStart[1] != secondStart[1];
|
||||||
}
|
}
|
||||||
@@ -208,12 +210,12 @@ public class StructurePlacementGridTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void anonymousIdentityPreservesAuthoredSourceOrder() {
|
public void anonymousIdentityPreservesAuthoredSourceOrder() {
|
||||||
IrisStructurePlacement first = placement(StructureDistribution.RANDOM_SPREAD);
|
StructurePlacement first = placement(StructureDistribution.RANDOM_SPREAD);
|
||||||
first.getStructures().add("test:second");
|
withAdded(first, "structures", "test:second");
|
||||||
IrisStructurePlacement reordered = placement(StructureDistribution.RANDOM_SPREAD);
|
StructurePlacement reordered = placement(StructureDistribution.RANDOM_SPREAD);
|
||||||
reordered.getStructures().clear();
|
TestSettings.with(reordered, "structures", new java.util.ArrayList<>());
|
||||||
reordered.getStructures().add("test:second");
|
withAdded(reordered, "structures", "test:second");
|
||||||
reordered.getStructures().add("test:structure");
|
withAdded(reordered, "structures", "test:structure");
|
||||||
|
|
||||||
assertNotEquals(StructurePlacementGrid.placementIdentity(first),
|
assertNotEquals(StructurePlacementGrid.placementIdentity(first),
|
||||||
StructurePlacementGrid.placementIdentity(reordered));
|
StructurePlacementGrid.placementIdentity(reordered));
|
||||||
@@ -225,17 +227,17 @@ public class StructurePlacementGridTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void blankIdsDeriveDistinctStableConcentricRingsFromContent() {
|
public void blankIdsDeriveDistinctStableConcentricRingsFromContent() {
|
||||||
IrisStructurePlacement first = placement(StructureDistribution.CONCENTRIC_RINGS);
|
StructurePlacement first = placement(StructureDistribution.CONCENTRIC_RINGS);
|
||||||
IrisStructurePlacement recreatedFirst = placement(StructureDistribution.CONCENTRIC_RINGS);
|
StructurePlacement recreatedFirst = placement(StructureDistribution.CONCENTRIC_RINGS);
|
||||||
IrisStructurePlacement second = placement(StructureDistribution.CONCENTRIC_RINGS);
|
StructurePlacement second = placement(StructureDistribution.CONCENTRIC_RINGS);
|
||||||
second.getStructures().clear();
|
TestSettings.with(second, "structures", new java.util.ArrayList<>());
|
||||||
second.getStructures().add("test:other");
|
withAdded(second, "structures", "test:other");
|
||||||
first.setRingCount(12);
|
TestSettings.with(first, "ringCount", 12);
|
||||||
recreatedFirst.setRingCount(12);
|
TestSettings.with(recreatedFirst, "ringCount", 12);
|
||||||
second.setRingCount(12);
|
TestSettings.with(second, "ringCount", 12);
|
||||||
|
|
||||||
boolean differs = false;
|
boolean differs = false;
|
||||||
for (int index = 0; index < first.getRingCount(); index++) {
|
for (int index = 0; index < first.ringCount(); index++) {
|
||||||
int[] firstPoint = StructurePlacementGrid.concentricRingChunk(first, index, 77123L);
|
int[] firstPoint = StructurePlacementGrid.concentricRingChunk(first, index, 77123L);
|
||||||
int[] recreatedPoint = StructurePlacementGrid.concentricRingChunk(recreatedFirst, index, 77123L);
|
int[] recreatedPoint = StructurePlacementGrid.concentricRingChunk(recreatedFirst, index, 77123L);
|
||||||
int[] secondPoint = StructurePlacementGrid.concentricRingChunk(second, index, 77123L);
|
int[] secondPoint = StructurePlacementGrid.concentricRingChunk(second, index, 77123L);
|
||||||
@@ -248,9 +250,9 @@ public class StructurePlacementGridTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void derivedPlacementIdentityIncludesPlacementSettings() {
|
public void derivedPlacementIdentityIncludesPlacementSettings() {
|
||||||
IrisStructurePlacement first = placement(StructureDistribution.DENSITY);
|
StructurePlacement first = placement(StructureDistribution.DENSITY);
|
||||||
IrisStructurePlacement second = placement(StructureDistribution.DENSITY);
|
StructurePlacement second = placement(StructureDistribution.DENSITY);
|
||||||
second.setMinHeight(first.getMinHeight() + 1);
|
TestSettings.with(second, "minHeight", first.minHeight() + 1);
|
||||||
long firstSeed = StructurePlacementGrid.placementRng(first, 9, 14, 42L).getSeed();
|
long firstSeed = StructurePlacementGrid.placementRng(first, 9, 14, 42L).getSeed();
|
||||||
long secondSeed = StructurePlacementGrid.placementRng(second, 9, 14, 42L).getSeed();
|
long secondSeed = StructurePlacementGrid.placementRng(second, 9, 14, 42L).getSeed();
|
||||||
assertNotEquals(firstSeed, secondSeed);
|
assertNotEquals(firstSeed, secondSeed);
|
||||||
@@ -258,9 +260,8 @@ public class StructurePlacementGridTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void legacyAnchorDoesNotMoveExistingPlacements() {
|
public void legacyAnchorDoesNotMoveExistingPlacements() {
|
||||||
IrisStructurePlacement implicit = placement(StructureDistribution.RANDOM_SPREAD);
|
StructurePlacement implicit = placement(StructureDistribution.RANDOM_SPREAD);
|
||||||
IrisStructurePlacement explicit = placement(StructureDistribution.RANDOM_SPREAD)
|
StructurePlacement explicit = TestSettings.with(placement(StructureDistribution.RANDOM_SPREAD), "anchor", StructureAnchorMode.LEGACY);
|
||||||
.setAnchor(IrisStructureAnchorMode.LEGACY);
|
|
||||||
|
|
||||||
assertEquals(StructurePlacementGrid.placementIdentity(implicit),
|
assertEquals(StructurePlacementGrid.placementIdentity(implicit),
|
||||||
StructurePlacementGrid.placementIdentity(explicit));
|
StructurePlacementGrid.placementIdentity(explicit));
|
||||||
@@ -270,10 +271,8 @@ public class StructurePlacementGridTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void caveAnchorConfigurationParticipatesInAnonymousIdentity() {
|
public void caveAnchorConfigurationParticipatesInAnonymousIdentity() {
|
||||||
IrisStructurePlacement floor = placement(StructureDistribution.RANDOM_SPREAD)
|
StructurePlacement floor = TestSettings.with(placement(StructureDistribution.RANDOM_SPREAD), "anchor", StructureAnchorMode.CAVE_FLOOR);
|
||||||
.setAnchor(IrisStructureAnchorMode.CAVE_FLOOR);
|
StructurePlacement ceiling = TestSettings.with(placement(StructureDistribution.RANDOM_SPREAD), "anchor", StructureAnchorMode.CAVE_CEILING);
|
||||||
IrisStructurePlacement ceiling = placement(StructureDistribution.RANDOM_SPREAD)
|
|
||||||
.setAnchor(IrisStructureAnchorMode.CAVE_CEILING);
|
|
||||||
|
|
||||||
assertNotEquals(StructurePlacementGrid.placementIdentity(floor),
|
assertNotEquals(StructurePlacementGrid.placementIdentity(floor),
|
||||||
StructurePlacementGrid.placementIdentity(ceiling));
|
StructurePlacementGrid.placementIdentity(ceiling));
|
||||||
@@ -283,14 +282,9 @@ public class StructurePlacementGridTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void unusedCaveSettingsDoNotMoveExplicitSurfacePlacements() {
|
public void unusedCaveSettingsDoNotMoveExplicitSurfacePlacements() {
|
||||||
IrisStructurePlacement first = placement(StructureDistribution.RANDOM_SPREAD)
|
StructurePlacement first = TestSettings.with(placement(StructureDistribution.RANDOM_SPREAD), "anchor", StructureAnchorMode.SURFACE);
|
||||||
.setAnchor(IrisStructureAnchorMode.SURFACE);
|
StructurePlacement second = TestSettings.with(placement(StructureDistribution.RANDOM_SPREAD), "anchor", StructureAnchorMode.SURFACE, "caveAnchorAttempts", 64, "caveAnchorScanStep", 16, "caveMinimumClearance", 64);
|
||||||
IrisStructurePlacement second = placement(StructureDistribution.RANDOM_SPREAD)
|
withAdded(second, "caveBiomes", "unused");
|
||||||
.setAnchor(IrisStructureAnchorMode.SURFACE)
|
|
||||||
.setCaveAnchorAttempts(64)
|
|
||||||
.setCaveAnchorScanStep(16)
|
|
||||||
.setCaveMinimumClearance(64);
|
|
||||||
second.getCaveBiomes().add("unused");
|
|
||||||
|
|
||||||
assertEquals(StructurePlacementGrid.placementIdentity(first),
|
assertEquals(StructurePlacementGrid.placementIdentity(first),
|
||||||
StructurePlacementGrid.placementIdentity(second));
|
StructurePlacementGrid.placementIdentity(second));
|
||||||
@@ -300,16 +294,14 @@ public class StructurePlacementGridTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void caveBiomeAllowlistIdentityIgnoresOrderCaseWhitespaceAndDuplicates() {
|
public void caveBiomeAllowlistIdentityIgnoresOrderCaseWhitespaceAndDuplicates() {
|
||||||
IrisStructurePlacement first = placement(StructureDistribution.RANDOM_SPREAD)
|
StructurePlacement first = TestSettings.with(placement(StructureDistribution.RANDOM_SPREAD), "anchor", StructureAnchorMode.CAVE_CENTER);
|
||||||
.setAnchor(IrisStructureAnchorMode.CAVE_CENTER);
|
withAdded(first, "caveBiomes", "crystal");
|
||||||
first.getCaveBiomes().add("crystal");
|
withAdded(first, "caveBiomes", "deep");
|
||||||
first.getCaveBiomes().add("deep");
|
StructurePlacement second = TestSettings.with(placement(StructureDistribution.RANDOM_SPREAD), "anchor", StructureAnchorMode.CAVE_CENTER);
|
||||||
IrisStructurePlacement second = placement(StructureDistribution.RANDOM_SPREAD)
|
withAdded(second, "caveBiomes", " DEEP ");
|
||||||
.setAnchor(IrisStructureAnchorMode.CAVE_CENTER);
|
withAdded(second, "caveBiomes", "CRYSTAL");
|
||||||
second.getCaveBiomes().add(" DEEP ");
|
withAdded(second, "caveBiomes", "crystal");
|
||||||
second.getCaveBiomes().add("CRYSTAL");
|
withAdded(second, "caveBiomes", " ");
|
||||||
second.getCaveBiomes().add("crystal");
|
|
||||||
second.getCaveBiomes().add(" ");
|
|
||||||
|
|
||||||
assertEquals(StructurePlacementGrid.placementIdentity(first),
|
assertEquals(StructurePlacementGrid.placementIdentity(first),
|
||||||
StructurePlacementGrid.placementIdentity(second));
|
StructurePlacementGrid.placementIdentity(second));
|
||||||
@@ -319,22 +311,22 @@ public class StructurePlacementGridTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void explicitPlacementIdentityKeepsRngStableAcrossSettingEdits() {
|
public void explicitPlacementIdentityKeepsRngStableAcrossSettingEdits() {
|
||||||
IrisStructurePlacement first = placement(StructureDistribution.DENSITY);
|
StructurePlacement first = placement(StructureDistribution.DENSITY);
|
||||||
first.setPlacementId("stable");
|
TestSettings.with(first, "placementId", "stable");
|
||||||
IrisStructurePlacement second = placement(StructureDistribution.DENSITY);
|
StructurePlacement second = placement(StructureDistribution.DENSITY);
|
||||||
second.setPlacementId("stable");
|
TestSettings.with(second, "placementId", "stable");
|
||||||
second.setMinHeight(first.getMinHeight() + 1);
|
TestSettings.with(second, "minHeight", first.minHeight() + 1);
|
||||||
second.setDensity(0.75);
|
TestSettings.with(second, "density", 0.75);
|
||||||
long firstSeed = StructurePlacementGrid.placementRng(first, 9, 14, 42L).getSeed();
|
long firstSeed = StructurePlacementGrid.placementRng(first, 9, 14, 42L).getSeed();
|
||||||
long secondSeed = StructurePlacementGrid.placementRng(second, 9, 14, 42L).getSeed();
|
long secondSeed = StructurePlacementGrid.placementRng(second, 9, 14, 42L).getSeed();
|
||||||
assertEquals(firstSeed, secondSeed);
|
assertEquals(firstSeed, secondSeed);
|
||||||
}
|
}
|
||||||
|
|
||||||
private IrisStructurePlacement placement(StructureDistribution distribution) {
|
private StructurePlacement placement(StructureDistribution distribution) {
|
||||||
IrisStructurePlacement placement = new IrisStructurePlacement();
|
StructurePlacement placement = new StructurePlacement();
|
||||||
placement.setDistribution(distribution);
|
TestSettings.with(placement, "distribution", distribution);
|
||||||
placement.getStructures().add("test:structure");
|
withAdded(placement, "structures", "test:structure");
|
||||||
placement.setSalt(31415926);
|
TestSettings.with(placement, "salt", 31415926);
|
||||||
return placement;
|
return placement;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+22
-23
@@ -4,11 +4,14 @@ import art.arcane.iris.engine.IrisComplex;
|
|||||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
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.dimension.IrisDimension;
|
||||||
import art.arcane.iris.engine.object.world.region.IrisRegion;
|
import art.arcane.iris.engine.object.world.region.IrisRegion;
|
||||||
import art.arcane.iris.engine.object.structure.IrisStructureAnchorMode;
|
import art.arcane.iris.builtin.structure.StructureAnchorMode;
|
||||||
import art.arcane.iris.engine.object.structure.IrisStructurePlacement;
|
import art.arcane.iris.builtin.structure.StructurePlacement;
|
||||||
import art.arcane.volmlib.util.collection.KList;
|
import art.arcane.volmlib.util.collection.KList;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static art.arcane.iris.engine.framework.StructurePlacementFixtures.placement;
|
||||||
|
import static art.arcane.iris.engine.framework.StructurePlacementFixtures.declare;
|
||||||
|
import static art.arcane.iris.engine.framework.StructurePlacementFixtures.declaring;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
@@ -21,25 +24,20 @@ import static org.mockito.Mockito.when;
|
|||||||
public class StructurePlacementScopeTest {
|
public class StructurePlacementScopeTest {
|
||||||
@Test
|
@Test
|
||||||
public void caveBiomeContributesOnlyCaveAnchoredPlacements() {
|
public void caveBiomeContributesOnlyCaveAnchoredPlacements() {
|
||||||
IrisStructurePlacement surfacePlacement = new IrisStructurePlacement();
|
StructurePlacement surfacePlacement = new StructurePlacement();
|
||||||
IrisStructurePlacement cavePlacement = new IrisStructurePlacement()
|
StructurePlacement cavePlacement = placement("anchor", StructureAnchorMode.CAVE_FLOOR);
|
||||||
.setAnchor(IrisStructureAnchorMode.CAVE_FLOOR);
|
StructurePlacement invalidCaveScopePlacement = placement("anchor", StructureAnchorMode.SURFACE);
|
||||||
IrisStructurePlacement invalidCaveScopePlacement = new IrisStructurePlacement()
|
StructurePlacement regionPlacement = new StructurePlacement();
|
||||||
.setAnchor(IrisStructureAnchorMode.SURFACE);
|
StructurePlacement dimensionPlacement = new StructurePlacement();
|
||||||
IrisStructurePlacement regionPlacement = new IrisStructurePlacement();
|
|
||||||
IrisStructurePlacement dimensionPlacement = new IrisStructurePlacement();
|
|
||||||
|
|
||||||
IrisBiome surfaceBiome = new IrisBiome();
|
IrisBiome surfaceBiome = declare(new IrisBiome(), surfacePlacement);
|
||||||
surfaceBiome.getStructures().add(surfacePlacement);
|
IrisBiome caveBiome = declare(new IrisBiome(), cavePlacement, invalidCaveScopePlacement);
|
||||||
IrisBiome caveBiome = new IrisBiome();
|
IrisRegion region = declare(new IrisRegion(), regionPlacement);
|
||||||
caveBiome.getStructures().add(cavePlacement);
|
|
||||||
caveBiome.getStructures().add(invalidCaveScopePlacement);
|
|
||||||
IrisRegion region = new IrisRegion();
|
|
||||||
region.getStructures().add(regionPlacement);
|
|
||||||
Engine engine = mock(Engine.class, RETURNS_DEEP_STUBS);
|
Engine engine = mock(Engine.class, RETURNS_DEEP_STUBS);
|
||||||
|
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
|
||||||
IrisComplex complex = engine.getComplex();
|
IrisComplex complex = engine.getComplex();
|
||||||
IrisDimension dimension = mock(IrisDimension.class);
|
IrisDimension dimension = mock(IrisDimension.class);
|
||||||
KList<IrisStructurePlacement> dimensionStructures = new KList<>();
|
KList<StructurePlacement> dimensionStructures = new KList<>();
|
||||||
dimensionStructures.add(dimensionPlacement);
|
dimensionStructures.add(dimensionPlacement);
|
||||||
dimensionStructures.add(cavePlacement);
|
dimensionStructures.add(cavePlacement);
|
||||||
KList<IrisRegion> allRegions = new KList<>();
|
KList<IrisRegion> allRegions = new KList<>();
|
||||||
@@ -49,13 +47,13 @@ public class StructurePlacementScopeTest {
|
|||||||
allBiomes.add(caveBiome);
|
allBiomes.add(caveBiome);
|
||||||
when(engine.getDimension()).thenReturn(dimension);
|
when(engine.getDimension()).thenReturn(dimension);
|
||||||
when(engine.getAllBiomes()).thenReturn(allBiomes);
|
when(engine.getAllBiomes()).thenReturn(allBiomes);
|
||||||
when(dimension.getStructures()).thenReturn(dimensionStructures);
|
when(dimension.getModuleSettings()).thenReturn(declaring(dimensionStructures));
|
||||||
when(dimension.getAllRegions(engine)).thenReturn(allRegions);
|
when(dimension.getAllRegions(engine)).thenReturn(allRegions);
|
||||||
when(complex.getTrueBiomeStream().get(8, 8)).thenReturn(surfaceBiome);
|
when(complex.getTrueBiomeStream().get(8, 8)).thenReturn(surfaceBiome);
|
||||||
when(complex.getCaveBiomeStream().get(8, 8)).thenReturn(caveBiome);
|
when(complex.getCaveBiomeStream().get(8, 8)).thenReturn(caveBiome);
|
||||||
when(complex.getRegionStream().get(8, 8)).thenReturn(region);
|
when(complex.getRegionStream().get(8, 8)).thenReturn(region);
|
||||||
|
|
||||||
KList<IrisStructurePlacement> placements = StructurePlacementScope.placementsAt(engine, 0, 0);
|
KList<StructurePlacement> placements = StructurePlacementScope.placementsAt(engine, 0, 0);
|
||||||
|
|
||||||
assertEquals(4, placements.size());
|
assertEquals(4, placements.size());
|
||||||
assertTrue(placements.contains(surfacePlacement));
|
assertTrue(placements.contains(surfacePlacement));
|
||||||
@@ -67,18 +65,19 @@ public class StructurePlacementScopeTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void dimensionOnlyPlacementsDoNotResolveBiomeScopes() {
|
public void dimensionOnlyPlacementsDoNotResolveBiomeScopes() {
|
||||||
IrisStructurePlacement dimensionPlacement = new IrisStructurePlacement();
|
StructurePlacement dimensionPlacement = new StructurePlacement();
|
||||||
Engine engine = mock(Engine.class, RETURNS_DEEP_STUBS);
|
Engine engine = mock(Engine.class, RETURNS_DEEP_STUBS);
|
||||||
|
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
|
||||||
IrisComplex complex = engine.getComplex();
|
IrisComplex complex = engine.getComplex();
|
||||||
IrisDimension dimension = mock(IrisDimension.class);
|
IrisDimension dimension = mock(IrisDimension.class);
|
||||||
KList<IrisStructurePlacement> dimensionStructures = new KList<>();
|
KList<StructurePlacement> dimensionStructures = new KList<>();
|
||||||
dimensionStructures.add(dimensionPlacement);
|
dimensionStructures.add(dimensionPlacement);
|
||||||
when(engine.getDimension()).thenReturn(dimension);
|
when(engine.getDimension()).thenReturn(dimension);
|
||||||
when(engine.getAllBiomes()).thenReturn(new KList<>());
|
when(engine.getAllBiomes()).thenReturn(new KList<>());
|
||||||
when(dimension.getStructures()).thenReturn(dimensionStructures);
|
when(dimension.getModuleSettings()).thenReturn(declaring(dimensionStructures));
|
||||||
when(dimension.getAllRegions(engine)).thenReturn(new KList<>());
|
when(dimension.getAllRegions(engine)).thenReturn(new KList<>());
|
||||||
|
|
||||||
KList<IrisStructurePlacement> placements = StructurePlacementScope.placementsAt(engine, 0, 0);
|
KList<StructurePlacement> placements = StructurePlacementScope.placementsAt(engine, 0, 0);
|
||||||
|
|
||||||
assertEquals(1, placements.size());
|
assertEquals(1, placements.size());
|
||||||
assertTrue(placements.contains(dimensionPlacement));
|
assertTrue(placements.contains(dimensionPlacement));
|
||||||
|
|||||||
+50
-61
@@ -1,6 +1,8 @@
|
|||||||
package art.arcane.iris.engine.framework.structure;
|
package art.arcane.iris.engine.framework.structure;
|
||||||
|
|
||||||
|
import art.arcane.iris.core.loader.IrisData;
|
||||||
import art.arcane.iris.engine.framework.Engine;
|
import art.arcane.iris.engine.framework.Engine;
|
||||||
|
import art.arcane.iris.engine.framework.EngineGeneration;
|
||||||
import art.arcane.iris.engine.framework.SeedManager;
|
import art.arcane.iris.engine.framework.SeedManager;
|
||||||
import art.arcane.iris.engine.framework.StructurePlacementGrid;
|
import art.arcane.iris.engine.framework.StructurePlacementGrid;
|
||||||
import art.arcane.iris.builtin.structure.StructureStilts;
|
import art.arcane.iris.builtin.structure.StructureStilts;
|
||||||
@@ -8,22 +10,27 @@ import art.arcane.iris.builtin.structure.StructureTerrain;
|
|||||||
import art.arcane.iris.builtin.structure.StructureTerrainMode;
|
import art.arcane.iris.builtin.structure.StructureTerrainMode;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.volmit.vanilla.JigsawOverrides;
|
import com.volmit.vanilla.JigsawOverrides;
|
||||||
import art.arcane.iris.engine.object.structure.vanilla.NativeStructureSuppression;
|
import art.arcane.iris.builtin.structure.NativeStructureSuppression;
|
||||||
import com.volmit.resource.ResourceId;
|
import com.volmit.resource.ResourceId;
|
||||||
import com.volmit.vanilla.VanillaStructureStart;
|
import com.volmit.vanilla.VanillaStructureStart;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.OptionalInt;
|
import java.util.OptionalInt;
|
||||||
|
|
||||||
import art.arcane.iris.engine.object.structure.vanilla.IrisNativeStructure;
|
import art.arcane.iris.builtin.structure.NativeStructureSource;
|
||||||
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
||||||
import art.arcane.iris.engine.object.structure.IrisStructureAnchorMode;
|
import art.arcane.iris.builtin.structure.StructureAnchorMode;
|
||||||
import art.arcane.iris.engine.object.structure.IrisStructurePlacement;
|
import art.arcane.iris.builtin.structure.StructurePlacement;
|
||||||
import art.arcane.iris.engine.object.structure.StructureDistribution;
|
import art.arcane.iris.builtin.structure.StructureDistribution;
|
||||||
import art.arcane.volmlib.util.collection.KList;
|
import art.arcane.volmlib.util.collection.KList;
|
||||||
import art.arcane.volmlib.util.math.RNG;
|
import art.arcane.volmlib.util.math.RNG;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import art.arcane.iris.engine.object.TestSettings;
|
||||||
|
|
||||||
|
import static art.arcane.iris.engine.framework.StructurePlacementFixtures.placement;
|
||||||
|
import static art.arcane.iris.engine.framework.StructurePlacementFixtures.nativeSource;
|
||||||
|
import static art.arcane.iris.engine.framework.StructurePlacementFixtures.declaring;
|
||||||
|
import static art.arcane.iris.engine.framework.StructurePlacementFixtures.withAdded;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.Assert.assertNull;
|
||||||
@@ -38,17 +45,14 @@ public class NativeStartPlannerTest {
|
|||||||
@Test
|
@Test
|
||||||
public void undergroundPlanIsDeterministicAndUsesConfiguredBand() {
|
public void undergroundPlanIsDeterministicAndUsesConfiguredBand() {
|
||||||
Engine engine = engine(982374L, -64, 384, 90);
|
Engine engine = engine(982374L, -64, 384, 90);
|
||||||
IrisStructurePlacement placement = nativePlacement()
|
StructurePlacement placement = TestSettings.with(nativePlacement(), "underground", true, "minHeight", -45, "maxHeight", -20);
|
||||||
.setUnderground(true)
|
|
||||||
.setMinHeight(-45)
|
|
||||||
.setMaxHeight(-20);
|
|
||||||
|
|
||||||
NativeStartPlanner.Plan first = NativeStartPlanner.planAt(engine, placement, 12, -7);
|
NativeStartPlanner.Plan first = NativeStartPlanner.planAt(engine, placement, 12, -7);
|
||||||
NativeStartPlanner.Plan second = NativeStartPlanner.planAt(engine, placement, 12, -7);
|
NativeStartPlanner.Plan second = NativeStartPlanner.planAt(engine, placement, 12, -7);
|
||||||
|
|
||||||
assertNotNull(first);
|
assertNotNull(first);
|
||||||
assertEquals(first, second);
|
assertEquals(first, second);
|
||||||
assertEquals("minecraft:ancient_city", first.source().getStructure());
|
assertEquals("minecraft:ancient_city", first.source().structure());
|
||||||
assertEquals(12, first.chunkX());
|
assertEquals(12, first.chunkX());
|
||||||
assertEquals(-7, first.chunkZ());
|
assertEquals(-7, first.chunkZ());
|
||||||
assertTrue(first.baseY() >= -45 && first.baseY() <= -20);
|
assertTrue(first.baseY() >= -45 && first.baseY() <= -20);
|
||||||
@@ -57,10 +61,7 @@ public class NativeStartPlannerTest {
|
|||||||
@Test
|
@Test
|
||||||
public void undergroundBandOutsideWorldBoundsSkipsTheCandidate() {
|
public void undergroundBandOutsideWorldBoundsSkipsTheCandidate() {
|
||||||
Engine engine = engine(982374L, -64, 384, 90);
|
Engine engine = engine(982374L, -64, 384, 90);
|
||||||
IrisStructurePlacement placement = nativePlacement()
|
StructurePlacement placement = TestSettings.with(nativePlacement(), "underground", true, "minHeight", 500, "maxHeight", 600);
|
||||||
.setUnderground(true)
|
|
||||||
.setMinHeight(500)
|
|
||||||
.setMaxHeight(600);
|
|
||||||
|
|
||||||
assertNull(NativeStartPlanner.planAt(engine, placement, 12, -7));
|
assertNull(NativeStartPlanner.planAt(engine, placement, 12, -7));
|
||||||
}
|
}
|
||||||
@@ -68,16 +69,14 @@ public class NativeStartPlannerTest {
|
|||||||
@Test
|
@Test
|
||||||
public void surfacePlanUsesIrisTerrainAndHonorsHeightGate() {
|
public void surfacePlanUsesIrisTerrainAndHonorsHeightGate() {
|
||||||
Engine engine = engine(77L, -64, 384, 150);
|
Engine engine = engine(77L, -64, 384, 150);
|
||||||
IrisStructurePlacement placement = nativePlacement()
|
StructurePlacement placement = TestSettings.with(nativePlacement(), "minHeight", 80, "maxHeight", 90);
|
||||||
.setMinHeight(80)
|
|
||||||
.setMaxHeight(90);
|
|
||||||
|
|
||||||
NativeStartPlanner.Plan plan = NativeStartPlanner.planAt(engine, placement, 0, 0);
|
NativeStartPlanner.Plan plan = NativeStartPlanner.planAt(engine, placement, 0, 0);
|
||||||
|
|
||||||
assertNotNull(plan);
|
assertNotNull(plan);
|
||||||
assertEquals(86, plan.baseY());
|
assertEquals(86, plan.baseY());
|
||||||
|
|
||||||
placement.setMinHeight(87);
|
TestSettings.with(placement, "minHeight", 87);
|
||||||
assertNull(NativeStartPlanner.planAt(engine, placement, 0, 0));
|
assertNull(NativeStartPlanner.planAt(engine, placement, 0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,14 +84,10 @@ public class NativeStartPlannerTest {
|
|||||||
public void aPlanBecomesAStartWithHeightsAboveTheBottomAndThePlacementsFitAndIdentity() {
|
public void aPlanBecomesAStartWithHeightsAboveTheBottomAndThePlacementsFitAndIdentity() {
|
||||||
Gson json = new Gson();
|
Gson json = new Gson();
|
||||||
StructureTerrain terrain = json.fromJson("{\"mode\":\"FORCE_CARVE\",\"horizontalPadding\":24}", StructureTerrain.class);
|
StructureTerrain terrain = json.fromJson("{\"mode\":\"FORCE_CARVE\",\"horizontalPadding\":24}", StructureTerrain.class);
|
||||||
IrisStructurePlacement placement = nativePlacement()
|
StructurePlacement placement = TestSettings.with(nativePlacement(), "underground", true, "nativeSuppression", NativeStructureSuppression.REPLACE_SOURCE, "terrain", terrain, "stilt", json.fromJson("{\"spacing\":3}", StructureStilts.class));
|
||||||
.setUnderground(true)
|
TestSettings.with(placement.nativeStructures().getFirst(), "jigsaw", JigsawOverrides.none().withMaxDepth(4));
|
||||||
.setNativeSuppression(NativeStructureSuppression.REPLACE_SOURCE)
|
|
||||||
.setTerrain(terrain)
|
|
||||||
.setStilt(json.fromJson("{\"spacing\":3}", StructureStilts.class));
|
|
||||||
placement.getNativeStructures().getFirst().setJigsaw(JigsawOverrides.none().withMaxDepth(4));
|
|
||||||
NativeStartPlanner.Plan plan = new NativeStartPlanner.Plan(
|
NativeStartPlanner.Plan plan = new NativeStartPlanner.Plan(
|
||||||
placement, placement.getNativeStructures().getFirst(), 3, 5, -30);
|
placement, placement.nativeStructures().getFirst(), 3, 5, -30);
|
||||||
|
|
||||||
VanillaStructureStart start = StructureVanillaStructures.start(plan, -64);
|
VanillaStructureStart start = StructureVanillaStructures.start(plan, -64);
|
||||||
|
|
||||||
@@ -108,45 +103,45 @@ public class NativeStartPlannerTest {
|
|||||||
assertEquals(OptionalInt.of(4), start.jigsaw().orElseThrow().maxDepth());
|
assertEquals(OptionalInt.of(4), start.jigsaw().orElseThrow().maxDepth());
|
||||||
assertEquals("a source without jigsaw overrides has none", Optional.empty(),
|
assertEquals("a source without jigsaw overrides has none", Optional.empty(),
|
||||||
StructureVanillaStructures.start(new NativeStartPlanner.Plan(nativePlacement(),
|
StructureVanillaStructures.start(new NativeStartPlanner.Plan(nativePlacement(),
|
||||||
nativePlacement().getNativeStructures().getFirst(), 0, 0, 70), -64).jigsaw());
|
nativePlacement().nativeStructures().getFirst(), 0, 0, 70), -64).jigsaw());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void underwaterFlagRejectsSubmergedColumnsForSurfaceAndUndergroundPlans() {
|
public void underwaterFlagRejectsSubmergedColumnsForSurfaceAndUndergroundPlans() {
|
||||||
Engine engine = engine(77L, -64, 384, 63);
|
Engine engine = engine(77L, -64, 384, 63);
|
||||||
IrisStructurePlacement placement = nativePlacement();
|
StructurePlacement placement = nativePlacement();
|
||||||
|
|
||||||
assertNull(NativeStartPlanner.planAt(engine, placement, 0, 0));
|
assertNull(NativeStartPlanner.planAt(engine, placement, 0, 0));
|
||||||
|
|
||||||
placement.setUnderground(true).setMinHeight(-40).setMaxHeight(-20);
|
TestSettings.with(placement, "underground", true, "minHeight", -40, "maxHeight", -20);
|
||||||
assertNull(NativeStartPlanner.planAt(engine, placement, 0, 0));
|
assertNull(NativeStartPlanner.planAt(engine, placement, 0, 0));
|
||||||
|
|
||||||
placement.setUnderwater(true);
|
TestSettings.with(placement, "underwater", true);
|
||||||
assertNotNull(NativeStartPlanner.planAt(engine, placement, 0, 0));
|
assertNotNull(NativeStartPlanner.planAt(engine, placement, 0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void fluidHeightBoundaryIsShoreForPlannerAndLocator() {
|
public void fluidHeightBoundaryIsShoreForPlannerAndLocator() {
|
||||||
Engine engine = engine(77L, -64, 384, 64);
|
Engine engine = engine(77L, -64, 384, 64);
|
||||||
IrisStructurePlacement placement = nativePlacement();
|
StructurePlacement placement = nativePlacement();
|
||||||
|
|
||||||
assertTrue(!NativeStartPlanner.isSubmerged(engine, 8, 8));
|
assertTrue(!NativeStartPlanner.isSubmerged(engine, 8, 8));
|
||||||
assertNotNull(NativeStartPlanner.planAt(engine, placement, 0, 0));
|
assertNotNull(NativeStartPlanner.planAt(engine, placement, 0, 0));
|
||||||
|
|
||||||
placement.setUnderground(true).setMinHeight(-40).setMaxHeight(-20);
|
TestSettings.with(placement, "underground", true, "minHeight", -40, "maxHeight", -20);
|
||||||
assertNotNull(NativeStartPlanner.planAt(engine, placement, 0, 0));
|
assertNotNull(NativeStartPlanner.planAt(engine, placement, 0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void duplicateSelectedStructureUsesOneDeterministicPlan() {
|
public void duplicateSelectedStructureUsesOneDeterministicPlan() {
|
||||||
Engine engine = engine(77L, -64, 384, 150);
|
Engine engine = engine(77L, -64, 384, 150);
|
||||||
IrisStructurePlacement first = nativePlacement().setPlacementId("first");
|
StructurePlacement first = TestSettings.with(nativePlacement(), "placementId", "first");
|
||||||
IrisStructurePlacement second = nativePlacement().setPlacementId("second");
|
StructurePlacement second = TestSettings.with(nativePlacement(), "placementId", "second");
|
||||||
bindPlacements(engine, first, second);
|
bindPlacements(engine, first, second);
|
||||||
|
|
||||||
List<NativeStartPlanner.Plan> plans = NativeStartPlanner.plansAt(engine, 0, 0);
|
List<NativeStartPlanner.Plan> plans = NativeStartPlanner.plansAt(engine, 0, 0);
|
||||||
|
|
||||||
IrisStructurePlacement expected = Long.compareUnsigned(
|
StructurePlacement expected = Long.compareUnsigned(
|
||||||
StructurePlacementGrid.placementIdentity(first),
|
StructurePlacementGrid.placementIdentity(first),
|
||||||
StructurePlacementGrid.placementIdentity(second)) <= 0 ? first : second;
|
StructurePlacementGrid.placementIdentity(second)) <= 0 ? first : second;
|
||||||
assertEquals(1, plans.size());
|
assertEquals(1, plans.size());
|
||||||
@@ -155,10 +150,10 @@ public class NativeStartPlannerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void weightedNativeSelectionPreservesAuthoredSourceOrder() {
|
public void weightedNativeSelectionPreservesAuthoredSourceOrder() {
|
||||||
KList<IrisNativeStructure> first = new KList<>();
|
KList<NativeStructureSource> first = new KList<>();
|
||||||
first.add(new IrisNativeStructure().setStructure("test:a").setWeight(1));
|
first.add(nativeSource("test:a", 1));
|
||||||
first.add(new IrisNativeStructure().setStructure("test:b").setWeight(3));
|
first.add(nativeSource("test:b", 3));
|
||||||
KList<IrisNativeStructure> reordered = new KList<>();
|
KList<NativeStructureSource> reordered = new KList<>();
|
||||||
reordered.add(first.get(1));
|
reordered.add(first.get(1));
|
||||||
reordered.add(first.get(0));
|
reordered.add(first.get(0));
|
||||||
|
|
||||||
@@ -169,33 +164,29 @@ public class NativeStartPlannerTest {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
assertEquals("test:a", NativeStartPlanner
|
assertEquals("test:a", NativeStartPlanner
|
||||||
.selectSource(first, selectsFirstWeightSlot).getStructure());
|
.selectSource(first, selectsFirstWeightSlot).structure());
|
||||||
assertEquals("test:b", NativeStartPlanner
|
assertEquals("test:b", NativeStartPlanner
|
||||||
.selectSource(reordered, selectsFirstWeightSlot).getStructure());
|
.selectSource(reordered, selectsFirstWeightSlot).structure());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void placementMustChooseExactlyOneBackend() {
|
public void placementMustChooseExactlyOneBackend() {
|
||||||
assertInvalid(new IrisStructurePlacement());
|
assertInvalid(new StructurePlacement());
|
||||||
IrisStructurePlacement mixed = nativePlacement();
|
StructurePlacement mixed = nativePlacement();
|
||||||
mixed.getStructures().add("legacy");
|
withAdded(mixed, "structures", "legacy");
|
||||||
assertInvalid(mixed);
|
assertInvalid(mixed);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void nativeBackendRejectsEveryExplicitIrisAnchorMode() {
|
public void nativeBackendRejectsEveryExplicitIrisAnchorMode() {
|
||||||
assertUnsupportedAnchor(nativePlacement().setAnchor(IrisStructureAnchorMode.SURFACE));
|
assertUnsupportedAnchor(TestSettings.with(nativePlacement(), "anchor", StructureAnchorMode.SURFACE));
|
||||||
assertUnsupportedAnchor(nativePlacement().setAnchor(IrisStructureAnchorMode.HEIGHT_BAND));
|
assertUnsupportedAnchor(TestSettings.with(nativePlacement(), "anchor", StructureAnchorMode.HEIGHT_BAND));
|
||||||
assertUnsupportedAnchor(nativePlacement().setAnchor(IrisStructureAnchorMode.CAVE_FLOOR));
|
assertUnsupportedAnchor(TestSettings.with(nativePlacement(), "anchor", StructureAnchorMode.CAVE_FLOOR));
|
||||||
}
|
}
|
||||||
|
|
||||||
private IrisStructurePlacement nativePlacement() {
|
private StructurePlacement nativePlacement() {
|
||||||
IrisStructurePlacement placement = new IrisStructurePlacement()
|
StructurePlacement placement = placement("distribution", StructureDistribution.DENSITY, "density", 1D);
|
||||||
.setDistribution(StructureDistribution.DENSITY)
|
withAdded(placement, "nativeStructures", nativeSource("minecraft:ancient_city", 1));
|
||||||
.setDensity(1D);
|
|
||||||
placement.getNativeStructures().add(new IrisNativeStructure()
|
|
||||||
.setStructure("minecraft:ancient_city")
|
|
||||||
.setWeight(1));
|
|
||||||
return placement;
|
return placement;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,18 +204,16 @@ public class NativeStartPlannerTest {
|
|||||||
return engine;
|
return engine;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void bindPlacements(Engine engine, IrisStructurePlacement... placements) {
|
private void bindPlacements(Engine engine, StructurePlacement... placements) {
|
||||||
IrisDimension dimension = engine.getDimension();
|
IrisDimension dimension = engine.getDimension();
|
||||||
KList<IrisStructurePlacement> configured = new KList<>();
|
when(engine.getData()).thenReturn(mock(IrisData.class));
|
||||||
for (IrisStructurePlacement placement : placements) {
|
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
|
||||||
configured.add(placement);
|
when(dimension.getModuleSettings()).thenReturn(declaring(placements));
|
||||||
}
|
|
||||||
when(dimension.getStructures()).thenReturn(configured);
|
|
||||||
when(dimension.getAllRegions(engine)).thenReturn(new KList<>());
|
when(dimension.getAllRegions(engine)).thenReturn(new KList<>());
|
||||||
when(dimension.getReachableBiomes(engine)).thenReturn(new KList<>());
|
when(dimension.getReachableBiomes(engine)).thenReturn(new KList<>());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertInvalid(IrisStructurePlacement placement) {
|
private void assertInvalid(StructurePlacement placement) {
|
||||||
try {
|
try {
|
||||||
NativeStartPlanner.validateBackend(placement);
|
NativeStartPlanner.validateBackend(placement);
|
||||||
fail("Expected an invalid structure backend");
|
fail("Expected an invalid structure backend");
|
||||||
@@ -233,7 +222,7 @@ public class NativeStartPlannerTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertUnsupportedAnchor(IrisStructurePlacement placement) {
|
private void assertUnsupportedAnchor(StructurePlacement placement) {
|
||||||
try {
|
try {
|
||||||
NativeStartPlanner.validateBackend(placement);
|
NativeStartPlanner.validateBackend(placement);
|
||||||
fail("Expected native structure anchor rejection");
|
fail("Expected native structure anchor rejection");
|
||||||
|
|||||||
+6
-4
@@ -3,13 +3,15 @@ package art.arcane.iris.engine.mantle.components;
|
|||||||
import art.arcane.iris.engine.framework.IrisStructureLocator;
|
import art.arcane.iris.engine.framework.IrisStructureLocator;
|
||||||
import art.arcane.iris.engine.framework.PlacedStructurePiece;
|
import art.arcane.iris.engine.framework.PlacedStructurePiece;
|
||||||
import art.arcane.iris.engine.object.structure.IrisStructure;
|
import art.arcane.iris.engine.object.structure.IrisStructure;
|
||||||
import art.arcane.iris.engine.object.structure.IrisStructurePlacement;
|
import art.arcane.iris.builtin.structure.StructurePlacement;
|
||||||
import art.arcane.iris.engine.object.structure.vanilla.NativeStructureSuppression;
|
import art.arcane.iris.builtin.structure.NativeStructureSuppression;
|
||||||
import art.arcane.iris.spi.PlatformBlockState;
|
import art.arcane.iris.spi.PlatformBlockState;
|
||||||
import art.arcane.volmlib.util.collection.KList;
|
import art.arcane.volmlib.util.collection.KList;
|
||||||
import art.arcane.volmlib.util.math.RNG;
|
import art.arcane.volmlib.util.math.RNG;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static art.arcane.iris.engine.framework.StructurePlacementFixtures.placement;
|
||||||
|
import static art.arcane.iris.engine.framework.StructurePlacementFixtures.withAdded;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertNotEquals;
|
import static org.junit.Assert.assertNotEquals;
|
||||||
@@ -95,8 +97,8 @@ public class StructurePlacingMarkerTest {
|
|||||||
NativeStructureSuppression suppression,
|
NativeStructureSuppression suppression,
|
||||||
KList<PlacedStructurePiece> pieces
|
KList<PlacedStructurePiece> pieces
|
||||||
) {
|
) {
|
||||||
IrisStructurePlacement placement = new IrisStructurePlacement().setNativeSuppression(suppression);
|
StructurePlacement placement = placement("nativeSuppression", suppression);
|
||||||
placement.getStructures().add("test:city");
|
withAdded(placement, "structures", "test:city");
|
||||||
IrisStructure structure = new IrisStructure();
|
IrisStructure structure = new IrisStructure();
|
||||||
structure.setLoadKey("test:city");
|
structure.setLoadKey("test:city");
|
||||||
return new IrisStructureLocator.ResolvedPlacement(
|
return new IrisStructureLocator.ResolvedPlacement(
|
||||||
|
|||||||
-35
@@ -1,35 +0,0 @@
|
|||||||
package art.arcane.iris.engine.object.structure;
|
|
||||||
|
|
||||||
import art.arcane.iris.engine.object.structure.IrisStructureAnchorMode;
|
|
||||||
import art.arcane.iris.engine.object.structure.IrisStructurePlacement;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.assertFalse;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
public class IrisStructureAnchorModeTest {
|
|
||||||
@Test
|
|
||||||
public void legacyPreservesUndergroundBehavior() {
|
|
||||||
IrisStructurePlacement surface = new IrisStructurePlacement();
|
|
||||||
IrisStructurePlacement underground = new IrisStructurePlacement().setUnderground(true);
|
|
||||||
|
|
||||||
assertEquals(IrisStructureAnchorMode.SURFACE, surface.resolvedAnchor());
|
|
||||||
assertEquals(IrisStructureAnchorMode.HEIGHT_BAND, underground.resolvedAnchor());
|
|
||||||
assertFalse(surface.isAnchoredUnderground());
|
|
||||||
assertTrue(underground.isAnchoredUnderground());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void explicitAnchorOverridesLegacyBoolean() {
|
|
||||||
IrisStructurePlacement floor = new IrisStructurePlacement()
|
|
||||||
.setUnderground(false)
|
|
||||||
.setAnchor(IrisStructureAnchorMode.CAVE_FLOOR);
|
|
||||||
IrisStructurePlacement surface = new IrisStructurePlacement()
|
|
||||||
.setUnderground(true)
|
|
||||||
.setAnchor(IrisStructureAnchorMode.SURFACE);
|
|
||||||
|
|
||||||
assertTrue(floor.isAnchoredUnderground());
|
|
||||||
assertFalse(surface.isAnchoredUnderground());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+19
-17
@@ -10,12 +10,12 @@ import art.arcane.iris.engine.framework.Engine;
|
|||||||
import art.arcane.iris.engine.framework.EngineGeneration;
|
import art.arcane.iris.engine.framework.EngineGeneration;
|
||||||
import art.arcane.iris.engine.mantle.components.StructureModule;
|
import art.arcane.iris.engine.mantle.components.StructureModule;
|
||||||
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
||||||
import art.arcane.iris.engine.object.structure.vanilla.IrisNativeStructure;
|
import art.arcane.iris.builtin.structure.NativeStructureSource;
|
||||||
import art.arcane.iris.engine.object.structure.IrisStructure;
|
import art.arcane.iris.engine.object.structure.IrisStructure;
|
||||||
import art.arcane.iris.engine.object.structure.IrisStructurePlacement;
|
import art.arcane.iris.builtin.structure.StructurePlacement;
|
||||||
import art.arcane.iris.engine.object.world.IrisWorld;
|
import art.arcane.iris.engine.object.world.IrisWorld;
|
||||||
import art.arcane.iris.engine.framework.NativeStructureGenerationStatus;
|
import art.arcane.iris.engine.framework.NativeStructureGenerationStatus;
|
||||||
import art.arcane.iris.engine.object.structure.StructureDistribution;
|
import art.arcane.iris.builtin.structure.StructureDistribution;
|
||||||
import art.arcane.iris.spi.IrisPlatform;
|
import art.arcane.iris.spi.IrisPlatform;
|
||||||
import art.arcane.iris.spi.IrisPlatforms;
|
import art.arcane.iris.spi.IrisPlatforms;
|
||||||
import art.arcane.iris.spi.PlatformStructureHooks;
|
import art.arcane.iris.spi.PlatformStructureHooks;
|
||||||
@@ -30,7 +30,11 @@ import java.nio.file.Path;
|
|||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import art.arcane.iris.engine.object.TestSettings;
|
||||||
|
|
||||||
|
import static art.arcane.iris.engine.framework.StructurePlacementFixtures.nativeSource;
|
||||||
|
import static art.arcane.iris.engine.framework.StructurePlacementFixtures.placementSettings;
|
||||||
|
import static art.arcane.iris.engine.framework.StructurePlacementFixtures.withAdded;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertSame;
|
import static org.junit.Assert.assertSame;
|
||||||
@@ -89,7 +93,7 @@ public class StructureHandlerTest {
|
|||||||
StructureSettings settings = new StructureSettings(List.of("pack:disabled", "pack:replacement", "pack:dormant_replacement"),
|
StructureSettings settings = new StructureSettings(List.of("pack:disabled", "pack:replacement", "pack:dormant_replacement"),
|
||||||
List.of(), 0, true, List.of(), List.of());
|
List.of(), 0, true, List.of(), List.of());
|
||||||
|
|
||||||
KList<IrisStructurePlacement> placements = new KList<>();
|
KList<StructurePlacement> placements = new KList<>();
|
||||||
placements.add(nativePlacement("pack:replacement", StructureDistribution.RANDOM_SPREAD, 1.0));
|
placements.add(nativePlacement("pack:replacement", StructureDistribution.RANDOM_SPREAD, 1.0));
|
||||||
placements.add(nativePlacement("pack:dormant_replacement", StructureDistribution.DENSITY, 0.0));
|
placements.add(nativePlacement("pack:dormant_replacement", StructureDistribution.DENSITY, 0.0));
|
||||||
placements.add(nativePlacement("pack:explicit", StructureDistribution.RANDOM_SPREAD, 1.0));
|
placements.add(nativePlacement("pack:explicit", StructureDistribution.RANDOM_SPREAD, 1.0));
|
||||||
@@ -114,8 +118,7 @@ public class StructureHandlerTest {
|
|||||||
when(engine.getMinHeight()).thenReturn(-64);
|
when(engine.getMinHeight()).thenReturn(-64);
|
||||||
when(engine.getHeight()).thenReturn(384);
|
when(engine.getHeight()).thenReturn(384);
|
||||||
when(world.platformWorld()).thenReturn(platformWorld);
|
when(world.platformWorld()).thenReturn(platformWorld);
|
||||||
when(dimension.getModuleSettings()).thenReturn(BuiltInPack.settings(settings));
|
when(dimension.getModuleSettings()).thenReturn(BuiltInPack.settings(settings, placementSettings(placements)));
|
||||||
when(dimension.getStructures()).thenReturn(placements);
|
|
||||||
when(dimension.getAllRegions(engine)).thenReturn(new KList<>());
|
when(dimension.getAllRegions(engine)).thenReturn(new KList<>());
|
||||||
when(dimension.getReachableBiomes(engine)).thenReturn(new KList<>());
|
when(dimension.getReachableBiomes(engine)).thenReturn(new KList<>());
|
||||||
when(platform.structureHooks()).thenReturn(hooks);
|
when(platform.structureHooks()).thenReturn(hooks);
|
||||||
@@ -169,7 +172,7 @@ public class StructureHandlerTest {
|
|||||||
IrisStructure replacement = new IrisStructure();
|
IrisStructure replacement = new IrisStructure();
|
||||||
replacement.setLoadKey("iris:replacement");
|
replacement.setLoadKey("iris:replacement");
|
||||||
replacement.setVanillaSource("minecraft:replacement");
|
replacement.setVanillaSource("minecraft:replacement");
|
||||||
KList<IrisStructurePlacement> placements = new KList<>();
|
KList<StructurePlacement> placements = new KList<>();
|
||||||
placements.add(editablePlacement("iris:editable_definition"));
|
placements.add(editablePlacement("iris:editable_definition"));
|
||||||
placements.add(editablePlacement("iris:replacement_definition"));
|
placements.add(editablePlacement("iris:replacement_definition"));
|
||||||
placements.add(nativePlacement("minecraft:explicit", StructureDistribution.RANDOM_SPREAD, 1.0));
|
placements.add(nativePlacement("minecraft:explicit", StructureDistribution.RANDOM_SPREAD, 1.0));
|
||||||
@@ -185,8 +188,7 @@ public class StructureHandlerTest {
|
|||||||
when(engine.getMinHeight()).thenReturn(-64);
|
when(engine.getMinHeight()).thenReturn(-64);
|
||||||
when(engine.getHeight()).thenReturn(384);
|
when(engine.getHeight()).thenReturn(384);
|
||||||
when(world.platformWorld()).thenReturn(platformWorld);
|
when(world.platformWorld()).thenReturn(platformWorld);
|
||||||
when(dimension.getModuleSettings()).thenReturn(BuiltInPack.settings(settings));
|
when(dimension.getModuleSettings()).thenReturn(BuiltInPack.settings(settings, placementSettings(placements)));
|
||||||
when(dimension.getStructures()).thenReturn(placements);
|
|
||||||
when(dimension.getAllRegions(engine)).thenReturn(new KList<>());
|
when(dimension.getAllRegions(engine)).thenReturn(new KList<>());
|
||||||
when(dimension.getReachableBiomes(engine)).thenReturn(new KList<>());
|
when(dimension.getReachableBiomes(engine)).thenReturn(new KList<>());
|
||||||
when(platform.structureHooks()).thenReturn(hooks);
|
when(platform.structureHooks()).thenReturn(hooks);
|
||||||
@@ -252,18 +254,18 @@ public class StructureHandlerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static IrisStructurePlacement nativePlacement(String key, StructureDistribution distribution,
|
private static StructurePlacement nativePlacement(String key, StructureDistribution distribution,
|
||||||
double density) {
|
double density) {
|
||||||
IrisStructurePlacement placement = new IrisStructurePlacement();
|
StructurePlacement placement = new StructurePlacement();
|
||||||
placement.getNativeStructures().add(new IrisNativeStructure().setStructure(key));
|
withAdded(placement, "nativeStructures", nativeSource(key));
|
||||||
placement.setDistribution(distribution);
|
TestSettings.with(placement, "distribution", distribution);
|
||||||
placement.setDensity(density);
|
TestSettings.with(placement, "density", density);
|
||||||
return placement;
|
return placement;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IrisStructurePlacement editablePlacement(String key) {
|
private static StructurePlacement editablePlacement(String key) {
|
||||||
IrisStructurePlacement placement = new IrisStructurePlacement();
|
StructurePlacement placement = new StructurePlacement();
|
||||||
placement.getStructures().add(key);
|
withAdded(placement, "structures", key);
|
||||||
return placement;
|
return placement;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user