mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-27 00:04:42 +00:00
Merge branch 'wave3/l'
# Conflicts: # CONTRACTS.md # README.md
This commit is contained in:
commit
bc2db7222f
6 files changed
+120
-2
No files matched your search
+4
-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`; 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` |
|
||||
| Dense chunk output | `Hunk<T>`, `GenerationContext.hunk`, reference `ArrayHunk<T>` |
|
||||
| Sparse geometry and transforms | `ObjectGenerator`, `GeneratedObject`, `ObjectTransform`, `ObjectTransformer` |
|
||||
@@ -184,6 +184,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,
|
||||
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`.
|
||||
- `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
|
||||
`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
|
||||
|
||||
@@ -969,6 +969,8 @@ 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
|
||||
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).
|
||||
`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
|
||||
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
|
||||
|
||||
@@ -296,6 +296,7 @@ final class RuinsObjects implements ObjectsAt {
|
||||
| `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). |
|
||||
|
||||
```
|
||||
@@ -409,7 +410,7 @@ public final class FloraSettings implements IrisFeature {
|
||||
- `@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`
|
||||
(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.
|
||||
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.
|
||||
|
||||
@@ -27,6 +27,8 @@ public enum Reference {
|
||||
POTION_EFFECT,
|
||||
/** An enchantment, such as {@code minecraft:sharpness}. */
|
||||
ENCHANTMENT,
|
||||
/** A mob of another plugin or content provider, such as {@code mythicmobs:skeleton_king}. */
|
||||
SPECIAL_ENTITY,
|
||||
/** A biome of the pack. */
|
||||
PACK_BIOME,
|
||||
/** 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");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package com.volmit;
|
||||
import com.volmit.entity.EntitySpec;
|
||||
import com.volmit.item.ItemDrop;
|
||||
import com.volmit.item.ItemEnchantment;
|
||||
import com.volmit.service.AmbientEffects;
|
||||
import com.volmit.service.BlockDrops;
|
||||
import com.volmit.service.EntitySpawns;
|
||||
import com.volmit.service.SaplingGrowth;
|
||||
@@ -57,6 +58,19 @@ class ItemAndEntityValuesTest {
|
||||
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) {
|
||||
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,
|
||||
|
||||
Reference in new issue
Block a user