Merge branch 'master' into wave3/s

This commit is contained in:
piexel committed 2026-10-10 13:21:43 +02:00
commit d7de5939d7
8 files changed
+199 -3

No files matched your search

+5 -2
View File
@@ -21,7 +21,7 @@ types that carry them and lists what the Iris adapter still owes.
| Pack-load validation and diagnostics | host `StageGraphBuilder`, `ResolvedGraph`, `LoadedModules` | | Pack-load validation and diagnostics | host `StageGraphBuilder`, `ResolvedGraph`, `LoadedModules` |
| Reference execution | host `PlacementRunner`, `ChunkRunner`, `MantleRunner` | | Reference execution | host `PlacementRunner`, `ChunkRunner`, `MantleRunner` |
| Work across chunks and mantle writes | `Stage.mantle`, `MantleStage`, `MantleStageContext`, `MantleGenerationContext`; chunk stages read the mantle only | | Work across chunks and mantle writes | `Stage.mantle`, `MantleStage`, `MantleStageContext`, `MantleGenerationContext`; chunk stages read the mantle only |
| Annotated settings | `IrisFeature`, `@Feature` (id, short JSON `key`, optional `root`), config annotations, `OptionsMetadata` | | Annotated settings | `IrisFeature`, `@Feature` (id, short JSON `key`, optional `root`), config annotations, `OptionsMetadata`, `LinkedBiomes` (`treeBiomes`, `usedBiomes`: pack biomes the settings bring into the layout) |
| Area a stage writes | `reach(blocks)`, `reach(PackReach)`, `writesMantle(...)` on stage definitions, `PackSettings`, host `StageReach`, `ResolvedStage.reachBlocks`, `PipelineReach` | | Area a stage writes | `reach(blocks)`, `reach(PackReach)`, `writesMantle(...)` on stage definitions, `PackSettings`, host `StageReach`, `ResolvedStage.reachBlocks`, `PipelineReach` |
| Settings described for studio | `@Desc`, `@Required`, `@MinNumber`, `@MaxNumber`, `@MinItems`, `@Snippet`, `@Ref`/`Reference`, `FeatureRegistry.registerSettings`, `FeatureRegistry.registerHeldType`, host `FeatureCatalog.heldTypes()`, host `LoadedPack.schema()` (`PackSchema`, `FeatureSchema`, `ObjectType`, `SchemaOption`, `ValueKind` with `HostKind`), `ModuleHost.describingHostTypesIn` | | Settings described for studio | `@Desc`, `@Required`, `@MinNumber`, `@MaxNumber`, `@MinItems`, `@Snippet`, `@Ref`/`Reference`, `FeatureRegistry.registerSettings`, `FeatureRegistry.registerHeldType`, host `FeatureCatalog.heldTypes()`, host `LoadedPack.schema()` (`PackSchema`, `FeatureSchema`, `ObjectType`, `SchemaOption`, `ValueKind` with `HostKind`), `ModuleHost.describingHostTypesIn` |
| Geometry and mantle registration | `FeatureRegistry`, host `ModuleRegistry`, `FeatureCatalog` | | Geometry and mantle registration | `FeatureRegistry`, host `ModuleRegistry`, `FeatureCatalog` |
@@ -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()` | | Module-owned pack checks | `Validator`, `ValidationContext`, `Problem`, `Severity`, `Subject`, `FeatureRegistry.registerValidator`, host `FeatureCatalog.validators()` |
| Per-world module state | `PackWorld` (`state`), `InvocationContext.world()`, host `WorldStates` | | Per-world module state | `PackWorld` (`state`), `InvocationContext.world()`, host `WorldStates` |
| Module lifecycle across loads, hotloads and reloads | `ModuleLifecycle`, `FeatureRegistry.registerLifecycle`, host `FeatureCatalog.lifecycles()`, `LifecycleRunner` | | 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`; 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`; values `ItemDrop`, `EntitySpec`, `ItemRegistry` (`PackResources.items()`) |
| Terrain and settings sampling | `TerrainSampler`, `BiomeSample`, `TerrainSample`, `FeatureSettings` | | Terrain and settings sampling | `TerrainSampler`, `BiomeSample`, `TerrainSample`, `FeatureSettings` |
| Dense chunk output | `Hunk<T>`, `GenerationContext.hunk`, reference `ArrayHunk<T>` | | Dense chunk output | `Hunk<T>`, `GenerationContext.hunk`, reference `ArrayHunk<T>` |
| Sparse geometry and transforms | `ObjectGenerator`, `GeneratedObject`, `ObjectTransform`, `ObjectTransformer` | | Sparse geometry and transforms | `ObjectGenerator`, `GeneratedObject`, `ObjectTransform`, `ObjectTransformer` |
@@ -191,6 +191,9 @@ running Iris is the pack publisher's responsibility.
- Create what `ItemDrop` and `EntitySpec` describe on the platform, skip what the platform lacks (an unknown enchantment, - Create what `ItemDrop` and `EntitySpec` describe on the platform, skip what the platform lacks (an unknown enchantment,
attribute or item flag) with a warning, and run the checks that come with an `EntitySpawns.Attempt` (light, surface, attribute or item flag) with a warning, and run the checks that come with an `EntitySpawns.Attempt` (light, surface,
free space) before spawning. Report how many entities appeared with `EntitySpawns.spawned`. free space) before spawning. Report how many entities appeared with `EntitySpawns.spawned`.
- `AmbientEffects.due`: ask for the player's last sampled position (not every tick's), carry out an `Effect` in the order
sound, particles, commands, potion, skip a part the platform lacks, and give no potion to a player who already has the
same one with a higher amplifier.
- Decode IrisApi's value types like settings: `BlockSpec`, `PaletteSpec`, `NoiseStyle`, `StyledRange`, `Range` and - Decode IrisApi's value types like settings: `BlockSpec`, `PaletteSpec`, `NoiseStyle`, `StyledRange`, `Range` and
`BlockPosition` from the JSON shapes in their docs, `Object` as maps, lists, `Double`s, strings and booleans. `BlockPosition` from the JSON shapes in their docs, `Object` as maps, lists, `Double`s, strings and booleans.
Read a `"snippet/<name>"` or `"snippet/<folder>/<name>"` string of a `@Snippet` type from Read a `"snippet/<name>"` or `"snippet/<folder>/<name>"` string of a `@Snippet` type from
+12
View File
@@ -989,11 +989,23 @@ from a sapling, which drops a block has. A module answers such questions through
damaged), and the host reads what only the platform knows (light, the surface below, free space, the blocks around a damaged), and the host reads what only the platform knows (light, the surface below, free space, the blocks around a
sapling) through the attempt's conditions or a `Surroundings` view. A service that must hear how its plan went has a sapling) through the attempt's conditions or a `Surroundings` view. A service that must hear how its plan went has a
second method for it (`EntitySpawns.spawned`, which keeps a spawner's rate limits). second method for it (`EntitySpawns.spawned`, which keeps a spawner's rate limits).
`AmbientEffects` follows the same rule: the module decides which effects are due (interval and chance, kept in the world's
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 - **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 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, and the
nearest start of one as a `LocateResult` (`Found`, `NotFound`, `SearchLimitReached`; a sealed interface, so callers 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. 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`). 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.
- **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
generators, and `usedBiomes`, which the dimension reaches without joining), instead of the host reading any module's
settings class. `usedBiomes` receives the dimension's own settings, since a name may stand for something the dimension
declares (a floating island's `carving` is a band id or a biome key).
- **Why not per-world provider instances.** A factory per world (`world -> provider`) would let a provider hold its - **Why not per-world provider instances.** A factory per world (`world -> provider`) would let a provider hold its
world, but every service method would then hide which world it answers for, and a host could not ask a pack-level world, but every service method would then hide which world it answers for, and a host could not ask a pack-level
question without a world. Passing the world keeps providers stateless like stage bodies and puts all per-world data question without a world. Passing the world keeps providers stateless like stage bodies and puts all per-world data
+9 -1
View File
@@ -308,6 +308,8 @@ final class RuinsObjects implements ObjectsAt {
| `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. | | `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. | | `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. | | `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, and fitting the terrain to the starts in one chunk through the `BlockAccess` the host hands over (see Vanilla structures). |
``` ```
@@ -422,7 +424,7 @@ public final class FloraSettings implements IrisFeature {
- `@Ref(Reference.X)` says what a `String` or `ResourceId` names, also on lists, sets and arrays of - `@Ref(Reference.X)` says what a `String` or `ResourceId` names, also on lists, sets and arrays of
them, so studio offers the right list: `BLOCK`, `ITEM`, `ENTITY`, `BIOME`, `STRUCTURE`, `STRUCTURE_PREFIX` them, so studio offers the right list: `BLOCK`, `ITEM`, `ENTITY`, `BIOME`, `STRUCTURE`, `STRUCTURE_PREFIX`
(a structure or a family prefix such as `minecraft:village`), `STRUCTURE_SET`, `TEMPLATE_POOL` (a jigsaw template pool), (a structure or a family prefix such as `minecraft:village`), `STRUCTURE_SET`, `TEMPLATE_POOL` (a jigsaw template pool),
`POTION_EFFECT` or `ENCHANTMENT` from the server's registries, `NOISE_STYLE` from the host's noise `POTION_EFFECT`, `ENCHANTMENT` or `SPECIAL_ENTITY` (a mob of another plugin) from the server's registries, `NOISE_STYLE` from the host's noise
styles, or `PACK_BIOME`, `PACK_REGION`, `PACK_OBJECT`, `PACK_EXPRESSION` or `PACK_IMAGE_MAP` of the pack. styles, or `PACK_BIOME`, `PACK_REGION`, `PACK_OBJECT`, `PACK_EXPRESSION` or `PACK_IMAGE_MAP` of the pack.
The pack kinds fit `String` only, in the form packs use (`desert/dunes`), never `ResourceId`. `BlockState` fields name blocks without it. `@Ref` on any other field fails The pack kinds fit `String` only, in the form packs use (`desert/dunes`), never `ResourceId`. `BlockState` fields name blocks without it. `@Ref` on any other field fails
the load. the load.
@@ -443,6 +445,12 @@ public final class FloraSettings implements IrisFeature {
(nothing could set another), or the load fails. There is no second form: the studio schema renders one shape and a (nothing could set another), or the load fails. There is no second form: the studio schema renders one shape and a
wrong shape fails with a message naming the key and the file. wrong shape fails with a message naming the key and the file.
- Options keep the order the class declares them in, a superclass's first. - Options keep the order the class declares them in, a superclass's first.
- Settings that bring other pack biomes into the pack's layout implement `LinkedBiomes`: `treeBiomes()` are biomes that join the
biome tree of every region the owner is in (the host registers their terrain generators with the region, as it does an
owner's children), and `usedBiomes(dimension)` are biomes the settings use besides, which the dimension reaches so their
objects, decorators and settings take part in generation. `dimension` is the settings the owner's dimension declares, for
settings that name something the dimension declares, such as a band of its caves. The host asks every dimension and biome
it reaches and ignores blank keys and keys naming no biome.
- Built-in settings may hold classes the host describes itself, such as Iris's palettes, which the host - Built-in settings may hold classes the host describes itself, such as Iris's palettes, which the host
names with `ModuleHost.describingHostTypesIn(...)`. They appear as `HostKind` and pack modules cannot names with `ModuleHost.describingHostTypesIn(...)`. They appear as `HostKind` and pack modules cannot
use them. use them.
@@ -0,0 +1,34 @@
package com.volmit.config;
import com.volmit.IrisFeature;
import java.util.Collection;
import java.util.Set;
/**
* Implemented by settings that make pack biomes part of a pack's layout besides the ones its regions list: the biome
* that a cave band puts underground, or the target of a floating island. The host asks the settings of every dimension
* and biome it reaches, without knowing the module behind them, so such a biome is loaded, registered and given its own
* settings like any other. Keys are pack biome keys as packs write them; blank keys and keys naming no biome are
* ignored.
*/
public interface LinkedBiomes {
/**
* Biomes that join the biome tree of every region the owner is part of, like the owner's children: the host registers
* them with the region, so their terrain generators take part in the region's terrain.
*/
default Set<String> treeBiomes() {
return Set.of();
}
/**
* Biomes the settings use besides, which a dimension reaches (their objects, decorators and settings take part in
* generation) without joining the region's biome tree.
*
* @param dimension the settings the owner's dimension declares, for settings that name something the dimension
* declares, such as a band of its caves
*/
default Set<String> usedBiomes(Collection<IrisFeature> dimension) {
return Set.of();
}
}
@@ -27,6 +27,8 @@ public enum Reference {
POTION_EFFECT, POTION_EFFECT,
/** An enchantment, such as {@code minecraft:sharpness}. */ /** An enchantment, such as {@code minecraft:sharpness}. */
ENCHANTMENT, ENCHANTMENT,
/** A mob of another plugin or content provider, such as {@code mythicmobs:skeleton_king}. */
SPECIAL_ENTITY,
/** A biome of the pack. */ /** A biome of the pack. */
PACK_BIOME, PACK_BIOME,
/** A region of the pack. */ /** A region of the pack. */
@@ -0,0 +1,96 @@
package com.volmit.service;
import com.volmit.entity.EntitySpec;
import com.volmit.world.BlockPosition;
import com.volmit.world.PackWorld;
import java.util.List;
import java.util.Objects;
/**
* The ambient effects of an area: sounds, particles, potion effects and commands that play around the players who stay
* in it. The host asks, now and then, for the players it keeps; the module says which effects of the area are due, and
* every random choice that goes with them (where the sound seems to come from, how the particles scatter, how long the
* potion lasts), so that the host only has to carry them out. An effect is due only now and then, as its interval and
* chance say, so most answers are empty. The host asks every provider and carries out all answers.
*/
@Service(Providers.ALL)
public interface AmbientEffects {
/**
* The effects due for a player standing at {@code at}.
*
* @param at world X and Z, Y the height above the dimension's bottom
*/
List<Effect> due(PackWorld world, BlockPosition at);
/**
* One effect that plays now. The host carries out the parts it has, in the order sound, particles, commands, potion.
* A part the platform lacks, such as an unknown sound, is skipped.
*
* @param sound a sound to play, or null
* @param particles particles to show, or null
* @param commands console commands to run, none when the effect has no commands that may run now
* @param potion a potion effect to give, or null
*/
record Effect(Sound sound, Particles particles, List<Command> commands, Potion potion) {
public Effect {
commands = List.copyOf(commands);
}
}
/**
* A sound played to the player.
*
* @param key the platform's sound key
* @param offsetX blocks from the player where the sound seems to come from, as the other offsets
* @param volume the sound's volume
* @param pitch the sound's pitch
*/
record Sound(String key, int offsetX, int offsetY, int offsetZ, float volume, float pitch) {
public Sound {
Objects.requireNonNull(key, "key");
}
}
/**
* Particles shown to the player. They appear {@code forward} blocks ahead of the player, {@code sideways} blocks to
* the right (negative for the left) and on the surface at that spot, one block up, moved by {@code jitterX} and
* {@code jitterZ} and by {@code lift} blocks up.
*
* @param key the platform's particle key
* @param count how many particles; none makes {@code altX}, {@code altY} and {@code altZ} their motion
* @param altX the particles' offset or motion, as the other two
* @param extra an extra value some particles take; 0 for none
*/
record Particles(String key, double forward, double sideways, double jitterX, double jitterZ, int lift, int count,
double altX, double altY, double altZ, double extra) {
public Particles {
Objects.requireNonNull(key, "key");
}
}
/**
* A command to run where the effect plays.
*
* @param command the commands, their delay and repeats; {@code {x}}, {@code {y}} and {@code {z}} stand for the block
* position
* @param offsetX blocks from the player where the command runs, as the other two
*/
record Command(EntitySpec.Command command, double offsetX, double offsetY, double offsetZ) {
public Command {
Objects.requireNonNull(command, "command");
}
}
/**
* A potion effect for the player. A player who has the same potion effect with a stronger amplifier keeps it.
*
* @param key the platform's potion effect key
* @param strength the amplifier
* @param ticks how long it lasts, in server ticks
*/
record Potion(String key, int strength, int ticks) {
public Potion {
Objects.requireNonNull(key, "key");
}
}
}
@@ -0,0 +1,27 @@
package com.volmit.service;
import com.volmit.world.PackWorld;
import java.util.Optional;
/**
* Which biome a module puts underground. The host places the cave biome of a position itself, from the biome its regions give
* the column and its terrain; this service tells it where a module overrides that and where a cave biome gives way to the
* surface's. A pack has one provider, since two modules deciding the biome of the same cave could not both be right.
*/
@Service(Providers.ONE)
public interface CaveBiomes {
/**
* The pack biome the module puts at the position whatever the regions say, such as a band of the deep dark. Empty where it
* overrides nothing.
*
* @param y the height above the dimension's bottom
* @return the biome key as packs write it
*/
Optional<String> overriddenBiome(PackWorld world, int x, int y, int z);
/**
* How many blocks below the surface a position must lie for the pack biome {@code biomeKey} to be the cave biome there;
* nearer the surface the surface's biome is. 0 for a biome that has no such limit.
*/
int minDepthBelowSurface(PackWorld world, String biomeKey);
}
@@ -3,6 +3,7 @@ package com.volmit;
import com.volmit.entity.EntitySpec; import com.volmit.entity.EntitySpec;
import com.volmit.item.ItemDrop; import com.volmit.item.ItemDrop;
import com.volmit.item.ItemEnchantment; import com.volmit.item.ItemEnchantment;
import com.volmit.service.AmbientEffects;
import com.volmit.service.BlockDrops; import com.volmit.service.BlockDrops;
import com.volmit.service.EntitySpawns; import com.volmit.service.EntitySpawns;
import com.volmit.service.SaplingGrowth; import com.volmit.service.SaplingGrowth;
@@ -57,6 +58,19 @@ class ItemAndEntityValuesTest {
assertTrue(SaplingGrowth.TreeObjects.NONE.objects().isEmpty()); assertTrue(SaplingGrowth.TreeObjects.NONE.objects().isEmpty());
} }
@Test
void anAmbientEffectKeepsItsCommandsApartAndRefusesPartsWithoutKeys() {
List<AmbientEffects.Command> commands = new ArrayList<>(List.of(
new AmbientEffects.Command(new EntitySpec.Command(List.of("say hi"), 0, false, 100), 1, 0, -1)));
AmbientEffects.Effect effect = new AmbientEffects.Effect(null, null, commands, new AmbientEffects.Potion("luck", 0, 100));
commands.clear();
assertEquals(1, effect.commands().size());
assertThrows(UnsupportedOperationException.class, () -> effect.commands().clear());
assertThrows(NullPointerException.class, () -> new AmbientEffects.Sound(null, 0, 0, 0, 1, 1));
assertThrows(NullPointerException.class, () -> new AmbientEffects.Command(null, 0, 0, 0));
}
private static EntitySpec entity(String type, String specialType) { private static EntitySpec entity(String type, String specialType) {
return new EntitySpec(type, specialType, null, "", new EntitySpec.Flags(false, true, true, false, true, false, false, return new EntitySpec(type, specialType, null, "", new EntitySpec.Flags(false, true, true, false, true, false, false,
false, false, false, false), EntitySpec.Equipment.NONE, List.of(), List.of(), List.of(), 0L, null, null, false, false, false, false, false), EntitySpec.Equipment.NONE, List.of(), List.of(), List.of(), 0L, null, null, false,