diff --git a/CONTRACTS.md b/CONTRACTS.md index 5f448c548..7ee4dd6e3 100644 --- a/CONTRACTS.md +++ b/CONTRACTS.md @@ -28,13 +28,13 @@ types that carry them and lists what the Iris adapter still owes. | Block states and palettes | `BlockState`, `BlockRegistry`, `BlockPalette`, `BlockSpec` (`BlockRegistry.resolve(BlockSpec)`, `blockEntity`), `PaletteSpec` and `PaletteSampler` (`BlockRegistry.palette`) | | Noise from pack-described styles | `NoiseStyle`, `StyledRange`, `PackResources.noise()`, `NoiseFactory`, `NoiseSampler` | | Values in settings | `BlockSpec`, `PaletteSpec`, `NoiseStyle`, `StyledRange`, `Range`, `BlockPosition`, `JigsawOverrides`, `Object` as `ValueKind.AnyKind` | -| Decisions over and fit of the platform's own structures | service `VanillaStructures` (`rule`, `starts`, `shift`, `reach`, `beforePieces`, `afterPieces`, `setup`), `VanillaStructureRule`, `VanillaStructureContext`, `VanillaStructureStart`, `VanillaStructureStartContext`, `VanillaStructureSetup`, `PlatformStart`, `StartMemo`, `StartReach`, `StructureFit` (`Start`, `Piece`, `ColumnVisitor`), `StructureStep`, `TerrainAdaptation`, `PieceKind`, `TemplateCells`, `world.BlockAccess`, host `FeatureCatalog.registrations(service)` | +| Decisions over and fit of the platform's own structures | service `VanillaStructures` (`rule`, `starts`, `shift`, `reach`, `beforePieces`, `afterPieces`, `setup`, `startedStructures`, `locatableStarts`, `locateStart`, `ChunkFilter`), `VanillaStructureRule`, `VanillaStructureContext`, `VanillaStructureStart`, `VanillaStructureStartContext`, `VanillaStructureSetup`, `PlatformStart`, `StartMemo`, `StartReach`, `StructureFit` (`Start`, `Piece`, `ColumnVisitor`), `DecorationStep`, `TerrainAdaptation`, `PieceKind`, `TemplateCells`, `world.BlockAccess`, host `FeatureCatalog.registrations(service)` | | Pack-scoped resolution | `ResourceId` (`ofPackKey`), `ResourceKey`, `PackResources` (`find`, `ids`, `idOf`), `PackBiome`, `PackRegion` | | Module-owned pack resources | `ResourceKind`, `FeatureRegistry.registerResourceKind`, `@ResourceRef`, host `ModuleHost.reservingFolders`, `FeatureCatalog.resourceKinds()`, `ResourceKindSchema`, `ValueKind.ResourceReferenceKind` | | Module-owned pack checks | `Validator`, `ValidationContext`, `Problem`, `Severity`, `Subject`, `FeatureRegistry.registerValidator`, host `FeatureCatalog.validators()` | | Per-world module state | `PackWorld` (`state`), `InvocationContext.world()`, host `WorldStates` | | Module lifecycle across loads, hotloads and reloads | `ModuleLifecycle`, `FeatureRegistry.registerLifecycle`, host `FeatureCatalog.lifecycles()`, `LifecycleRunner` | -| Host questions answered by modules | `@Service`, `Providers`, `FeatureRegistry.registerService`, host `FeatureCatalog.services(type)` / `service(type)`; services `ObjectsAt`, `StructureLocator` (`LocateResult`), `SaplingGrowth`, `Loot`, `BlockDrops`, `EntitySpawns`, `CaveBiomes`, `AmbientEffects`; values `ItemDrop`, `EntitySpec`, `ItemRegistry` (`PackResources.items()`) | +| Host questions answered by modules | `@Service`, `Providers`, `FeatureRegistry.registerService`, host `FeatureCatalog.services(type)` / `service(type)`; services `ObjectsAt`, `StructureLocator` (`LocateResult`), `SaplingGrowth`, `Loot`, `BlockDrops`, `EntitySpawns`, `CaveBiomes`, `AmbientEffects`, `VanillaFeatures` (`DecorationStep`); values `ItemDrop`, `EntitySpec`, `ItemRegistry` (`PackResources.items()`) | | Terrain and settings sampling | `TerrainSampler`, `BiomeSample`, `TerrainSample`, `FeatureSettings` | | Dense chunk output | `Hunk`, `GenerationContext.hunk`, reference `ArrayHunk` | | Sparse geometry and transforms | `ObjectGenerator`, `GeneratedObject`, `ObjectTransform`, `ObjectTransformer` | @@ -233,9 +233,17 @@ running Iris is the pack publisher's responsibility. structure, let a start take the chunk from a platform start only when it says so or the structure is `REPLACE`d, apply its jigsaw overrides, keep its memo, record its identity with every start the host publishes, and ask again (same answer) when locating or verifying a start found in the world. +- Send the platform's locate of a structure some provider lists in `startedStructures` to that provider's + `locateStart` (module id order, the first that lists it in `locatableStarts`), convert the start's Y to the platform's, + check the start the platform made there before reporting it, and search again refusing that chunk when the check fails. + Route the host's own structure commands by `startedStructures` the same way. - Ask `setup` per dimension before its worlds build their structure state and when installing data packs; multiply frequencies per structure set (0.01 to 16), protect the platform's definitions in every installed data pack once any dimension of any loaded pack asks for it. +- Run the platform's own placed features over a world only when some `VanillaFeatures` provider's `generates` says so; + then skip a decoration step any provider refuses (`generatesStep`, empty for a step the API does not name) and a + feature any provider refuses (`generatesFeature`). Ask once per world, step and feature, and keep the answers while + the world runs. Keep the platform's own pass otherwise unchanged: its biome tables, order and seeds. ## Open diff --git a/DESIGN.md b/DESIGN.md index e9980b45e..f7104797a 100644 --- a/DESIGN.md +++ b/DESIGN.md @@ -1022,13 +1022,18 @@ from a sapling, which drops a block has. A module answers such questions through state) and every random value they carry, the host only plays them. - **Services now.** `ObjectsAt` (`ALL`): pack object keys a module would place in a chunk, predicted without generating it, and the biomes and regions whose settings place a given object (`PlacedBy`, named by pack keys; the - host builds its search area from them through the biome tree it owns). `StructureLocator` (`FIRST`): every structure key a module knows, the ones a world places, and the + host builds its search area from them through the biome tree it owns). `StructureLocator` (`FIRST`): every structure key a module knows, the ones a world places (`locatable`; `placed` adds the + platform structures the module starts or stands in for, and keys it places but cannot search for), and the nearest start of one as a `LocateResult` (`Found`, `NotFound`, `SearchLimitReached`; a sealed interface, so callers switch over every outcome). Keys are pack keys as packs write them and match without regard to case. `CaveBiomes` (`ONE`): the pack biome a module puts at a position whatever the regions say (a band of the deep dark, `overriddenBiome`, the height counted above the dimension's bottom) and how deep below the surface a biome's caves begin (`minDepthBelowSurface`, asked once per biome and kept while the world runs). The host owns the 3D biome of a position (its regions, terrain height and the cave biome stream) and asks this only where a module decides; one provider, since two modules could not both decide the biome of one cave. + `VanillaFeatures` (`ALL`): whether the platform's own placed features run over a world's terrain (`generates`, off unless a + module turns it on) and which decoration steps and features they skip (`generatesStep`, `generatesFeature`; any module may + refuse one). The host asks once per world, step and feature and keeps the answers; the platform's feature pass itself, its + biome tables, seeds and order, stays the host's. - **Settings that name biomes.** The host owns the biome tree (a region's biomes and their children) and the set of biomes a dimension reaches, and both must include biomes that module settings name: a cave band's biome, the target of a floating island. Settings say so by implementing `LinkedBiomes` (`treeBiomes`, which join a region's tree and so its terrain @@ -1088,6 +1093,7 @@ This is an inventory of where each existing family should land, not a claim that | Floating islands and child biomes | Terrain/biome sampling + chunk and placement stages | | Structures, jigsaw pools and foundations | Structure assembly producing placement requests | | Imported/native structures and ownership | `VanillaStructures` service (rule, starts, shift, reach, beforePieces, afterPieces, setup); host native-generation bridge per platform | +| Imported/native placed features | `VanillaFeatures` service (generates, generatesStep, generatesFeature); host feature pass per platform | | Terrain layers, fluids, bedrock, interpolation | Terrain providers + chunk stages | | Region/biome selection | Biome providers + platform biome writer | | Image maps, noise expressions, pack injection | Compiled immutable pack resources | diff --git a/README.md b/README.md index c65720678..b790929a6 100644 --- a/README.md +++ b/README.md @@ -331,14 +331,15 @@ final class RuinsObjects implements ObjectsAt { | Service | Providers | What the host asks | | --- | --- | --- | | `ObjectsAt` | `ALL` | The pack objects a module would place in a chunk, predicted without generating it, and the biomes and regions of the layout that place a given object (`PlacedBy`), so the host can narrow an object search to the areas it can appear in. | -| `StructureLocator` | `FIRST` | Every structure key the module knows (the structure index), the ones a world places (commands complete them), and the nearest start of one, as a `LocateResult`: `Found(position)`, `NotFound` or `SearchLimitReached`. Keys match without regard to case. | +| `StructureLocator` | `FIRST` | Every structure key the module knows (the structure index), the ones a world places and can locate (commands complete them), every key under which it finds what a world places (`placed`: its own structures and the platform structures it starts or stands in for), and the nearest start of one, as a `LocateResult`: `Found(position)`, `NotFound` or `SearchLimitReached`. Keys match without regard to case. | | `SaplingGrowth` | `ALL` | The tree a growing sapling becomes, as a `Growth` of placed blocks (the first module with one wins; none leaves the growth to the platform), and the objects the module places as trees (`TreeObjects`). The host passes `Surroundings` to read the world around the sapling and places the blocks itself. | | `Loot` | `ALL` | The loot tables a container draws from at a `Site` (`Table` of the pack, `PlatformTable` with the seed to draw it with), in the order their items are added, and the `ItemDrop`s one table gives there. The host puts them together, tells listeners, creates the stacks and shuffles the container. | | `BlockDrops` | `ALL` | What a module drops for a broken block: `ItemDrop`s, and whether the platform's own drops of the block are replaced. | | `EntitySpawns` | `ALL` | A `Plan` of entities to spawn in a chunk or at a marker, each `Attempt` an `EntitySpec` with the block, light range and surface it needs; how many appeared (`spawned`); what a marker means (`MarkerRule`); one entity of the pack on request. The host checks light, surface and free space, spawns, and applies the spec. | | `CaveBiomes` | `ONE` | The pack biome a module puts at a position whatever the regions say (a band of the deep dark), and how far below the surface a biome's caves begin. The host places the cave biome of a position itself and asks this where a module overrides it. | | `AmbientEffects` | `ALL` | The effects due for a player standing at a position: a `Sound`, `Particles`, `Command`s and a `Potion` per `Effect`, every random choice already made (offsets, scatter, duration). The host asks now and then, carries out the parts the platform has, and keeps a stronger potion effect the player already has. | -| `VanillaStructures` | `ALL` | Rules, starts, shifts and reaches for the platform's own structures, and fitting the terrain to the starts in one chunk through the `BlockAccess` the host hands over (see Vanilla structures). | +| `VanillaStructures` | `ALL` | Rules, starts, shifts and reaches for the platform's own structures, fitting the terrain to the starts in one chunk through the `BlockAccess` the host hands over, and finding the starts a module makes of them (see Vanilla structures). | +| `VanillaFeatures` | `ALL` | Whether the platform runs its own placed features (ores, trees, plants, springs) over a world's terrain, and which decoration steps (`DecorationStep`) and features it skips there. Off unless a module turns it on; any module may refuse a step or a feature. Asked once per world, step and feature. | ``` Service example.Clock is provided by module example:alpha from modules/alpha.jar already, and module example:beta from modules/beta.jar provides it too; a pack has one provider of it (Providers.ONE), so remove one of them @@ -606,6 +607,11 @@ Every method has a default that changes nothing, so a provider implements only w - `setup(context)`: before any world of the dimension exists, how often each structure set starts (`withFrequency`, multipliers of several modules multiply) and whether the data packs the host installs must leave the platform's own structure definitions alone (`protectingVanillaDefinitions`, for every pack once any dimension asks for it). +- `startedStructures(world)`, `locatableStarts(world)` and `locateStart(world, structure, fromX, fromZ, maxRings, + accepts)`: the platform structures the module starts itself, the ones of them it can find, and the nearest start of one, + searched ring by ring through the module's own placement grids. The host sends the platform's `/locate` and its own + structure commands for those structures here, then checks the start it got in the world; `accepts` lets it skip chunks + it already refused. ```java @Override diff --git a/src/main/java/com/volmit/service/StructureLocator.java b/src/main/java/com/volmit/service/StructureLocator.java index 7c15ca30b..fe0c86511 100644 --- a/src/main/java/com/volmit/service/StructureLocator.java +++ b/src/main/java/com/volmit/service/StructureLocator.java @@ -6,7 +6,7 @@ import java.util.Set; /** Finds the structures a module places, for the host's structure commands and index. Structures are named by their * keys, in the form packs write them ({@code castle}, {@code villages/plains}). The host asks the providers in order and - * sends a key to the first that can locate it in the world. + * sends a key to the first that places it in the world ({@link #placed}). */ @Service(Providers.FIRST) public interface StructureLocator { @@ -20,10 +20,19 @@ public interface StructureLocator { */ Set locatable(PackWorld world); + /** The keys under which {@link #locate} finds the structures this module places in {@code world}, locatable or not: its + * own structures, the platform structures it starts itself and the platform structures its own stand in for (namespaced, + * such as {@code minecraft:ancient_city}). Commands report them and send a search for one of them here. By default the + * {@link #locatable} ones. + */ + default Set placed(PackWorld world) { + return locatable(world); + } + /** * The start of structure {@code key} nearest to the column {@code fromX}, {@code fromZ} (world coordinates), searched * up to {@code maxRadiusChunks} chunks away from it. The position is the structure's origin: world X and Z, and Y the - * height above the dimension's bottom of its base. Called with a key from {@link #locatable}. May take long; the + * height above the dimension's bottom of its base. Called with a key from {@link #placed}. May take long; the * host calls it off the server's main thread. */ LocateResult locate(PackWorld world, String key, int fromX, int fromZ, int maxRadiusChunks); diff --git a/src/main/java/com/volmit/service/VanillaFeatures.java b/src/main/java/com/volmit/service/VanillaFeatures.java new file mode 100644 index 000000000..7b3e20bbd --- /dev/null +++ b/src/main/java/com/volmit/service/VanillaFeatures.java @@ -0,0 +1,38 @@ +package com.volmit.service; + +import com.volmit.resource.ResourceId; +import com.volmit.vanilla.DecorationStep; +import com.volmit.world.PackWorld; + +import java.util.Optional; + +/** + * A module's say over the platform's own placed features in the pack's worlds: the ores, trees, plants, springs and other + * decorations Minecraft, data packs and mods declare for a biome. By default the platform runs none of them over the pack's + * terrain. The host asks every provider, in module id order: it runs the platform's feature pass in a world when any + * provider turns it on with {@link #generates}, and then skips a decoration step or a feature that any provider refuses. + * + *

Every answer is decided from the world alone (its settings and resources), never from a position: the host asks once + * per world, and once per world and step or feature, and keeps the answer while the world runs. Every method may be + * called from any thread, concurrently. + */ +@Service(Providers.ALL) +public interface VanillaFeatures { + /** Whether the platform runs its placed features over the terrain of {@code world}. False when the module has no part in it. */ + default boolean generates(PackWorld world) { + return false; + } + + /** + * Whether the platform places the features of decoration step {@code step} in {@code world}: empty for a step of a newer + * platform the API does not know yet. True when the module has no part in it. + */ + default boolean generatesStep(PackWorld world, Optional step) { + return true; + } + + /** Whether the platform places the feature {@code feature}, such as {@code minecraft:ore_diamond}, in {@code world}. True when the module has no part in it. */ + default boolean generatesFeature(PackWorld world, ResourceId feature) { + return true; + } +} diff --git a/src/main/java/com/volmit/service/VanillaStructures.java b/src/main/java/com/volmit/service/VanillaStructures.java index 896720138..49fa021d2 100644 --- a/src/main/java/com/volmit/service/VanillaStructures.java +++ b/src/main/java/com/volmit/service/VanillaStructures.java @@ -10,8 +10,10 @@ import com.volmit.vanilla.VanillaStructureRule; import com.volmit.vanilla.VanillaStructureSetup; import com.volmit.vanilla.VanillaStructureStart; import com.volmit.vanilla.VanillaStructureStartContext; +import com.volmit.world.PackWorld; import java.util.List; import java.util.Optional; +import java.util.Set; /** A module's say over the platform's own structures, the ones Minecraft, data packs and mods register, in the pack's * worlds. The host asks every provider, in module id order: @@ -91,4 +93,37 @@ public interface VanillaStructures { default VanillaStructureSetup setup(VanillaStructureContext context) { return VanillaStructureSetup.UNCHANGED; } + + /** The platform structures this module starts itself in {@code world} ({@link #starts}), wherever its own placements put + * them. The host's locate and structure commands send them to {@link #locateStart}. + */ + default Set startedStructures(PackWorld world) { + return Set.of(); + } + + /** Those of {@link #startedStructures} whose starts {@link #locateStart} can find in {@code world}: a start whose + * placement can never start in the world's height, for one, cannot be searched for. + */ + default Set locatableStarts(PackWorld world) { + return Set.of(); + } + + /** + * The start of the platform structure {@code structure} this module makes nearest to the column {@code fromX}, + * {@code fromZ} (world coordinates), searched ring by ring outward through its placements' grids up to {@code maxRings} + * rings: the nearest start of the first ring that has one. The position is the start's origin: world X and Z, and Y the + * height above the dimension's bottom of its base. Only chunks {@code accepts} allows count; the host checks the start + * the platform made there and searches again without a chunk it refuses. An exception {@code accepts} throws ends the + * search and reaches the caller. Called with a structure from {@link #locatableStarts}, off the server's main thread. + */ + default LocateResult locateStart(PackWorld world, ResourceId structure, int fromX, int fromZ, int maxRings, + ChunkFilter accepts) { + return LocateResult.NOT_FOUND; + } + + /** Which chunks a {@link #locateStart} search may answer with. */ + @FunctionalInterface + interface ChunkFilter { + boolean accepts(int chunkX, int chunkZ); + } } diff --git a/src/main/java/com/volmit/vanilla/DecorationStep.java b/src/main/java/com/volmit/vanilla/DecorationStep.java new file mode 100644 index 000000000..0bfb92304 --- /dev/null +++ b/src/main/java/com/volmit/vanilla/DecorationStep.java @@ -0,0 +1,37 @@ +package com.volmit.vanilla; + +import com.volmit.config.Desc; + +/** A decoration step of the platform's chunk generation, in the platform's order: the step in which it places a structure's + * pieces, or a placed feature such as an ore or a tree. + */ +@Desc("A decoration step of the platform's chunk generation. Structures and placed features are grouped into these steps, which run in this order.") +public enum DecorationStep { + @Desc("Raw generation - the earliest step, before lakes.") + RAW_GENERATION, + @Desc("Lakes.") + LAKES, + @Desc("Local modifications such as amethyst geodes, icebergs and dripstone clusters.") + LOCAL_MODIFICATIONS, + @Desc("Underground structures, and the features tagged to run with them.") + UNDERGROUND_STRUCTURES, + @Desc("Surface structures, and the features tagged to run with them.") + SURFACE_STRUCTURES, + @Desc("Strongholds.") + STRONGHOLDS, + @Desc("Underground ores. This is the step that carries vanilla and mod ore veins.") + UNDERGROUND_ORES, + @Desc("Underground decoration such as glow lichen, sculk patches and cave vegetation.") + UNDERGROUND_DECORATION, + @Desc("Fluid springs - the small water and lava spring features.") + FLUID_SPRINGS, + @Desc("Vegetal decoration - trees, grass, flowers, kelp and most surface plant life.") + VEGETAL_DECORATION, + @Desc("Top layer modification - freezing and snow placement.") + TOP_LAYER_MODIFICATION; + + /** Whether this is one of the steps the platform places its underground structures in. */ + public boolean isUnderground() { + return this == UNDERGROUND_STRUCTURES || this == UNDERGROUND_DECORATION || this == STRONGHOLDS; + } +} diff --git a/src/main/java/com/volmit/vanilla/StructureFit.java b/src/main/java/com/volmit/vanilla/StructureFit.java index fa58bfa21..bae1f942c 100644 --- a/src/main/java/com/volmit/vanilla/StructureFit.java +++ b/src/main/java/com/volmit/vanilla/StructureFit.java @@ -67,7 +67,7 @@ public interface StructureFit { int chunkZ(); - StructureStep step(); + DecorationStep step(); /** The terrain adaptation the platform's definition of the structure asks for. */ TerrainAdaptation adaptation(); diff --git a/src/main/java/com/volmit/vanilla/StructureStep.java b/src/main/java/com/volmit/vanilla/StructureStep.java deleted file mode 100644 index ce10204af..000000000 --- a/src/main/java/com/volmit/vanilla/StructureStep.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.volmit.vanilla; - -/** The decoration step in which the platform places a structure's pieces, in the platform's order. */ -public enum StructureStep { - RAW_GENERATION, - LAKES, - LOCAL_MODIFICATIONS, - UNDERGROUND_STRUCTURES, - SURFACE_STRUCTURES, - STRONGHOLDS, - UNDERGROUND_ORES, - UNDERGROUND_DECORATION, - FLUID_SPRINGS, - VEGETAL_DECORATION, - TOP_LAYER_MODIFICATION; - - /** Whether this is one of the steps the platform places its underground structures in. */ - public boolean isUnderground() { - return this == UNDERGROUND_STRUCTURES || this == UNDERGROUND_DECORATION || this == STRONGHOLDS; - } -} diff --git a/src/test/java/com/volmit/VanillaStructureValuesTest.java b/src/test/java/com/volmit/VanillaStructureValuesTest.java index e5b78a2a1..cc13e9ed7 100644 --- a/src/test/java/com/volmit/VanillaStructureValuesTest.java +++ b/src/test/java/com/volmit/VanillaStructureValuesTest.java @@ -2,22 +2,28 @@ package com.volmit; import com.volmit.block.BlockState; import com.volmit.config.OptionsMetadata; +import com.volmit.resource.PackResources; import com.volmit.resource.ResourceId; +import com.volmit.service.LocateResult; +import com.volmit.service.StructureLocator; +import com.volmit.service.VanillaFeatures; import com.volmit.service.VanillaStructures; +import com.volmit.vanilla.DecorationStep; import com.volmit.vanilla.JigsawOverrides; import com.volmit.vanilla.StartMemo; import com.volmit.vanilla.StartReach; -import com.volmit.vanilla.StructureStep; import com.volmit.vanilla.TemplateCells; import com.volmit.vanilla.VanillaStructureContext; import com.volmit.vanilla.VanillaStructureRule; import com.volmit.vanilla.VanillaStructureSetup; import com.volmit.vanilla.VanillaStructureStart; +import com.volmit.world.PackWorld; import org.junit.jupiter.api.Test; import java.util.List; import java.util.Map; import java.util.Optional; import java.util.OptionalInt; +import java.util.Set; import static org.junit.jupiter.api.Assertions.*; /** The values a vanilla structures provider answers with and how the host combines several modules' answers. */ @@ -69,8 +75,8 @@ class VanillaStructureValuesTest { @Test void onlyTheUndergroundStepsAreUnderground() { - assertEquals(List.of(StructureStep.UNDERGROUND_STRUCTURES, StructureStep.STRONGHOLDS, StructureStep.UNDERGROUND_DECORATION), - java.util.Arrays.stream(StructureStep.values()).filter(StructureStep::isUnderground).toList()); + assertEquals(List.of(DecorationStep.UNDERGROUND_STRUCTURES, DecorationStep.STRONGHOLDS, DecorationStep.UNDERGROUND_DECORATION), + java.util.Arrays.stream(DecorationStep.values()).filter(DecorationStep::isUnderground).toList()); } @Test @@ -122,6 +128,49 @@ class VanillaStructureValuesTest { assertEquals(StartReach.PLATFORM, provider.reach(CITY, true, Optional.empty(), null)); assertEquals(VanillaStructureSetup.UNCHANGED, provider.setup(null)); assertEquals(VanillaStructureRule.GENERATE, new VanillaStructures() { }.rule(CITY, null)); + assertEquals(Set.of(), provider.startedStructures(null)); + assertEquals(Set.of(), provider.locatableStarts(null)); + assertEquals(LocateResult.NOT_FOUND, provider.locateStart(null, CITY, 0, 0, 8, (chunkX, chunkZ) -> true)); + } + + @Test + public void aLocatorPlacesWhatItCanLocateUnlessItSaysMore() { + StructureLocator locator = new StructureLocator() { + @Override + public Set structures(PackResources pack) { + return Set.of("castle", "tower"); + } + + @Override + public Set locatable(PackWorld world) { + return Set.of("castle"); + } + + @Override + public LocateResult locate(PackWorld world, String key, int fromX, int fromZ, int maxRadiusChunks) { + return LocateResult.NOT_FOUND; + } + }; + + assertEquals(Set.of("castle"), locator.placed(null)); + } + + @Test + void aFeatureProviderThatSaysNothingLeavesThePlatformsFeaturesOff() { + VanillaFeatures silent = new VanillaFeatures() { }; + + assertFalse(silent.generates(null)); + assertTrue(silent.generatesStep(null, Optional.of(DecorationStep.UNDERGROUND_ORES))); + assertTrue(silent.generatesStep(null, Optional.empty())); + assertTrue(silent.generatesFeature(null, ResourceId.parse("minecraft:ore_diamond"))); + } + + @Test + void everyDecorationStepDescribesItselfForStudio() throws NoSuchFieldException { + assertNotNull(DecorationStep.class.getAnnotation(com.volmit.config.Desc.class)); + for (DecorationStep step : DecorationStep.values()) { + assertNotNull(DecorationStep.class.getField(step.name()).getAnnotation(com.volmit.config.Desc.class), step.name()); + } } private static List names(Class type) {