mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 00:34:19 +00:00
VanillaFeatures service: whether the platform's own placed features run over a world and which steps and features they skip
@Service(ALL): generates(world) (off unless a module turns it on), generatesStep(world, Optional<DecorationStep>) (empty for a step the API does not name) and generatesFeature(world, feature); any provider may refuse a step or a feature. Answers depend on the world only; the host asks once per world, step and feature. README services table, DESIGN services and feature map, CONTRACTS types and host duty; a test that a silent provider leaves the pass off.
This commit is contained in:
1 parent
cf8b2bb0f6
commit
8676ebc328
5 files changed
+60
-1
No files matched your search
+5
-1
@@ -34,7 +34,7 @@ types that carry them and lists what the Iris adapter still owes.
|
||||
| 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<T>`, `GenerationContext.hunk`, reference `ArrayHunk<T>` |
|
||||
| Sparse geometry and transforms | `ObjectGenerator`, `GeneratedObject`, `ObjectTransform`, `ObjectTransformer` |
|
||||
@@ -236,6 +236,10 @@ running Iris is the pack publisher's responsibility.
|
||||
- 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
|
||||
|
||||
|
||||
@@ -1027,6 +1027,10 @@ from a sapling, which drops a block has. A module answers such questions through
|
||||
`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
|
||||
@@ -1086,6 +1090,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 |
|
||||
|
||||
@@ -337,6 +337,7 @@ final class RuinsObjects implements ObjectsAt {
|
||||
| `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). |
|
||||
| `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
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
* <p>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<DecorationStep> 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;
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package com.volmit;
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.config.OptionsMetadata;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.service.VanillaFeatures;
|
||||
import com.volmit.service.VanillaStructures;
|
||||
import com.volmit.vanilla.DecorationStep;
|
||||
import com.volmit.vanilla.JigsawOverrides;
|
||||
@@ -124,6 +125,16 @@ class VanillaStructureValuesTest {
|
||||
assertEquals(VanillaStructureRule.GENERATE, new VanillaStructures() { }.rule(CITY, 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")));
|
||||
}
|
||||
|
||||
private static List<String> names(Class<?> type) {
|
||||
return OptionsMetadata.inspect(type).options().stream().map(OptionsMetadata.Option::name).toList();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user