mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 08:44:50 +00:00
Merge branch 'wave2/e2' into feat/irisapi-host
# Conflicts: # core/src/test/java/art/arcane/iris/core/project/SchemaBuilderParityTest.java
This commit is contained in:
commit
9e69f0666d
40 files changed
+1421
-477
No files matched your search
+1
-1
@@ -18,6 +18,7 @@
|
||||
|
||||
package art.arcane.iris.core.commands;
|
||||
|
||||
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
|
||||
import art.arcane.iris.engine.framework.structure.StructureResources;
|
||||
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
|
||||
import art.arcane.iris.Iris;
|
||||
@@ -39,7 +40,6 @@ import art.arcane.iris.engine.object.structure.vanilla.IrisNativeStructureDecisi
|
||||
import art.arcane.iris.engine.object.value.IrisPosition;
|
||||
import art.arcane.iris.engine.object.structure.IrisStructure;
|
||||
import art.arcane.iris.engine.object.structure.vanilla.NativeStructureGenerationStatus;
|
||||
import art.arcane.iris.engine.object.placement.ObjectPlaceMode;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.iris.util.common.director.DirectorExecutor;
|
||||
import art.arcane.iris.util.common.format.C;
|
||||
|
||||
+1
-1
@@ -18,6 +18,7 @@
|
||||
|
||||
package art.arcane.iris.modded.command;
|
||||
|
||||
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
|
||||
import art.arcane.iris.engine.framework.structure.StructureResources;
|
||||
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
|
||||
import art.arcane.iris.modded.ModdedIrisLog;
|
||||
@@ -29,7 +30,6 @@ import art.arcane.iris.engine.framework.StructureAssembler;
|
||||
import art.arcane.iris.engine.framework.structure.StructureAssemblyResult;
|
||||
import art.arcane.iris.engine.object.value.IrisPosition;
|
||||
import art.arcane.iris.engine.object.structure.IrisStructure;
|
||||
import art.arcane.iris.engine.object.placement.ObjectPlaceMode;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
|
||||
@@ -698,11 +698,11 @@ public class IrisData implements ExclusionStrategy, TypeAdapterFactory {
|
||||
|
||||
@Override
|
||||
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) {
|
||||
if (!typeToken.getRawType().isAnnotationPresent(Snippet.class)) {
|
||||
String snippetType = snippetFolder(typeToken.getRawType());
|
||||
if (snippetType == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String snippetType = typeToken.getRawType().getDeclaredAnnotation(Snippet.class).value();
|
||||
String snippedBase = "snippet/" + snippetType + "/";
|
||||
|
||||
return new TypeAdapter<>() {
|
||||
@@ -752,6 +752,17 @@ public class IrisData implements ExclusionStrategy, TypeAdapterFactory {
|
||||
};
|
||||
}
|
||||
|
||||
/** The snippet folder of a class Iris's or a built-in module's {@code @Snippet} names, or null. */
|
||||
private static String snippetFolder(Class<?> type) {
|
||||
if (type.isAnnotationPresent(Snippet.class)) {
|
||||
return type.getDeclaredAnnotation(Snippet.class).value();
|
||||
}
|
||||
if (type.isAnnotationPresent(com.volmit.config.Snippet.class)) {
|
||||
return type.getDeclaredAnnotation(com.volmit.config.Snippet.class).value();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public KList<String> getPossibleSnippets(String f) {
|
||||
return possibleSnippets.computeIfAbsent(f, (k) -> {
|
||||
KList<String> l = new KList<>();
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
package art.arcane.iris.core.modules;
|
||||
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.data.cache.LazyBoundedCache;
|
||||
import art.arcane.iris.engine.object.material.IrisBlockData;
|
||||
import art.arcane.iris.engine.object.material.IrisMaterialPalette;
|
||||
import art.arcane.iris.engine.object.prefab.TileData;
|
||||
@@ -51,9 +52,12 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
* the seed the palette's old {@code RNG} had.
|
||||
*/
|
||||
final class IrisBlockRegistry implements BlockRegistry {
|
||||
/** Enough for the palettes of a pack with their world seeds; seeds that differ per call (a placement's) wear out the oldest. */
|
||||
private static final int PALETTE_CACHE_SIZE = 256;
|
||||
|
||||
private final IrisData data;
|
||||
private final Map<BlockSpec, IrisBlockData> specs = new ConcurrentHashMap<>();
|
||||
private final Map<SeededPalette, PaletteSampler> palettes = new ConcurrentHashMap<>();
|
||||
private final LazyBoundedCache<SeededPalette, PaletteSampler> palettes = new LazyBoundedCache<>(PALETTE_CACHE_SIZE);
|
||||
|
||||
/** @param data the pack whose {@code blocks} folder custom blocks come from */
|
||||
IrisBlockRegistry(IrisData data) {
|
||||
|
||||
@@ -129,8 +129,11 @@ public final class IrisValues {
|
||||
return map;
|
||||
}
|
||||
|
||||
/** {@code style} as the generator style Iris builds noise from; a style name Iris does not know is flat. */
|
||||
static IrisGeneratorStyle generatorStyle(com.volmit.noise.NoiseStyle style) {
|
||||
/**
|
||||
* {@code style} as the generator style Iris builds noise from; a style name Iris does not know is flat. For behaviour that
|
||||
* reads Iris's generator itself, such as the cave carvers' signed 3D reads, which {@code PackResources.noise()} does not offer.
|
||||
*/
|
||||
public static IrisGeneratorStyle generatorStyle(com.volmit.noise.NoiseStyle style) {
|
||||
IrisGeneratorStyle iris = new IrisGeneratorStyle(irisStyle(style.style()));
|
||||
iris.setCellularFrequency(style.cellularFrequency());
|
||||
iris.setCellularZoom(style.cellularZoom());
|
||||
@@ -144,6 +147,16 @@ public final class IrisValues {
|
||||
return iris;
|
||||
}
|
||||
|
||||
/** {@code range} as the range Iris reads the same JSON into. */
|
||||
public static IrisRange range(Range range) {
|
||||
return new IrisRange(range.min(), range.max());
|
||||
}
|
||||
|
||||
/** {@code range} as the styled range Iris reads the same JSON into. */
|
||||
public static IrisStyledRange styledRange(StyledRange range) {
|
||||
return new IrisStyledRange(range.min(), range.max(), generatorStyle(range.style()));
|
||||
}
|
||||
|
||||
private static NoiseStyle irisStyle(String name) {
|
||||
try {
|
||||
return NoiseStyle.valueOf(name);
|
||||
|
||||
@@ -115,8 +115,13 @@ final class ModuleSchemaRenderer {
|
||||
return property;
|
||||
}
|
||||
|
||||
/** Whether the pack's modules describe the class {@code typeName}. */
|
||||
boolean describes(String typeName) {
|
||||
return schema.types().stream().anyMatch(type -> type.name().equals(typeName));
|
||||
}
|
||||
|
||||
/** The definition key of a settings class, built the first time a property names it. */
|
||||
private String definition(String typeName) {
|
||||
String definition(String typeName) {
|
||||
String key = DEFINITION_PREFIX + typeName.replace('.', '-').replace('$', '-').toLowerCase(Locale.ROOT);
|
||||
if (definitions.containsKey(key)) {
|
||||
return key;
|
||||
|
||||
@@ -81,6 +81,7 @@ import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
@@ -394,13 +395,7 @@ public class SchemaBuilder {
|
||||
|
||||
/** Iris's own definition of one of its classes that a built-in module's settings hold, as Iris's fields describe it. */
|
||||
private String hostDefinition(String typeName) {
|
||||
Class<?> type = hostType(typeName);
|
||||
String key = objectDefinitionKey(type);
|
||||
if (!definitions.containsKey(key)) {
|
||||
definitions.put(key, new JSONObject());
|
||||
definitions.put(key, buildProperties(type));
|
||||
}
|
||||
return key;
|
||||
return objectDefinition(hostType(typeName));
|
||||
}
|
||||
|
||||
private static Class<?> hostType(String typeName) {
|
||||
@@ -411,6 +406,24 @@ public class SchemaBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
/** The definition key of a class an Iris field holds: the module's own description of a held type, else Iris's. */
|
||||
private String objectDefinition(Class<?> type) {
|
||||
if (isHeldType(type)) {
|
||||
return moduleSchemas().definition(type.getName());
|
||||
}
|
||||
String key = objectDefinitionKey(type);
|
||||
if (!definitions.containsKey(key)) {
|
||||
definitions.put(key, new JSONObject());
|
||||
definitions.put(key, buildProperties(type));
|
||||
}
|
||||
return key;
|
||||
}
|
||||
|
||||
/** Whether a built-in module registered {@code type} because Iris's classes hold it, so its fields are the module's. */
|
||||
private boolean isHeldType(Class<?> type) {
|
||||
return type.isAnnotationPresent(com.volmit.config.Desc.class) && moduleSchemas().describes(type.getName());
|
||||
}
|
||||
|
||||
private static String objectDefinitionKey(Class<?> type) {
|
||||
return "obj-" + type.getCanonicalName().replaceAll("\\Q.\\E", "-").toLowerCase();
|
||||
}
|
||||
@@ -721,12 +734,7 @@ public class SchemaBuilder {
|
||||
}
|
||||
} else {
|
||||
fancyType = k.getType().getSimpleName().replaceAll("\\QIris\\E", "") + " (Object)";
|
||||
String key = objectDefinitionKey(k.getType());
|
||||
if (!definitions.containsKey(key)) {
|
||||
definitions.put(key, new JSONObject());
|
||||
definitions.put(key, buildProperties(k.getType()));
|
||||
}
|
||||
prop.put("$ref", "#/definitions/" + key);
|
||||
prop.put("$ref", "#/definitions/" + objectDefinition(k.getType()));
|
||||
}
|
||||
}
|
||||
case "array" -> {
|
||||
@@ -749,13 +757,8 @@ public class SchemaBuilder {
|
||||
case "number" -> fancyType = "List of Numbers";
|
||||
case "object" -> {
|
||||
fancyType = "List of " + t.type().getSimpleName().replaceAll("\\QIris\\E", "") + "s (Objects)";
|
||||
String key = objectDefinitionKey(t.type());
|
||||
if (!definitions.containsKey(key)) {
|
||||
definitions.put(key, new JSONObject());
|
||||
definitions.put(key, buildProperties(t.type()));
|
||||
}
|
||||
JSONObject items = new JSONObject();
|
||||
items.put("$ref", "#/definitions/" + key);
|
||||
items.put("$ref", "#/definitions/" + objectDefinition(t.type()));
|
||||
prop.put("items", items);
|
||||
}
|
||||
case "string" -> {
|
||||
@@ -868,16 +871,16 @@ public class SchemaBuilder {
|
||||
boolean present = !typeDesc.isBlank();
|
||||
if (present) d.add(typeDesc);
|
||||
|
||||
Snippet snippet = k.getType().getDeclaredAnnotation(Snippet.class);
|
||||
if (snippet == null) {
|
||||
Optional<String> snippetFolder = snippetFolder(k.getType());
|
||||
if (snippetFolder.isEmpty()) {
|
||||
ArrayType array = k.getType().getDeclaredAnnotation(ArrayType.class);
|
||||
if (array != null) {
|
||||
snippet = array.type().getDeclaredAnnotation(Snippet.class);
|
||||
snippetFolder = snippetFolder(array.type());
|
||||
}
|
||||
}
|
||||
|
||||
if (snippet != null) {
|
||||
String sm = snippet.value();
|
||||
if (snippetFolder.isPresent()) {
|
||||
String sm = snippetFolder.get();
|
||||
if (present) d.add(" ");
|
||||
d.add("You can instead specify \"snippet/" + sm + "/some-name.json\" to use a snippet file instead of specifying it here.");
|
||||
present = false;
|
||||
@@ -913,6 +916,16 @@ public class SchemaBuilder {
|
||||
return buildSnippet(prop, k.getType());
|
||||
}
|
||||
|
||||
/** The snippet folder of a class, as Iris's or the module's {@code @Snippet} names it. */
|
||||
private static Optional<String> snippetFolder(Class<?> type) {
|
||||
Snippet snippet = type.getDeclaredAnnotation(Snippet.class);
|
||||
if (snippet != null) {
|
||||
return Optional.of(snippet.value());
|
||||
}
|
||||
com.volmit.config.Snippet moduleSnippet = type.getDeclaredAnnotation(com.volmit.config.Snippet.class);
|
||||
return moduleSnippet == null ? Optional.empty() : Optional.of(moduleSnippet.value());
|
||||
}
|
||||
|
||||
private JSONObject buildSnippet(JSONObject prop, Class<?> type) {
|
||||
Snippet snippet = type.getDeclaredAnnotation(Snippet.class);
|
||||
if (snippet == null) return prop;
|
||||
@@ -980,15 +993,14 @@ public class SchemaBuilder {
|
||||
@NotNull
|
||||
private <T> String addEnum(Class<?> type, JSONObject prop, KList<String> description, T[] values, Function<T, String> function) {
|
||||
JSONArray a = new JSONArray();
|
||||
boolean advanced = type.isAnnotationPresent(Desc.class);
|
||||
boolean advanced = type.isAnnotationPresent(Desc.class) || type.isAnnotationPresent(com.volmit.config.Desc.class);
|
||||
for (T gg : values) {
|
||||
if (advanced) {
|
||||
try {
|
||||
JSONObject j = new JSONObject();
|
||||
String name = function.apply(gg);
|
||||
j.put("const", name);
|
||||
Desc dd = type.getField(name).getAnnotation(Desc.class);
|
||||
String desc = dd == null ? ("No Description for " + name) : dd.value();
|
||||
String desc = constantDescription(type, name);
|
||||
j.put("description", desc);
|
||||
j.put("x-intellij-html-description", desc.replace("\n", "<br>"));
|
||||
a.put(j);
|
||||
@@ -1013,6 +1025,16 @@ public class SchemaBuilder {
|
||||
return type.getSimpleName().replaceAll("\\QIris\\E", "");
|
||||
}
|
||||
|
||||
private static String constantDescription(Class<?> enumType, String name) throws NoSuchFieldException {
|
||||
Field constant = enumType.getField(name);
|
||||
Desc described = constant.getAnnotation(Desc.class);
|
||||
if (described != null) {
|
||||
return described.value();
|
||||
}
|
||||
com.volmit.config.Desc moduleDescribed = constant.getAnnotation(com.volmit.config.Desc.class);
|
||||
return moduleDescribed == null ? "No Description for " + name : moduleDescribed.value();
|
||||
}
|
||||
|
||||
private JSONObject buildBlockPropertyJson(PlatformBlockProperty property) {
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("type", property.jsonType());
|
||||
@@ -1087,7 +1109,8 @@ public class SchemaBuilder {
|
||||
return "object";
|
||||
}
|
||||
|
||||
if (!c.isAnnotationPresent(Desc.class) && c.getCanonicalName().startsWith("art.arcane.iris.")) {
|
||||
if (!c.isAnnotationPresent(Desc.class) && !c.isAnnotationPresent(com.volmit.config.Desc.class)
|
||||
&& c.getCanonicalName().startsWith("art.arcane.iris.")) {
|
||||
warnings.addIfMissing("Unsupported Type: " + c.getCanonicalName() + " Did you forget @Desc?");
|
||||
}
|
||||
|
||||
@@ -1109,6 +1132,10 @@ public class SchemaBuilder {
|
||||
return r.getDeclaredAnnotation(Desc.class).value();
|
||||
}
|
||||
|
||||
if (r.isAnnotationPresent(com.volmit.config.Desc.class)) {
|
||||
return r.getDeclaredAnnotation(com.volmit.config.Desc.class).value();
|
||||
}
|
||||
|
||||
if (!r.isPrimitive() && !r.equals(KList.class) && !r.equals(KMap.class) && r.getCanonicalName().startsWith("art.arcane.")) {
|
||||
warnings.addIfMissing("Missing @Desc on " + r.getSimpleName() + " in " + (r.getDeclaringClass() != null ? r.getDeclaringClass().getCanonicalName() : " NOSRC"));
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,5 +1,6 @@
|
||||
package art.arcane.iris.core.structure.export;
|
||||
|
||||
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
|
||||
import art.arcane.iris.engine.framework.structure.CompiledStructureGraph;
|
||||
import art.arcane.iris.engine.framework.structure.PlanarJigsawWorkcellResolver;
|
||||
import art.arcane.iris.engine.framework.structure.StructureGraphCompilation;
|
||||
@@ -16,7 +17,6 @@ import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawWorkcellArchetyp
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import art.arcane.iris.engine.object.value.IrisPosition;
|
||||
import art.arcane.iris.engine.object.structure.IrisStructure;
|
||||
import art.arcane.iris.engine.object.placement.ObjectPlaceMode;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import art.arcane.iris.util.common.math.IrisBlockVector;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
+1
-1
@@ -18,11 +18,11 @@
|
||||
|
||||
package art.arcane.iris.core.modules;
|
||||
|
||||
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
|
||||
import art.arcane.iris.builtin.IrisStages;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.object.placement.IObjectPlacer;
|
||||
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
|
||||
import art.arcane.iris.engine.object.placement.ObjectPlaceMode;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import art.arcane.iris.spi.IrisPlatform;
|
||||
import art.arcane.iris.spi.IrisPlatforms;
|
||||
|
||||
@@ -64,6 +64,7 @@ import art.arcane.iris.core.modules.ModuleResourceFixture;
|
||||
import com.volmit.FeatureAttachment.Target;
|
||||
import com.volmit.IrisFeature;
|
||||
import com.volmit.FeatureRegistry;
|
||||
import art.arcane.iris.core.modules.IrisModuleHost;
|
||||
import com.volmit.IrisModule;
|
||||
import com.volmit.ModuleInfo;
|
||||
import com.volmit.config.Feature;
|
||||
@@ -78,12 +79,14 @@ import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.UncheckedIOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
@@ -292,6 +295,34 @@ public class SchemaBuilderParityTest {
|
||||
assertFalse(properties.has("surfaceOpeningClearance"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void objectPlacementSchemaDescribesTheClassesItHoldsFromTheirModules() {
|
||||
JSONObject schema = new SchemaBuilder(IrisObjectPlacement.class, structureSchemaData()).construct();
|
||||
JSONObject definitions = schema.getJSONObject("definitions");
|
||||
JSONObject properties = rootProperties(schema);
|
||||
|
||||
JSONObject clamp = definitions.getJSONObject(definitionKey(properties.getJSONObject("clamp")));
|
||||
JSONObject clampProperties = clamp.getJSONArray("anyOf").getJSONObject(0).getJSONObject("properties");
|
||||
assertEquals("module-art-arcane-iris-builtin-validate-objectlimit", definitionKey(properties.getJSONObject("clamp")));
|
||||
assertEquals(-2048, clampProperties.getJSONObject("minimumHeight").getInt("minimum"));
|
||||
assertEquals(2048, clampProperties.getJSONObject("maximumHeight").getInt("maximum"));
|
||||
assertEquals("The maximum height for placement (top of object)", clampProperties.getJSONObject("maximumHeight").getString("description"));
|
||||
assertEquals("a held type may be a snippet, as its Iris class was", "^snippet/",
|
||||
clamp.getJSONArray("anyOf").getJSONObject(1).getString("pattern"));
|
||||
|
||||
JSONObject stilt = definitions.getJSONObject(definitionKey(properties.getJSONObject("stiltSettings")));
|
||||
JSONObject stiltProperties = stilt.getJSONArray("anyOf").getJSONObject(0).getJSONObject("properties");
|
||||
assertEquals(48, stiltProperties.getJSONObject("organicMaxScan").getInt("default"));
|
||||
JSONObject palette = definitions.getJSONObject(definitionKey(stiltProperties.getJSONObject("palette")));
|
||||
assertEquals("a held type's palette is Iris's palette", "obj-art-arcane-iris-engine-object-material-irismaterialpalette",
|
||||
definitionKey(palette.getJSONArray("anyOf").getJSONObject(0)));
|
||||
|
||||
JSONObject edit = properties.getJSONObject("edit");
|
||||
JSONObject replace = definitions.getJSONObject(definitionKey(edit.getJSONObject("items")));
|
||||
assertEquals("module-art-arcane-iris-builtin-blocks-objectreplace", definitionKey(edit.getJSONObject("items")));
|
||||
assertEquals(1, replace.getJSONArray("anyOf").getJSONObject(0).getJSONObject("properties").getJSONObject("find").getInt("minItems"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void objectPlacementSchemaRendersModuleSettingsUnderTheirId() throws IOException {
|
||||
JSONObject schema = new SchemaBuilder(IrisObjectPlacement.class, structureSchemaData(glowModuleSchema())).construct();
|
||||
@@ -379,7 +410,11 @@ public class SchemaBuilderParityTest {
|
||||
}
|
||||
|
||||
private static IrisData structureSchemaData() {
|
||||
return structureSchemaData(new PackSchema(List.of(), List.of(), List.of()));
|
||||
try {
|
||||
return structureSchemaData(schemaOfBuiltInsWith());
|
||||
} catch (IOException failure) {
|
||||
throw new UncheckedIOException(failure);
|
||||
}
|
||||
}
|
||||
|
||||
/** {@code modules} is what the pack's modules add to its JSON. */
|
||||
@@ -704,11 +739,7 @@ public class SchemaBuilderParityTest {
|
||||
}
|
||||
|
||||
private static PackSchema glowModuleSchema() throws IOException {
|
||||
Path root = Files.createTempDirectory("glow-pack");
|
||||
try (LoadedPack pack = LoadedPack.load(Files.createDirectory(root.resolve("pack")),
|
||||
ModuleHost.of(List.of(new GlowModule())).copyingJarsTo(Files.createDirectory(root.resolve("copies"))))) {
|
||||
return pack.schema();
|
||||
}
|
||||
return schemaOfBuiltInsWith(new GlowModule());
|
||||
}
|
||||
|
||||
/** The schema of {@code iris:structure}'s settings alone, without the module's stages. */
|
||||
@@ -738,9 +769,18 @@ public class SchemaBuilderParityTest {
|
||||
}
|
||||
|
||||
private static PackSchema tintModuleSchema() throws IOException {
|
||||
Path root = Files.createTempDirectory("tint-pack");
|
||||
return schemaOfBuiltInsWith(new TintModule());
|
||||
}
|
||||
|
||||
/** What the pack tells studio when Iris's built-in modules and {@code extra} are loaded: Iris's classes hold built-in types. */
|
||||
private static PackSchema schemaOfBuiltInsWith(IrisModule... extra) throws IOException {
|
||||
Path root = Files.createTempDirectory("schema-pack");
|
||||
List<IrisModule> modules = Stream.concat(IrisModuleHost.builtInModules().stream(), Stream.of(extra)).toList();
|
||||
try (LoadedPack pack = LoadedPack.load(Files.createDirectory(root.resolve("pack")),
|
||||
ModuleHost.of(List.of(new TintModule())).copyingJarsTo(Files.createDirectory(root.resolve("copies"))))) {
|
||||
ModuleHost.of(modules)
|
||||
.exposing(IrisModuleHost.BUILT_IN_API_PACKAGE)
|
||||
.describingHostTypesIn(IrisModuleHost.HOST_TYPE_PACKAGE)
|
||||
.copyingJarsTo(Files.createDirectory(root.resolve("copies"))))) {
|
||||
return pack.schema();
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,5 +1,6 @@
|
||||
package art.arcane.iris.core.structure;
|
||||
|
||||
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
|
||||
import art.arcane.iris.core.structure.export.VanillaJigsawDatapackExporter;
|
||||
import art.arcane.iris.core.structure.export.VanillaJigsawExportRequest;
|
||||
import art.arcane.iris.core.structure.export.VanillaJigsawExportResult;
|
||||
@@ -13,7 +14,6 @@ import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPieceEntry;
|
||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPool;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import art.arcane.iris.engine.object.structure.IrisStructure;
|
||||
import art.arcane.iris.engine.object.placement.ObjectPlaceMode;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.nbt.io.NBTUtil;
|
||||
|
||||
+3
-3
@@ -1,6 +1,7 @@
|
||||
package art.arcane.iris.core.structure.export;
|
||||
|
||||
import art.arcane.iris.engine.object.placement.IrisObjectReplace;
|
||||
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
|
||||
import art.arcane.iris.builtin.blocks.ObjectReplace;
|
||||
import art.arcane.iris.engine.framework.structure.StructureGraphResolver;
|
||||
import art.arcane.iris.engine.object.value.IrisDirection;
|
||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawBranchFailurePolicy;
|
||||
@@ -14,7 +15,6 @@ import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawThemeSet;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import art.arcane.iris.engine.object.value.IrisPosition;
|
||||
import art.arcane.iris.engine.object.structure.IrisStructure;
|
||||
import art.arcane.iris.engine.object.placement.ObjectPlaceMode;
|
||||
import art.arcane.iris.engine.object.prefab.TileData;
|
||||
import art.arcane.iris.spi.IrisPlatform;
|
||||
import art.arcane.iris.spi.IrisPlatforms;
|
||||
@@ -268,7 +268,7 @@ public class VanillaJigsawDatapackExporterTest {
|
||||
graph.structure.setPlaceMode(ObjectPlaceMode.CENTER_HEIGHT);
|
||||
graph.structure.setMaxDepth(21);
|
||||
graph.structure.setMaxSizeChunks(9);
|
||||
graph.structure.getEdit().add(new IrisObjectReplace());
|
||||
graph.structure.getEdit().add(new ObjectReplace());
|
||||
graph.structure.getLoot().add("loot/test");
|
||||
graph.structure.getThemeSets().add(new IrisJigsawThemeSet("variant-1", 1));
|
||||
graph.structure.setRequireCaps(true);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package art.arcane.iris.engine.decorator;
|
||||
|
||||
import art.arcane.iris.builtin.prepare.SlopeClip;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.IrisComplex;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
@@ -8,7 +9,6 @@ import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import art.arcane.iris.engine.object.decoration.IrisDecorationPart;
|
||||
import art.arcane.iris.engine.object.decoration.IrisDecorator;
|
||||
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
||||
import art.arcane.iris.engine.object.placement.IrisSlopeClip;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import art.arcane.iris.util.project.hunk.Hunk;
|
||||
import art.arcane.iris.util.project.stream.ProceduralStream;
|
||||
@@ -95,7 +95,7 @@ public class IrisShoreLineDecoratorTest {
|
||||
IrisData data = mock(IrisData.class);
|
||||
IrisBiome biome = mock(IrisBiome.class);
|
||||
IrisDecorator decorator = mock(IrisDecorator.class);
|
||||
IrisSlopeClip slope = mock(IrisSlopeClip.class);
|
||||
SlopeClip slope = mock(SlopeClip.class);
|
||||
PlatformBlockState decorant = mock(PlatformBlockState.class);
|
||||
ProceduralStream<Double> heightStream = mock(ProceduralStream.class);
|
||||
|
||||
|
||||
+1
-1
@@ -18,6 +18,7 @@
|
||||
|
||||
package art.arcane.iris.engine.framework;
|
||||
|
||||
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
|
||||
import art.arcane.iris.engine.framework.structure.StructureResources;
|
||||
import art.arcane.iris.core.modules.ModuleResourceFixture;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
@@ -39,7 +40,6 @@ import art.arcane.iris.engine.object.structure.IrisStructurePlacement;
|
||||
import art.arcane.iris.engine.object.structure.IrisStructureTerrain;
|
||||
import art.arcane.iris.engine.object.structure.IrisStructureTerrainMode;
|
||||
import art.arcane.iris.engine.object.structure.vanilla.NativeStructureSuppression;
|
||||
import art.arcane.iris.engine.object.placement.ObjectPlaceMode;
|
||||
import art.arcane.iris.engine.object.structure.StructureDistribution;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
|
||||
+22
-21
@@ -1,7 +1,8 @@
|
||||
package art.arcane.iris.engine.mantle.components;
|
||||
|
||||
import art.arcane.iris.builtin.carve.CaveProfile;
|
||||
import art.arcane.iris.engine.object.TestSettings;
|
||||
import art.arcane.iris.engine.object.value.IrisRange;
|
||||
import art.arcane.iris.engine.object.terrain.carving.IrisCaveProfile;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -24,7 +25,7 @@ public class CaveCarvingTop2BlendTest {
|
||||
@BeforeClass
|
||||
public static void setup() throws Exception {
|
||||
Class<?> weightedProfileClass = Class.forName("art.arcane.iris.engine.mantle.components.CaveCarving$WeightedProfile");
|
||||
weightedProfileConstructor = weightedProfileClass.getDeclaredConstructor(IrisCaveProfile.class, double[].class, double.class, Class.forName("art.arcane.iris.engine.object.value.IrisRange"), int.class);
|
||||
weightedProfileConstructor = weightedProfileClass.getDeclaredConstructor(CaveProfile.class, double[].class, double.class, Class.forName("art.arcane.iris.engine.object.value.IrisRange"), int.class);
|
||||
weightedProfileConstructor.setAccessible(true);
|
||||
limitMethod = CaveCarving.class.getDeclaredMethod("limitAndMergeBlendedProfiles", List.class, int.class, int.class);
|
||||
limitMethod.setAccessible(true);
|
||||
@@ -40,9 +41,9 @@ public class CaveCarvingTop2BlendTest {
|
||||
List<?> limited = invokeLimit(input.weightedProfiles(), 2);
|
||||
assertEquals(2, limited.size());
|
||||
|
||||
Map<IrisCaveProfile, double[]> byProfile = extractWeightsByProfile(limited);
|
||||
IrisCaveProfile first = input.profiles().first();
|
||||
IrisCaveProfile second = input.profiles().second();
|
||||
Map<CaveProfile, double[]> byProfile = extractWeightsByProfile(limited);
|
||||
CaveProfile first = input.profiles().first();
|
||||
CaveProfile second = input.profiles().second();
|
||||
|
||||
assertEquals(1.0D, byProfile.get(first)[1], 0D);
|
||||
assertEquals(1.0D, byProfile.get(second)[0], 0D);
|
||||
@@ -55,8 +56,8 @@ public class CaveCarvingTop2BlendTest {
|
||||
List<?> first = invokeLimit(firstInput.weightedProfiles(), 2);
|
||||
List<?> second = invokeLimit(secondInput.weightedProfiles(), 2);
|
||||
|
||||
Map<IrisCaveProfile, double[]> firstByProfile = extractWeightsByProfile(first);
|
||||
Map<IrisCaveProfile, double[]> secondByProfile = extractWeightsByProfile(second);
|
||||
Map<CaveProfile, double[]> firstByProfile = extractWeightsByProfile(first);
|
||||
Map<CaveProfile, double[]> secondByProfile = extractWeightsByProfile(second);
|
||||
|
||||
assertEquals(firstByProfile.get(firstInput.profiles().first())[0], secondByProfile.get(secondInput.profiles().first())[0], 0D);
|
||||
assertEquals(firstByProfile.get(firstInput.profiles().first())[1], secondByProfile.get(secondInput.profiles().first())[1], 0D);
|
||||
@@ -69,9 +70,9 @@ public class CaveCarvingTop2BlendTest {
|
||||
WeightedInput input = createWeightedProfiles();
|
||||
List<?> limited = invokeLimit(input.weightedProfiles(), 2);
|
||||
|
||||
Map<IrisCaveProfile, double[]> byProfile = extractWeightsByProfile(limited);
|
||||
IrisCaveProfile first = input.profiles().first();
|
||||
IrisCaveProfile second = input.profiles().second();
|
||||
Map<CaveProfile, double[]> byProfile = extractWeightsByProfile(limited);
|
||||
CaveProfile first = input.profiles().first();
|
||||
CaveProfile second = input.profiles().second();
|
||||
|
||||
assertEquals(1.0D, byProfile.get(first)[255], 0D);
|
||||
assertEquals(1.0D, byProfile.get(second)[254], 0D);
|
||||
@@ -79,9 +80,9 @@ public class CaveCarvingTop2BlendTest {
|
||||
|
||||
@Test
|
||||
public void topTwoTieBreaksBySequenceNotIdentity() throws Exception {
|
||||
IrisCaveProfile first = new IrisCaveProfile().setEnabled(true).setBaseWeight(1.0D);
|
||||
IrisCaveProfile second = new IrisCaveProfile().setEnabled(true).setBaseWeight(1.0D);
|
||||
IrisCaveProfile third = new IrisCaveProfile().setEnabled(true).setBaseWeight(1.0D);
|
||||
CaveProfile first = TestSettings.of(CaveProfile.class, "{\"enabled\":true,\"baseWeight\":1.0}");
|
||||
CaveProfile second = TestSettings.of(CaveProfile.class, "{\"enabled\":true,\"baseWeight\":1.0}");
|
||||
CaveProfile third = TestSettings.of(CaveProfile.class, "{\"enabled\":true,\"baseWeight\":1.0}");
|
||||
|
||||
double[] weightsA = new double[256];
|
||||
double[] weightsB = new double[256];
|
||||
@@ -98,16 +99,16 @@ public class CaveCarvingTop2BlendTest {
|
||||
List<?> limited = invokeLimit(weighted, 2);
|
||||
assertEquals(2, limited.size());
|
||||
|
||||
Map<IrisCaveProfile, double[]> byProfile = extractWeightsByProfile(limited);
|
||||
Map<CaveProfile, double[]> byProfile = extractWeightsByProfile(limited);
|
||||
assertEquals(true, byProfile.containsKey(first));
|
||||
assertEquals(true, byProfile.containsKey(second));
|
||||
assertEquals(false, byProfile.containsKey(third));
|
||||
}
|
||||
|
||||
private WeightedInput createWeightedProfiles() throws Exception {
|
||||
IrisCaveProfile first = new IrisCaveProfile().setEnabled(true).setBaseWeight(1.31D);
|
||||
IrisCaveProfile second = new IrisCaveProfile().setEnabled(true).setBaseWeight(1.17D);
|
||||
IrisCaveProfile third = new IrisCaveProfile().setEnabled(true).setBaseWeight(0.93D);
|
||||
CaveProfile first = TestSettings.of(CaveProfile.class, "{\"enabled\":true,\"baseWeight\":1.31}");
|
||||
CaveProfile second = TestSettings.of(CaveProfile.class, "{\"enabled\":true,\"baseWeight\":1.17}");
|
||||
CaveProfile third = TestSettings.of(CaveProfile.class, "{\"enabled\":true,\"baseWeight\":0.93}");
|
||||
Profiles profiles = new Profiles(first, second, third);
|
||||
|
||||
double[] firstWeights = new double[256];
|
||||
@@ -137,10 +138,10 @@ public class CaveCarvingTop2BlendTest {
|
||||
return (List<?>) limitMethod.invoke(null, weightedProfiles, limit, 256);
|
||||
}
|
||||
|
||||
private Map<IrisCaveProfile, double[]> extractWeightsByProfile(List<?> weightedProfiles) throws Exception {
|
||||
Map<IrisCaveProfile, double[]> byProfile = new IdentityHashMap<>();
|
||||
private Map<CaveProfile, double[]> extractWeightsByProfile(List<?> weightedProfiles) throws Exception {
|
||||
Map<CaveProfile, double[]> byProfile = new IdentityHashMap<>();
|
||||
for (Object weightedProfile : weightedProfiles) {
|
||||
IrisCaveProfile profile = (IrisCaveProfile) profileField.get(weightedProfile);
|
||||
CaveProfile profile = (CaveProfile) profileField.get(weightedProfile);
|
||||
double[] weights = (double[]) columnWeightsField.get(weightedProfile);
|
||||
byProfile.put(profile, weights);
|
||||
}
|
||||
@@ -155,7 +156,7 @@ public class CaveCarvingTop2BlendTest {
|
||||
return total / weights.length;
|
||||
}
|
||||
|
||||
private record Profiles(IrisCaveProfile first, IrisCaveProfile second, IrisCaveProfile third) {
|
||||
private record Profiles(CaveProfile first, CaveProfile second, CaveProfile third) {
|
||||
}
|
||||
|
||||
private record WeightedInput(List<Object> weightedProfiles, Profiles profiles) {
|
||||
|
||||
+5
-3
@@ -18,13 +18,15 @@
|
||||
|
||||
package art.arcane.iris.engine.mantle.components;
|
||||
|
||||
import art.arcane.iris.engine.framework.EngineGeneration;
|
||||
import art.arcane.iris.engine.object.TestSettings;
|
||||
import art.arcane.iris.builtin.floating.FloatingChildBiome;
|
||||
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.core.loader.ResourceLoader;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
||||
import art.arcane.iris.engine.object.terrain.floating.IrisFloatingChildBiomes;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObjectTranslate;
|
||||
import art.arcane.iris.spi.IrisPlatform;
|
||||
@@ -93,8 +95,7 @@ public class FloatingObjectPlacingBoundaryRadiusTest {
|
||||
IrisObjectPlacement placement = new IrisObjectPlacement()
|
||||
.setPlace(new KList<>("test/floating"))
|
||||
.setTranslate(new IrisObjectTranslate().setX(32));
|
||||
IrisFloatingChildBiomes floatingChild = new IrisFloatingChildBiomes()
|
||||
.setFloatingObjects(new KList<>(placement));
|
||||
FloatingChildBiome floatingChild = TestSettings.with(new FloatingChildBiome(), "floatingObjects", new KList<>(placement));
|
||||
IrisBiome biome = new IrisBiome().setFloatingChildBiomes(new KList<>(floatingChild));
|
||||
IrisDimension dimension = mock(IrisDimension.class);
|
||||
when(dimension.getReachableBiomes(org.mockito.ArgumentMatchers.any())).thenReturn(new KList<>(biome));
|
||||
@@ -107,6 +108,7 @@ public class FloatingObjectPlacingBoundaryRadiusTest {
|
||||
Engine engine = mock(Engine.class);
|
||||
when(engine.getDimension()).thenReturn(dimension);
|
||||
when(engine.getData()).thenReturn(data);
|
||||
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
|
||||
|
||||
assertEquals(33, new FloatingObjectPlacing(engine).reach());
|
||||
}
|
||||
|
||||
+5
-4
@@ -1,8 +1,9 @@
|
||||
package art.arcane.iris.engine.mantle.components;
|
||||
|
||||
import art.arcane.iris.builtin.floating.FloatingChildBiome;
|
||||
import art.arcane.iris.engine.object.terrain.floating.ResolvedFloatingChild;
|
||||
import art.arcane.iris.engine.object.terrain.floating.FloatingIslandSample;
|
||||
import art.arcane.iris.engine.object.placement.FloatingObjectFootprint;
|
||||
import art.arcane.iris.engine.object.terrain.floating.IrisFloatingChildBiomes;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObjectRotation;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -48,9 +49,9 @@ public class FloatingObjectPlacingInvertedPlacementTest {
|
||||
);
|
||||
}
|
||||
|
||||
private FloatingIslandSample sample(IrisFloatingChildBiomes entry) throws Exception {
|
||||
private FloatingIslandSample sample(ResolvedFloatingChild entry) throws Exception {
|
||||
Constructor<FloatingIslandSample> constructor = FloatingIslandSample.class.getDeclaredConstructor(
|
||||
IrisFloatingChildBiomes.class,
|
||||
ResolvedFloatingChild.class,
|
||||
int.class,
|
||||
int.class,
|
||||
int.class,
|
||||
@@ -110,7 +111,7 @@ public class FloatingObjectPlacingInvertedPlacementTest {
|
||||
|
||||
@Test
|
||||
public void topFootprintChecksNeighborChunkTerrain() throws Exception {
|
||||
IrisFloatingChildBiomes entry = new IrisFloatingChildBiomes();
|
||||
ResolvedFloatingChild entry = new ResolvedFloatingChild(new FloatingChildBiome());
|
||||
FloatingIslandSample sample = sample(entry);
|
||||
long[] cells = {0L, 1L << 32};
|
||||
FloatingObjectFootprint footprint = footprint(0, 0, 0, 0, cells);
|
||||
|
||||
+107
-159
@@ -1,13 +1,15 @@
|
||||
package art.arcane.iris.engine.mantle.components;
|
||||
|
||||
import art.arcane.iris.builtin.carve.CaveFieldModule;
|
||||
import art.arcane.iris.builtin.carve.CaveProfile;
|
||||
import art.arcane.iris.engine.object.TestSettings;
|
||||
import art.arcane.iris.engine.object.noise.IrisGeneratorStyle;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.framework.EngineMetrics;
|
||||
import art.arcane.iris.engine.framework.SeedManager;
|
||||
import art.arcane.iris.engine.mantle.MantleWriter;
|
||||
import art.arcane.iris.engine.object.terrain.carving.IrisCaveFieldModule;
|
||||
import art.arcane.iris.engine.object.terrain.carving.IrisCaveProfile;
|
||||
import art.arcane.iris.engine.object.terrain.carving.ResolvedCaveProfile;
|
||||
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
||||
import art.arcane.iris.engine.object.value.IrisRange;
|
||||
import art.arcane.iris.engine.object.noise.IrisStyledRange;
|
||||
@@ -29,6 +31,7 @@ import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
@@ -87,12 +90,12 @@ public class IrisCaveCarver3DNearParityTest {
|
||||
|
||||
@Test
|
||||
public void genericFluidContractKeepsOverworldDefaults() {
|
||||
IrisCaveProfile profile = new IrisCaveProfile();
|
||||
CaveProfile profile = new CaveProfile();
|
||||
IrisDimension dimension = new IrisDimension();
|
||||
|
||||
assertTrue(profile.isAllowFluid());
|
||||
assertEquals(12, profile.getFluidMinDepthBelowSurface());
|
||||
assertTrue(profile.isFluidRequiresFloor());
|
||||
assertTrue(profile.allowFluid());
|
||||
assertEquals(12, profile.fluidMinDepthBelowSurface());
|
||||
assertTrue(profile.fluidRequiresFloor());
|
||||
assertEquals("water", dimension.getFluidPalette().getPalette().get(0).getBlock());
|
||||
}
|
||||
|
||||
@@ -117,12 +120,12 @@ public class IrisCaveCarver3DNearParityTest {
|
||||
@Test
|
||||
public void warpCacheDoesNotCrossContaminateCarverInstancesOnSameThread() throws Exception {
|
||||
Engine engine = createEngine(128, 92);
|
||||
IrisCaveProfile firstProfile = createProfile(true, false);
|
||||
firstProfile.setWarpStyle(new IrisGeneratorStyle(NoiseStyle.SIMPLEX).zoomed(0.12D));
|
||||
IrisCaveProfile secondProfile = createProfile(true, false);
|
||||
secondProfile.setWarpStyle(new IrisGeneratorStyle(NoiseStyle.CELLULAR).zoomed(0.12D));
|
||||
IrisCaveProfile controlProfile = createProfile(true, false);
|
||||
controlProfile.setWarpStyle(new IrisGeneratorStyle(NoiseStyle.CELLULAR).zoomed(0.12D));
|
||||
CaveProfile firstProfile = createProfile(true, false);
|
||||
TestSettings.with(firstProfile, "warpStyle", com.volmit.noise.NoiseStyle.of("SIMPLEX").withZoom(0.12D));
|
||||
CaveProfile secondProfile = createProfile(true, false);
|
||||
TestSettings.with(secondProfile, "warpStyle", com.volmit.noise.NoiseStyle.of("CELLULAR").withZoom(0.12D));
|
||||
CaveProfile controlProfile = createProfile(true, false);
|
||||
TestSettings.with(controlProfile, "warpStyle", com.volmit.noise.NoiseStyle.of("CELLULAR").withZoom(0.12D));
|
||||
IrisCaveCarver3D firstCarver = new IrisCaveCarver3D(engine, firstProfile);
|
||||
IrisCaveCarver3D secondCarver = new IrisCaveCarver3D(engine, secondProfile);
|
||||
IrisCaveCarver3D controlCarver = new IrisCaveCarver3D(engine, controlProfile);
|
||||
@@ -172,22 +175,8 @@ public class IrisCaveCarver3DNearParityTest {
|
||||
|
||||
@Test
|
||||
public void flatSurfaceDoesNotHardClipLargeCaveCeiling() {
|
||||
assertFlatSurfaceCeiling(createFluidProfile()
|
||||
.setVerticalRange(new IrisRange(20D, 72D))
|
||||
.setAllowSurfaceBreak(false)
|
||||
.setSurfaceClearance(5)
|
||||
.setAllowFluid(false)
|
||||
.setAllowLava(false)
|
||||
.setAdaptiveSampling(false)
|
||||
.setSampleStep(1));
|
||||
assertFlatSurfaceCeiling(createFluidProfile()
|
||||
.setVerticalRange(new IrisRange(20D, 72D))
|
||||
.setAllowSurfaceBreak(false)
|
||||
.setSurfaceClearance(5)
|
||||
.setAllowFluid(false)
|
||||
.setAllowLava(false)
|
||||
.setAdaptiveSampling(true)
|
||||
.setSampleStep(1));
|
||||
assertFlatSurfaceCeiling(TestSettings.with(createFluidProfile(), "verticalRange", com.volmit.config.Range.of(20D, 72D), "allowSurfaceBreak", false, "surfaceClearance", 5, "allowFluid", false, "allowLava", false, "adaptiveSampling", false, "sampleStep", 1));
|
||||
assertFlatSurfaceCeiling(TestSettings.with(createFluidProfile(), "verticalRange", com.volmit.config.Range.of(20D, 72D), "allowSurfaceBreak", false, "surfaceClearance", 5, "allowFluid", false, "allowLava", false, "adaptiveSampling", true, "sampleStep", 1));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -207,12 +196,12 @@ public class IrisCaveCarver3DNearParityTest {
|
||||
int[] precomputedSurfaceHeights = filledHeights(90);
|
||||
IrisRange worldYRange = new IrisRange(0D, 88D);
|
||||
|
||||
IrisCaveProfile exactProfile = createProfile(true, true).setSampleStep(1).setAdaptiveSampling(false);
|
||||
CaveProfile exactProfile = TestSettings.with(createProfile(true, true), "sampleStep", 1, "adaptiveSampling", false);
|
||||
IrisCaveCarver3D exactCarver = new IrisCaveCarver3D(engine, exactProfile);
|
||||
WriterCapture exactCapture = createWriterCapture(96);
|
||||
int exactCarved = exactCarver.carve(exactCapture.writer, 5, -1, columnWeights, 0D, 0D, worldYRange, precomputedSurfaceHeights);
|
||||
|
||||
IrisCaveProfile legacyProfile = createProfile(true, true).setSampleStep(2).setAdaptiveSampling(false);
|
||||
CaveProfile legacyProfile = TestSettings.with(createProfile(true, true), "sampleStep", 2, "adaptiveSampling", false);
|
||||
IrisCaveCarver3D legacyCarver = new IrisCaveCarver3D(engine, legacyProfile);
|
||||
WriterCapture legacyCapture = createWriterCapture(96);
|
||||
int legacyCarved = legacyCarver.carve(legacyCapture.writer, 5, -1, columnWeights, 0D, 0D, worldYRange, precomputedSurfaceHeights);
|
||||
@@ -228,12 +217,12 @@ public class IrisCaveCarver3DNearParityTest {
|
||||
double[] columnWeights = fullWeights();
|
||||
int[] precomputedSurfaceHeights = filledHeights(46);
|
||||
|
||||
IrisCaveProfile lavaProfile = createProfile(false, false).setAllowLava(true).setAllowFluid(false);
|
||||
CaveProfile lavaProfile = TestSettings.with(createProfile(false, false), "allowLava", true, "allowFluid", false);
|
||||
IrisCaveCarver3D lavaCarver = new IrisCaveCarver3D(engine, lavaProfile);
|
||||
WriterCapture lavaCapture = createWriterCapture(48);
|
||||
lavaCarver.carve(lavaCapture.writer, 0, 0, columnWeights, 0D, 0D, new IrisRange(0D, 80D), precomputedSurfaceHeights);
|
||||
|
||||
IrisCaveProfile forcedAirProfile = createProfile(false, false).setAllowLava(false).setAllowFluid(false);
|
||||
CaveProfile forcedAirProfile = TestSettings.with(createProfile(false, false), "allowLava", false, "allowFluid", false);
|
||||
IrisCaveCarver3D forcedAirCarver = new IrisCaveCarver3D(engine, forcedAirProfile);
|
||||
WriterCapture forcedAirCapture = createWriterCapture(48);
|
||||
forcedAirCarver.carve(forcedAirCapture.writer, 0, 0, columnWeights, 0D, 0D, new IrisRange(0D, 80D), precomputedSurfaceHeights);
|
||||
@@ -248,19 +237,12 @@ public class IrisCaveCarver3DNearParityTest {
|
||||
public void fluidPrecedesForcedAirWhenLavaIsDisabled() {
|
||||
Engine engine = createEngine(48, 46);
|
||||
int[] surfaceHeights = filledHeights(46);
|
||||
IrisCaveProfile wetProfile = createFluidProfile()
|
||||
.setVerticalRange(new IrisRange(2D, 18D))
|
||||
.setAllowLava(false)
|
||||
.setFluidRequiresFloor(false);
|
||||
CaveProfile wetProfile = TestSettings.with(createFluidProfile(), "verticalRange", com.volmit.config.Range.of(2D, 18D), "allowLava", false, "fluidRequiresFloor", false);
|
||||
WriterCapture wetCapture = createWriterCapture(48);
|
||||
new IrisCaveCarver3D(engine, wetProfile).carve(
|
||||
wetCapture.writer, 0, 0, fullWeights(), 0D, 0D, null, surfaceHeights);
|
||||
|
||||
IrisCaveProfile dryProfile = createFluidProfile()
|
||||
.setVerticalRange(new IrisRange(2D, 18D))
|
||||
.setAllowFluid(false)
|
||||
.setAllowLava(false)
|
||||
.setFluidRequiresFloor(false);
|
||||
CaveProfile dryProfile = TestSettings.with(createFluidProfile(), "verticalRange", com.volmit.config.Range.of(2D, 18D), "allowFluid", false, "allowLava", false, "fluidRequiresFloor", false);
|
||||
WriterCapture dryCapture = createWriterCapture(48);
|
||||
new IrisCaveCarver3D(engine, dryProfile).carve(
|
||||
dryCapture.writer, 0, 0, fullWeights(), 0D, 0D, null, surfaceHeights);
|
||||
@@ -277,12 +259,12 @@ public class IrisCaveCarver3DNearParityTest {
|
||||
Engine engine = createEngine(80, 70);
|
||||
int[] surfaceHeights = splitSurfaceHeights(40, 70);
|
||||
|
||||
IrisCaveProfile enabledProfile = createFluidProfile().setAllowFluid(true).setFluidMinDepthBelowSurface(10);
|
||||
CaveProfile enabledProfile = TestSettings.with(createFluidProfile(), "allowFluid", true, "fluidMinDepthBelowSurface", 10);
|
||||
WriterCapture enabledCapture = createWriterCapture(80);
|
||||
new IrisCaveCarver3D(engine, enabledProfile).carve(
|
||||
enabledCapture.writer, 0, 0, fullWeights(), 0D, 0D, null, surfaceHeights);
|
||||
|
||||
IrisCaveProfile disabledProfile = createFluidProfile().setAllowFluid(false).setFluidMinDepthBelowSurface(10);
|
||||
CaveProfile disabledProfile = TestSettings.with(createFluidProfile(), "allowFluid", false, "fluidMinDepthBelowSurface", 10);
|
||||
WriterCapture disabledCapture = createWriterCapture(80);
|
||||
new IrisCaveCarver3D(engine, disabledProfile).carve(
|
||||
disabledCapture.writer, 0, 0, fullWeights(), 0D, 0D, null, surfaceHeights);
|
||||
@@ -298,7 +280,7 @@ public class IrisCaveCarver3DNearParityTest {
|
||||
@Test
|
||||
public void dimensionFluidHeightCapsFluidIntent() {
|
||||
Engine engine = createEngine(80, 70);
|
||||
IrisCaveProfile profile = createFluidProfile().setFluidMinDepthBelowSurface(0);
|
||||
CaveProfile profile = TestSettings.with(createFluidProfile(), "fluidMinDepthBelowSurface", 0);
|
||||
WriterCapture capture = createWriterCapture(80);
|
||||
|
||||
new IrisCaveCarver3D(engine, profile).carve(
|
||||
@@ -311,9 +293,9 @@ public class IrisCaveCarver3DNearParityTest {
|
||||
|
||||
@Test
|
||||
public void surfaceFluidBoundaryProtectsReservoirWithoutFloodingDeeperCaves() {
|
||||
assertSurfaceFluidBoundaryForProfile(createFluidProfile().setAdaptiveSampling(false).setSampleStep(1));
|
||||
assertSurfaceFluidBoundaryForProfile(createFluidProfile().setAdaptiveSampling(true).setSampleStep(1));
|
||||
assertSurfaceFluidBoundaryForProfile(createFluidProfile().setAdaptiveSampling(false).setSampleStep(4));
|
||||
assertSurfaceFluidBoundaryForProfile(TestSettings.with(createFluidProfile(), "adaptiveSampling", false, "sampleStep", 1));
|
||||
assertSurfaceFluidBoundaryForProfile(TestSettings.with(createFluidProfile(), "adaptiveSampling", true, "sampleStep", 1));
|
||||
assertSurfaceFluidBoundaryForProfile(TestSettings.with(createFluidProfile(), "adaptiveSampling", false, "sampleStep", 4));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -323,11 +305,8 @@ public class IrisCaveCarver3DNearParityTest {
|
||||
int chunkX = -8;
|
||||
int chunkZ = -1;
|
||||
|
||||
IrisStyledRange cupThreshold = new IrisStyledRange(0.15D, 0.15D, new IrisGeneratorStyle(NoiseStyle.FLAT));
|
||||
IrisCaveProfile supportedProfile = createFluidProfile()
|
||||
.setDensityThreshold(cupThreshold)
|
||||
.setFluidMinDepthBelowSurface(0)
|
||||
.setFluidRequiresFloor(true);
|
||||
com.volmit.noise.StyledRange cupThreshold = com.volmit.noise.StyledRange.of(0.15D, 0.15D, com.volmit.noise.NoiseStyle.of("FLAT"));
|
||||
CaveProfile supportedProfile = TestSettings.with(createFluidProfile(), "densityThreshold", cupThreshold, "fluidMinDepthBelowSurface", 0, "fluidRequiresFloor", true);
|
||||
WriterCapture firstCapture = createWriterCapture(80);
|
||||
CaveFluidSupportPlan supportPlan = new CaveFluidSupportPlan();
|
||||
new IrisCaveCarver3D(engine, supportedProfile).carve(
|
||||
@@ -335,18 +314,12 @@ public class IrisCaveCarver3DNearParityTest {
|
||||
int candidateCount = countLiquid(firstCapture, (byte) 1);
|
||||
supportPlan.resolve(firstCapture.writer.acquireChunk(chunkX, chunkZ));
|
||||
|
||||
IrisCaveProfile repeatedProfile = createFluidProfile()
|
||||
.setDensityThreshold(cupThreshold)
|
||||
.setFluidMinDepthBelowSurface(0)
|
||||
.setFluidRequiresFloor(true);
|
||||
CaveProfile repeatedProfile = TestSettings.with(createFluidProfile(), "densityThreshold", cupThreshold, "fluidMinDepthBelowSurface", 0, "fluidRequiresFloor", true);
|
||||
WriterCapture secondCapture = createWriterCapture(80);
|
||||
new IrisCaveCarver3D(engine, repeatedProfile).carve(
|
||||
secondCapture.writer, chunkX, chunkZ, fullWeights(), 0D, 0D, null, surfaceHeights);
|
||||
|
||||
IrisCaveProfile unrestrictedProfile = createFluidProfile()
|
||||
.setDensityThreshold(cupThreshold)
|
||||
.setFluidMinDepthBelowSurface(0)
|
||||
.setFluidRequiresFloor(false);
|
||||
CaveProfile unrestrictedProfile = TestSettings.with(createFluidProfile(), "densityThreshold", cupThreshold, "fluidMinDepthBelowSurface", 0, "fluidRequiresFloor", false);
|
||||
WriterCapture unrestrictedCapture = createWriterCapture(80);
|
||||
new IrisCaveCarver3D(engine, unrestrictedProfile).carve(
|
||||
unrestrictedCapture.writer, chunkX, chunkZ, fullWeights(), 0D, 0D, null, surfaceHeights);
|
||||
@@ -385,10 +358,8 @@ public class IrisCaveCarver3DNearParityTest {
|
||||
int[] surfaceHeights = filledHeights(70);
|
||||
WriterCapture capture = createWriterCapture(80);
|
||||
CaveFluidSupportPlan fluidSupportPlan = new CaveFluidSupportPlan();
|
||||
IrisCaveProfile fluidProfile = createFluidProfile()
|
||||
.setDensityThreshold(new IrisStyledRange(0.15D, 0.15D, new IrisGeneratorStyle(NoiseStyle.FLAT)))
|
||||
.setFluidRequiresFloor(true);
|
||||
IrisCaveProfile airProfile = createFluidProfile().setAllowFluid(false);
|
||||
CaveProfile fluidProfile = TestSettings.with(createFluidProfile(), "densityThreshold", com.volmit.noise.StyledRange.of(0.15D, 0.15D, com.volmit.noise.NoiseStyle.of("FLAT")), "fluidRequiresFloor", true);
|
||||
CaveProfile airProfile = TestSettings.with(createFluidProfile(), "allowFluid", false);
|
||||
|
||||
new IrisCaveCarver3D(engine, fluidProfile).carve(
|
||||
capture.writer, 0, 0, fullWeights(), 0D, 0D, null, surfaceHeights,
|
||||
@@ -408,8 +379,8 @@ public class IrisCaveCarver3DNearParityTest {
|
||||
@Test
|
||||
public void optimizedExactPathOutperformsNaiveReference() throws Exception {
|
||||
Engine engine = createEngine(128, 92);
|
||||
IrisCaveCarver3D optimizedCarver = new IrisCaveCarver3D(engine, createProfile(true, true).setAdaptiveSampling(false));
|
||||
IrisCaveCarver3D naiveCarver = new IrisCaveCarver3D(engine, createProfile(true, true).setAdaptiveSampling(false));
|
||||
IrisCaveCarver3D optimizedCarver = new IrisCaveCarver3D(engine, TestSettings.with(createProfile(true, true), "adaptiveSampling", false));
|
||||
IrisCaveCarver3D naiveCarver = new IrisCaveCarver3D(engine, TestSettings.with(createProfile(true, true), "adaptiveSampling", false));
|
||||
double[] columnWeights = fullWeights();
|
||||
int[] precomputedSurfaceHeights = filledHeights(92);
|
||||
IrisRange worldYRange = new IrisRange(0D, 96D);
|
||||
@@ -446,11 +417,11 @@ public class IrisCaveCarver3DNearParityTest {
|
||||
int[] precomputedSurfaceHeights = filledHeights(90);
|
||||
IrisRange worldYRange = new IrisRange(0D, 88D);
|
||||
|
||||
IrisCaveCarver3D adaptiveCarver = new IrisCaveCarver3D(engine, createProfile(true, true).setAdaptiveSampling(true));
|
||||
IrisCaveCarver3D adaptiveCarver = new IrisCaveCarver3D(engine, TestSettings.with(createProfile(true, true), "adaptiveSampling", true));
|
||||
WriterCapture adaptiveCapture = createWriterCapture(96);
|
||||
int adaptiveCarved = adaptiveCarver.carve(adaptiveCapture.writer, 5, -1, columnWeights, 0D, 0D, worldYRange, precomputedSurfaceHeights);
|
||||
|
||||
IrisCaveCarver3D exactCarver = new IrisCaveCarver3D(engine, createProfile(true, true).setAdaptiveSampling(false));
|
||||
IrisCaveCarver3D exactCarver = new IrisCaveCarver3D(engine, TestSettings.with(createProfile(true, true), "adaptiveSampling", false));
|
||||
WriterCapture exactCapture = createWriterCapture(96);
|
||||
int exactCarved = exactCarver.carve(exactCapture.writer, 5, -1, columnWeights, 0D, 0D, worldYRange, precomputedSurfaceHeights);
|
||||
|
||||
@@ -467,7 +438,7 @@ public class IrisCaveCarver3DNearParityTest {
|
||||
assertTrue("expected carved cell delta below 3.5% but was " + differingRatio, differingRatio <= 0.035D);
|
||||
}
|
||||
|
||||
private void assertFlatSurfaceCeiling(IrisCaveProfile profile) {
|
||||
private void assertFlatSurfaceCeiling(CaveProfile profile) {
|
||||
Engine engine = createEngine(96, 72);
|
||||
WriterCapture capture = createWriterCapture(96);
|
||||
|
||||
@@ -505,11 +476,11 @@ public class IrisCaveCarver3DNearParityTest {
|
||||
int[] precomputedSurfaceHeights = filledHeights(90);
|
||||
IrisRange worldYRange = new IrisRange(0D, 88D);
|
||||
|
||||
IrisCaveCarver3D optimizedCarver = new IrisCaveCarver3D(engine, createProfile(warp, modules).setAdaptiveSampling(adaptiveSampling));
|
||||
IrisCaveCarver3D optimizedCarver = new IrisCaveCarver3D(engine, TestSettings.with(createProfile(warp, modules), "adaptiveSampling", adaptiveSampling));
|
||||
WriterCapture optimizedCapture = createWriterCapture(96);
|
||||
int optimizedCarved = optimizedCarver.carve(optimizedCapture.writer, 5, -1, columnWeights, 0D, 0D, worldYRange, precomputedSurfaceHeights);
|
||||
|
||||
IrisCaveCarver3D naiveCarver = new IrisCaveCarver3D(engine, createProfile(warp, modules).setAdaptiveSampling(false));
|
||||
IrisCaveCarver3D naiveCarver = new IrisCaveCarver3D(engine, TestSettings.with(createProfile(warp, modules), "adaptiveSampling", false));
|
||||
WriterCapture naiveCapture = createWriterCapture(96);
|
||||
int naiveCarved = carveNaiveExact(naiveCarver, naiveCapture.writer, 5, -1, columnWeights, worldYRange, precomputedSurfaceHeights);
|
||||
|
||||
@@ -543,7 +514,7 @@ public class IrisCaveCarver3DNearParityTest {
|
||||
private int carveNaiveExact(IrisCaveCarver3D carver, MantleWriter writer, int chunkX, int chunkZ, double[] columnWeights, IrisRange worldYRange, int[] precomputedSurfaceHeights) throws Exception {
|
||||
Engine engine = (Engine) engineField.get(carver);
|
||||
IrisData data = (IrisData) dataField.get(carver);
|
||||
IrisCaveProfile profile = (IrisCaveProfile) profileField.get(carver);
|
||||
CaveProfile profile = (CaveProfile) profileField.get(carver);
|
||||
CNG surfaceBreakDensity = (CNG) surfaceBreakDensityField.get(carver);
|
||||
RNG thresholdRng = (RNG) thresholdRngField.get(carver);
|
||||
MatterCavern carveAir = (MatterCavern) carveAirField.get(carver);
|
||||
@@ -557,8 +528,8 @@ public class IrisCaveCarver3DNearParityTest {
|
||||
}
|
||||
|
||||
int worldHeight = writer.getMantle().getWorldHeight();
|
||||
int minY = Math.max(0, (int) Math.floor(profile.getVerticalRange().getMin()));
|
||||
int maxY = Math.min(worldHeight - 1, (int) Math.ceil(profile.getVerticalRange().getMax()));
|
||||
int minY = Math.max(0, (int) Math.floor(profile.verticalRange().min()));
|
||||
int maxY = Math.min(worldHeight - 1, (int) Math.ceil(profile.verticalRange().max()));
|
||||
if (worldYRange != null) {
|
||||
int worldMinHeight = engine.getWorld().minHeight();
|
||||
int rangeMinY = (int) Math.floor(worldYRange.getMin() - worldMinHeight);
|
||||
@@ -570,11 +541,11 @@ public class IrisCaveCarver3DNearParityTest {
|
||||
return 0;
|
||||
}
|
||||
|
||||
boolean allowSurfaceBreak = profile.isAllowSurfaceBreak();
|
||||
int surfaceClearance = Math.max(0, profile.getSurfaceClearance());
|
||||
int surfaceBreakDepth = Math.max(0, profile.getSurfaceBreakDepth());
|
||||
double surfaceBreakNoiseThreshold = profile.getSurfaceBreakNoiseThreshold();
|
||||
double surfaceBreakThresholdBoost = Math.max(0D, profile.getSurfaceBreakThresholdBoost());
|
||||
boolean allowSurfaceBreak = profile.allowSurfaceBreak();
|
||||
int surfaceClearance = Math.max(0, profile.surfaceClearance());
|
||||
int surfaceBreakDepth = Math.max(0, profile.surfaceBreakDepth());
|
||||
double surfaceBreakNoiseThreshold = profile.surfaceBreakNoiseThreshold();
|
||||
double surfaceBreakThresholdBoost = Math.max(0D, profile.surfaceBreakThresholdBoost());
|
||||
int[] columnTopY = new int[256];
|
||||
int[] surfaceBreakFloorY = new int[256];
|
||||
boolean[] surfaceBreakColumn = new boolean[256];
|
||||
@@ -604,8 +575,8 @@ public class IrisCaveCarver3DNearParityTest {
|
||||
boolean breakColumn = allowSurfaceBreak && signed(surfaceBreakDensity.noiseFast2D(x, z)) >= surfaceBreakNoiseThreshold;
|
||||
int resolvedTopY = breakColumn ? Math.min(maxY, Math.max(minY, columnSurfaceY)) : clearanceTopY;
|
||||
columnTopY[columnIndex] = resolvedTopY;
|
||||
fluidMaxY[columnIndex] = profile.isAllowFluid()
|
||||
? Math.min(engine.getDimension().getFluidHeight(), columnSurfaceY - Math.max(0, profile.getFluidMinDepthBelowSurface()))
|
||||
fluidMaxY[columnIndex] = profile.allowFluid()
|
||||
? Math.min(engine.getDimension().getFluidHeight(), columnSurfaceY - Math.max(0, profile.fluidMinDepthBelowSurface()))
|
||||
: Integer.MIN_VALUE;
|
||||
surfaceBreakFloorY[columnIndex] = Math.max(minY, columnSurfaceY - surfaceBreakDepth);
|
||||
surfaceBreakColumn[columnIndex] = breakColumn;
|
||||
@@ -616,7 +587,7 @@ public class IrisCaveCarver3DNearParityTest {
|
||||
continue;
|
||||
}
|
||||
|
||||
passThreshold[columnIndex] = profile.getDensityThreshold().get(thresholdRng, x, z, data) - profile.getThresholdBias();
|
||||
passThreshold[columnIndex] = ResolvedCaveProfile.of(profile).densityThreshold().get(thresholdRng, x, z, data) - profile.thresholdBias();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -700,42 +671,42 @@ public class IrisCaveCarver3DNearParityTest {
|
||||
return closureThreshold + ((threshold - closureThreshold) * smooth);
|
||||
}
|
||||
|
||||
private double[] computeSurfaceClosureThresholds(IrisCaveProfile profile, int minY, int maxY) {
|
||||
double normalization = Math.abs(profile.getBaseWeight()) + Math.abs(profile.getDetailWeight());
|
||||
for (IrisCaveFieldModule module : profile.getModules()) {
|
||||
normalization += Math.abs(module.getWeight());
|
||||
private double[] computeSurfaceClosureThresholds(CaveProfile profile, int minY, int maxY) {
|
||||
double normalization = Math.abs(profile.baseWeight()) + Math.abs(profile.detailWeight());
|
||||
for (ResolvedCaveProfile.Module module : ResolvedCaveProfile.of(profile).modules()) {
|
||||
normalization += Math.abs(module.weight());
|
||||
}
|
||||
if (normalization <= 0D) {
|
||||
normalization = 1D;
|
||||
}
|
||||
|
||||
double[] thresholds = new double[Math.max(0, maxY - minY + 1)];
|
||||
double baseMinimum = -Math.abs(profile.getBaseWeight()) - Math.abs(profile.getDetailWeight());
|
||||
double baseMinimum = -Math.abs(profile.baseWeight()) - Math.abs(profile.detailWeight());
|
||||
for (int y = minY; y <= maxY; y++) {
|
||||
double minimumDensity = baseMinimum;
|
||||
for (IrisCaveFieldModule module : profile.getModules()) {
|
||||
IrisRange range = module.getVerticalRange();
|
||||
for (ResolvedCaveProfile.Module module : ResolvedCaveProfile.of(profile).modules()) {
|
||||
IrisRange range = module.verticalRange();
|
||||
if (y < Math.floor(range.getMin()) || y > Math.ceil(range.getMax())) {
|
||||
continue;
|
||||
}
|
||||
double rawMinimum = module.isInvert()
|
||||
? module.getThreshold() - 1D
|
||||
: -1D - module.getThreshold();
|
||||
double rawMaximum = module.isInvert()
|
||||
? module.getThreshold() + 1D
|
||||
: 1D - module.getThreshold();
|
||||
minimumDensity += Math.min(rawMinimum * module.getWeight(), rawMaximum * module.getWeight());
|
||||
double rawMinimum = module.invert()
|
||||
? module.threshold() - 1D
|
||||
: -1D - module.threshold();
|
||||
double rawMaximum = module.invert()
|
||||
? module.threshold() + 1D
|
||||
: 1D - module.threshold();
|
||||
minimumDensity += Math.min(rawMinimum * module.weight(), rawMaximum * module.weight());
|
||||
}
|
||||
thresholds[y - minY] = (minimumDensity / normalization) - SURFACE_CEILING_SOLID_EPSILON;
|
||||
}
|
||||
return thresholds;
|
||||
}
|
||||
|
||||
private double[] computeVerticalEdgeFade(IrisCaveProfile profile, int minY, int maxY) {
|
||||
private double[] computeVerticalEdgeFade(CaveProfile profile, int minY, int maxY) {
|
||||
int size = Math.max(0, maxY - minY + 1);
|
||||
double[] verticalEdgeFade = new double[size];
|
||||
int fadeRange = Math.max(0, profile.getVerticalEdgeFade());
|
||||
double fadeStrength = Math.max(0D, profile.getVerticalEdgeFadeStrength());
|
||||
int fadeRange = Math.max(0, profile.verticalEdgeFade());
|
||||
double fadeStrength = Math.max(0D, profile.verticalEdgeFadeStrength());
|
||||
if (size == 0 || fadeRange <= 0 || maxY <= minY || fadeStrength <= 0D) {
|
||||
return verticalEdgeFade;
|
||||
}
|
||||
@@ -757,9 +728,9 @@ public class IrisCaveCarver3DNearParityTest {
|
||||
return verticalEdgeFade;
|
||||
}
|
||||
|
||||
private MatterCavern[] computeMatterByY(Engine engine, IrisCaveProfile profile, MatterCavern carveAir, MatterCavern carveLava, MatterCavern carveForcedAir, int minY, int maxY) {
|
||||
private MatterCavern[] computeMatterByY(Engine engine, CaveProfile profile, MatterCavern carveAir, MatterCavern carveLava, MatterCavern carveForcedAir, int minY, int maxY) {
|
||||
MatterCavern[] matterByY = new MatterCavern[Math.max(0, maxY - minY + 1)];
|
||||
boolean allowLava = profile.isAllowLava();
|
||||
boolean allowLava = profile.allowLava();
|
||||
int lavaHeight = engine.getDimension().getCaveLavaHeight();
|
||||
|
||||
for (int y = minY; y <= maxY; y++) {
|
||||
@@ -800,71 +771,48 @@ public class IrisCaveCarver3DNearParityTest {
|
||||
return engine;
|
||||
}
|
||||
|
||||
private IrisCaveProfile createProfile(boolean warp, boolean modules) {
|
||||
IrisCaveProfile profile = new IrisCaveProfile();
|
||||
profile.setEnabled(true);
|
||||
profile.setVerticalRange(new IrisRange(0D, 120D));
|
||||
profile.setVerticalEdgeFade(14);
|
||||
profile.setVerticalEdgeFadeStrength(0.21D);
|
||||
profile.setBaseDensityStyle(new IrisGeneratorStyle(NoiseStyle.SIMPLEX).zoomed(0.07D));
|
||||
profile.setDetailDensityStyle(new IrisGeneratorStyle(NoiseStyle.SIMPLEX).zoomed(0.17D));
|
||||
profile.setWarpStyle(new IrisGeneratorStyle(NoiseStyle.SIMPLEX).zoomed(0.12D));
|
||||
profile.setSurfaceBreakStyle(new IrisGeneratorStyle(NoiseStyle.SIMPLEX).zoomed(0.09D));
|
||||
profile.setBaseWeight(1D);
|
||||
profile.setDetailWeight(0.48D);
|
||||
profile.setWarpStrength(warp ? 0.37D : 0D);
|
||||
profile.setDensityThreshold(new IrisStyledRange(1D, 1D, new IrisGeneratorStyle(NoiseStyle.FLAT)));
|
||||
profile.setThresholdBias(0D);
|
||||
profile.setSampleStep(1);
|
||||
profile.setSurfaceClearance(5);
|
||||
profile.setAllowSurfaceBreak(true);
|
||||
profile.setSurfaceBreakNoiseThreshold(0.16D);
|
||||
profile.setSurfaceBreakDepth(12);
|
||||
profile.setSurfaceBreakThresholdBoost(0.17D);
|
||||
profile.setAllowFluid(true);
|
||||
profile.setFluidMinDepthBelowSurface(8);
|
||||
profile.setFluidRequiresFloor(false);
|
||||
profile.setAllowLava(true);
|
||||
private CaveProfile createProfile(boolean warp, boolean modules) {
|
||||
CaveProfile profile = new CaveProfile();
|
||||
TestSettings.with(profile, "enabled", true);
|
||||
TestSettings.with(profile, "verticalRange", com.volmit.config.Range.of(0D, 120D));
|
||||
TestSettings.with(profile, "verticalEdgeFade", 14);
|
||||
TestSettings.with(profile, "verticalEdgeFadeStrength", 0.21D);
|
||||
TestSettings.with(profile, "baseDensityStyle", com.volmit.noise.NoiseStyle.of("SIMPLEX").withZoom(0.07D));
|
||||
TestSettings.with(profile, "detailDensityStyle", com.volmit.noise.NoiseStyle.of("SIMPLEX").withZoom(0.17D));
|
||||
TestSettings.with(profile, "warpStyle", com.volmit.noise.NoiseStyle.of("SIMPLEX").withZoom(0.12D));
|
||||
TestSettings.with(profile, "surfaceBreakStyle", com.volmit.noise.NoiseStyle.of("SIMPLEX").withZoom(0.09D));
|
||||
TestSettings.with(profile, "baseWeight", 1D);
|
||||
TestSettings.with(profile, "detailWeight", 0.48D);
|
||||
TestSettings.with(profile, "warpStrength", warp ? 0.37D : 0D);
|
||||
TestSettings.with(profile, "densityThreshold", com.volmit.noise.StyledRange.of(1D, 1D, com.volmit.noise.NoiseStyle.of("FLAT")));
|
||||
TestSettings.with(profile, "thresholdBias", 0D);
|
||||
TestSettings.with(profile, "sampleStep", 1);
|
||||
TestSettings.with(profile, "surfaceClearance", 5);
|
||||
TestSettings.with(profile, "allowSurfaceBreak", true);
|
||||
TestSettings.with(profile, "surfaceBreakNoiseThreshold", 0.16D);
|
||||
TestSettings.with(profile, "surfaceBreakDepth", 12);
|
||||
TestSettings.with(profile, "surfaceBreakThresholdBoost", 0.17D);
|
||||
TestSettings.with(profile, "allowFluid", true);
|
||||
TestSettings.with(profile, "fluidMinDepthBelowSurface", 8);
|
||||
TestSettings.with(profile, "fluidRequiresFloor", false);
|
||||
TestSettings.with(profile, "allowLava", true);
|
||||
if (modules) {
|
||||
KList<IrisCaveFieldModule> caveModules = new KList<>();
|
||||
caveModules.add(new IrisCaveFieldModule(
|
||||
new IrisGeneratorStyle(NoiseStyle.SIMPLEX).zoomed(0.11D),
|
||||
0.23D,
|
||||
0.04D,
|
||||
new IrisRange(0D, 72D),
|
||||
false
|
||||
));
|
||||
caveModules.add(new IrisCaveFieldModule(
|
||||
new IrisGeneratorStyle(NoiseStyle.SIMPLEX).zoomed(0.19D),
|
||||
0.17D,
|
||||
-0.06D,
|
||||
new IrisRange(24D, 120D),
|
||||
true
|
||||
));
|
||||
profile.setModules(caveModules);
|
||||
TestSettings.with(profile, "modules", List.of(
|
||||
TestSettings.of(CaveFieldModule.class, "{\"style\": {\"style\": \"SIMPLEX\", \"zoom\": 0.11}, \"weight\": 0.23,"
|
||||
+ " \"threshold\": 0.04, \"verticalRange\": {\"min\": 0, \"max\": 72}, \"invert\": false}"),
|
||||
TestSettings.of(CaveFieldModule.class, "{\"style\": {\"style\": \"SIMPLEX\", \"zoom\": 0.19}, \"weight\": 0.17,"
|
||||
+ " \"threshold\": -0.06, \"verticalRange\": {\"min\": 24, \"max\": 120}, \"invert\": true}")));
|
||||
} else {
|
||||
profile.setModules(new KList<>());
|
||||
TestSettings.with(profile, "modules", List.of());
|
||||
}
|
||||
return profile;
|
||||
}
|
||||
|
||||
private IrisCaveProfile createFluidProfile() {
|
||||
return createProfile(false, false)
|
||||
.setVerticalRange(new IrisRange(20D, 70D))
|
||||
.setVerticalEdgeFade(0)
|
||||
.setVerticalEdgeFadeStrength(0D)
|
||||
.setDensityThreshold(new IrisStyledRange(2D, 2D, new IrisGeneratorStyle(NoiseStyle.FLAT)))
|
||||
.setAdaptiveSampling(false)
|
||||
.setSurfaceClearance(5)
|
||||
.setAllowSurfaceBreak(true)
|
||||
.setSurfaceBreakNoiseThreshold(-1D)
|
||||
.setSurfaceBreakThresholdBoost(0D)
|
||||
.setAllowFluid(true)
|
||||
.setFluidRequiresFloor(false)
|
||||
.setAllowLava(true);
|
||||
private CaveProfile createFluidProfile() {
|
||||
return TestSettings.with(createProfile(false, false), "verticalRange", com.volmit.config.Range.of(20D, 70D), "verticalEdgeFade", 0, "verticalEdgeFadeStrength", 0D, "densityThreshold", com.volmit.noise.StyledRange.of(2D, 2D, com.volmit.noise.NoiseStyle.of("FLAT")), "adaptiveSampling", false, "surfaceClearance", 5, "allowSurfaceBreak", true, "surfaceBreakNoiseThreshold", -1D, "surfaceBreakThresholdBoost", 0D, "allowFluid", true, "fluidRequiresFloor", false, "allowLava", true);
|
||||
}
|
||||
|
||||
private void assertSurfaceFluidBoundaryForProfile(IrisCaveProfile profile) {
|
||||
private void assertSurfaceFluidBoundaryForProfile(CaveProfile profile) {
|
||||
Engine engine = createEngine(80, 70);
|
||||
int[] surfaceHeights = filledHeights(70);
|
||||
surfaceHeights[0] = 60;
|
||||
@@ -875,7 +823,7 @@ public class IrisCaveCarver3DNearParityTest {
|
||||
WriterCapture capture = createWriterCapture(80);
|
||||
CaveFluidSupportPlan supportPlan = new CaveFluidSupportPlan();
|
||||
|
||||
new IrisCaveCarver3D(engine, profile.setFluidMinDepthBelowSurface(0).setFluidRequiresFloor(false)).carve(
|
||||
new IrisCaveCarver3D(engine, TestSettings.with(profile, "fluidMinDepthBelowSurface", 0, "fluidRequiresFloor", false)).carve(
|
||||
capture.writer,
|
||||
0,
|
||||
0,
|
||||
|
||||
+4
-3
@@ -1,5 +1,8 @@
|
||||
package art.arcane.iris.engine.mantle.components;
|
||||
|
||||
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
|
||||
import art.arcane.iris.engine.object.TestSettings;
|
||||
import art.arcane.iris.builtin.vacuum.VacuumSettings;
|
||||
import art.arcane.iris.engine.object.noise.IrisGeneratorStyle;
|
||||
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
@@ -17,9 +20,7 @@ import art.arcane.iris.engine.object.prefab.IrisObjectTranslate;
|
||||
import art.arcane.iris.engine.object.procedural.IrisProceduralObjects;
|
||||
import art.arcane.iris.engine.object.procedural.IrisProceduralPlacement;
|
||||
import art.arcane.iris.engine.object.world.region.IrisRegion;
|
||||
import art.arcane.iris.engine.object.placement.IrisVacuumSettings;
|
||||
import art.arcane.iris.engine.object.noise.NoiseStyle;
|
||||
import art.arcane.iris.engine.object.placement.ObjectPlaceMode;
|
||||
import art.arcane.iris.spi.IrisPlatform;
|
||||
import art.arcane.iris.spi.IrisPlatforms;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
@@ -100,7 +101,7 @@ public class ObjectPlacingBoundaryRadiusTest {
|
||||
.setScale(new IrisObjectScale().setSize(2D))
|
||||
.setWarp(new IrisGeneratorStyle(NoiseStyle.SIMPLEX).setMultiplier(10D))
|
||||
.setMode(ObjectPlaceMode.VACUUM)
|
||||
.setVacuumSettings(new IrisVacuumSettings().setRadius(12));
|
||||
.setVacuumSettings(TestSettings.of(VacuumSettings.class, "{\"radius\":12}"));
|
||||
|
||||
assertEquals(43, ObjectPlacing.calculatePlacementReach(new IrisBlockVector(5, 4, 3), placement));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package art.arcane.iris.engine.object;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
/** Settings classes of the built-in modules have no setters; tests write them as the JSON packs hold. */
|
||||
public final class TestSettings {
|
||||
private static final Gson GSON = new Gson();
|
||||
|
||||
private TestSettings() {
|
||||
}
|
||||
|
||||
public static <T> T of(Class<T> type, String json) {
|
||||
return GSON.fromJson(json, type);
|
||||
}
|
||||
|
||||
/** Sets fields of settings a test built, as a pack's JSON would have: {@code with(settings, "name", value, "other", value)}; returns {@code settings}. */
|
||||
public static <T> T with(T settings, Object... namesAndValues) {
|
||||
for (int index = 0; index < namesAndValues.length; index += 2) {
|
||||
set(settings, (String) namesAndValues[index], namesAndValues[index + 1]);
|
||||
}
|
||||
return settings;
|
||||
}
|
||||
|
||||
private static void set(Object settings, String field, Object value) {
|
||||
try {
|
||||
java.lang.reflect.Field target = settings.getClass().getDeclaredField(field);
|
||||
target.setAccessible(true);
|
||||
target.set(settings, value);
|
||||
} catch (ReflectiveOperationException failure) {
|
||||
throw new IllegalArgumentException("No settings field " + field + " in " + settings.getClass().getName(), failure);
|
||||
}
|
||||
}
|
||||
}
|
||||
+10
-12
@@ -1,15 +1,13 @@
|
||||
package art.arcane.iris.engine.object.mod;
|
||||
|
||||
import art.arcane.iris.builtin.prepare.SlopeClip;
|
||||
import art.arcane.iris.builtin.validate.ObjectLimit;
|
||||
import art.arcane.iris.engine.object.mod.IrisMod;
|
||||
import art.arcane.iris.engine.object.mod.IrisModNoiseStyleReplacer;
|
||||
import art.arcane.iris.engine.object.mod.IrisModObjectReplacer;
|
||||
import art.arcane.iris.engine.object.placement.IrisObjectLimit;
|
||||
import art.arcane.iris.engine.object.placement.IrisSlopeClip;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import art.arcane.iris.engine.object.annotations.ArrayType;
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import art.arcane.iris.engine.object.annotations.MaxNumber;
|
||||
import art.arcane.iris.engine.object.annotations.MinNumber;
|
||||
import art.arcane.iris.engine.object.annotations.RegistryListResource;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -21,22 +19,22 @@ import static org.junit.Assert.assertFalse;
|
||||
public class SchemaMetadataCorrectionsTest {
|
||||
@Test
|
||||
public void objectHeightLimitsAdmitTheirDefaults() throws Exception {
|
||||
Field minimum = IrisObjectLimit.class.getDeclaredField("minimumHeight");
|
||||
Field maximum = IrisObjectLimit.class.getDeclaredField("maximumHeight");
|
||||
Field minimum = ObjectLimit.class.getDeclaredField("minimumHeight");
|
||||
Field maximum = ObjectLimit.class.getDeclaredField("maximumHeight");
|
||||
|
||||
assertEquals(-2048D, minimum.getAnnotation(MinNumber.class).value(), 0D);
|
||||
assertEquals(2048D, minimum.getAnnotation(MaxNumber.class).value(), 0D);
|
||||
assertEquals(-2048D, maximum.getAnnotation(MinNumber.class).value(), 0D);
|
||||
assertEquals(2048D, maximum.getAnnotation(MaxNumber.class).value(), 0D);
|
||||
assertEquals(-2048D, minimum.getAnnotation(com.volmit.config.MinNumber.class).value(), 0D);
|
||||
assertEquals(2048D, minimum.getAnnotation(com.volmit.config.MaxNumber.class).value(), 0D);
|
||||
assertEquals(-2048D, maximum.getAnnotation(com.volmit.config.MinNumber.class).value(), 0D);
|
||||
assertEquals(2048D, maximum.getAnnotation(com.volmit.config.MaxNumber.class).value(), 0D);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void correctedTypesDescribeTheSchemaTheyExpose() {
|
||||
assertEquals("Represents a pack modification schema", IrisMod.class.getAnnotation(Desc.class).value());
|
||||
assertEquals("Limits object placement by minimum and maximum world height",
|
||||
IrisObjectLimit.class.getAnnotation(Desc.class).value());
|
||||
ObjectLimit.class.getAnnotation(com.volmit.config.Desc.class).value());
|
||||
assertEquals("Limits placement to a minimum and maximum terrain slope",
|
||||
IrisSlopeClip.class.getAnnotation(Desc.class).value());
|
||||
SlopeClip.class.getAnnotation(com.volmit.config.Desc.class).value());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+13
-11
@@ -1,19 +1,21 @@
|
||||
package art.arcane.iris.engine.object.placement;
|
||||
|
||||
import art.arcane.iris.builtin.carve.CarvingMode;
|
||||
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
|
||||
import art.arcane.iris.builtin.validate.ObjectLimit;
|
||||
import art.arcane.iris.engine.object.TestSettings;
|
||||
import art.arcane.iris.builtin.stilt.StiltSettings;
|
||||
import art.arcane.iris.builtin.prepare.SlopeClip;
|
||||
import art.arcane.iris.builtin.vacuum.VacuumSettings;
|
||||
import art.arcane.iris.builtin.IrisStages;
|
||||
import art.arcane.iris.engine.object.noise.IrisNoiseGenerator;
|
||||
import art.arcane.iris.engine.object.placement.IObjectPlacer;
|
||||
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
|
||||
import art.arcane.iris.engine.object.placement.IrisSlopeClip;
|
||||
import art.arcane.iris.engine.object.placement.IrisStiltSettings;
|
||||
import art.arcane.iris.engine.object.placement.IrisVacuumSettings;
|
||||
import art.arcane.iris.engine.object.placement.ObjectPlaceMode;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObjectRotation;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObjectTranslate;
|
||||
import art.arcane.iris.engine.object.prefab.TileData;
|
||||
import art.arcane.iris.engine.object.terrain.carving.CarveResult;
|
||||
import art.arcane.iris.engine.object.terrain.carving.CarvingMode;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.core.modules.BuiltInPack;
|
||||
import art.arcane.iris.core.modules.InMemoryMantle;
|
||||
@@ -281,7 +283,7 @@ public class IrisObjectPlacementRegressionTest {
|
||||
IrisObjectPlacement config = placement();
|
||||
config.setMode(ObjectPlaceMode.CEILING_HANG);
|
||||
config.setTranslate(new IrisObjectTranslate().setY(3));
|
||||
config.setStiltSettings(new IrisStiltSettings().setOrganicJitter(0).setOrganicScratch(0));
|
||||
config.setStiltSettings(TestSettings.of(StiltSettings.class, "{\"organicJitter\":0,\"organicScratch\":0}"));
|
||||
|
||||
boxObject(1, 3, 1).place(0, ANCHOR_Y, 0, placer, config, new RNG(2L), data);
|
||||
|
||||
@@ -296,7 +298,7 @@ public class IrisObjectPlacementRegressionTest {
|
||||
placer.world.put("0:75:0", solid);
|
||||
IrisObjectPlacement config = placement();
|
||||
config.setMode(ObjectPlaceMode.ORGANIC_STILT);
|
||||
config.setStiltSettings(new IrisStiltSettings().setOrganicJitter(0).setOrganicScratch(0));
|
||||
config.setStiltSettings(TestSettings.of(StiltSettings.class, "{\"organicJitter\":0,\"organicScratch\":0}"));
|
||||
|
||||
lineObject(1).place(0, ANCHOR_Y, 0, placer, config, new RNG(2L), data);
|
||||
|
||||
@@ -578,7 +580,7 @@ public class IrisObjectPlacementRegressionTest {
|
||||
config.setUnderwater(true);
|
||||
placer.fluidHeight = ANCHOR_Y;
|
||||
}
|
||||
case "height-clamp" -> config.getClamp().setMaximumHeight(ANCHOR_Y - 1);
|
||||
case "height-clamp" -> config.setClamp(TestSettings.of(ObjectLimit.class, "{\"maximumHeight\":" + (ANCHOR_Y - 1) + "}"));
|
||||
}
|
||||
ObjectPlacementResult result = place(config, anchor, placer, cave);
|
||||
assertEquals(Optional.of(reason), result.rejection());
|
||||
@@ -646,7 +648,7 @@ public class IrisObjectPlacementRegressionTest {
|
||||
object.setUnsigned(0, 2, 0, schematicAir);
|
||||
IrisObjectPlacement config = placement().setMode(ObjectPlaceMode.VACUUM).setSnow(0.1);
|
||||
config.setTranslate(new IrisObjectTranslate().setY(3));
|
||||
config.setVacuumSettings(new IrisVacuumSettings().setRadius(1));
|
||||
config.setVacuumSettings(TestSettings.of(VacuumSettings.class, "{\"radius\":1}"));
|
||||
|
||||
object.place(0, ANCHOR_Y, 0, placer, config, new RNG(2L), data);
|
||||
|
||||
@@ -665,7 +667,7 @@ public class IrisObjectPlacementRegressionTest {
|
||||
when(complex.getSlopeStream()).thenReturn(slopes);
|
||||
when(slopes.get(anyDouble(), anyDouble())).thenReturn(0.5);
|
||||
IrisObjectPlacement config = placement().setBore(true);
|
||||
config.setSlopeCondition(new IrisSlopeClip(1, 2));
|
||||
config.setSlopeCondition(TestSettings.of(SlopeClip.class, "{\"minimumSlope\":1,\"maximumSlope\":2}"));
|
||||
RNG rng = new RNG(91);
|
||||
RecordingPlacer placer = new RecordingPlacer(engine);
|
||||
|
||||
@@ -689,7 +691,7 @@ public class IrisObjectPlacementRegressionTest {
|
||||
lineObject(3).place(0, ANCHOR_Y, 0, placer, config, new RNG(2L), data);
|
||||
|
||||
assertSame(original, config.getRotation());
|
||||
assertEquals(0, original.getYAxis().getMin(), 0);
|
||||
assertEquals(0, original.getYAxis().min(), 0);
|
||||
assertEquals(3, placer.writes().size());
|
||||
assertTrue(placer.writes().stream().allMatch(write -> write.x() == 0));
|
||||
assertEquals(List.of(-1, 0, 1), placer.writes().stream().map(BlockWrite::z).sorted().toList());
|
||||
|
||||
+14
-14
@@ -1,5 +1,12 @@
|
||||
package art.arcane.iris.engine.object.placement;
|
||||
|
||||
import art.arcane.iris.builtin.carve.CarvingMode;
|
||||
import art.arcane.iris.builtin.carve.CaveAnchorMode;
|
||||
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
|
||||
import art.arcane.iris.builtin.blocks.ObjectReplace;
|
||||
import art.arcane.iris.builtin.stilt.StiltSettings;
|
||||
import art.arcane.iris.builtin.prepare.SlopeClip;
|
||||
import art.arcane.iris.builtin.validate.ObjectLimit;
|
||||
import art.arcane.iris.engine.object.loot.IrisObjectLoot;
|
||||
import art.arcane.iris.engine.object.loot.IrisObjectVanillaLoot;
|
||||
import art.arcane.iris.engine.object.marker.IrisObjectMarker;
|
||||
@@ -7,18 +14,11 @@ import art.arcane.iris.engine.object.noise.IrisGeneratorStyle;
|
||||
import art.arcane.iris.engine.object.noise.IrisNoiseGenerator;
|
||||
import art.arcane.iris.engine.object.noise.IrisStyledRange;
|
||||
import art.arcane.iris.engine.object.noise.NoiseStyle;
|
||||
import art.arcane.iris.engine.object.placement.IrisObjectLimit;
|
||||
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
|
||||
import art.arcane.iris.engine.object.placement.IrisObjectReplace;
|
||||
import art.arcane.iris.engine.object.placement.IrisSlopeClip;
|
||||
import art.arcane.iris.engine.object.placement.IrisStiltSettings;
|
||||
import art.arcane.iris.engine.object.placement.IrisTree;
|
||||
import art.arcane.iris.engine.object.placement.ObjectPlaceMode;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObjectRotation;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObjectScale;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObjectTranslate;
|
||||
import art.arcane.iris.engine.object.terrain.carving.CarvingMode;
|
||||
import art.arcane.iris.engine.object.terrain.carving.IrisCaveAnchorMode;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -32,15 +32,15 @@ public class IrisObjectPlacementToPlacementTest {
|
||||
public void toPlacement_preservesInheritedPlacementMetadata() {
|
||||
IrisObjectPlacement source = new IrisObjectPlacement();
|
||||
IrisObjectRotation rotation = new IrisObjectRotation();
|
||||
IrisObjectLimit clamp = new IrisObjectLimit();
|
||||
ObjectLimit clamp = new ObjectLimit();
|
||||
IrisStyledRange densityStyle = new IrisStyledRange();
|
||||
densityStyle.setMin(7D);
|
||||
densityStyle.setMax(7D);
|
||||
IrisStiltSettings stiltSettings = new IrisStiltSettings();
|
||||
StiltSettings stiltSettings = new StiltSettings();
|
||||
KList<IrisObjectMarker> markers = new KList<>();
|
||||
IrisNoiseGenerator heightmap = new IrisNoiseGenerator(false);
|
||||
IrisGeneratorStyle warp = NoiseStyle.SIMPLEX.style();
|
||||
KList<IrisObjectReplace> edit = new KList<>();
|
||||
KList<ObjectReplace> edit = new KList<>();
|
||||
IrisObjectTranslate translate = new IrisObjectTranslate();
|
||||
IrisObjectScale scale = new IrisObjectScale();
|
||||
KList<IrisObjectLoot> loot = new KList<>();
|
||||
@@ -48,10 +48,10 @@ public class IrisObjectPlacementToPlacementTest {
|
||||
KList<IrisTree> trees = new KList<>();
|
||||
KList<String> allowedCollisions = new KList<>();
|
||||
KList<String> forbiddenCollisions = new KList<>();
|
||||
IrisSlopeClip slopeCondition = new IrisSlopeClip();
|
||||
SlopeClip slopeCondition = new SlopeClip();
|
||||
|
||||
markers.add(new IrisObjectMarker());
|
||||
edit.add(new IrisObjectReplace());
|
||||
edit.add(new ObjectReplace());
|
||||
loot.add(new IrisObjectLoot());
|
||||
vanillaLoot.add(new IrisObjectVanillaLoot());
|
||||
trees.add(new IrisTree());
|
||||
@@ -76,7 +76,7 @@ public class IrisObjectPlacementToPlacementTest {
|
||||
source.setSurfaceSupportBuffer(3);
|
||||
source.setSurfaceSupportDepth(4);
|
||||
source.setRequireSurfaceSupport(false);
|
||||
source.setCaveAnchorMode(IrisCaveAnchorMode.CEILING);
|
||||
source.setCaveAnchorMode(CaveAnchorMode.CEILING);
|
||||
source.setHeightmap(heightmap);
|
||||
source.setSmartBore(true);
|
||||
source.setWaterloggable(true);
|
||||
@@ -120,7 +120,7 @@ public class IrisObjectPlacementToPlacementTest {
|
||||
assertEquals(3, copy.getSurfaceSupportBuffer());
|
||||
assertEquals(4, copy.getSurfaceSupportDepth());
|
||||
assertFalse(copy.isRequireSurfaceSupport());
|
||||
assertEquals(IrisCaveAnchorMode.CEILING, copy.getCaveAnchorMode());
|
||||
assertEquals(CaveAnchorMode.CEILING, copy.getCaveAnchorMode());
|
||||
assertSame(heightmap, copy.getHeightmap());
|
||||
assertTrue(copy.isSmartBore());
|
||||
assertTrue(copy.isWaterloggable());
|
||||
|
||||
+6
-5
@@ -1,13 +1,14 @@
|
||||
package art.arcane.iris.engine.object.placement;
|
||||
|
||||
import art.arcane.iris.builtin.carve.CarvingMode;
|
||||
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
|
||||
import art.arcane.iris.engine.object.TestSettings;
|
||||
import art.arcane.iris.builtin.prepare.SlopeClip;
|
||||
import art.arcane.iris.engine.object.placement.IObjectPlacer;
|
||||
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
|
||||
import art.arcane.iris.engine.object.placement.IrisSlopeClip;
|
||||
import art.arcane.iris.engine.object.placement.ObjectPlaceMode;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObjectTranslate;
|
||||
import art.arcane.iris.engine.object.prefab.TileData;
|
||||
import art.arcane.iris.engine.object.terrain.carving.CarvingMode;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.core.modules.BuiltInPack;
|
||||
import com.volmit.host.LoadedPack;
|
||||
@@ -212,7 +213,7 @@ public class IrisObjectSurfaceSupportPlacementTest {
|
||||
when(data.getEngine()).thenReturn(null);
|
||||
SurfacePlacer placer = new SurfacePlacer();
|
||||
IrisObjectPlacement placement = placement(ObjectPlaceMode.STRUCTURE_PIECE);
|
||||
placement.setSlopeCondition(new IrisSlopeClip().setMinimumSlope(100).setMaximumSlope(100));
|
||||
placement.setSlopeCondition(TestSettings.of(SlopeClip.class, "{\"minimumSlope\":100,\"maximumSlope\":100}"));
|
||||
placement.setForcePlace(true);
|
||||
|
||||
assertTrue(place(placer, placement, SURFACE_Y) >= 0);
|
||||
@@ -225,7 +226,7 @@ public class IrisObjectSurfaceSupportPlacementTest {
|
||||
when(data.getEngine()).thenReturn(null);
|
||||
SurfacePlacer placer = new SurfacePlacer();
|
||||
IrisObjectPlacement placement = placement(ObjectPlaceMode.STRUCTURE_PIECE);
|
||||
placement.setSlopeCondition(new IrisSlopeClip().setMinimumSlope(100).setMaximumSlope(100));
|
||||
placement.setSlopeCondition(TestSettings.of(SlopeClip.class, "{\"minimumSlope\":100,\"maximumSlope\":100}"));
|
||||
placement.setForcePlace(true);
|
||||
placement.setRotateTowardsSlope(true);
|
||||
|
||||
|
||||
+7
-11
@@ -18,9 +18,10 @@
|
||||
|
||||
package art.arcane.iris.engine.object.placement;
|
||||
|
||||
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
|
||||
import art.arcane.iris.engine.object.TestSettings;
|
||||
import art.arcane.iris.builtin.vacuum.VacuumSettings;
|
||||
import art.arcane.iris.engine.object.placement.IrisObjectVacuum;
|
||||
import art.arcane.iris.engine.object.placement.IrisVacuumSettings;
|
||||
import art.arcane.iris.engine.object.placement.ObjectPlaceMode;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
@@ -106,8 +107,7 @@ public class IrisObjectVacuumTest {
|
||||
assertEquals(12, IrisObjectVacuum.resolveRadius(ObjectPlaceMode.VACUUM_ORGANIC, null));
|
||||
assertEquals(12, IrisObjectVacuum.resolveRadius(ObjectPlaceMode.VACUUM_WAVY, null));
|
||||
|
||||
IrisVacuumSettings settings = new IrisVacuumSettings();
|
||||
settings.setRadius(30);
|
||||
VacuumSettings settings = TestSettings.of(VacuumSettings.class, "{\"radius\":30}");
|
||||
assertEquals(30, IrisObjectVacuum.resolveRadius(ObjectPlaceMode.VACUUM_FAST, settings));
|
||||
}
|
||||
|
||||
@@ -176,18 +176,14 @@ public class IrisObjectVacuumTest {
|
||||
assertEquals(3.0, IrisObjectVacuum.resolveWaveAmplitude(null), 0.0001);
|
||||
assertEquals(5.0, IrisObjectVacuum.resolveWaveScale(null), 0.0001);
|
||||
|
||||
IrisVacuumSettings settings = new IrisVacuumSettings();
|
||||
settings.setWaveAmplitude(6);
|
||||
settings.setWaveScale(2.5);
|
||||
VacuumSettings settings = TestSettings.of(VacuumSettings.class, "{\"waveAmplitude\":6,\"waveScale\":2.5}");
|
||||
assertEquals(6.0, IrisObjectVacuum.resolveWaveAmplitude(settings), 0.0001);
|
||||
assertEquals(2.5, IrisObjectVacuum.resolveWaveScale(settings), 0.0001);
|
||||
|
||||
IrisVacuumSettings disabled = new IrisVacuumSettings();
|
||||
disabled.setWaveAmplitude(0);
|
||||
VacuumSettings disabled = TestSettings.of(VacuumSettings.class, "{\"waveAmplitude\":0}");
|
||||
assertEquals("amplitude 0 disables the wave", 0.0, IrisObjectVacuum.resolveWaveAmplitude(disabled), 0.0001);
|
||||
|
||||
IrisVacuumSettings badScale = new IrisVacuumSettings();
|
||||
badScale.setWaveScale(0);
|
||||
VacuumSettings badScale = TestSettings.of(VacuumSettings.class, "{\"waveScale\":0}");
|
||||
assertEquals("non-positive scale falls back to the default", 5.0, IrisObjectVacuum.resolveWaveScale(badScale), 0.0001);
|
||||
}
|
||||
|
||||
|
||||
+6
-6
@@ -1,5 +1,8 @@
|
||||
package art.arcane.iris.engine.object.placement;
|
||||
|
||||
import art.arcane.iris.engine.object.procedural.formation.ResolvedFormation;
|
||||
import art.arcane.iris.engine.object.TestSettings;
|
||||
import art.arcane.iris.builtin.objects.formation.Formation;
|
||||
import art.arcane.iris.engine.object.placement.IObjectPlacer;
|
||||
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
|
||||
import art.arcane.iris.engine.object.placement.IrisSurfaceSupport;
|
||||
@@ -7,7 +10,6 @@ import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObjectRotation;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObjectTranslate;
|
||||
import art.arcane.iris.engine.object.prefab.TileData;
|
||||
import art.arcane.iris.engine.object.procedural.formation.IrisFormation;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
@@ -164,13 +166,11 @@ public class IrisSurfaceSupportTest {
|
||||
|
||||
@Test
|
||||
public void formationDefaultsToWiderBufferThanObjectDefault() {
|
||||
IrisFormation formation = new IrisFormation();
|
||||
|
||||
assertEquals(2, new IrisObjectPlacement().getSurfaceSupportBuffer());
|
||||
assertEquals(3, formation.asPlacement().getSurfaceSupportBuffer());
|
||||
assertEquals(3, new ResolvedFormation(new Formation()).asPlacement().getSurfaceSupportBuffer());
|
||||
|
||||
formation.setSurfaceSupportBuffer(0);
|
||||
assertEquals(0, formation.asPlacement().getSurfaceSupportBuffer());
|
||||
Formation flush = TestSettings.with(new Formation(), "surfaceSupportBuffer", 0);
|
||||
assertEquals(0, new ResolvedFormation(flush).asPlacement().getSurfaceSupportBuffer());
|
||||
}
|
||||
|
||||
private static boolean isUnsupported(IObjectPlacer placer, List<IrisBlockVector> footprint,
|
||||
|
||||
+238
@@ -0,0 +1,238 @@
|
||||
/*
|
||||
* 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.engine.object.placement;
|
||||
|
||||
import art.arcane.iris.builtin.blocks.ObjectReplace;
|
||||
import art.arcane.iris.builtin.prepare.AxisRotationClamp;
|
||||
import art.arcane.iris.builtin.prepare.SlopeClip;
|
||||
import art.arcane.iris.builtin.stilt.StiltSettings;
|
||||
import art.arcane.iris.builtin.vacuum.VacuumSettings;
|
||||
import art.arcane.iris.builtin.validate.ObjectLimit;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.volmit.block.BlockSpec;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.CALLS_REAL_METHODS;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
/**
|
||||
* The placement settings packs have always written inside an object placement, read into the settings classes of the
|
||||
* built-in modules (IrisApi types only) with the values Iris's own classes read from the same JSON. The JSON is the
|
||||
* overworld pack's.
|
||||
*/
|
||||
public class PlacementSettingsDecodingTest {
|
||||
private static final String MANGROVE = """
|
||||
{"chance": 0.45, "waterloggable": true, "clamp": {"maximumHeight": 225}, "density": 3,
|
||||
"place": ["trees/mangrove/mangrove1"]}
|
||||
""";
|
||||
private static final String CLAMPED_FROM_GROUND = """
|
||||
{"place": ["clutter/stonedirtsetter7"], "clamp": {"minimumHeight": 0}}
|
||||
""";
|
||||
private static final String CENTER_STILT = """
|
||||
{"mode": "CENTER_STILT", "stiltSettings": {"yMax": 4, "yRand": 1},
|
||||
"rotation": {"yAxis": {"min": 0, "max": 270, "interval": 90, "enabled": true}}}
|
||||
""";
|
||||
private static final String ORGANIC_STILT = """
|
||||
{"mode": "ORGANIC_STILT", "stiltSettings": {"organicScratch": 1, "organicJitter": 6, "enabled": true, "minHeight": 1, "maxHeight": 3}}
|
||||
""";
|
||||
private static final String STILT_WITH_PALETTE = """
|
||||
{"mode": "STILT", "stiltSettings": {"overStilt": 2, "organicMaxScan": 12,
|
||||
"palette": {"style": {"style": "PERLIN", "zoom": 0.2}, "zoom": 3,
|
||||
"palette": [{"block": "minecraft:oak_log", "data": {"axis": "y"}, "weight": 2}, {"block": "minecraft:stone"}]}}}
|
||||
""";
|
||||
private static final String VACUUM = """
|
||||
{"mode": "VACUUM_WAVY", "vacuumSettings": {"radius": 24, "falloff": 1.5, "organicJitter": 2, "waveAmplitude": 5, "waveScale": 3.5}}
|
||||
""";
|
||||
private static final String STEEP_ONLY = """
|
||||
{"place": ["rocks/spire"], "slopeCondition": {"minimumSlope": 2, "maximumSlope": 3.5}}
|
||||
""";
|
||||
private static final String SPRUCE_LEAVES_TO_PERLIN_LEAVES = """
|
||||
{"place": ["trees/spruce/vgeneric1"], "snow": 0.5, "edit": [
|
||||
{"find": [{"block": "minecraft:dark_oak_fence"}, {"block": "minecraft:dark_oak_fence_gate"}],
|
||||
"replace": {"palette": [{"block": "minecraft:spruce_leaves"}]}},
|
||||
{"find": [{"block": "minecraft:spruce_leaves"}], "exact": true, "chance": 0.5,
|
||||
"replace": {"style": {"style": "PERLIN", "zoom": 0.2},
|
||||
"palette": [{"block": "minecraft:oak_leaves"}, {"block": "minecraft:birch_leaves", "weight": 3}]}},
|
||||
"snippet/object-block-replacer/leaves", {}
|
||||
]}
|
||||
""";
|
||||
|
||||
@Rule
|
||||
public TemporaryFolder folder = new TemporaryFolder();
|
||||
|
||||
private Gson gson;
|
||||
|
||||
@Before
|
||||
public void decodeLikeIrisDoes() throws IOException {
|
||||
File snippets = folder.newFolder("snippet", "object-block-replacer");
|
||||
Files.writeString(new File(snippets, "leaves.json").toPath(),
|
||||
"{\"find\": [{\"block\": \"minecraft:oak_leaves\"}], \"replace\": \"snippet/palette/autumn\"}");
|
||||
File palettes = folder.newFolder("snippet", "palette");
|
||||
Files.writeString(new File(palettes, "autumn.json").toPath(), "{\"palette\": [{\"block\": \"minecraft:red_terracotta\"}]}");
|
||||
IrisData data = mock(IrisData.class, CALLS_REAL_METHODS);
|
||||
doReturn(folder.getRoot()).when(data).getDataFolder();
|
||||
gson = new GsonBuilder().registerTypeAdapterFactory(data).create();
|
||||
}
|
||||
|
||||
private IrisObjectPlacement placement(String json) {
|
||||
return gson.fromJson(json, IrisObjectPlacement.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void clampReadsTheHeightsThePackSetAndKeepsIrisDefaultsForTheRest() {
|
||||
ObjectLimit mangrove = placement(MANGROVE).getClamp();
|
||||
assertEquals(-2048, mangrove.minimumHeight());
|
||||
assertEquals(225, mangrove.maximumHeight());
|
||||
assertTrue(mangrove.canPlace(225, 100));
|
||||
assertFalse(mangrove.canPlace(226, 100));
|
||||
|
||||
ObjectLimit fromGround = placement(CLAMPED_FROM_GROUND).getClamp();
|
||||
assertEquals(0, fromGround.minimumHeight());
|
||||
assertEquals(2048, fromGround.maximumHeight());
|
||||
assertFalse(fromGround.canPlace(10, -1));
|
||||
|
||||
ObjectLimit untouched = placement("{}").getClamp();
|
||||
assertEquals(-2048, untouched.minimumHeight());
|
||||
assertEquals(2048, untouched.maximumHeight());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void slopeConditionReadsItsBoundsAndNoConditionPassesEverySlope() {
|
||||
SlopeClip steep = placement(STEEP_ONLY).getSlopeCondition();
|
||||
assertEquals(2, steep.minimumSlope(), 0);
|
||||
assertEquals(3.5, steep.maximumSlope(), 0);
|
||||
assertFalse(steep.isDefault());
|
||||
assertTrue(steep.isValid(3));
|
||||
assertFalse(steep.isValid(1.9));
|
||||
assertFalse(steep.isValid(3.6));
|
||||
|
||||
SlopeClip none = placement("{}").getSlopeCondition();
|
||||
assertTrue(none.isDefault());
|
||||
assertTrue(none.isValid(9999));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void stiltSettingsReadTheirFieldsAndIgnoreWhatTheyNeverHad() {
|
||||
StiltSettings center = placement(CENTER_STILT).getStiltSettings();
|
||||
assertEquals(4, center.yMax());
|
||||
assertEquals(1, center.yRand());
|
||||
assertEquals(0, center.overStilt());
|
||||
assertTrue(center.palette().isEmpty());
|
||||
assertEquals(48, center.organicMaxScan());
|
||||
assertEquals(3, center.organicJitter());
|
||||
assertEquals(0.55, center.organicScratch(), 0);
|
||||
|
||||
StiltSettings organic = placement(ORGANIC_STILT).getStiltSettings();
|
||||
assertEquals(1, organic.organicScratch(), 0);
|
||||
assertEquals(6, organic.organicJitter());
|
||||
|
||||
assertEquals(null, placement("{}").getStiltSettings());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void stiltPaletteIsAPaletteSpecWithItsStyleZoomAndWeightedBlocks() {
|
||||
StiltSettings stilt = placement(STILT_WITH_PALETTE).getStiltSettings();
|
||||
|
||||
assertEquals(2, stilt.overStilt());
|
||||
assertEquals(12, stilt.organicMaxScan());
|
||||
var palette = stilt.palette().orElseThrow();
|
||||
assertEquals("PERLIN", palette.style().style());
|
||||
assertEquals(3, palette.zoom(), 0);
|
||||
assertEquals(2, palette.palette().get(0).weight());
|
||||
assertEquals("y", palette.palette().get(0).data().get("axis"));
|
||||
assertEquals("minecraft:stone", palette.palette().get(1).block());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void vacuumSettingsReadEveryField() {
|
||||
VacuumSettings vacuum = placement(VACUUM).getVacuumSettings();
|
||||
assertEquals(24, vacuum.radius());
|
||||
assertEquals(1.5, vacuum.falloff(), 0);
|
||||
assertEquals(2, vacuum.organicJitter());
|
||||
assertEquals(5, vacuum.waveAmplitude());
|
||||
assertEquals(3.5, vacuum.waveScale(), 0);
|
||||
|
||||
VacuumSettings defaults = gson.fromJson("{}", VacuumSettings.class);
|
||||
assertEquals(0, defaults.radius());
|
||||
assertEquals(2.0, defaults.falloff(), 0);
|
||||
assertEquals(4, defaults.organicJitter());
|
||||
assertEquals(3, defaults.waveAmplitude());
|
||||
assertEquals(5.0, defaults.waveScale(), 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void editsReadTheirFindListPaletteExactnessAndChance() {
|
||||
List<ObjectReplace> edits = placement(SPRUCE_LEAVES_TO_PERLIN_LEAVES).getEdit();
|
||||
|
||||
ObjectReplace fences = edits.get(0);
|
||||
assertEquals(List.of("minecraft:dark_oak_fence", "minecraft:dark_oak_fence_gate"), fences.find().stream().map(BlockSpec::block).toList());
|
||||
assertEquals("minecraft:spruce_leaves", fences.replace().palette().get(0).block());
|
||||
assertFalse(fences.exact());
|
||||
assertEquals(1F, fences.chance(), 0);
|
||||
assertEquals("STATIC", fences.replace().style().style());
|
||||
|
||||
ObjectReplace leaves = edits.get(1);
|
||||
assertTrue(leaves.exact());
|
||||
assertEquals(0.5F, leaves.chance(), 0);
|
||||
assertEquals("PERLIN", leaves.replace().style().style());
|
||||
assertEquals(3, leaves.replace().palette().get(1).weight());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void editsMayBeSnippetsWhoseFieldsMayBeSnippetsToo() {
|
||||
ObjectReplace snippet = placement(SPRUCE_LEAVES_TO_PERLIN_LEAVES).getEdit().get(2);
|
||||
|
||||
assertNotNull(snippet);
|
||||
assertEquals("minecraft:oak_leaves", snippet.find().get(0).block());
|
||||
assertEquals("minecraft:red_terracotta", snippet.replace().palette().get(0).block());
|
||||
|
||||
ObjectReplace empty = placement(SPRUCE_LEAVES_TO_PERLIN_LEAVES).getEdit().get(3);
|
||||
assertTrue(empty.find().isEmpty());
|
||||
assertEquals("stone", empty.replace().palette().get(0).block());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rotationAxesReadTheirAnglesAndStepsAndTheYAxisIsOnByDefault() {
|
||||
AxisRotationClamp yAxis = placement(CENTER_STILT).getRotation().getYAxis();
|
||||
assertTrue(yAxis.enabled());
|
||||
assertEquals(0, yAxis.min(), 0);
|
||||
assertEquals(270, yAxis.max(), 0);
|
||||
assertEquals(90, yAxis.interval(), 0);
|
||||
|
||||
AxisRotationClamp defaults = placement("{}").getRotation().getYAxis();
|
||||
assertTrue(defaults.enabled());
|
||||
assertEquals(90, defaults.interval(), 0);
|
||||
assertFalse(placement("{}").getRotation().getXAxis().enabled());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
/*
|
||||
* 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.engine.object.placement;
|
||||
|
||||
import art.arcane.iris.core.modules.BlockEntities;
|
||||
import art.arcane.iris.engine.object.prefab.TileData;
|
||||
import art.arcane.iris.spi.IrisPlatform;
|
||||
import art.arcane.iris.spi.IrisPlatforms;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import art.arcane.iris.spi.PlatformRegistries;
|
||||
import art.arcane.volmlib.util.collection.KMap;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.block.BlockRegistry;
|
||||
import com.volmit.block.BlockSpec;
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.block.PaletteSampler;
|
||||
import com.volmit.block.PaletteSpec;
|
||||
import com.volmit.object.BlockEntityData;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/** What an {@link art.arcane.iris.builtin.blocks.ObjectReplace} does to a block: the seed its palette is picked with and the draws of its tile pick. */
|
||||
public class ResolvedReplaceTest {
|
||||
private static final long SEED = 4242L;
|
||||
private TileData.TileReader previousReader;
|
||||
|
||||
@Before
|
||||
public void bindPlatform() {
|
||||
IrisPlatforms.unbind();
|
||||
PlatformRegistries registries = mock(PlatformRegistries.class);
|
||||
when(registries.block(anyString())).thenAnswer(call -> state(call.getArgument(0)));
|
||||
when(registries.blockOrNull(anyString(), anyBoolean())).thenAnswer(call -> state(call.getArgument(0)));
|
||||
IrisPlatform platform = mock(IrisPlatform.class);
|
||||
when(platform.registries()).thenReturn(registries);
|
||||
IrisPlatforms.bind(platform);
|
||||
previousReader = TileData.bindPlatformReader(in -> new TileData(in.readUTF(), new KMap<>()));
|
||||
}
|
||||
|
||||
@After
|
||||
public void unbindPlatform() {
|
||||
TileData.restorePlatformReader(previousReader);
|
||||
IrisPlatforms.unbind();
|
||||
}
|
||||
|
||||
private static PlatformBlockState state(String key) {
|
||||
PlatformBlockState state = mock(PlatformBlockState.class);
|
||||
when(state.key()).thenReturn(key);
|
||||
return state;
|
||||
}
|
||||
|
||||
private static BlockEntityData tile(String material) {
|
||||
return BlockEntities.of(new TileData(material, new KMap<>()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void thePaletteIsPickedWithTheSeedOfTheRngThePlacementHandsIn() {
|
||||
BlockRegistry blocks = mock(BlockRegistry.class);
|
||||
PaletteSpec spec = PaletteSpec.of(List.of(BlockSpec.of("oak_leaves"), BlockSpec.of("birch_leaves")));
|
||||
double[] asked = new double[3];
|
||||
PaletteSampler sampler = (x, y, z) -> {
|
||||
asked[0] = x;
|
||||
asked[1] = y;
|
||||
asked[2] = z;
|
||||
return BlockState.parse("minecraft:birch_leaves");
|
||||
};
|
||||
when(blocks.palette(spec, SEED)).thenReturn(sampler);
|
||||
|
||||
ResolvedReplace replace = new ResolvedReplace(List.of(), false, 1F, spec, blocks);
|
||||
|
||||
assertEquals("minecraft:birch_leaves", replace.replacement(new RNG(SEED), 10, 64, -3).key());
|
||||
assertEquals(List.of(10D, 64D, -3D), List.of(asked[0], asked[1], asked[2]));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aSingleWeightedEntryGivesItsTileWithoutDrawing() {
|
||||
BlockRegistry blocks = mock(BlockRegistry.class);
|
||||
PaletteSpec spec = PaletteSpec.of(List.of(BlockSpec.of("chest")));
|
||||
when(blocks.blockEntity(any())).thenReturn(Optional.of(tile("minecraft:chest")));
|
||||
ResolvedReplace replace = new ResolvedReplace(List.of(), false, 1F, spec, blocks);
|
||||
RNG rng = new RNG(SEED);
|
||||
|
||||
assertEquals("minecraft:chest", replace.tile(rng).orElseThrow().getMaterialKey());
|
||||
assertEquals("no draw", new RNG(SEED).nextInt(1000), rng.nextInt(1000));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void severalEntriesGiveTheTileOfTheUniformlyDrawnEntry() {
|
||||
BlockRegistry blocks = mock(BlockRegistry.class);
|
||||
BlockSpec first = BlockSpec.of("chest");
|
||||
BlockSpec second = BlockSpec.of("barrel");
|
||||
BlockSpec third = BlockSpec.of("furnace").withWeight(5);
|
||||
when(blocks.blockEntity(first)).thenReturn(Optional.of(tile("minecraft:chest")));
|
||||
when(blocks.blockEntity(second)).thenReturn(Optional.of(tile("minecraft:barrel")));
|
||||
when(blocks.blockEntity(third)).thenReturn(Optional.empty());
|
||||
ResolvedReplace replace = new ResolvedReplace(List.of(), false, 1F, PaletteSpec.of(List.of(first, second, third)), blocks);
|
||||
|
||||
for (long seed = 0; seed < 40; seed++) {
|
||||
int drawn = new RNG(seed).nextInt(3);
|
||||
Optional<TileData> tile = replace.tile(new RNG(seed));
|
||||
if (drawn == 2) {
|
||||
assertTrue("an entry without tile data gives none", tile.isEmpty());
|
||||
} else {
|
||||
assertEquals(drawn == 0 ? "minecraft:chest" : "minecraft:barrel", tile.orElseThrow().getMaterialKey());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aPaletteWithNoWeightGivesNoTile() {
|
||||
BlockRegistry blocks = mock(BlockRegistry.class);
|
||||
ResolvedReplace replace = new ResolvedReplace(List.of(), false, 1F, PaletteSpec.of(List.of(BlockSpec.of("chest").withWeight(0))), blocks);
|
||||
|
||||
assertTrue(replace.tile(new RNG(SEED)).isEmpty());
|
||||
}
|
||||
}
|
||||
+9
-11
@@ -1,6 +1,6 @@
|
||||
package art.arcane.iris.engine.object.prefab;
|
||||
|
||||
import art.arcane.iris.engine.object.prefab.IrisAxisRotationClamp;
|
||||
import art.arcane.iris.builtin.prepare.AxisRotationClamp;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -10,10 +10,8 @@ import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class IrisAxisRotationClampPurityTest {
|
||||
private static IrisAxisRotationClamp unlimited(double interval) {
|
||||
IrisAxisRotationClamp clamp = new IrisAxisRotationClamp();
|
||||
clamp.setEnabled(true);
|
||||
clamp.setInterval(interval);
|
||||
private static AxisRotationClamp unlimited(double interval) {
|
||||
AxisRotationClamp clamp = AxisRotationClamp.of(true, false, 0, 0, interval);
|
||||
return clamp;
|
||||
}
|
||||
|
||||
@@ -24,9 +22,9 @@ public class IrisAxisRotationClampPurityTest {
|
||||
|
||||
@Test
|
||||
public void getRadiansDoesNotMutateIntervalWhenUnlimited() {
|
||||
IrisAxisRotationClamp clamp = unlimited(0);
|
||||
AxisRotationClamp clamp = unlimited(0);
|
||||
clamp.getRadians(37);
|
||||
assertEquals(0D, clamp.getInterval(), 0D);
|
||||
assertEquals(0D, clamp.interval(), 0D);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -43,8 +41,8 @@ public class IrisAxisRotationClampPurityTest {
|
||||
|
||||
@Test
|
||||
public void equalsAndHashCodeSurviveRepeatedGetRadians() {
|
||||
IrisAxisRotationClamp a = unlimited(0);
|
||||
IrisAxisRotationClamp b = unlimited(0);
|
||||
AxisRotationClamp a = unlimited(0);
|
||||
AxisRotationClamp b = unlimited(0);
|
||||
a.getRadians(123);
|
||||
assertEquals(a, b);
|
||||
assertEquals(a.hashCode(), b.hashCode());
|
||||
@@ -52,7 +50,7 @@ public class IrisAxisRotationClampPurityTest {
|
||||
|
||||
@Test
|
||||
public void concurrentGetRadiansLeavesIntervalUntouched() throws InterruptedException {
|
||||
IrisAxisRotationClamp shared = unlimited(0);
|
||||
AxisRotationClamp shared = unlimited(0);
|
||||
List<Thread> threads = new ArrayList<>();
|
||||
for (int t = 0; t < 8; t++) {
|
||||
Thread thread = new Thread(() -> {
|
||||
@@ -66,6 +64,6 @@ public class IrisAxisRotationClampPurityTest {
|
||||
for (Thread thread : threads) {
|
||||
thread.join();
|
||||
}
|
||||
assertTrue("interval must stay at the authored value", shared.getInterval() == 0D);
|
||||
assertTrue("interval must stay at the authored value", shared.interval() == 0D);
|
||||
}
|
||||
}
|
||||
+193
@@ -0,0 +1,193 @@
|
||||
/*
|
||||
* 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.engine.object.procedural;
|
||||
|
||||
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
|
||||
import art.arcane.iris.builtin.carve.CarvingMode;
|
||||
import art.arcane.iris.builtin.objects.coral.Coral;
|
||||
import art.arcane.iris.builtin.objects.coral.CoralForm;
|
||||
import art.arcane.iris.builtin.objects.crystal.Crystal;
|
||||
import art.arcane.iris.builtin.objects.crystal.CrystalDistribution;
|
||||
import art.arcane.iris.builtin.objects.formation.Formation;
|
||||
import art.arcane.iris.builtin.objects.formation.FormationForm;
|
||||
import art.arcane.iris.builtin.objects.fungi.Fungus;
|
||||
import art.arcane.iris.builtin.objects.ruin.Ruin;
|
||||
import art.arcane.iris.builtin.objects.tree.TreeLeafMode;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.CALLS_REAL_METHODS;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
/**
|
||||
* The procedural objects the overworld pack's biomes write ({@code snippet/procedural-objects/frozen/...}) read into the module settings
|
||||
* classes (IrisApi types only) with the values Iris's own classes read from the same JSON, and made placeable.
|
||||
*/
|
||||
public class ProceduralSettingsDecodingTest {
|
||||
private static final String ICEBERG = """
|
||||
{"name": "glacial-iceberg", "chance": 0.08, "density": 1, "variants": 24, "seed": 5055001, "mode": "CENTER_HEIGHT",
|
||||
"carvingSupport": "SURFACE_ONLY", "surfaceSupportBuffer": 1, "block": "minecraft:packed_ice",
|
||||
"blockPalette": "snippet/palette/frozen/magical-ice", "capBlock": "minecraft:blue_ice",
|
||||
"rotation": {"enabled": true, "yAxis": {"enabled": true, "min": 0, "max": 360, "interval": 45}},
|
||||
"form": "ICEBERG", "translate": {"y": -4}, "heightMin": 12, "heightMax": 22, "baseWidthMin": 5, "baseWidthMax": 8,
|
||||
"icebergPeaks": 4, "roughness": 0.42, "jitter": 0.14}
|
||||
""";
|
||||
private static final String FROST_BLOOM = """
|
||||
{"mode": "CENTER_HEIGHT", "carvingSupport": "SURFACE_ONLY",
|
||||
"rotation": {"enabled": true, "yAxis": {"enabled": true, "min": 0, "max": 360, "interval": 45}},
|
||||
"growthSurface": "FLOOR", "block": "minecraft:packed_ice", "blockPalette": "snippet/palette/frozen/magical-ice",
|
||||
"tipBlock": "minecraft:blue_ice", "baseBlock": "minecraft:blue_ice", "tipChance": 0.65, "name": "glacial-frost-bloom",
|
||||
"chance": 0.28, "density": 2, "variants": 24, "seed": 5055031, "translate": {"y": -1}, "baseRadius": 1.8, "baseNoise": 0.4,
|
||||
"shardCountMin": 3, "shardCountMax": 6, "shardLengthMin": 2, "shardLengthMax": 5, "shardBaseRadius": 1.1,
|
||||
"shardTaper": 1.0, "spreadAngle": 68, "distribution": "GOLDEN_ANGLE", "jitter": 0.35}
|
||||
""";
|
||||
private static final String BIOME = """
|
||||
{"name": "Glacial", "proceduralObjects": "snippet/procedural-objects/frozen/magical-ice-spikes-biome"}
|
||||
""";
|
||||
|
||||
@Rule
|
||||
public TemporaryFolder folder = new TemporaryFolder();
|
||||
|
||||
private Gson gson;
|
||||
|
||||
@Before
|
||||
public void decodeLikeIrisDoes() throws IOException {
|
||||
File palettes = folder.newFolder("snippet", "palette", "frozen");
|
||||
Files.writeString(new File(palettes, "magical-ice.json").toPath(),
|
||||
"{\"style\": {\"style\": \"SIMPLEX\", \"zoom\": 0.4}, \"palette\": [{\"block\": \"minecraft:packed_ice\"}, {\"block\": \"minecraft:blue_ice\", \"weight\": 2}]}");
|
||||
File objects = folder.newFolder("snippet", "procedural-objects", "frozen");
|
||||
Files.writeString(new File(objects, "magical-ice-spikes-biome.json").toPath(),
|
||||
"{\"formations\": [" + ICEBERG + "], \"crystals\": [" + FROST_BLOOM + "]}");
|
||||
IrisData data = mock(IrisData.class, CALLS_REAL_METHODS);
|
||||
doReturn(folder.getRoot()).when(data).getDataFolder();
|
||||
gson = new GsonBuilder().registerTypeAdapterFactory(data).create();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aFormationReadsEveryFieldIrisReadFromIt() {
|
||||
Formation iceberg = gson.fromJson(ICEBERG, Formation.class);
|
||||
|
||||
assertEquals("glacial-iceberg", iceberg.name());
|
||||
assertEquals(0.08, iceberg.chance(), 0);
|
||||
assertEquals(24, iceberg.variants());
|
||||
assertEquals(5055001L, iceberg.seed());
|
||||
assertEquals(ObjectPlaceMode.CENTER_HEIGHT, iceberg.mode());
|
||||
assertEquals(CarvingMode.SURFACE_ONLY, iceberg.carvingSupport());
|
||||
assertEquals(1, iceberg.surfaceSupportBuffer());
|
||||
assertEquals("minecraft:packed_ice", iceberg.block());
|
||||
assertEquals("minecraft:blue_ice", iceberg.capBlock().orElseThrow());
|
||||
assertEquals(FormationForm.ICEBERG, iceberg.form());
|
||||
assertEquals(-4, iceberg.translate().y());
|
||||
assertTrue(iceberg.rotation().yAxis().enabled());
|
||||
assertEquals(45, iceberg.rotation().yAxis().interval(), 0);
|
||||
assertEquals(360, iceberg.rotation().yAxis().max(), 0);
|
||||
assertEquals(4, iceberg.icebergPeaks());
|
||||
assertEquals(0.42, iceberg.roughness(), 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void palettesMayBeSnippetsAndReadAsPaletteSpecs() {
|
||||
Formation iceberg = gson.fromJson(ICEBERG, Formation.class);
|
||||
|
||||
var palette = iceberg.blockPalette().orElseThrow();
|
||||
assertEquals("SIMPLEX", palette.style().style());
|
||||
assertEquals(0.4, palette.style().zoom(), 0);
|
||||
assertEquals(2, palette.palette().size());
|
||||
assertEquals(2, palette.palette().get(1).weight());
|
||||
assertTrue(gson.fromJson("{}", Formation.class).blockPalette().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aCrystalReadsItsFieldsAndEnums() {
|
||||
Crystal bloom = gson.fromJson(FROST_BLOOM, Crystal.class);
|
||||
|
||||
assertEquals("glacial-frost-bloom", bloom.name());
|
||||
assertEquals(CrystalDistribution.GOLDEN_ANGLE, bloom.distribution());
|
||||
assertEquals(1.8, bloom.baseRadius(), 0);
|
||||
assertEquals(6, bloom.shardCountMax());
|
||||
assertEquals("minecraft:blue_ice", bloom.baseBlock());
|
||||
assertEquals(-1, bloom.translate().y());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aBiomeHoldsItsProceduralObjectsFromASnippet() {
|
||||
IrisBiome biome = gson.fromJson(BIOME, IrisBiome.class);
|
||||
|
||||
IrisProceduralObjects objects = biome.getProceduralObjects();
|
||||
assertEquals(1, objects.getFormations().size());
|
||||
assertEquals(1, objects.getCrystals().size());
|
||||
assertEquals("glacial-iceberg", objects.getFormations().get(0).name());
|
||||
assertFalse(objects.isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void everyKindPlacesWithItsSettingsAndMakesTheSamePlacementEachTime() {
|
||||
IrisProceduralObjects objects = gson.fromJson("{\"coral\": [{}], \"fungi\": [{}], \"ruins\": [{}], "
|
||||
+ "\"formations\": [" + ICEBERG + "], \"crystals\": [" + FROST_BLOOM + "]}", IrisProceduralObjects.class);
|
||||
|
||||
List<IrisProceduralPlacement> placements = objects.getAllPlacements();
|
||||
assertEquals(5, placements.size());
|
||||
assertSame("one placeable per settings, kept", placements.get(0), objects.getAllPlacements().get(0));
|
||||
|
||||
IrisProceduralPlacement iceberg = placements.get(1);
|
||||
assertEquals("glacial-iceberg", iceberg.getName());
|
||||
assertEquals(0.08, iceberg.getChance(), 0);
|
||||
IrisObjectPlacement placement = iceberg.asPlacement();
|
||||
assertEquals(ObjectPlaceMode.CENTER_HEIGHT, placement.getMode());
|
||||
assertEquals(1, placement.getSurfaceSupportBuffer());
|
||||
assertEquals(-4, placement.getTranslate().getY());
|
||||
assertEquals(45, placement.getRotation().getYAxis().interval(), 0);
|
||||
assertTrue(placement.getRotation().isEnabled());
|
||||
assertFalse(iceberg.isPlausible());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void emptyKindsHaveIrisDefaults() {
|
||||
Coral coral = gson.fromJson("{}", Coral.class);
|
||||
assertEquals("coral", coral.name());
|
||||
assertEquals(0.4, coral.chance(), 0);
|
||||
assertEquals(CoralForm.BRANCHING, coral.form());
|
||||
assertEquals("minecraft:tube_coral_block", coral.block());
|
||||
assertTrue(coral.underwater());
|
||||
assertTrue(coral.tipBlock().isEmpty());
|
||||
assertTrue(coral.stiltSettings().isEmpty());
|
||||
|
||||
assertEquals(ObjectPlaceMode.MIN_HEIGHT, gson.fromJson("{}", Ruin.class).mode());
|
||||
assertEquals("fungus", gson.fromJson("{}", Fungus.class).name());
|
||||
assertEquals(3, gson.fromJson("{}", Formation.class).surfaceSupportBuffer());
|
||||
assertEquals(TreeLeafMode.TRIMMED, TreeLeafMode.valueOf("TRIMMED"));
|
||||
}
|
||||
}
|
||||
+40
-39
@@ -1,8 +1,9 @@
|
||||
package art.arcane.iris.engine.object.procedural.formation;
|
||||
|
||||
import art.arcane.iris.engine.object.TestSettings;
|
||||
import art.arcane.iris.builtin.objects.formation.Formation;
|
||||
import art.arcane.iris.engine.object.procedural.formation.FormationCanvas;
|
||||
import art.arcane.iris.engine.object.procedural.formation.FormationShapeBuilder;
|
||||
import art.arcane.iris.engine.object.procedural.formation.IrisFormation;
|
||||
import art.arcane.iris.util.common.math.Vector3i;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import org.junit.Test;
|
||||
@@ -65,18 +66,18 @@ public class FormationShapeBuilderTest {
|
||||
|
||||
@Test
|
||||
public void thinLeaningSpireRetainsAConnectedPointedTip() {
|
||||
IrisFormation formation = baseFormation();
|
||||
formation.setRoughness(0.12);
|
||||
formation.setJitter(0.02);
|
||||
formation.setTopWidth(0);
|
||||
formation.setLean(10);
|
||||
formation.setLeanAzimuth(18);
|
||||
Formation formation = baseFormation();
|
||||
TestSettings.with(formation, "roughness", 0.12);
|
||||
TestSettings.with(formation, "jitter", 0.02);
|
||||
TestSettings.with(formation, "topWidth", 0);
|
||||
TestSettings.with(formation, "lean", 10);
|
||||
TestSettings.with(formation, "leanAzimuth", 18);
|
||||
FormationCanvas canvas = new FormationCanvas();
|
||||
int height = 48;
|
||||
FormationShapeBuilder.spire(canvas, formation, height, 1.0, new RNG(137L));
|
||||
double shear = Math.tan(Math.toRadians(formation.getLean())) * (height - 1);
|
||||
int tipX = (int) Math.round(Math.cos(Math.toRadians(formation.getLeanAzimuth())) * shear);
|
||||
int tipZ = (int) Math.round(Math.sin(Math.toRadians(formation.getLeanAzimuth())) * shear);
|
||||
double shear = Math.tan(Math.toRadians(formation.lean())) * (height - 1);
|
||||
int tipX = (int) Math.round(Math.cos(Math.toRadians(formation.leanAzimuth())) * shear);
|
||||
int tipZ = (int) Math.round(Math.sin(Math.toRadians(formation.leanAzimuth())) * shear);
|
||||
|
||||
assertEquals(FormationCanvas.Role.CAP, canvas.getCells().get(new Vector3i(tipX, height - 1, tipZ)));
|
||||
assertEquals(height - 1, maxY(canvas));
|
||||
@@ -86,10 +87,10 @@ public class FormationShapeBuilderTest {
|
||||
|
||||
@Test
|
||||
public void archRetainsGroundedLegsAndAnOpenCenter() {
|
||||
IrisFormation formation = baseFormation();
|
||||
formation.setArchSpan(10);
|
||||
formation.setArchThickness(2);
|
||||
formation.setArchAsymmetry(0.8);
|
||||
Formation formation = baseFormation();
|
||||
TestSettings.with(formation, "archSpan", 10);
|
||||
TestSettings.with(formation, "archThickness", 2);
|
||||
TestSettings.with(formation, "archAsymmetry", 0.8);
|
||||
FormationCanvas canvas = arch(formation, 149L);
|
||||
FormationCanvas repeated = arch(formation, 149L);
|
||||
FormationCanvas different = arch(formation, 151L);
|
||||
@@ -107,17 +108,17 @@ public class FormationShapeBuilderTest {
|
||||
|
||||
@Test
|
||||
public void zeroAsymmetryKeepsArchMirroredAndThicknessScales() {
|
||||
IrisFormation formation = baseFormation();
|
||||
formation.setRoughness(0.0);
|
||||
formation.setJitter(0.0);
|
||||
formation.setArchSpan(10);
|
||||
formation.setArchAsymmetry(0.0);
|
||||
Formation formation = baseFormation();
|
||||
TestSettings.with(formation, "roughness", 0.0);
|
||||
TestSettings.with(formation, "jitter", 0.0);
|
||||
TestSettings.with(formation, "archSpan", 10);
|
||||
TestSettings.with(formation, "archAsymmetry", 0.0);
|
||||
|
||||
formation.setArchThickness(1);
|
||||
TestSettings.with(formation, "archThickness", 1);
|
||||
FormationCanvas thin = arch(formation, 173L);
|
||||
formation.setArchThickness(2);
|
||||
TestSettings.with(formation, "archThickness", 2);
|
||||
FormationCanvas medium = arch(formation, 173L);
|
||||
formation.setArchThickness(3);
|
||||
TestSettings.with(formation, "archThickness", 3);
|
||||
FormationCanvas thick = arch(formation, 173L);
|
||||
|
||||
assertEquals(0, unmirroredCells(medium));
|
||||
@@ -135,51 +136,51 @@ public class FormationShapeBuilderTest {
|
||||
}
|
||||
|
||||
private FormationCanvas iceberg(long seed) {
|
||||
IrisFormation formation = baseFormation();
|
||||
formation.setIcebergPeaks(4);
|
||||
Formation formation = baseFormation();
|
||||
TestSettings.with(formation, "icebergPeaks", 4);
|
||||
FormationCanvas canvas = new FormationCanvas();
|
||||
FormationShapeBuilder.iceberg(canvas, formation, 20, 5.0, new RNG(seed));
|
||||
return canvas;
|
||||
}
|
||||
|
||||
private FormationCanvas fissure(long seed) {
|
||||
IrisFormation formation = baseFormation();
|
||||
formation.setFractureCount(3);
|
||||
formation.setFractureSeparation(4);
|
||||
Formation formation = baseFormation();
|
||||
TestSettings.with(formation, "fractureCount", 3);
|
||||
TestSettings.with(formation, "fractureSeparation", 4);
|
||||
FormationCanvas canvas = new FormationCanvas();
|
||||
FormationShapeBuilder.fissure(canvas, formation, 18, 4.0, new RNG(seed));
|
||||
return canvas;
|
||||
}
|
||||
|
||||
private FormationCanvas spiral(long seed) {
|
||||
IrisFormation formation = baseFormation();
|
||||
formation.setSpiralTurns(1.75);
|
||||
formation.setSpiralRadius(6);
|
||||
formation.setSpiralThickness(1);
|
||||
Formation formation = baseFormation();
|
||||
TestSettings.with(formation, "spiralTurns", 1.75);
|
||||
TestSettings.with(formation, "spiralRadius", 6);
|
||||
TestSettings.with(formation, "spiralThickness", 1);
|
||||
FormationCanvas canvas = new FormationCanvas();
|
||||
FormationShapeBuilder.spiral(canvas, formation, 20, 4.0, new RNG(seed));
|
||||
return canvas;
|
||||
}
|
||||
|
||||
private FormationCanvas overhang(long seed) {
|
||||
IrisFormation formation = baseFormation();
|
||||
formation.setOverhangReach(14);
|
||||
formation.setOverhangDrop(4);
|
||||
Formation formation = baseFormation();
|
||||
TestSettings.with(formation, "overhangReach", 14);
|
||||
TestSettings.with(formation, "overhangDrop", 4);
|
||||
FormationCanvas canvas = new FormationCanvas();
|
||||
FormationShapeBuilder.overhang(canvas, formation, 20, 3.0, new RNG(seed));
|
||||
return canvas;
|
||||
}
|
||||
|
||||
private FormationCanvas arch(IrisFormation formation, long seed) {
|
||||
private FormationCanvas arch(Formation formation, long seed) {
|
||||
FormationCanvas canvas = new FormationCanvas();
|
||||
FormationShapeBuilder.arch(canvas, formation, 18, 4.0, new RNG(seed));
|
||||
return canvas;
|
||||
}
|
||||
|
||||
private IrisFormation baseFormation() {
|
||||
IrisFormation formation = new IrisFormation();
|
||||
formation.setRoughness(0.2);
|
||||
formation.setJitter(0.05);
|
||||
private Formation baseFormation() {
|
||||
Formation formation = new Formation();
|
||||
TestSettings.with(formation, "roughness", 0.2);
|
||||
TestSettings.with(formation, "jitter", 0.05);
|
||||
return formation;
|
||||
}
|
||||
|
||||
|
||||
+30
-29
@@ -1,12 +1,13 @@
|
||||
package art.arcane.iris.engine.object.procedural.tree;
|
||||
|
||||
import art.arcane.iris.engine.object.procedural.tree.IrisTreeAzimuthMode;
|
||||
import art.arcane.iris.engine.object.procedural.tree.IrisTreeBranchProbability;
|
||||
import art.arcane.iris.engine.object.procedural.tree.IrisTreeBranches;
|
||||
import art.arcane.iris.engine.object.procedural.tree.IrisTreeFunction;
|
||||
import art.arcane.iris.engine.object.procedural.tree.IrisTreeLeafMode;
|
||||
import art.arcane.iris.engine.object.procedural.tree.IrisTreeProfile;
|
||||
import art.arcane.iris.engine.object.procedural.tree.IrisTreeSubBranches;
|
||||
import art.arcane.iris.engine.object.TestSettings;
|
||||
import art.arcane.iris.builtin.objects.tree.TreeSubBranches;
|
||||
import art.arcane.iris.builtin.objects.tree.TreeBranches;
|
||||
import art.arcane.iris.builtin.objects.tree.TreeProfile;
|
||||
import art.arcane.iris.builtin.objects.tree.TreeLeafMode;
|
||||
import art.arcane.iris.builtin.objects.tree.TreeFunction;
|
||||
import art.arcane.iris.builtin.objects.tree.TreeBranchProbability;
|
||||
import art.arcane.iris.builtin.objects.tree.TreeAzimuthMode;
|
||||
import art.arcane.iris.engine.object.procedural.tree.TreeBlockCanvas;
|
||||
import art.arcane.iris.engine.object.procedural.tree.TreeCanopyBuilder;
|
||||
import art.arcane.iris.engine.object.procedural.tree.TreePlausibility;
|
||||
@@ -81,7 +82,7 @@ public class ProceduralTreeGeneratorTest {
|
||||
IrisProceduralTree tree = new IrisProceduralTree();
|
||||
tree.setTrunk("minecraft:oak_log");
|
||||
tree.setLeaves("minecraft:oak_leaves");
|
||||
tree.setProfile(IrisTreeProfile.OAK);
|
||||
tree.setProfile(TreeProfile.OAK);
|
||||
|
||||
TreeBlockCanvas canvas = new TreeBlockCanvas();
|
||||
int height = 9;
|
||||
@@ -99,19 +100,19 @@ public class ProceduralTreeGeneratorTest {
|
||||
|
||||
@Test
|
||||
public void hollowCanopyHasFewerLeavesThanFilled() {
|
||||
TreeBlockCanvas filled = canopyOnly(IrisTreeLeafMode.FILLED);
|
||||
TreeBlockCanvas hollow = canopyOnly(IrisTreeLeafMode.HOLLOW);
|
||||
TreeBlockCanvas filled = canopyOnly(TreeLeafMode.FILLED);
|
||||
TreeBlockCanvas hollow = canopyOnly(TreeLeafMode.HOLLOW);
|
||||
assertTrue("hollow canopy should place fewer leaves than filled",
|
||||
hollow.getLeaf().size() < filled.getLeaf().size());
|
||||
assertFalse("hollow canopy still places a leaf shell", hollow.getLeaf().isEmpty());
|
||||
}
|
||||
|
||||
private TreeBlockCanvas canopyOnly(IrisTreeLeafMode mode) {
|
||||
private TreeBlockCanvas canopyOnly(TreeLeafMode mode) {
|
||||
IrisProceduralTree tree = new IrisProceduralTree();
|
||||
tree.setTrunk("minecraft:oak_log");
|
||||
tree.setLeaves("minecraft:oak_leaves");
|
||||
tree.setProfile(IrisTreeProfile.OAK);
|
||||
tree.getCanopy().setMode(mode);
|
||||
tree.setProfile(TreeProfile.OAK);
|
||||
TestSettings.with(tree.getCanopy(), "mode", mode);
|
||||
TreeBlockCanvas canvas = new TreeBlockCanvas();
|
||||
int height = 10;
|
||||
double[][] offsets = TreeTrunkBuilder.build(canvas, tree, height).get(0).offsets();
|
||||
@@ -124,14 +125,14 @@ public class ProceduralTreeGeneratorTest {
|
||||
IrisProceduralTree tree = new IrisProceduralTree();
|
||||
tree.setTrunk("minecraft:jungle_log");
|
||||
tree.setLeaves("minecraft:jungle_leaves");
|
||||
tree.setProfile(IrisTreeProfile.JUNGLE);
|
||||
IrisTreeBranches branches = new IrisTreeBranches();
|
||||
branches.setProbabilityFunction(IrisTreeBranchProbability.CONSTANT);
|
||||
branches.setProbabilityConstant(1.0);
|
||||
branches.setLengthFunction(IrisTreeFunction.CONSTANT);
|
||||
branches.setLengthConstant(4);
|
||||
branches.setAzimuthMode(art.arcane.iris.engine.object.procedural.tree.IrisTreeAzimuthMode.GOLDEN_ANGLE);
|
||||
tree.getCanopy().setBranches(branches);
|
||||
tree.setProfile(TreeProfile.JUNGLE);
|
||||
TreeBranches branches = new TreeBranches();
|
||||
TestSettings.with(branches, "probabilityFunction", TreeBranchProbability.CONSTANT);
|
||||
TestSettings.with(branches, "probabilityConstant", 1.0);
|
||||
TestSettings.with(branches, "lengthFunction", TreeFunction.CONSTANT);
|
||||
TestSettings.with(branches, "lengthConstant", 4);
|
||||
TestSettings.with(branches, "azimuthMode", art.arcane.iris.builtin.objects.tree.TreeAzimuthMode.GOLDEN_ANGLE);
|
||||
TestSettings.with(tree.getCanopy(), "branches", branches);
|
||||
|
||||
TreeBlockCanvas canvas = new TreeBlockCanvas();
|
||||
int height = 14;
|
||||
@@ -176,14 +177,14 @@ public class ProceduralTreeGeneratorTest {
|
||||
IrisProceduralTree tree = new IrisProceduralTree();
|
||||
tree.setTrunk("minecraft:oak_log");
|
||||
tree.setLeaves("minecraft:oak_leaves");
|
||||
IrisTreeBranches branches = new IrisTreeBranches();
|
||||
branches.setProbabilityFunction(IrisTreeBranchProbability.CONSTANT);
|
||||
branches.setProbabilityConstant(1.0);
|
||||
branches.setLengthFunction(IrisTreeFunction.CONSTANT);
|
||||
branches.setLengthConstant(4);
|
||||
branches.setBranchDepth(depth);
|
||||
branches.setSubBranches(new art.arcane.iris.engine.object.procedural.tree.IrisTreeSubBranches());
|
||||
tree.getCanopy().setBranches(branches);
|
||||
TreeBranches branches = new TreeBranches();
|
||||
TestSettings.with(branches, "probabilityFunction", TreeBranchProbability.CONSTANT);
|
||||
TestSettings.with(branches, "probabilityConstant", 1.0);
|
||||
TestSettings.with(branches, "lengthFunction", TreeFunction.CONSTANT);
|
||||
TestSettings.with(branches, "lengthConstant", 4);
|
||||
TestSettings.with(branches, "branchDepth", depth);
|
||||
TestSettings.with(branches, "subBranches", new art.arcane.iris.builtin.objects.tree.TreeSubBranches());
|
||||
TestSettings.with(tree.getCanopy(), "branches", branches);
|
||||
|
||||
TreeBlockCanvas canvas = new TreeBlockCanvas();
|
||||
int height = 14;
|
||||
|
||||
+1
-1
@@ -1,8 +1,8 @@
|
||||
package art.arcane.iris.engine.object.structure.vanilla;
|
||||
|
||||
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
|
||||
import art.arcane.iris.engine.object.placement.IObjectPlacer;
|
||||
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
|
||||
import art.arcane.iris.engine.object.placement.ObjectPlaceMode;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import art.arcane.iris.engine.object.prefab.TileData;
|
||||
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
||||
|
||||
+171
@@ -0,0 +1,171 @@
|
||||
/*
|
||||
* 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.engine.object.terrain.carving;
|
||||
|
||||
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
|
||||
import art.arcane.iris.builtin.carve.CaveAnchorMode;
|
||||
import art.arcane.iris.builtin.carve.CaveProfile;
|
||||
import art.arcane.iris.builtin.carve.CarvingMode;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.CALLS_REAL_METHODS;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
/**
|
||||
* The cave profile of the overworld pack's dimension, read into {@link CaveProfile} (IrisApi types only) with the values
|
||||
* Iris's own cave profile class read from the same JSON, and what the carvers read it as ({@link ResolvedCaveProfile}).
|
||||
*/
|
||||
public class CaveProfileDecodingTest {
|
||||
private static final String OVERWORLD_CAVE_PROFILE = """
|
||||
{"enabled": true, "verticalRange": {"min": 6, "max": 700},
|
||||
"baseDensityStyle": {"style": "PERLIN_IRIS", "zoom": 0.72}, "detailDensityStyle": {"style": "SIMPLEX", "zoom": 0.54},
|
||||
"warpStyle": {"style": "FRACTAL_WATER", "zoom": 0.5}, "baseWeight": 0.9, "detailWeight": 0.11, "warpStrength": 0.24,
|
||||
"densityThreshold": {"min": -0.14, "max": -0.06, "style": {"style": "SIMPLEX", "zoom": 0.74}},
|
||||
"thresholdBias": 0.14, "sampleStep": 3, "surfaceClearance": 5, "allowSurfaceBreak": true,
|
||||
"surfaceBreakStyle": {"style": "SIMPLEX", "zoom": 0.88}, "surfaceBreakNoiseThreshold": 0.6, "surfaceBreakDepth": 16,
|
||||
"surfaceBreakThresholdBoost": 0.1, "objectMinDepthBelowSurface": 14, "defaultObjectAnchor": "FLOOR",
|
||||
"defaultObjectPlaceMode": "ORGANIC_STILT", "anchorScanStep": 1, "anchorSearchAttempts": 12, "allowFluid": true,
|
||||
"fluidMinDepthBelowSurface": 20, "fluidRequiresFloor": true, "allowLava": true,
|
||||
"modules": [{"style": {"style": "SIMPLEX_VASCULAR", "zoom": 1.08}, "weight": 0.08, "threshold": 0.03,
|
||||
"verticalRange": {"min": 24, "max": 660}, "invert": false},
|
||||
{"style": {"style": "FRACTAL_FBM_SIMPLEX", "zoom": 0.24}, "weight": 0.04, "threshold": 0.08,
|
||||
"verticalRange": {"min": 6, "max": 240}, "invert": true}],
|
||||
"verticalEdgeFade": 24, "verticalEdgeFadeStrength": 0.18, "minCarveCells": 24, "recoveryThresholdBoost": 0.07}
|
||||
""";
|
||||
private static final String DARK_DEPTHS_OBJECT = """
|
||||
{"place": ["rocks/a"], "chance": 0.235719, "density": 4, "carvingSupport": "CARVING_ONLY",
|
||||
"caveAnchorMode": "PROFILE_DEFAULT", "translate": {"y": -1}, "bottom": true, "force": true}
|
||||
""";
|
||||
|
||||
@Rule
|
||||
public TemporaryFolder folder = new TemporaryFolder();
|
||||
|
||||
private Gson gson;
|
||||
|
||||
@Before
|
||||
public void decodeLikeIrisDoes() throws IOException {
|
||||
File snippets = folder.newFolder("snippet", "cave-profile");
|
||||
Files.writeString(new File(snippets, "lush.json").toPath(), "{\"enabled\": true, \"sampleStep\": 2}");
|
||||
IrisData data = mock(IrisData.class, CALLS_REAL_METHODS);
|
||||
doReturn(folder.getRoot()).when(data).getDataFolder();
|
||||
gson = new GsonBuilder().registerTypeAdapterFactory(data).create();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void theOverworldProfileReadsEveryFieldIrisReadFromIt() {
|
||||
CaveProfile profile = gson.fromJson(OVERWORLD_CAVE_PROFILE, CaveProfile.class);
|
||||
|
||||
assertTrue(profile.enabled());
|
||||
assertEquals(6, profile.verticalRange().min(), 0);
|
||||
assertEquals(700, profile.verticalRange().max(), 0);
|
||||
assertEquals("PERLIN_IRIS", profile.baseDensityStyle().style());
|
||||
assertEquals(0.72, profile.baseDensityStyle().zoom(), 0);
|
||||
assertEquals("FRACTAL_WATER", profile.warpStyle().style());
|
||||
assertEquals(0.9, profile.baseWeight(), 0);
|
||||
assertEquals(0.24, profile.warpStrength(), 0);
|
||||
assertEquals(-0.14, profile.densityThreshold().min(), 0);
|
||||
assertEquals("SIMPLEX", profile.densityThreshold().style().style());
|
||||
assertEquals(3, profile.sampleStep());
|
||||
assertEquals(CaveAnchorMode.FLOOR, profile.defaultObjectAnchor());
|
||||
assertEquals(ObjectPlaceMode.ORGANIC_STILT, profile.defaultObjectPlaceMode().orElseThrow());
|
||||
assertEquals(12, profile.anchorSearchAttempts());
|
||||
assertEquals(24, profile.verticalEdgeFade());
|
||||
assertEquals(2, profile.modules().size());
|
||||
assertEquals("SIMPLEX_VASCULAR", profile.modules().get(0).style().style());
|
||||
assertFalse(profile.modules().get(0).invert());
|
||||
assertTrue(profile.modules().get(1).invert());
|
||||
assertEquals(240, profile.modules().get(1).verticalRange().max(), 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void anEmptyProfileHasIrisDefaults() {
|
||||
CaveProfile profile = gson.fromJson("{}", CaveProfile.class);
|
||||
|
||||
assertFalse(profile.enabled());
|
||||
assertEquals(0, profile.verticalRange().min(), 0);
|
||||
assertEquals(384, profile.verticalRange().max(), 0);
|
||||
assertEquals("CELLULAR_IRIS_DOUBLE", profile.baseDensityStyle().style());
|
||||
assertEquals("SIMPLEX", profile.detailDensityStyle().style());
|
||||
assertEquals("FLAT", profile.warpStyle().style());
|
||||
assertEquals(0.08, profile.surfaceBreakStyle().zoom(), 0);
|
||||
assertEquals(-0.2, profile.densityThreshold().min(), 0);
|
||||
assertEquals(0.2, profile.densityThreshold().max(), 0);
|
||||
assertEquals(0.35, profile.detailWeight(), 0);
|
||||
assertEquals(0.16, profile.thresholdBias(), 0);
|
||||
assertEquals(20, profile.verticalEdgeFade());
|
||||
assertEquals(CaveAnchorMode.FLOOR, profile.defaultObjectAnchor());
|
||||
assertTrue(profile.defaultObjectPlaceMode().isEmpty());
|
||||
assertTrue(profile.modules().isEmpty());
|
||||
assertTrue(profile.allowFluid() && profile.fluidRequiresFloor() && profile.allowLava() && profile.adaptiveSampling());
|
||||
assertEquals(12, profile.fluidMinDepthBelowSurface());
|
||||
assertEquals(6, profile.anchorSearchAttempts());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void profilesMayBeSnippets() {
|
||||
CaveProfile profile = gson.fromJson("\"snippet/cave-profile/lush\"", CaveProfile.class);
|
||||
|
||||
assertTrue(profile.enabled());
|
||||
assertEquals(2, profile.sampleStep());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void placementsReadTheirCarvingSupportAndAnchorMode() {
|
||||
IrisObjectPlacement placement = gson.fromJson(DARK_DEPTHS_OBJECT, IrisObjectPlacement.class);
|
||||
|
||||
assertEquals(CarvingMode.CARVING_ONLY, placement.getCarvingSupport());
|
||||
assertTrue(placement.getCarvingSupport().supportsCarving());
|
||||
assertFalse(placement.getCarvingSupport().supportsSurface());
|
||||
assertEquals(CaveAnchorMode.PROFILE_DEFAULT, placement.getCaveAnchorMode());
|
||||
assertEquals(CarvingMode.SURFACE_ONLY, gson.fromJson("{}", IrisObjectPlacement.class).getCarvingSupport());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void carversReadTheProfileAsIrisStylesAndRanges() {
|
||||
ResolvedCaveProfile resolved = ResolvedCaveProfile.of(gson.fromJson(OVERWORLD_CAVE_PROFILE, CaveProfile.class));
|
||||
|
||||
assertEquals(6, resolved.verticalRange().getMin(), 0);
|
||||
assertEquals(700, resolved.verticalRange().getMax(), 0);
|
||||
assertEquals("PERLIN_IRIS", resolved.baseDensityStyle().getStyle().name());
|
||||
assertEquals(0.72, resolved.baseDensityStyle().getZoom(), 0);
|
||||
assertEquals("FRACTAL_WATER", resolved.warpStyle().getStyle().name());
|
||||
assertEquals(0.88, resolved.surfaceBreakStyle().getZoom(), 0);
|
||||
assertEquals(-0.06, resolved.densityThreshold().getMax(), 0);
|
||||
assertEquals("SIMPLEX", resolved.densityThreshold().getStyle().getStyle().name());
|
||||
assertEquals(2, resolved.modules().size());
|
||||
assertEquals(0.08, resolved.modules().get(0).weight(), 0);
|
||||
assertEquals(24, resolved.modules().get(0).verticalRange().getMin(), 0);
|
||||
assertTrue(resolved.modules().get(1).invert());
|
||||
}
|
||||
}
|
||||
+157
@@ -0,0 +1,157 @@
|
||||
/*
|
||||
* 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.engine.object.terrain.floating;
|
||||
|
||||
import art.arcane.iris.builtin.floating.FloatingBottomPaletteMode;
|
||||
import art.arcane.iris.builtin.floating.FloatingChildBiome;
|
||||
import art.arcane.iris.builtin.floating.OverrideMode;
|
||||
import art.arcane.iris.builtin.floating.TopShapeMode;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.CALLS_REAL_METHODS;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
/** The floating child of the overworld pack's magnetics/dunes biome, read into {@link FloatingChildBiome} with the values Iris's own class read from the same JSON. */
|
||||
public class FloatingChildBiomeDecodingTest {
|
||||
private static final String DUNES_CHILD = """
|
||||
{"biome": "magnetics/dunes", "rarity": 1,
|
||||
"footprintStyle": {"style": "CELLULAR_IRIS", "zoom": 0.55, "fracture": {"style": "SIMPLEX", "zoom": 0.2, "multiplier": 4}},
|
||||
"footprintThreshold": 0.52, "pickerStyle": {"style": "SIMPLEX", "zoom": 4.0}, "altitudeStyle": {"style": "SIMPLEX", "zoom": 2.6},
|
||||
"minHeightAboveSurface": 90, "maxHeightAboveSurface": 130, "topShapeMode": "NOISE", "maxTopHeight": 16,
|
||||
"topShapeStyle": {"style": "FRACTAL_SMOKE", "zoom": 0.45, "fracture": {"style": "SIMPLEX", "zoom": 0.22, "multiplier": 4}},
|
||||
"topShapeAmp": 0.75, "edgeTaperWidth": 14, "edgeTaperExponent": 1.45,
|
||||
"edgeTaperVariationStyle": {"style": "SIMPLEX", "zoom": 0.18}, "edgeTaperVariationAmplitude": 4,
|
||||
"bottomStyle": {"style": "SIMPLEX_VASCULAR", "zoom": 0.28}, "bottomDepthMin": 5, "bottomDepthMax": 48, "bottomExponent": 2.35,
|
||||
"bottomPaletteMode": "CUSTOM",
|
||||
"bottomPalette": [{"minHeight": 2, "maxHeight": 5, "palette": [{"block": "minecraft:sandstone"}, {"block": "minecraft:smooth_sandstone"}]}],
|
||||
"maxThickness": 72, "wallWarpStyle": {"style": "SIMPLEX", "zoom": 0.24}, "wallWarpAmplitude": 5,
|
||||
"carving": "carving/sand-hollows-child", "carveStyle": {"style": "SIMPLEX", "zoom": 0.2}, "carveThreshold": 0.86,
|
||||
"inheritDecorators": true, "inheritObjects": false, "objectShrinkFactor": 0.55, "topObjectMode": "MERGE",
|
||||
"topObjectOverrides": [{"place": ["clutter/boulder1"], "chance": 0.55, "mode": "CENTER_HEIGHT", "density": 5},
|
||||
{"place": ["clutter/shrub1"], "chance": 0.42, "density": 4}],
|
||||
"bottomObjectMode": "REPLACE",
|
||||
"bottomObjectOverrides": [{"place": ["clutter/bone4"], "chance": 0.04, "mode": "FAST_MIN_HEIGHT", "density": 1}]}
|
||||
""";
|
||||
|
||||
@Rule
|
||||
public TemporaryFolder folder = new TemporaryFolder();
|
||||
|
||||
private Gson gson;
|
||||
|
||||
@Before
|
||||
public void decodeLikeIrisDoes() {
|
||||
IrisData data = mock(IrisData.class, CALLS_REAL_METHODS);
|
||||
doReturn(folder.getRoot()).when(data).getDataFolder();
|
||||
gson = new GsonBuilder().registerTypeAdapterFactory(data).create();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void theMagneticsDunesChildReadsEveryFieldIrisReadFromIt() {
|
||||
FloatingChildBiome child = gson.fromJson(DUNES_CHILD, FloatingChildBiome.class);
|
||||
|
||||
assertEquals("magnetics/dunes", child.biome());
|
||||
assertEquals("CELLULAR_IRIS", child.footprintStyle().style());
|
||||
assertEquals(0.55, child.footprintStyle().zoom(), 0);
|
||||
assertEquals("SIMPLEX", child.footprintStyle().fracture().orElseThrow().style());
|
||||
assertEquals(4, child.footprintStyle().fracture().orElseThrow().multiplier(), 0);
|
||||
assertEquals(0.52, child.footprintThreshold(), 0);
|
||||
assertEquals(4.0, child.pickerStyle().zoom(), 0);
|
||||
assertEquals(90, child.minHeightAboveSurface());
|
||||
assertEquals(TopShapeMode.NOISE, child.topShapeMode());
|
||||
assertEquals(14, child.edgeTaperWidth());
|
||||
assertEquals(1.45, child.edgeTaperExponent(), 0);
|
||||
assertEquals(4, child.edgeTaperVariationAmplitude(), 0);
|
||||
assertEquals(FloatingBottomPaletteMode.CUSTOM, child.bottomPaletteMode());
|
||||
assertEquals(1, child.bottomPalette().size());
|
||||
assertEquals(5, child.bottomPalette().get(0).getMaxHeight());
|
||||
assertEquals("SIMPLEX", child.wallWarpStyle().orElseThrow().style());
|
||||
assertEquals(5, child.wallWarpAmplitude(), 0);
|
||||
assertEquals("carving/sand-hollows-child", child.carving());
|
||||
assertEquals(0.86, child.carveThreshold(), 0);
|
||||
assertFalse(child.inheritObjects());
|
||||
assertEquals(0.55, child.objectShrinkFactor(), 0);
|
||||
assertEquals(OverrideMode.MERGE, child.topObjectMode());
|
||||
assertEquals(2, child.topObjectOverrides().size());
|
||||
assertEquals(5, child.topObjectOverrides().get(0).getDensity());
|
||||
assertEquals(OverrideMode.REPLACE, child.bottomObjectMode());
|
||||
assertEquals("clutter/bone4", child.bottomObjectOverrides().get(0).getPlace().get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void anEmptyChildHasIrisDefaults() {
|
||||
FloatingChildBiome child = gson.fromJson("{}", FloatingChildBiome.class);
|
||||
|
||||
assertEquals("", child.biome());
|
||||
assertEquals(1, child.rarity());
|
||||
assertEquals("SIMPLEX", child.footprintStyle().style());
|
||||
assertEquals(0.18, child.edgeTaperVariationStyle().zoom(), 0);
|
||||
assertEquals(0.5, child.footprintThreshold(), 0);
|
||||
assertEquals(10, child.edgeTaperWidth());
|
||||
assertEquals(160, child.minHeightAboveSurface());
|
||||
assertEquals(210, child.maxHeightAboveSurface());
|
||||
assertEquals(TopShapeMode.BIOME, child.topShapeMode());
|
||||
assertEquals(FloatingBottomPaletteMode.DEPTH, child.bottomPaletteMode());
|
||||
assertTrue(child.wallWarpStyle().isEmpty());
|
||||
assertTrue(child.carveStyle().isEmpty());
|
||||
assertTrue(child.minAbsoluteY().isEmpty());
|
||||
assertTrue(child.localFluidHeight().isEmpty());
|
||||
assertEquals("minecraft:water", child.fluidBlock());
|
||||
assertTrue(child.inheritDecorators() && child.inheritObjects());
|
||||
assertEquals(OverrideMode.INHERIT_ONLY, child.topObjectMode());
|
||||
assertEquals(96, child.maxThickness());
|
||||
assertEquals(1.0, child.carveThreshold(), 0);
|
||||
assertTrue(child.topObjectOverrides().isEmpty());
|
||||
assertNull(child.color().isEmpty() ? null : child.color());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aBiomeHoldsItsChildrenAsSettings() {
|
||||
IrisBiome biome = gson.fromJson("{\"floatingChildBiomes\": [" + DUNES_CHILD + ", {}]}", IrisBiome.class);
|
||||
|
||||
assertEquals(2, biome.getFloatingChildBiomes().size());
|
||||
assertEquals("magnetics/dunes", biome.getFloatingChildBiomes().get(0).biome());
|
||||
assertNotNull(biome.getFloatingChildBiomes().get(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void theEdgeTaperProfileKeepsTheSettingsWidthExponentAndVariation() {
|
||||
FloatingChildBiome child = gson.fromJson(DUNES_CHILD, FloatingChildBiome.class);
|
||||
ResolvedFloatingChild resolved = new ResolvedFloatingChild(child);
|
||||
|
||||
FloatingIslandEdgeProfile profile = resolved.getEdgeTaperProfile(77L, mock(IrisData.class));
|
||||
|
||||
assertEquals(14, profile.width());
|
||||
assertEquals(1.45, profile.exponent(), 0);
|
||||
assertEquals(4, profile.variationAmplitude(), 0);
|
||||
assertEquals(2, resolved.getRarity() + 1);
|
||||
}
|
||||
}
|
||||
+28
-56
@@ -18,10 +18,11 @@
|
||||
|
||||
package art.arcane.iris.engine.object.terrain.floating;
|
||||
|
||||
import art.arcane.iris.builtin.floating.FloatingChildBiome;
|
||||
import art.arcane.iris.engine.object.TestSettings;
|
||||
import art.arcane.iris.builtin.floating.TopShapeMode;
|
||||
import art.arcane.iris.engine.object.terrain.floating.FloatingIslandBoundarySampler;
|
||||
import art.arcane.iris.engine.object.terrain.floating.FloatingIslandSample;
|
||||
import art.arcane.iris.engine.object.terrain.floating.IrisFloatingChildBiomes;
|
||||
import art.arcane.iris.engine.object.terrain.floating.TopShapeMode;
|
||||
import art.arcane.iris.engine.object.world.IrisWorld;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
@@ -403,9 +404,9 @@ public class FloatingIslandBoundarySamplerTest {
|
||||
|
||||
@Test
|
||||
public void ownershipFade_tapersAcrossPickerBoundary() {
|
||||
IrisFloatingChildBiomes left = new IrisFloatingChildBiomes().setRarity(1);
|
||||
IrisFloatingChildBiomes right = new IrisFloatingChildBiomes().setRarity(1);
|
||||
KList<IrisFloatingChildBiomes> entries = new KList<>();
|
||||
ResolvedFloatingChild left = new ResolvedFloatingChild(new FloatingChildBiome());
|
||||
ResolvedFloatingChild right = new ResolvedFloatingChild(new FloatingChildBiome());
|
||||
KList<ResolvedFloatingChild> entries = new KList<>();
|
||||
entries.add(left);
|
||||
entries.add(right);
|
||||
CNG picker = new CNG(new RNG(18)) {
|
||||
@@ -432,9 +433,9 @@ public class FloatingIslandBoundarySamplerTest {
|
||||
|
||||
@Test
|
||||
public void ownershipFade_rejectsThinPickerRegion() {
|
||||
IrisFloatingChildBiomes left = new IrisFloatingChildBiomes().setRarity(1);
|
||||
IrisFloatingChildBiomes right = new IrisFloatingChildBiomes().setRarity(1);
|
||||
KList<IrisFloatingChildBiomes> entries = new KList<>();
|
||||
ResolvedFloatingChild left = new ResolvedFloatingChild(new FloatingChildBiome());
|
||||
ResolvedFloatingChild right = new ResolvedFloatingChild(new FloatingChildBiome());
|
||||
KList<ResolvedFloatingChild> entries = new KList<>();
|
||||
entries.add(left);
|
||||
entries.add(right);
|
||||
CNG picker = new CNG(new RNG(24)) {
|
||||
@@ -462,9 +463,9 @@ public class FloatingIslandBoundarySamplerTest {
|
||||
leftParent.setLoadKey("left");
|
||||
IrisBiome rightParent = new IrisBiome();
|
||||
rightParent.setLoadKey("right");
|
||||
IrisFloatingChildBiomes leftChild = new IrisFloatingChildBiomes().setRarity(1);
|
||||
IrisFloatingChildBiomes rightChild = new IrisFloatingChildBiomes().setRarity(1);
|
||||
KList<IrisFloatingChildBiomes> entries = new KList<>();
|
||||
ResolvedFloatingChild leftChild = new ResolvedFloatingChild(new FloatingChildBiome());
|
||||
ResolvedFloatingChild rightChild = new ResolvedFloatingChild(new FloatingChildBiome());
|
||||
KList<ResolvedFloatingChild> entries = new KList<>();
|
||||
entries.add(leftChild);
|
||||
entries.add(rightChild);
|
||||
CNG picker = new CNG(new RNG(29)) {
|
||||
@@ -494,9 +495,9 @@ public class FloatingIslandBoundarySamplerTest {
|
||||
public void sampler_fieldsPublishSafelyAcrossConcurrentReaders() throws Exception {
|
||||
IrisBiome parent = new IrisBiome();
|
||||
parent.setLoadKey("parent");
|
||||
IrisFloatingChildBiomes left = new IrisFloatingChildBiomes().setRarity(1);
|
||||
IrisFloatingChildBiomes right = new IrisFloatingChildBiomes().setRarity(1);
|
||||
KList<IrisFloatingChildBiomes> entries = new KList<>();
|
||||
ResolvedFloatingChild left = new ResolvedFloatingChild(new FloatingChildBiome());
|
||||
ResolvedFloatingChild right = new ResolvedFloatingChild(new FloatingChildBiome());
|
||||
KList<ResolvedFloatingChild> entries = new KList<>();
|
||||
entries.add(left);
|
||||
entries.add(right);
|
||||
CNG constant = new CNG(new RNG(26)) {
|
||||
@@ -555,46 +556,32 @@ public class FloatingIslandBoundarySamplerTest {
|
||||
return 1.0D;
|
||||
}
|
||||
};
|
||||
IrisFloatingChildBiomes entry = mock(IrisFloatingChildBiomes.class);
|
||||
ResolvedFloatingChild entry = mock(ResolvedFloatingChild.class);
|
||||
IrisBiome parent = mock(IrisBiome.class);
|
||||
IrisData data = mock(IrisData.class);
|
||||
Engine engine = mock(Engine.class);
|
||||
IrisWorld world = IrisWorld.builder().minHeight(0).maxHeight(320).build();
|
||||
KList<IrisFloatingChildBiomes> entries = new KList<>();
|
||||
KList<ResolvedFloatingChild> entries = new KList<>();
|
||||
entries.add(entry);
|
||||
when(parent.getFloatingChildBiomes()).thenReturn(entries);
|
||||
when(parent.isMergeFloatingChildBiomes()).thenReturn(false);
|
||||
when(entry.getFootprintCng(anyLong(), same(data))).thenReturn(footprint);
|
||||
when(entry.getFootprintThreshold()).thenReturn(0.5D);
|
||||
when(entry.getAltitudeCng(anyLong(), same(data))).thenReturn(constant);
|
||||
when(entry.getMinHeightAboveSurface()).thenReturn(160);
|
||||
when(entry.getMaxHeightAboveSurface()).thenReturn(160);
|
||||
when(entry.getRealBiome(parent, data)).thenReturn(parent);
|
||||
when(entry.getTopShapeMode()).thenReturn(TopShapeMode.NOISE);
|
||||
when(entry.getTopShapeCng(anyLong(), same(data))).thenReturn(constant);
|
||||
when(entry.getTopShapeAmp()).thenReturn(1.0D);
|
||||
when(entry.getMaxTopHeight()).thenReturn(18);
|
||||
when(entry.getBottomCng(anyLong(), same(data))).thenReturn(constant);
|
||||
when(entry.getBottomExponent()).thenReturn(1.0D);
|
||||
when(entry.getBottomDepthMin()).thenReturn(20);
|
||||
when(entry.getBottomDepthMax()).thenReturn(20);
|
||||
when(entry.getMaxThickness()).thenReturn(64);
|
||||
when(entry.getMinAbsoluteY()).thenReturn(null);
|
||||
when(entry.getMaxAbsoluteY()).thenReturn(null);
|
||||
when(entry.getWallWarpCng(anyLong(), same(data))).thenReturn(null);
|
||||
when(entry.getWallWarpAmplitude()).thenReturn(0.0D);
|
||||
when(entry.getCarvingProfileSampler(engine, data)).thenReturn(null);
|
||||
when(entry.hasCarvingReference()).thenReturn(false);
|
||||
when(entry.getCarveCng(anyLong(), same(data))).thenReturn(constant);
|
||||
when(entry.getCarveThreshold()).thenReturn(0.5D);
|
||||
when(entry.settings()).thenReturn(TestSettings.with(new FloatingChildBiome(), "footprintThreshold", 0.5D, "minHeightAboveSurface", 160, "maxHeightAboveSurface", 160, "topShapeMode", TopShapeMode.NOISE, "topShapeAmp", 1.0D, "maxTopHeight", 18, "bottomExponent", 1.0D, "bottomDepthMin", 20, "bottomDepthMax", 20, "maxThickness", 64, "wallWarpAmplitude", 0.0D, "carveThreshold", 0.5D));
|
||||
when(engine.getWorld()).thenReturn(world);
|
||||
FloatingIslandBoundarySampler sampler = new FloatingIslandBoundarySampler((x, z) -> parent);
|
||||
int[] expectedBottom = {159, 158, 156, 153, 150, 147, 144, 142, 141, 140};
|
||||
int[] expectedTop = {161, 162, 164, 166, 169, 172, 174, 176, 177, 178};
|
||||
|
||||
assertNull(FloatingIslandSample.sample(parent, 0, 0, 320, 31L, data, engine, sampler));
|
||||
assertNull(FloatingIslandSample.sample(parent, entries, 0, 0, 320, 31L, data, engine, sampler));
|
||||
for (int i = 0; i < expectedBottom.length; i++) {
|
||||
FloatingIslandSample sample = FloatingIslandSample.sample(parent, i + 1, 0, 320, 31L, data, engine, sampler);
|
||||
FloatingIslandSample sample = FloatingIslandSample.sample(parent, entries, i + 1, 0, 320, 31L, data, engine, sampler);
|
||||
assertNotNull("distance " + (i + 2) + " rejected with code " + FloatingIslandSample.getLastReject(), sample);
|
||||
assertEquals(expectedBottom[i], sample.bottomY());
|
||||
assertEquals(expectedTop[i], sample.topY());
|
||||
@@ -634,49 +621,34 @@ public class FloatingIslandBoundarySamplerTest {
|
||||
return 1.0D;
|
||||
}
|
||||
};
|
||||
IrisFloatingChildBiomes lower = mock(IrisFloatingChildBiomes.class);
|
||||
IrisFloatingChildBiomes upper = mock(IrisFloatingChildBiomes.class);
|
||||
ResolvedFloatingChild lower = mock(ResolvedFloatingChild.class);
|
||||
ResolvedFloatingChild upper = mock(ResolvedFloatingChild.class);
|
||||
IrisBiome parent = mock(IrisBiome.class);
|
||||
IrisData data = mock(IrisData.class);
|
||||
Engine engine = mock(Engine.class);
|
||||
IrisWorld world = IrisWorld.builder().minHeight(0).maxHeight(320).build();
|
||||
KList<IrisFloatingChildBiomes> entries = new KList<>();
|
||||
KList<ResolvedFloatingChild> entries = new KList<>();
|
||||
entries.add(lower);
|
||||
entries.add(upper);
|
||||
when(parent.getFloatingChildBiomes()).thenReturn(entries);
|
||||
when(parent.isMergeFloatingChildBiomes()).thenReturn(true);
|
||||
for (IrisFloatingChildBiomes entry : entries) {
|
||||
for (ResolvedFloatingChild entry : entries) {
|
||||
when(entry.getFootprintCng(anyLong(), same(data))).thenReturn(footprint);
|
||||
when(entry.getFootprintThreshold()).thenReturn(0.5D);
|
||||
when(entry.getAltitudeCng(anyLong(), same(data))).thenReturn(constant);
|
||||
when(entry.getRealBiome(parent, data)).thenReturn(parent);
|
||||
when(entry.getTopShapeMode()).thenReturn(TopShapeMode.NOISE);
|
||||
when(entry.getTopShapeCng(anyLong(), same(data))).thenReturn(constant);
|
||||
when(entry.getTopShapeAmp()).thenReturn(1.0D);
|
||||
when(entry.getMaxTopHeight()).thenReturn(18);
|
||||
when(entry.getBottomCng(anyLong(), same(data))).thenReturn(constant);
|
||||
when(entry.getBottomExponent()).thenReturn(1.0D);
|
||||
when(entry.getBottomDepthMin()).thenReturn(20);
|
||||
when(entry.getBottomDepthMax()).thenReturn(20);
|
||||
when(entry.getMaxThickness()).thenReturn(64);
|
||||
when(entry.getMinAbsoluteY()).thenReturn(null);
|
||||
when(entry.getMaxAbsoluteY()).thenReturn(null);
|
||||
when(entry.getWallWarpCng(anyLong(), same(data))).thenReturn(null);
|
||||
when(entry.getWallWarpAmplitude()).thenReturn(0.0D);
|
||||
when(entry.getCarvingProfileSampler(engine, data)).thenReturn(null);
|
||||
when(entry.hasCarvingReference()).thenReturn(false);
|
||||
when(entry.getCarveCng(anyLong(), same(data))).thenReturn(null);
|
||||
when(entry.getCarveThreshold()).thenReturn(1.0D);
|
||||
when(entry.settings()).thenReturn(TestSettings.with(new FloatingChildBiome(), "footprintThreshold", 0.5D, "topShapeMode", TopShapeMode.NOISE, "topShapeAmp", 1.0D, "maxTopHeight", 18, "bottomExponent", 1.0D, "bottomDepthMin", 20, "bottomDepthMax", 20, "maxThickness", 64, "wallWarpAmplitude", 0.0D, "carveThreshold", 1.0D,
|
||||
"minHeightAboveSurface", entry == lower ? 160 : 180, "maxHeightAboveSurface", entry == lower ? 160 : 180));
|
||||
}
|
||||
when(lower.getMinHeightAboveSurface()).thenReturn(160);
|
||||
when(lower.getMaxHeightAboveSurface()).thenReturn(160);
|
||||
when(upper.getMinHeightAboveSurface()).thenReturn(180);
|
||||
when(upper.getMaxHeightAboveSurface()).thenReturn(180);
|
||||
when(engine.getWorld()).thenReturn(world);
|
||||
FloatingIslandBoundarySampler sampler = new FloatingIslandBoundarySampler((x, z) -> parent);
|
||||
|
||||
assertNull(FloatingIslandSample.sample(parent, 0, 0, 320, 35L, data, engine, sampler));
|
||||
FloatingIslandSample sample = FloatingIslandSample.sample(parent, 1, 0, 320, 35L, data, engine, sampler);
|
||||
assertNull(FloatingIslandSample.sample(parent, entries, 0, 0, 320, 35L, data, engine, sampler));
|
||||
FloatingIslandSample sample = FloatingIslandSample.sample(parent, entries, 1, 0, 320, 35L, data, engine, sampler);
|
||||
|
||||
assertNotNull(sample);
|
||||
assertTrue(sample.hasMergedEntries());
|
||||
|
||||
+6
-6
@@ -1,7 +1,8 @@
|
||||
package art.arcane.iris.engine.object.terrain.floating;
|
||||
|
||||
import art.arcane.iris.engine.object.TestSettings;
|
||||
import art.arcane.iris.builtin.floating.FloatingChildBiome;
|
||||
import art.arcane.iris.engine.object.terrain.floating.FloatingIslandSample;
|
||||
import art.arcane.iris.engine.object.terrain.floating.IrisFloatingChildBiomes;
|
||||
import art.arcane.iris.util.project.noise.CNG;
|
||||
import art.arcane.iris.util.project.noise.NoiseGenerator;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
@@ -62,10 +63,10 @@ public class FloatingIslandSampleBottomYTest {
|
||||
|
||||
@Test
|
||||
public void mergedEntryMask_preservesTopAndBottomOwners() {
|
||||
IrisFloatingChildBiomes bottom = new IrisFloatingChildBiomes();
|
||||
IrisFloatingChildBiomes top = new IrisFloatingChildBiomes();
|
||||
ResolvedFloatingChild bottom = new ResolvedFloatingChild(new FloatingChildBiome());
|
||||
ResolvedFloatingChild top = new ResolvedFloatingChild(new FloatingChildBiome());
|
||||
boolean[] mask = {true, true, false, true};
|
||||
IrisFloatingChildBiomes[] entryMask = {bottom, bottom, null, top};
|
||||
ResolvedFloatingChild[] entryMask = {bottom, bottom, null, top};
|
||||
FloatingIslandSample sample = FloatingIslandSample.constructForTest(top, 80, mask.length, 3, 3, mask, entryMask);
|
||||
|
||||
assertSame(top, sample.entry);
|
||||
@@ -327,8 +328,7 @@ public class FloatingIslandSampleBottomYTest {
|
||||
|
||||
@Test
|
||||
public void directCarveEnabled_respectsCarvingReferenceOverride() {
|
||||
IrisFloatingChildBiomes entry = new IrisFloatingChildBiomes();
|
||||
entry.setCarving("carving/mushroom");
|
||||
ResolvedFloatingChild entry = new ResolvedFloatingChild(TestSettings.with(new FloatingChildBiome(), "carving", "carving/mushroom"));
|
||||
CNG carve = new CNG(new RNG(9));
|
||||
|
||||
assertFalse(FloatingIslandSample.directCarveEnabled(entry, null, carve, 0.5));
|
||||
|
||||
+3
-4
@@ -1,6 +1,5 @@
|
||||
package art.arcane.iris.engine.object.terrain.floating;
|
||||
|
||||
import art.arcane.iris.engine.object.terrain.floating.IrisFloatingChildBiomes;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
||||
import art.arcane.iris.engine.object.terrain.carving.IrisDimensionCarvingEntry;
|
||||
@@ -28,7 +27,7 @@ import static org.mockito.Mockito.doAnswer;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
public class IrisFloatingChildBiomesCarvingResolutionTest {
|
||||
public class ResolvedFloatingChildCarvingResolutionTest {
|
||||
@BeforeClass
|
||||
public static void setupBukkit() {
|
||||
if (Bukkit.getServer() != null) {
|
||||
@@ -60,7 +59,7 @@ public class IrisFloatingChildBiomesCarvingResolutionTest {
|
||||
IrisBiome biome = mock(IrisBiome.class);
|
||||
Fixture fixture = createFixture(Map.of(), Map.of("carving/mushroom", biome));
|
||||
|
||||
IrisBiome resolved = IrisFloatingChildBiomes.resolveCarvingBiome("carving/mushroom", fixture.engine, fixture.data);
|
||||
IrisBiome resolved = ResolvedFloatingChild.resolveCarvingBiome("carving/mushroom", fixture.engine, fixture.data);
|
||||
|
||||
assertSame(biome, resolved);
|
||||
}
|
||||
@@ -82,7 +81,7 @@ public class IrisFloatingChildBiomesCarvingResolutionTest {
|
||||
|
||||
Fixture fixture = createFixture(entries, biomes);
|
||||
|
||||
IrisBiome resolved = IrisFloatingChildBiomes.resolveCarvingBiome("global-deepdark-band", fixture.engine, fixture.data);
|
||||
IrisBiome resolved = ResolvedFloatingChild.resolveCarvingBiome("global-deepdark-band", fixture.engine, fixture.data);
|
||||
|
||||
assertSame(entryBiome, resolved);
|
||||
}
|
||||
+11
-24
@@ -1,24 +1,23 @@
|
||||
package art.arcane.iris.engine.object.terrain.floating;
|
||||
|
||||
import art.arcane.iris.builtin.floating.FloatingChildBiome;
|
||||
import art.arcane.iris.engine.object.TestSettings;
|
||||
import art.arcane.iris.builtin.floating.OverrideMode;
|
||||
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
|
||||
import art.arcane.iris.engine.object.terrain.floating.IrisFloatingChildBiomes;
|
||||
import art.arcane.iris.engine.object.terrain.floating.OverrideMode;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class IrisFloatingChildBiomesResolverTest {
|
||||
public class ResolvedFloatingChildTest {
|
||||
@Test
|
||||
public void resolveTopObjects_inheritOnly_withInheritTrue_returnsSurfaceObjects() {
|
||||
IrisObjectPlacement placement = new IrisObjectPlacement();
|
||||
KList<IrisObjectPlacement> surface = new KList<>();
|
||||
surface.add(placement);
|
||||
|
||||
IrisFloatingChildBiomes entry = new IrisFloatingChildBiomes();
|
||||
entry.setInheritObjects(true);
|
||||
entry.setTopObjectMode(OverrideMode.INHERIT_ONLY);
|
||||
ResolvedFloatingChild entry = new ResolvedFloatingChild(TestSettings.with(new FloatingChildBiome(), "inheritObjects", true, "topObjectMode", OverrideMode.INHERIT_ONLY));
|
||||
|
||||
KList<IrisObjectPlacement> result = entry.resolveTopObjectsFromSurface(surface);
|
||||
|
||||
@@ -34,10 +33,7 @@ public class IrisFloatingChildBiomesResolverTest {
|
||||
KList<IrisObjectPlacement> overrides = new KList<>();
|
||||
overrides.add(overridePlacement);
|
||||
|
||||
IrisFloatingChildBiomes entry = new IrisFloatingChildBiomes();
|
||||
entry.setInheritObjects(true);
|
||||
entry.setTopObjectMode(OverrideMode.REPLACE);
|
||||
entry.setTopObjectOverrides(overrides);
|
||||
ResolvedFloatingChild entry = new ResolvedFloatingChild(TestSettings.with(new FloatingChildBiome(), "inheritObjects", true, "topObjectMode", OverrideMode.REPLACE, "topObjectOverrides", overrides));
|
||||
|
||||
KList<IrisObjectPlacement> result = entry.resolveTopObjectsFromSurface(surface);
|
||||
|
||||
@@ -54,10 +50,7 @@ public class IrisFloatingChildBiomesResolverTest {
|
||||
KList<IrisObjectPlacement> overrides = new KList<>();
|
||||
overrides.add(overridePlacement);
|
||||
|
||||
IrisFloatingChildBiomes entry = new IrisFloatingChildBiomes();
|
||||
entry.setInheritObjects(true);
|
||||
entry.setTopObjectMode(OverrideMode.MERGE);
|
||||
entry.setTopObjectOverrides(overrides);
|
||||
ResolvedFloatingChild entry = new ResolvedFloatingChild(TestSettings.with(new FloatingChildBiome(), "inheritObjects", true, "topObjectMode", OverrideMode.MERGE, "topObjectOverrides", overrides));
|
||||
|
||||
KList<IrisObjectPlacement> result = entry.resolveTopObjectsFromSurface(surface);
|
||||
|
||||
@@ -68,8 +61,7 @@ public class IrisFloatingChildBiomesResolverTest {
|
||||
|
||||
@Test
|
||||
public void resolveTopObjects_inheritOnly_emptySurface_returnsEmpty() {
|
||||
IrisFloatingChildBiomes entry = new IrisFloatingChildBiomes();
|
||||
entry.setTopObjectMode(OverrideMode.INHERIT_ONLY);
|
||||
ResolvedFloatingChild entry = new ResolvedFloatingChild(TestSettings.with(new FloatingChildBiome(), "topObjectMode", OverrideMode.INHERIT_ONLY));
|
||||
|
||||
KList<IrisObjectPlacement> result = entry.resolveTopObjectsFromSurface(new KList<>());
|
||||
|
||||
@@ -78,8 +70,7 @@ public class IrisFloatingChildBiomesResolverTest {
|
||||
|
||||
@Test
|
||||
public void resolveBottomObjects_inheritOnly_returnsEmptyList() {
|
||||
IrisFloatingChildBiomes entry = new IrisFloatingChildBiomes();
|
||||
entry.setBottomObjectMode(OverrideMode.INHERIT_ONLY);
|
||||
ResolvedFloatingChild entry = new ResolvedFloatingChild(TestSettings.with(new FloatingChildBiome(), "bottomObjectMode", OverrideMode.INHERIT_ONLY));
|
||||
|
||||
KList<IrisObjectPlacement> result = entry.resolveBottomObjects(null);
|
||||
|
||||
@@ -92,9 +83,7 @@ public class IrisFloatingChildBiomesResolverTest {
|
||||
KList<IrisObjectPlacement> overrides = new KList<>();
|
||||
overrides.add(overridePlacement);
|
||||
|
||||
IrisFloatingChildBiomes entry = new IrisFloatingChildBiomes();
|
||||
entry.setBottomObjectMode(OverrideMode.REPLACE);
|
||||
entry.setBottomObjectOverrides(overrides);
|
||||
ResolvedFloatingChild entry = new ResolvedFloatingChild(TestSettings.with(new FloatingChildBiome(), "bottomObjectMode", OverrideMode.REPLACE, "bottomObjectOverrides", overrides));
|
||||
|
||||
KList<IrisObjectPlacement> result = entry.resolveBottomObjects(null);
|
||||
|
||||
@@ -104,9 +93,7 @@ public class IrisFloatingChildBiomesResolverTest {
|
||||
|
||||
@Test
|
||||
public void resolveTopObjects_inheritTrue_nullTargetProduces_emptySurface() {
|
||||
IrisFloatingChildBiomes entry = new IrisFloatingChildBiomes();
|
||||
entry.setInheritObjects(true);
|
||||
entry.setTopObjectMode(OverrideMode.INHERIT_ONLY);
|
||||
ResolvedFloatingChild entry = new ResolvedFloatingChild(TestSettings.with(new FloatingChildBiome(), "inheritObjects", true, "topObjectMode", OverrideMode.INHERIT_ONLY));
|
||||
|
||||
KList<IrisObjectPlacement> result = entry.resolveTopObjects(null);
|
||||
|
||||
+6
-5
@@ -1,6 +1,7 @@
|
||||
package art.arcane.iris.engine.object.world.dimension;
|
||||
|
||||
import art.arcane.iris.engine.object.terrain.floating.IrisFloatingChildBiomes;
|
||||
import art.arcane.iris.builtin.floating.FloatingChildBiome;
|
||||
import art.arcane.iris.engine.object.TestSettings;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
||||
import art.arcane.iris.engine.object.terrain.carving.IrisDimensionCarvingEntry;
|
||||
@@ -141,11 +142,11 @@ public class IrisDimensionReachableBiomesTest {
|
||||
return biome;
|
||||
}
|
||||
|
||||
private IrisFloatingChildBiomes floating(String biomeKey) {
|
||||
return new IrisFloatingChildBiomes().setBiome(biomeKey);
|
||||
private FloatingChildBiome floating(String biomeKey) {
|
||||
return TestSettings.with(new FloatingChildBiome(), "biome", biomeKey);
|
||||
}
|
||||
|
||||
private IrisFloatingChildBiomes floating(String biomeKey, String carvingKey) {
|
||||
return floating(biomeKey).setCarving(carvingKey);
|
||||
private FloatingChildBiome floating(String biomeKey, String carvingKey) {
|
||||
return TestSettings.with(new FloatingChildBiome(), "biome", biomeKey, "carving", carvingKey);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user