mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-27 16:25:36 +00:00
Batch 6 part 4a: built-ins on purpose seeds and the running world
Finding 40, first step. IrisSeeds and LiveWorld are gone: seeds are world.seed(IrisSeedPurposes.X), which Iris answers with its legacy seeds, and the loot, spawn, effect and tree services read world.running() (TerrainSampler, FeatureSettings, sky, highest block). The block-biome rule is the module's BlockBiomes. ObjectHost loses its layout and settings lookups (columnSettings, regionAt, biome and region declarations, cave lava and fluid heights, upper objects, procedural): object placing reads the chunk's terrain, settings and upper dimension, and caches procedural objects in world state. Object loot moved to ObjectHost.placedLoot; spawner cooldowns stay an Iris extension because Iris persists them with the world. FloatingHost loses surfaceBiome and biome(key) to the running layout and PackResources.
This commit is contained in:
1 parent
7be7c311e3
commit
45cb5e4bcf
41 files changed
+459
-459
No files matched your search
@@ -61,7 +61,8 @@ the same JSON as Iris's `IrisObjectPlacement` and keeps the JSON it was read fro
|
||||
a placement as their own class (`ObjectPlacements.host`). What a jar cannot do, Iris does through the facades `ObjectHost` and
|
||||
`ObjectChunk` in `art.arcane.iris.builtin.objects`: loading and scaling the pack's objects, placing one with the placement
|
||||
stages into the chunk's mantle (on the surface, in a cave inside the cave's bounds, or hung from the terrain above), reading the
|
||||
carved space the cave carver planned, and the layout around a position. `ObjectPlacing` and its helpers (`ChunkObjectPlacing`,
|
||||
carved space the cave carver planned, and the loot an object placed at a block defines; the layout, the settings of a column and
|
||||
the upper dimension's objects come from IrisApi (`TerrainSampler`, `FeatureSettings`, `UpperDimension`). `ObjectPlacing` and its helpers (`ChunkObjectPlacing`,
|
||||
`CaveAnchors`, `PlacementReach`) decide what to place and where. The procedural generators (`engine/object/procedural`) stay
|
||||
compiled in, behind `ProceduralPlacement`, until they build `GeneratedObject`s instead of Iris objects.
|
||||
`iris:loot` owns the loot table resource kind (`LootResources`, folder `loot`), checks the tables and the references to
|
||||
@@ -183,7 +184,7 @@ The jar holds `iris:post`, `iris:perfection`, `iris:matter`, `iris:loot`, `iris:
|
||||
written against IrisApi and `art.arcane.iris.builtin` alone: the chunk's `BlockState` hunk, the block registry's traits and
|
||||
`canPlaceOn`, the terrain sampler (heights around the chunk, slope, fluid height, where the upper dimension begins) and the
|
||||
mantle's planned blocks; the placement stages read the placement being run through the `ObjectPlacement` facade, and the loot and
|
||||
spawn services, which have no chunk to ask, ask `LiveWorld` (both below). Without the jar a pack's world has no caves, vanilla
|
||||
spawn services, which have no chunk to ask, ask the running world (`world.running()`, IrisApi's `RunningWorld`). Without the jar a pack's world has no caves, vanilla
|
||||
placed features, loot, block drops, entity spawns or ambient effects, and its biomes' `loot`, `blockDrops`, `entitySpawners` and
|
||||
`effects` are not read.
|
||||
Iris no longer compiles them in (`IrisModuleHost.generationModules()`); every pack gets them from the bundled jar. A pack
|
||||
@@ -193,14 +194,14 @@ none of the jar's modules (`IrisModuleHost.JAR_MODULE_IDS`, which a test keeps e
|
||||
|
||||
`art.arcane.iris.builtin` also holds what the compiled-in built-ins and the jar must share, because each sees its own copy of
|
||||
every other class. The facades among them are interfaces Iris implements and offers through IrisApi's extension point, never
|
||||
through the thread or a cast: a module asks `world.extension(X.class)` for what belongs to a world (`IrisSeeds`, `LiveWorld`,
|
||||
`ObjectHost`, `FloatingHost`, `StructureHost`), `context.extension(X.class)` for what belongs to one invocation (`ObjectPlacement`
|
||||
through the thread or a cast: a module asks `world.extension(X.class)` for what belongs to a world (`ObjectHost`,
|
||||
`FloatingHost`, `StructureHost`, `spawn.SpawnCooldowns`), `context.extension(X.class)` for what belongs to one invocation (`ObjectPlacement`
|
||||
in a placement stage, `MatterMantle` in a chunk or mantle stage) and `settings.extension(X.class)` for a reach worked out
|
||||
before any world exists, each with `.orElseThrow()`, since a built-in runs only where Iris offers them. `IrisSeeds` gives
|
||||
Iris's per-feature world seeds (`seeds.seed(IrisSeed.CARVE)`), so existing worlds generate the same; `terrain.LayerBlocks` (the world's picks from the biomes' palette layers: terrain, caves and post pick from the same
|
||||
layers, and a layer's noise is built once per world by whichever asks first), `LiveWorld` (what the loot and spawn services ask a
|
||||
running world, outside any chunk stage: the layout and settings at a block, the platform's weather and loot tables, the
|
||||
objects' loot and the spawner cooldowns Iris saves with the world; values only),
|
||||
before any world exists, each with `.orElseThrow()`, since a built-in runs only where Iris offers them. Iris's per-feature world seeds are
|
||||
IrisApi purpose seeds: `world.seed(IrisSeedPurposes.CARVE)` (`iris:seed/carve`), which Iris answers with the seeds its worlds always
|
||||
had, so existing worlds generate the same; `terrain.LayerBlocks` (the world's picks from the biomes' palette layers: terrain, caves and post pick from the same
|
||||
layers, and a layer's noise is built once per world by whichever asks first), `spawn.SpawnCooldowns` (the spawner cooldowns
|
||||
Iris saves with the world's data, so they survive a restart),
|
||||
`loot.LootResolver` (the random streams loot is drawn from, shared with the hosts that fill containers) and the loot and
|
||||
marker lists of an object placement (`loot.ObjectLoot`, `loot.ObjectVanillaLoot`, `spawn.PlacementMarker`, which the modules
|
||||
register as held types, because Iris's `IrisObjectPlacement` holds them). The placement stages need more of the object being
|
||||
@@ -219,5 +220,5 @@ so it writes nothing outside its chunk. What a
|
||||
cave's walls, floor and ceiling get comes from the terrain and decorant built-ins of the same jar (`terrain.BiomeLayers`,
|
||||
`terrain.TerrainPalettes`, the biome decorators), through carve's own `CaveDressing`, which tests replace with fixed blocks.
|
||||
A cave's dimension, region and biome settings are found by the id the layout's biome samples carry (`DeclaredByLevel`), its
|
||||
absolute world Y bands convert with `PackWorld.minHeight()`, and its noise reads `NoiseSampler.signed(...)` (Iris's memoised signed read)
|
||||
absolute world Y bands convert with `PackWorld.minWorldY()`, and its noise reads `NoiseSampler.signed(...)` (Iris's memoised signed read)
|
||||
and `scaled(...)`. `caveLavaHeight` and `upperDimensionCarving` are its dimension settings.
|
||||
@@ -1,31 +0,0 @@
|
||||
/*
|
||||
* 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.builtin;
|
||||
|
||||
import com.volmit.world.PackWorld;
|
||||
|
||||
/**
|
||||
* The seeds Iris derives from a world's seed for its own features. Iris derives them one after another from a shared
|
||||
* random, so they cannot be worked out from the world seed alone. Built-in modules seed their randoms and noise with
|
||||
* them, so worlds generated before the features were modules generate the same; a pack module derives its own seeds
|
||||
* from {@link PackWorld#seed()}. A world Iris generates answers for them through its {@link IrisSeeds} extension.
|
||||
*/
|
||||
public enum IrisSeed {
|
||||
BIOME, CARVE, COMPLEX, COMPONENT, DECORATOR, DEPOSIT, ENTITY, LOOT, MANTLE, POST, TERRAIN
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* 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.builtin;
|
||||
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.world.PackWorld;
|
||||
|
||||
/**
|
||||
* The purposes Iris's built-in modules ask {@link PackWorld#seed(ResourceId)} for. Iris answers each with the seed its
|
||||
* worlds always used for that feature, derived one after another from a shared random rather than by the API's rule,
|
||||
* so worlds generated before the features were modules generate the same.
|
||||
*/
|
||||
public final class IrisSeedPurposes {
|
||||
public static final ResourceId BIOME = purpose("biome");
|
||||
public static final ResourceId CARVE = purpose("carve");
|
||||
public static final ResourceId COMPLEX = purpose("complex");
|
||||
public static final ResourceId COMPONENT = purpose("component");
|
||||
public static final ResourceId DECORATOR = purpose("decorator");
|
||||
public static final ResourceId DEPOSIT = purpose("deposit");
|
||||
public static final ResourceId ENTITY = purpose("entity");
|
||||
public static final ResourceId LOOT = purpose("loot");
|
||||
public static final ResourceId MANTLE = purpose("mantle");
|
||||
public static final ResourceId POST = purpose("post");
|
||||
public static final ResourceId TERRAIN = purpose("terrain");
|
||||
|
||||
private static final String NAMESPACE = "iris";
|
||||
private static final String PATH_PREFIX = "seed/";
|
||||
|
||||
private IrisSeedPurposes() {
|
||||
}
|
||||
|
||||
private static ResourceId purpose(String name) {
|
||||
return new ResourceId(NAMESPACE, PATH_PREFIX + name);
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
/*
|
||||
* 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.builtin;
|
||||
|
||||
/**
|
||||
* The {@link IrisSeed}s of a world Iris generates, which it offers as an extension of the world:
|
||||
* {@code world.extension(IrisSeeds.class).orElseThrow().seed(IrisSeed.CARVE)}.
|
||||
*/
|
||||
public interface IrisSeeds {
|
||||
long seed(IrisSeed seed);
|
||||
}
|
||||
@@ -1,122 +0,0 @@
|
||||
/*
|
||||
* 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.builtin;
|
||||
|
||||
import art.arcane.iris.builtin.loot.ObjectLoot;
|
||||
import art.arcane.iris.builtin.loot.ObjectVanillaLoot;
|
||||
import art.arcane.iris.builtin.spawn.SpawnCooldowns;
|
||||
import com.volmit.IrisFeature;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.geometry.BlockPosition;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* What Iris's own services ask a world that is running, outside any chunk stage: the layout and the objects at a block
|
||||
* as they are now, the platform's weather and loot tables, and the data Iris keeps with the world. A chunk stage reads
|
||||
* the layout through its {@link com.volmit.world.TerrainSampler}; a service has no chunk, so it asks here.
|
||||
*
|
||||
* <p>X and Z are world coordinates; Y is the height above the dimension's bottom, as everywhere in IrisApi.
|
||||
* Safe to use from any thread. Iris offers it as an extension of its worlds: {@code world.extension(LiveWorld.class)}.
|
||||
*/
|
||||
public interface LiveWorld {
|
||||
/** The platform's block Y of height 0, the dimension's bottom: a position's height plus this is its Y in the platform. */
|
||||
int bottomY();
|
||||
|
||||
/** The pack biome at the column's surface. */
|
||||
ResourceId surfaceBiome(int x, int z);
|
||||
|
||||
/** The pack biome at the block when it lies in a cave biome, else the surface biome. */
|
||||
ResourceId caveBiome(int x, int y, int z);
|
||||
|
||||
/** What the surface biome of the column is for: land, sea, shore or cave. */
|
||||
BiomeKind surfaceKind(int x, int z);
|
||||
|
||||
/** The terrain's height at the column, before anything was placed on it. */
|
||||
double terrainHeight(int x, int z);
|
||||
|
||||
/** The height of the highest block placed in the column, with the terrain and what objects and structures added. */
|
||||
int highestBlock(int x, int z, boolean ignoreFluid);
|
||||
|
||||
/**
|
||||
* The settings of {@code type} that the dimension, the region or a biome declares for the block, as they are
|
||||
* decoded for generation; empty when that level declares none.
|
||||
*/
|
||||
<F extends IrisFeature> Optional<F> settings(Class<F> type, Level level, int x, int y, int z);
|
||||
|
||||
/** The time and weather of the world, or empty when the world has no platform world yet. */
|
||||
Optional<Sky> sky();
|
||||
|
||||
/** Whether the world is a studio world. */
|
||||
boolean studio();
|
||||
|
||||
/** The keys of the loot tables the platform has, such as {@code minecraft:chests/simple_dungeon}. They do not change while the world runs. */
|
||||
Set<String> platformLootTables();
|
||||
|
||||
/** The floors of the caves marked in the chunk, none on a platform that cannot read them. */
|
||||
List<BlockPosition> caveFloors(int chunkX, int chunkZ);
|
||||
|
||||
/** The loot the object placed at the block defines, or empty when no object placement covers the block. */
|
||||
Optional<ObjectLoots> objectLoots(int x, int y, int z);
|
||||
|
||||
/** The cooldowns of the world's spawners. */
|
||||
SpawnCooldowns spawnCooldowns();
|
||||
|
||||
/** Where the layout is asked: the dimension, the region of the column, or one of its biomes. */
|
||||
enum Level {
|
||||
DIMENSION,
|
||||
REGION,
|
||||
/** The biome at the column's surface. */
|
||||
SURFACE_BIOME,
|
||||
/** The biome at the block: a cave biome below the surface, the surface biome above. */
|
||||
BIOME,
|
||||
/** The cave biome at the block, the surface biome when it has none. */
|
||||
CAVE_BIOME
|
||||
}
|
||||
|
||||
/** What a biome is for, which decides the spawners that fit it. */
|
||||
enum BiomeKind {
|
||||
LAND, SEA, SHORE, CAVE
|
||||
}
|
||||
|
||||
/** The world's time of day in ticks, whether it is storming and whether it thunders. */
|
||||
record Sky(long time, boolean storming, boolean thundering) {
|
||||
}
|
||||
|
||||
/**
|
||||
* The loot an object placement gives its containers.
|
||||
*
|
||||
* @param packTables tables of the pack
|
||||
* @param platformTables tables of the platform
|
||||
* @param overridesGlobalLoot whether the placement's tables replace those of the dimension, region and biomes
|
||||
*/
|
||||
record ObjectLoots(List<ObjectLoot> packTables, List<ObjectVanillaLoot> platformTables, boolean overridesGlobalLoot) {
|
||||
public ObjectLoots {
|
||||
packTables = List.copyOf(packTables);
|
||||
platformTables = List.copyOf(platformTables);
|
||||
}
|
||||
|
||||
/** Whether the placement names any table. */
|
||||
public boolean defined() {
|
||||
return !packTables.isEmpty() || !platformTables.isEmpty();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -27,17 +27,11 @@ import com.volmit.resource.ResourceId;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* What {@code iris:floating} asks of Iris beyond the API: the biome of any column, a biome's own terrain height, the sky
|
||||
* biome an island paints, and placing Iris objects against an island. Iris offers it as an extension of its worlds and
|
||||
* of the settings of the pack it loads: {@code world.extension(FloatingHost.class)}.
|
||||
* What {@code iris:floating} asks of Iris beyond the API: a biome's own terrain height, the sky biome an island paints,
|
||||
* and placing Iris objects against an island. Iris offers it as an extension of its worlds:
|
||||
* {@code world.extension(FloatingHost.class)}.
|
||||
*/
|
||||
public interface FloatingHost {
|
||||
/** The biome of the column's surface, the biome an island grows from; any column, not only the chunk's. */
|
||||
ResourceId surfaceBiome(int worldX, int worldZ);
|
||||
|
||||
/** The biome {@code key} names in the pack; empty when the pack has none. */
|
||||
Optional<ResourceId> biome(String key);
|
||||
|
||||
/** The height the terrain generators of {@code biome} give the column, as Iris shapes the biome's terrain with {@code seed}. */
|
||||
double biomeHeight(ResourceId biome, int worldX, int worldZ, long seed);
|
||||
|
||||
|
||||
@@ -18,36 +18,30 @@
|
||||
|
||||
package art.arcane.iris.builtin.objects;
|
||||
|
||||
import art.arcane.iris.builtin.loot.ObjectLoot;
|
||||
import art.arcane.iris.builtin.loot.ObjectVanillaLoot;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.IrisFeature;
|
||||
import com.volmit.config.FeatureSettings;
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.generation.InvocationContext;
|
||||
import com.volmit.resource.ResourceId;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* What {@code iris:objects} asks of Iris: the objects of the pack, how Iris scales and places them, and the layout around
|
||||
* a world position. Iris offers it as an extension of its worlds and of the settings of the pack it loads:
|
||||
* {@code world.extension(ObjectHost.class)}, {@code settings.extension(ObjectHost.class)}. Nothing here hands out the
|
||||
* engine.
|
||||
* What {@code iris:objects} asks of Iris's object system: the pack's objects, how Iris scales, picks and places them, and
|
||||
* the loot of what it placed. The layout, settings and seeds around an object are the API's. Iris offers it as an
|
||||
* extension of its worlds and of the settings of the pack it loads: {@code world.extension(ObjectHost.class)},
|
||||
* {@code settings.extension(ObjectHost.class)}.
|
||||
*
|
||||
* <p>Objects are named by the keys placements hold ({@link ObjectPlacement#place()}). The randoms are VolmLib's
|
||||
* {@link RNG}, since the streams Iris draws objects with decide where existing worlds have them.
|
||||
*/
|
||||
public interface ObjectHost {
|
||||
/** Whether Iris's debug setting is on. */
|
||||
/** Whether Iris's debug setting is on, which makes object placing trace what it does. */
|
||||
boolean debugging();
|
||||
|
||||
/** The height, above the dimension's bottom, up to which caves are filled with lava. */
|
||||
int caveLavaHeight();
|
||||
|
||||
/** The height of the dimension's fluid. */
|
||||
int fluidHeight();
|
||||
|
||||
/** The settings that apply at a world column, for work outside a chunk's generation. */
|
||||
FeatureSettings columnSettings();
|
||||
|
||||
/** The random a chunk's objects are placed with: the same for the same chunk of the same world. */
|
||||
RNG chunkRandom(int chunkX, int chunkZ);
|
||||
|
||||
@@ -69,42 +63,42 @@ public interface ObjectHost {
|
||||
/** Builds what placing the placement would build on first use, so the first chunk to place it does not wait. */
|
||||
void warm(ObjectPlacement placement, RNG rng);
|
||||
|
||||
/** The procedural objects {@code settings} declare, made placeable by {@code resolve} once per world. */
|
||||
List<ProceduralPlacement> procedural(ProceduralObjectSettings settings,
|
||||
Function<ProceduralObjectSettings, List<ProceduralPlacement>> resolve);
|
||||
|
||||
/** A builder for one bake of objects made block by block. */
|
||||
ObjectBuilder builder();
|
||||
|
||||
/** The object settings of the biome and the region of the dimension stacked above, at the column; none where nothing sits above. */
|
||||
Optional<UpperObjects> upperObjects(int worldX, int worldZ);
|
||||
|
||||
/** Places the object into {@code sink}, which is outside any chunk's generation, such as a growing sapling's tree. */
|
||||
int placeInto(PlaceableObject object, int x, int y, int z, ObjectPlacement placement, ObjectSink sink, RNG rng);
|
||||
|
||||
/** The region at the column. */
|
||||
ResourceId regionAt(int worldX, int worldZ);
|
||||
/** The loot of the object placed at the block; empty when no object placement covers the block. */
|
||||
Optional<ObjectLoots> placedLoot(int x, int y, int z);
|
||||
|
||||
/** The surface biome at the column. */
|
||||
ResourceId surfaceBiomeAt(int worldX, int worldZ);
|
||||
|
||||
/** The biome at the position, which is the cave biome underground. */
|
||||
ResourceId biomeAt(int worldX, int y, int worldZ);
|
||||
|
||||
/** The settings the biome declares itself, whichever column it is found at; empty when it declares none. */
|
||||
<F extends IrisFeature> Optional<F> biomeDeclaration(ResourceId biome, Class<F> type);
|
||||
|
||||
/** The settings the region declares itself; empty when it declares none. */
|
||||
<F extends IrisFeature> Optional<F> regionDeclaration(ResourceId region, Class<F> type);
|
||||
|
||||
/** Every region and every reachable biome that declares the settings, by the key the pack knows it by, regions first. */
|
||||
/**
|
||||
* Every region and every reachable biome that declares the settings, regions first. Unlike the sources of
|
||||
* {@link com.volmit.config.PackSettings#declared}, which name the resource that declares them, each is named by the
|
||||
* id a {@link com.volmit.world.BiomeSample} gives it.
|
||||
*/
|
||||
<F extends IrisFeature> List<Declaration<F>> declarations(Class<F> type);
|
||||
|
||||
/** What the dimension stacked above declares to place at a column, where each is null when its level declares none. */
|
||||
record UpperObjects(ObjectSettings biome, ObjectSettings region, String biomeKey, String regionKey) {
|
||||
/** One region's or biome's declaration of settings, by the id of the region or biome. */
|
||||
record Declaration<F extends IrisFeature>(Level level, ResourceId id, F settings) {
|
||||
}
|
||||
|
||||
/** One region's or biome's declaration of settings. */
|
||||
record Declaration<F extends IrisFeature>(Level level, String key, F settings) {
|
||||
/**
|
||||
* The loot an object placement gives its containers.
|
||||
*
|
||||
* @param packTables tables of the pack
|
||||
* @param platformTables tables of the platform
|
||||
* @param overridesGlobalLoot whether the placement's tables replace those of the dimension, region and biomes
|
||||
*/
|
||||
record ObjectLoots(List<ObjectLoot> packTables, List<ObjectVanillaLoot> platformTables, boolean overridesGlobalLoot) {
|
||||
public ObjectLoots {
|
||||
packTables = List.copyOf(packTables);
|
||||
platformTables = List.copyOf(platformTables);
|
||||
}
|
||||
|
||||
/** Whether the placement names any table. */
|
||||
public boolean defined() {
|
||||
return !packTables.isEmpty() || !platformTables.isEmpty();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -29,7 +29,8 @@
|
||||
* <p>
|
||||
* Besides those, it holds what the compiled-in built-ins and the built-ins jar must share, since each sees its own copy
|
||||
* of every other class: narrow facades only Iris's own built-ins use, interfaces Iris's worlds implement
|
||||
* ({@link art.arcane.iris.builtin.IrisSeed}, {@link art.arcane.iris.builtin.LiveWorld}, {@link art.arcane.iris.builtin.objects.ObjectHost}),
|
||||
* ({@link art.arcane.iris.builtin.spawn.SpawnCooldowns}, {@link art.arcane.iris.builtin.objects.ObjectHost}), the seed purposes Iris
|
||||
* answers with its legacy seeds ({@link art.arcane.iris.builtin.IrisSeedPurposes}),
|
||||
* and per-world state several of them use ({@link art.arcane.iris.builtin.terrain.LayerBlocks},
|
||||
* {@link art.arcane.iris.builtin.terrain.BiomeLayers}, {@link art.arcane.iris.builtin.terrain.TerrainPalettes}). Keep them few: each is
|
||||
* a promise.
|
||||
|
||||
@@ -22,8 +22,8 @@ import java.util.function.ToLongFunction;
|
||||
|
||||
/**
|
||||
* When spawners last fired, which Iris keeps with the world's data so that a spawner's rates hold across restarts. Rates
|
||||
* count per spawner, by the key the pack names it by, in the world and in each chunk. Reached through
|
||||
* {@link art.arcane.iris.builtin.LiveWorld#spawnCooldowns()}.
|
||||
* count per spawner, by the key the pack names it by, in the world and in each chunk. Iris offers it as an extension of
|
||||
* its worlds: {@code world.extension(SpawnCooldowns.class)}.
|
||||
*/
|
||||
public interface SpawnCooldowns {
|
||||
/** Whether the spawner may fire in the world again, {@code intervalMilliseconds} after it last did. */
|
||||
|
||||
@@ -17,8 +17,7 @@
|
||||
*/
|
||||
package art.arcane.iris.builtin.terrain;
|
||||
|
||||
import art.arcane.iris.builtin.IrisSeed;
|
||||
import art.arcane.iris.builtin.IrisSeeds;
|
||||
import art.arcane.iris.builtin.IrisSeedPurposes;
|
||||
import art.arcane.volmlib.util.cache.AtomicCache;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.block.BlockState;
|
||||
@@ -63,7 +62,7 @@ public final class TerrainPalettes {
|
||||
|
||||
TerrainPalettes(PackWorld world) {
|
||||
this.world = world;
|
||||
this.complexSeed = world.extension(IrisSeeds.class).orElseThrow().seed(IrisSeed.COMPLEX);
|
||||
this.complexSeed = world.seed(IrisSeedPurposes.COMPLEX);
|
||||
}
|
||||
|
||||
/** The palettes of {@code world}. */
|
||||
|
||||
@@ -17,8 +17,7 @@
|
||||
*/
|
||||
package art.arcane.iris.engine.actuator;
|
||||
|
||||
import art.arcane.iris.builtin.IrisSeed;
|
||||
import art.arcane.iris.builtin.IrisSeeds;
|
||||
import art.arcane.iris.builtin.IrisSeedPurposes;
|
||||
import art.arcane.iris.builtin.terrain.OreSettings;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.config.FeatureSettings.Entry;
|
||||
@@ -50,7 +49,7 @@ final class OreWarmUp {
|
||||
OreWarmUp(PackWorld world, TerrainOres ores) {
|
||||
this.world = world;
|
||||
this.ores = ores;
|
||||
this.root = new RNG(world.extension(IrisSeeds.class).orElseThrow().seed(IrisSeed.COMPONENT) + ROOT_SEED_SALT);
|
||||
this.root = new RNG(world.seed(IrisSeedPurposes.COMPONENT) + ROOT_SEED_SALT);
|
||||
}
|
||||
|
||||
void warm() {
|
||||
|
||||
@@ -17,8 +17,7 @@
|
||||
*/
|
||||
package art.arcane.iris.engine.actuator;
|
||||
|
||||
import art.arcane.iris.builtin.IrisSeed;
|
||||
import art.arcane.iris.builtin.IrisSeeds;
|
||||
import art.arcane.iris.builtin.IrisSeedPurposes;
|
||||
import art.arcane.iris.builtin.terrain.OreSettings;
|
||||
import com.volmit.resource.PackResources;
|
||||
import com.volmit.world.PackWorld;
|
||||
@@ -37,7 +36,7 @@ final class TerrainOres {
|
||||
|
||||
TerrainOres(PackWorld world) {
|
||||
this.resources = world.resources();
|
||||
this.terrainSeed = world.extension(IrisSeeds.class).orElseThrow().seed(IrisSeed.TERRAIN);
|
||||
this.terrainSeed = world.seed(IrisSeedPurposes.TERRAIN);
|
||||
}
|
||||
|
||||
/** The ores of {@code world}. */
|
||||
|
||||
@@ -17,8 +17,7 @@
|
||||
*/
|
||||
package art.arcane.iris.engine.actuator;
|
||||
|
||||
import art.arcane.iris.builtin.IrisSeed;
|
||||
import art.arcane.iris.builtin.IrisSeeds;
|
||||
import art.arcane.iris.builtin.IrisSeedPurposes;
|
||||
import art.arcane.iris.builtin.terrain.BedrockSettings;
|
||||
import art.arcane.iris.builtin.terrain.HideOresSettings;
|
||||
import art.arcane.iris.builtin.terrain.OreSettings;
|
||||
@@ -67,7 +66,7 @@ final class TerrainShaper {
|
||||
this.palettes = palettes;
|
||||
this.layers = layers;
|
||||
this.ores = ores;
|
||||
this.rng = new RNG(world.extension(IrisSeeds.class).orElseThrow().seed(IrisSeed.TERRAIN));
|
||||
this.rng = new RNG(world.seed(IrisSeedPurposes.TERRAIN));
|
||||
this.levelsBelowTheDimensionDeclareOres = world.settings().declared(OreSettings.class).entries().stream()
|
||||
.anyMatch(entry -> entry.level() != Level.DIMENSION);
|
||||
}
|
||||
|
||||
@@ -17,8 +17,7 @@
|
||||
*/
|
||||
package art.arcane.iris.engine.decorator;
|
||||
|
||||
import art.arcane.iris.builtin.IrisSeed;
|
||||
import art.arcane.iris.builtin.IrisSeeds;
|
||||
import art.arcane.iris.builtin.IrisSeedPurposes;
|
||||
import art.arcane.iris.builtin.decorant.DecorantSettings;
|
||||
import art.arcane.iris.builtin.decorant.DecorationPart;
|
||||
import art.arcane.iris.builtin.decorant.Decorator;
|
||||
@@ -60,7 +59,7 @@ public final class BiomeDecorators {
|
||||
this.world = world;
|
||||
this.resources = world.resources();
|
||||
this.log = world.log();
|
||||
this.decoratorSeed = world.extension(IrisSeeds.class).orElseThrow().seed(IrisSeed.DECORATOR);
|
||||
this.decoratorSeed = world.seed(IrisSeedPurposes.DECORATOR);
|
||||
}
|
||||
|
||||
/** The world's decorators, kept in its state store. */
|
||||
|
||||
@@ -17,8 +17,7 @@
|
||||
*/
|
||||
package art.arcane.iris.engine.decorator;
|
||||
|
||||
import art.arcane.iris.builtin.IrisSeed;
|
||||
import art.arcane.iris.builtin.IrisSeeds;
|
||||
import art.arcane.iris.builtin.IrisSeedPurposes;
|
||||
import com.volmit.ModuleLog;
|
||||
import com.volmit.block.BlockRegistry;
|
||||
import com.volmit.block.BlockState;
|
||||
@@ -53,7 +52,7 @@ public final class DecorationScene {
|
||||
public static DecorationScene of(ChunkStageContext context) {
|
||||
Mantle mantle = context.mantle();
|
||||
return new DecorationScene(context.blocks(),context.world().resources().blocks(), context.terrain(),
|
||||
mantle == null ? null : mantle.blocks(), BiomeDecorators.of(context.world()), context.world().extension(IrisSeeds.class).orElseThrow().seed(IrisSeed.COMPONENT),
|
||||
mantle == null ? null : mantle.blocks(), BiomeDecorators.of(context.world()), context.world().seed(IrisSeedPurposes.COMPONENT),
|
||||
context.log());
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* 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.loot;
|
||||
|
||||
import com.volmit.IrisFeature;
|
||||
import com.volmit.geometry.BlockPosition;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.world.RunningWorld;
|
||||
import com.volmit.world.TerrainSampler;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* The biome of a block in a running world, as block drops and ambient effects read it: the cave biome where the block
|
||||
* lies at least two blocks under the column's highest solid block, the surface biome everywhere else.
|
||||
*/
|
||||
public final class BlockBiomes {
|
||||
private static final int CAVE_DEPTH_BELOW_HIGHEST_BLOCK = 2;
|
||||
|
||||
private BlockBiomes() {
|
||||
}
|
||||
|
||||
public static ResourceId biomeAt(RunningWorld running, int x, int y, int z) {
|
||||
TerrainSampler layout = running.layout();
|
||||
ResourceId surface = layout.surfaceBiome(x, z);
|
||||
if (!layout.bounds().contains(x, y, z) || y > running.highestBlock(x, z, true) - CAVE_DEPTH_BELOW_HIGHEST_BLOCK) {
|
||||
return surface;
|
||||
}
|
||||
return layout.caveBiome(x, y, z).orElse(surface);
|
||||
}
|
||||
|
||||
/** The settings the biome of the block declares; empty when it declares none. */
|
||||
public static <F extends IrisFeature> Optional<F> declaredAt(RunningWorld running, Class<F> type, BlockPosition at) {
|
||||
return running.settings().declaredBy(biomeAt(running, at.x(), at.y(), at.z()), type);
|
||||
}
|
||||
}
|
||||
@@ -18,19 +18,21 @@
|
||||
|
||||
package art.arcane.iris.engine.loot;
|
||||
|
||||
import art.arcane.iris.builtin.LiveWorld;
|
||||
import art.arcane.iris.builtin.LiveWorld.Level;
|
||||
import art.arcane.iris.builtin.loot.BlockDrop;
|
||||
import art.arcane.iris.builtin.loot.BlockDropSettings;
|
||||
import art.arcane.iris.builtin.loot.LootEntry;
|
||||
import art.arcane.iris.builtin.loot.LootResolver;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.config.SettingsStack;
|
||||
import com.volmit.item.ItemDrop;
|
||||
import com.volmit.service.BlockDrops;
|
||||
import com.volmit.world.PackWorld;
|
||||
import com.volmit.world.RunningWorld;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
@@ -41,17 +43,15 @@ import java.util.concurrent.ConcurrentMap;
|
||||
public final class BlockDropping implements BlockDrops {
|
||||
@Override
|
||||
public Result drops(PackWorld world, Broken broken) {
|
||||
LiveWorld live = world.extension(LiveWorld.class).orElseThrow();
|
||||
int x = broken.position().x();
|
||||
int y = broken.position().y();
|
||||
int z = broken.position().z();
|
||||
RunningWorld running = world.running().orElseThrow();
|
||||
String brokenKey = world.resources().blocks().find(broken.block().key()).orElse(broken.block()).key();
|
||||
ResolvedDrops resolved = world.state(ResolvedDrops.class, ignored -> new ResolvedDrops());
|
||||
SettingsStack<BlockDropSettings> column = running.settings().at(BlockDropSettings.class, broken.position().x(), broken.position().z());
|
||||
|
||||
List<ResolvedBlockDrop> providers = dropsFor(live, Level.BIOME, x, y, z, brokenKey, resolved, world);
|
||||
List<ResolvedBlockDrop> providers = dropsFor(BlockBiomes.declaredAt(running, BlockDropSettings.class, broken.position()), brokenKey, resolved, world);
|
||||
if (providers.stream().noneMatch(provider -> provider.drop().skipParents())) {
|
||||
providers.addAll(dropsFor(live, Level.REGION, x, y, z, brokenKey, resolved, world));
|
||||
providers.addAll(dropsFor(live, Level.DIMENSION, x, y, z, brokenKey, resolved, world));
|
||||
providers.addAll(dropsFor(column.level(Level.REGION), brokenKey, resolved, world));
|
||||
providers.addAll(dropsFor(column.dimension(), brokenKey, resolved, world));
|
||||
}
|
||||
|
||||
LootItems items = new LootItems(world.resources().items(), false, world.log());
|
||||
@@ -73,10 +73,10 @@ public final class BlockDropping implements BlockDrops {
|
||||
}
|
||||
}
|
||||
|
||||
private static List<ResolvedBlockDrop> dropsFor(LiveWorld live, Level level, int x, int y, int z, String brokenKey,
|
||||
ResolvedDrops resolved, PackWorld world) {
|
||||
private static List<ResolvedBlockDrop> dropsFor(Optional<BlockDropSettings> declared, String brokenKey, ResolvedDrops resolved,
|
||||
PackWorld world) {
|
||||
List<ResolvedBlockDrop> matching = new ArrayList<>();
|
||||
for (BlockDrop drop : live.settings(BlockDropSettings.class, level, x, y, z).map(BlockDropSettings::drops).orElse(List.of())) {
|
||||
for (BlockDrop drop : declared.map(BlockDropSettings::drops).orElse(List.of())) {
|
||||
ResolvedBlockDrop candidate = resolved.of(drop, world);
|
||||
if (candidate.dropsFor(brokenKey)) {
|
||||
matching.add(candidate);
|
||||
|
||||
@@ -18,11 +18,10 @@
|
||||
|
||||
package art.arcane.iris.engine.loot;
|
||||
|
||||
import art.arcane.iris.builtin.IrisSeed;
|
||||
import art.arcane.iris.builtin.IrisSeeds;
|
||||
import art.arcane.iris.builtin.LiveWorld;
|
||||
import art.arcane.iris.builtin.LiveWorld.ObjectLoots;
|
||||
import art.arcane.iris.builtin.IrisSeedPurposes;
|
||||
import art.arcane.iris.builtin.loot.LootResolver;
|
||||
import art.arcane.iris.builtin.objects.ObjectHost;
|
||||
import art.arcane.iris.builtin.objects.ObjectHost.ObjectLoots;
|
||||
import art.arcane.iris.builtin.loot.LootTable;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.item.ItemDrop;
|
||||
@@ -42,19 +41,19 @@ import java.util.Optional;
|
||||
public final class LootGiving implements Loot {
|
||||
@Override
|
||||
public List<Source> tables(PackWorld world, Site site) {
|
||||
LiveWorld live = world.extension(LiveWorld.class).orElseThrow();
|
||||
int x = site.position().x();
|
||||
int z = site.position().z();
|
||||
int relativeY = site.position().y();
|
||||
int worldY = relativeY + live.bottomY();
|
||||
int worldY = relativeY + world.minWorldY();
|
||||
RNG rng = LootResolver.containerRng(lootSeed(world), x, worldY, z);
|
||||
|
||||
List<Source> sources = new ArrayList<>();
|
||||
boolean objectLootDefined = site.nativeLootDefined();
|
||||
Optional<ObjectLoots> objectLoots = site.container().isEmpty() ? Optional.empty() : live.objectLoots(x, relativeY, z);
|
||||
Optional<ObjectLoots> objectLoots = site.container().isEmpty() ? Optional.empty()
|
||||
: world.extension(ObjectHost.class).orElseThrow().placedLoot(x, relativeY, z);
|
||||
if (objectLoots.isPresent()) {
|
||||
objectLootDefined = objectLootDefined || objectLoots.get().defined();
|
||||
Source picked = placementLoot(world, live).pick(objectLoots.get().platformTables(), objectLoots.get().packTables(),
|
||||
Source picked = placementLoot(world).pick(objectLoots.get().platformTables(), objectLoots.get().packTables(),
|
||||
site.container().get(), rng, x, worldY, z);
|
||||
if (picked != null) {
|
||||
sources.add(picked);
|
||||
@@ -75,16 +74,16 @@ public final class LootGiving implements Loot {
|
||||
if (table == null) {
|
||||
return List.of();
|
||||
}
|
||||
int worldY = site.position().y() + world.extension(LiveWorld.class).orElseThrow().bottomY();
|
||||
int worldY = site.position().y() + world.minWorldY();
|
||||
return new LootItems(world.resources().items(), site.debug(), world.log())
|
||||
.draw(tableId.path(), table, lootSeed(world), site.position().x(), worldY, site.position().z());
|
||||
}
|
||||
|
||||
private static PlacementLoot placementLoot(PackWorld world, LiveWorld live) {
|
||||
return new PlacementLoot(world.resources(), live::platformLootTables, lootSeed(world), world.log());
|
||||
private static PlacementLoot placementLoot(PackWorld world) {
|
||||
return new PlacementLoot(world.resources(), () -> world.running().orElseThrow().platformLootTables(), lootSeed(world), world.log());
|
||||
}
|
||||
|
||||
private static long lootSeed(PackWorld world) {
|
||||
return world.extension(IrisSeeds.class).orElseThrow().seed(IrisSeed.LOOT);
|
||||
return world.seed(IrisSeedPurposes.LOOT);
|
||||
}
|
||||
}
|
||||
@@ -18,16 +18,20 @@
|
||||
|
||||
package art.arcane.iris.engine.loot;
|
||||
|
||||
import art.arcane.iris.builtin.LiveWorld;
|
||||
import art.arcane.iris.builtin.LiveWorld.Level;
|
||||
import art.arcane.iris.builtin.loot.LootMode;
|
||||
import art.arcane.iris.builtin.loot.LootResolver;
|
||||
import art.arcane.iris.builtin.loot.LootSettings;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.config.SettingsStack;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.world.PackWorld;
|
||||
import com.volmit.world.RunningWorld;
|
||||
import com.volmit.world.TerrainSampler;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
@@ -63,9 +67,18 @@ public final class LootTables {
|
||||
return LootResolver.spatialOneIn(lootSeed, identity, entryIndex, x, y, z, rarity);
|
||||
}
|
||||
|
||||
/** The loot settings the level declares at the block; the defaults, which add nothing, when it declares none. */
|
||||
private static LootSettings settingsAt(LiveWorld live, Level level, int x, int relativeY, int z) {
|
||||
return live.settings(LootSettings.class, level, x, relativeY, z).orElseGet(LootSettings::new);
|
||||
/** The declared loot settings; the defaults, which add nothing, when none are declared. */
|
||||
private static LootSettings orDefaults(Optional<LootSettings> declared) {
|
||||
return declared.orElseGet(LootSettings::new);
|
||||
}
|
||||
|
||||
/** The cave biome of a block under the terrain's surface, when it is not the column's surface biome. */
|
||||
private static Optional<ResourceId> distinctCaveBiome(TerrainSampler layout, int x, int relativeY, int z) {
|
||||
if (relativeY >= layout.surfaceY(x, z) || !layout.bounds().contains(x, relativeY, z)) {
|
||||
return Optional.empty();
|
||||
}
|
||||
ResourceId surface = layout.surfaceBiome(x, z);
|
||||
return layout.caveBiome(x, relativeY, z).filter(cave -> !cave.equals(surface));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -83,15 +96,17 @@ public final class LootTables {
|
||||
boolean objectLootDefined,
|
||||
Function<String, T> mapper
|
||||
) {
|
||||
LiveWorld live = world.extension(LiveWorld.class).orElseThrow();
|
||||
boolean belowSurface = relativeY < live.terrainHeight(x, z);
|
||||
boolean distinctContextualBiome = belowSurface && !live.caveBiome(x, relativeY, z).equals(live.surfaceBiome(x, z));
|
||||
RunningWorld running = world.running().orElseThrow();
|
||||
Optional<ResourceId> distinctCaveBiome = distinctCaveBiome(running.layout(), x, relativeY, z);
|
||||
SettingsStack<LootSettings> column = running.settings().at(LootSettings.class, x, z);
|
||||
|
||||
LootSettings dimensionLoot = settingsAt(live, Level.DIMENSION, x, relativeY, z);
|
||||
LootSettings regionLoot = settingsAt(live, Level.REGION, x, relativeY, z);
|
||||
LootSettings surfaceLoot = settingsAt(live, Level.SURFACE_BIOME, x, relativeY, z);
|
||||
LootSettings dimensionLoot = orDefaults(column.dimension());
|
||||
LootSettings regionLoot = orDefaults(column.level(Level.REGION));
|
||||
LootSettings surfaceLoot = orDefaults(column.level(Level.BIOME));
|
||||
double multiplier = dimensionLoot.multiplier() * regionLoot.multiplier() * surfaceLoot.multiplier();
|
||||
LootSettings contextualLoot = distinctContextualBiome ? settingsAt(live, Level.CAVE_BIOME, x, relativeY, z) : null;
|
||||
LootSettings contextualLoot = distinctCaveBiome
|
||||
.map(cave -> orDefaults(running.settings().declaredBy(cave, LootSettings.class)))
|
||||
.orElse(null);
|
||||
if (contextualLoot != null) {
|
||||
multiplier *= contextualLoot.multiplier();
|
||||
}
|
||||
|
||||
@@ -45,12 +45,12 @@ final class PlacementLoot {
|
||||
private static final char PROPERTIES_START = '[';
|
||||
|
||||
private final PackResources resources;
|
||||
private final Supplier<Set<String>> platformTables;
|
||||
private final Supplier<Set<ResourceId>> platformTables;
|
||||
private final long lootSeed;
|
||||
private final ModuleLog log;
|
||||
|
||||
/** @param platformTables the keys of the loot tables the platform has, asked for only when a placement names one */
|
||||
PlacementLoot(PackResources resources, Supplier<Set<String>> platformTables, long lootSeed, ModuleLog log) {
|
||||
/** @param platformTables the ids of the loot tables the platform has, asked for only when a placement names one */
|
||||
PlacementLoot(PackResources resources, Supplier<Set<ResourceId>> platformTables, long lootSeed, ModuleLog log) {
|
||||
this.resources = resources;
|
||||
this.platformTables = platformTables;
|
||||
this.lootSeed = lootSeed;
|
||||
@@ -92,10 +92,20 @@ final class PlacementLoot {
|
||||
|
||||
private Loot.Source platformSource(String name, int x, int worldY, int z) {
|
||||
String key = platformKey(name);
|
||||
if (key == null || !platformTables.get().contains(key)) {
|
||||
ResourceId table = key == null ? null : platformTableId(key);
|
||||
if (table == null || !platformTables.get().contains(table)) {
|
||||
return null;
|
||||
}
|
||||
return new Loot.PlatformTable(table, LootTables.seed(lootSeed, LootTables.platformIdentity(key), x, worldY, z));
|
||||
}
|
||||
|
||||
/** The id of the platform table the key names, or null for a key that is no id, which names no table. */
|
||||
private static ResourceId platformTableId(String key) {
|
||||
try {
|
||||
return ResourceId.parse(key);
|
||||
} catch (IllegalArgumentException notAnId) {
|
||||
return null;
|
||||
}
|
||||
return new Loot.PlatformTable(ResourceId.parse(key), LootTables.seed(lootSeed, LootTables.platformIdentity(key), x, worldY, z));
|
||||
}
|
||||
|
||||
/** A placement's name for a platform table as the platform's key for it, or null for a name that cannot be one. */
|
||||
|
||||
@@ -20,6 +20,7 @@ package art.arcane.iris.engine.mantle.components;
|
||||
|
||||
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
|
||||
import art.arcane.iris.builtin.carve.CarvingMode;
|
||||
import art.arcane.iris.builtin.carve.CaveLavaHeightSettings;
|
||||
import art.arcane.iris.builtin.carve.CaveProfile;
|
||||
import art.arcane.iris.builtin.objects.CavePlacement;
|
||||
import art.arcane.iris.builtin.objects.ObjectChunk;
|
||||
@@ -40,6 +41,7 @@ import art.arcane.iris.engine.object.procedural.ResolvedProceduralObjects;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.IrisFeature;
|
||||
import com.volmit.ModuleLog;
|
||||
import com.volmit.config.FeatureSettings.Entry;
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.config.SettingsStack;
|
||||
import com.volmit.resource.ResourceId;
|
||||
@@ -99,7 +101,7 @@ final class ChunkObjectPlacing {
|
||||
this.traceRegen = Thread.currentThread().getName().startsWith(REGEN_THREAD_PREFIX) && host.debugging();
|
||||
this.golden = chunk.goldenDebug(chunkX, chunkZ);
|
||||
this.worldHeight = context.mantle().bounds().maxY();
|
||||
this.caveLavaHeight = host.caveLavaHeight();
|
||||
this.caveLavaHeight = Optional.ofNullable(dimensionLevel(CaveLavaHeightSettings.class)).orElseGet(CaveLavaHeightSettings::new).height();
|
||||
this.effective = new EffectivePlacements(dimensionRequiresSurfaceSupport(), dimensionSurfaceSupportBuffer());
|
||||
this.caves = new CaveSettings(dimensionLevel(CaveProfile.class));
|
||||
}
|
||||
@@ -125,8 +127,8 @@ final class ChunkObjectPlacing {
|
||||
|
||||
/** The region and biomes at the chunk's centre and what each declares. */
|
||||
private Column readColumn() {
|
||||
ResourceId region = host.regionAt(centerX, centerZ);
|
||||
ResourceId surface = host.surfaceBiomeAt(centerX, centerZ);
|
||||
ResourceId region = terrain.biome(centerX, terrain.bounds().minY(), centerZ).region();
|
||||
ResourceId surface = terrain.surfaceBiome(centerX, centerZ);
|
||||
int surfaceY = terrain.surfaceHeight(centerX, centerZ);
|
||||
ResourceId cave = resolveCaveObjectBiome(surfaceY, surface);
|
||||
return new Column(region, surface, cave, surfaceY, objectsOf(cave, region, surface), proceduralOf(cave, region, surface),
|
||||
@@ -141,7 +143,7 @@ final class ChunkObjectPlacing {
|
||||
if (sampled.isEmpty() || sampled.get().equals(surfaceBiome)) {
|
||||
continue;
|
||||
}
|
||||
if (hasCarvingObjects(host.biomeDeclaration(sampled.get(), ObjectSettings.class))) {
|
||||
if (hasCarvingObjects(context.settings().declaredBy(sampled.get(), ObjectSettings.class))) {
|
||||
ladderChoice = sampled.get();
|
||||
}
|
||||
}
|
||||
@@ -178,7 +180,7 @@ final class ChunkObjectPlacing {
|
||||
if (cave.equals(surface)) {
|
||||
return levelValue(declared, Level.BIOME);
|
||||
}
|
||||
return host.biomeDeclaration(cave, type).orElse(null);
|
||||
return context.settings().declaredBy(cave, type).orElse(null);
|
||||
}
|
||||
|
||||
private <F extends IrisFeature> F dimensionLevel(Class<F> type) {
|
||||
@@ -395,7 +397,7 @@ final class ChunkObjectPlacing {
|
||||
}
|
||||
|
||||
private List<ProceduralPlacement> proceduralPlacements(ProceduralObjectSettings settings) {
|
||||
return settings == null ? List.of() : ResolvedProceduralObjects.of(host, settings);
|
||||
return settings == null ? List.of() : ResolvedProceduralObjects.of(context.world(), settings);
|
||||
}
|
||||
|
||||
private void placeProceduralFrom(List<ProceduralPlacement> placements, String scope, CaveProfile caveProfile, ResourceId expectedCaveBiome) {
|
||||
@@ -491,17 +493,26 @@ final class ChunkObjectPlacing {
|
||||
}
|
||||
|
||||
private void placeUpperObjects(Column column) {
|
||||
Optional<ObjectHost.UpperObjects> upper = host.upperObjects(centerX, centerZ);
|
||||
if (upper.isEmpty() || (upper.get().biome() == null && upper.get().region() == null)) {
|
||||
SettingsStack<ObjectSettings> upper = terrain.upperDimension()
|
||||
.map(dimension -> dimension.settings().at(ObjectSettings.class, centerX, centerZ))
|
||||
.orElse(SettingsStack.empty());
|
||||
Optional<Entry<ObjectSettings>> biome = levelEntry(upper, Level.BIOME);
|
||||
Optional<Entry<ObjectSettings>> region = levelEntry(upper, Level.REGION);
|
||||
if (biome.isEmpty() && region.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
boolean forcePlace = upperObjectsForced();
|
||||
placeUpperScope(upper.get().biome(), upper.get().biomeKey(), "upper-biome-surface", "biome", forcePlace);
|
||||
placeUpperScope(upper.get().region(), upper.get().regionKey(), "upper-region-surface", "region", forcePlace);
|
||||
biome.ifPresent(declared -> placeUpperScope(declared, "upper-biome-surface", "biome", forcePlace));
|
||||
region.ifPresent(declared -> placeUpperScope(declared, "upper-region-surface", "region", forcePlace));
|
||||
}
|
||||
|
||||
private void placeUpperScope(ObjectSettings settings, String ownerKey, String scope, String kind, boolean forcePlace) {
|
||||
for (ObjectPlacement placement : surfaceObjects(settings)) {
|
||||
private static Optional<Entry<ObjectSettings>> levelEntry(SettingsStack<ObjectSettings> declared, Level level) {
|
||||
return declared.entries().stream().filter(entry -> entry.level() == level).findFirst();
|
||||
}
|
||||
|
||||
private void placeUpperScope(Entry<ObjectSettings> declared, String scope, String kind, boolean forcePlace) {
|
||||
String ownerKey = declared.source().toString();
|
||||
for (ObjectPlacement placement : surfaceObjects(declared.value())) {
|
||||
if (!rng.chance(placement.chance() + rng.d(-CHANCE_JITTER, CHANCE_JITTER))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -18,14 +18,14 @@
|
||||
|
||||
package art.arcane.iris.engine.mantle.components;
|
||||
|
||||
import art.arcane.iris.builtin.IrisSeed;
|
||||
import art.arcane.iris.builtin.IrisSeeds;
|
||||
import art.arcane.iris.builtin.IrisSeedPurposes;
|
||||
import art.arcane.iris.builtin.floating.FloatingChildBiome;
|
||||
import art.arcane.iris.builtin.floating.FloatingChildSettings;
|
||||
import art.arcane.iris.builtin.floating.FloatingHost;
|
||||
import art.arcane.iris.builtin.floating.IslandFootprint;
|
||||
import art.arcane.iris.builtin.objects.ObjectHost;
|
||||
import art.arcane.iris.builtin.objects.ObjectPlacement;
|
||||
import art.arcane.iris.builtin.objects.ObjectSettings;
|
||||
import art.arcane.iris.builtin.objects.ObjectSize;
|
||||
import art.arcane.iris.builtin.objects.PlaceableObject;
|
||||
import art.arcane.iris.engine.object.terrain.floating.FloatingIslandBoundarySampler;
|
||||
@@ -89,7 +89,7 @@ public final class FloatingObjectPlacing {
|
||||
public static FloatingObjectPlacing of(PackWorld world, ModuleLog log) {
|
||||
return world.state(FloatingObjectPlacing.class,
|
||||
generating -> new FloatingObjectPlacing(FloatingWorld.of(generating),
|
||||
generating.extension(IrisSeeds.class).orElseThrow().seed(IrisSeed.MANTLE), log));
|
||||
generating.seed(IrisSeedPurposes.MANTLE), log));
|
||||
}
|
||||
|
||||
/** Places what originates in the chunk of {@code context} into the mantle. */
|
||||
@@ -100,7 +100,7 @@ public final class FloatingObjectPlacing {
|
||||
int worldHeight = bounds.maxY() - bounds.minY();
|
||||
RNG chunkRng = new RNG(CacheKey.key(context.chunkX(), context.chunkZ()) + mantleSeed + CHUNK_RANDOM_SALT);
|
||||
FloatingIslandSampleResolver samples = new FloatingIslandSampleResolver(world, worldHeight,
|
||||
new FloatingIslandBoundarySampler(host::surfaceBiome), log);
|
||||
new FloatingIslandBoundarySampler(world::surfaceBiome), log);
|
||||
|
||||
FloatingIslandSample.clearChunkMemo();
|
||||
Chunk chunk = new Chunk(context, minX, minZ,worldHeight, chunkRng, samples, sampleColumns(samples, minX, minZ));
|
||||
@@ -388,8 +388,7 @@ public final class FloatingObjectPlacing {
|
||||
|
||||
/** How far, in blocks along X and Z, the floating objects of the pack {@code settings} describe may write beyond their chunk. */
|
||||
public static int reach(PackSettings settings, ModuleLog log) {
|
||||
Reach reach = new Reach(settings.extension(FloatingHost.class).orElseThrow(),
|
||||
settings.extension(ObjectHost.class).orElseThrow(), log);
|
||||
Reach reach = new Reach(settings.extension(ObjectHost.class).orElseThrow(), biomeObjectsOf(settings), log);
|
||||
int maxObjectExtent = MIN_REACH_BLOCKS;
|
||||
try {
|
||||
for (Entry<FloatingChildSettings> declared : settings.declared(FloatingChildSettings.class)) {
|
||||
@@ -413,20 +412,42 @@ public final class FloatingObjectPlacing {
|
||||
return path.startsWith(BIOME_PATH_PREFIX) ? new ResourceId(source.namespace(), path.substring(BIOME_PATH_PREFIX.length())) : source;
|
||||
}
|
||||
|
||||
/** The object settings every biome of the pack declares, by the biome's id. */
|
||||
private static Map<ResourceId, ObjectSettings> biomeObjectsOf(PackSettings settings) {
|
||||
Map<ResourceId, ObjectSettings> byBiome = new HashMap<>();
|
||||
for (Entry<ObjectSettings> declared : settings.declared(ObjectSettings.class)) {
|
||||
if (declared.level() == Level.BIOME) {
|
||||
byBiome.putIfAbsent(biomeIdOf(declared.source()), declared.value());
|
||||
}
|
||||
}
|
||||
return byBiome;
|
||||
}
|
||||
|
||||
/** The reach of floating children's objects, each object sized once. */
|
||||
private static final class Reach {
|
||||
private final FloatingHost host;
|
||||
private final ObjectHost objects;
|
||||
private final Map<ResourceId, ObjectSettings> biomeObjects;
|
||||
private final ModuleLog log;
|
||||
private final Map<String, Optional<ObjectSize>> sizes = new HashMap<>();
|
||||
private final Set<String> warnedLargeObjects = new HashSet<>();
|
||||
|
||||
private Reach(FloatingHost host, ObjectHost objects, ModuleLog log) {
|
||||
this.host = host;
|
||||
private Reach(ObjectHost objects, Map<ResourceId, ObjectSettings> biomeObjects, ModuleLog log) {
|
||||
this.objects = objects;
|
||||
this.biomeObjects = biomeObjects;
|
||||
this.log = log;
|
||||
}
|
||||
|
||||
/**
|
||||
* The surface objects a child inherits: those of the biome it names when that biome declares objects, else its
|
||||
* parent's. A named biome the pack lacks inherits the parent's while placing; one that declares no objects
|
||||
* inherits none, so counting the parent's for it only widens the reach.
|
||||
*/
|
||||
private List<ObjectPlacement> inheritedSurfaceObjects(FloatingChildBiome child, ResourceId parent) {
|
||||
ResourceId named = child.biome().isBlank() ? parent : ResourceId.ofPackKey(parent.namespace(), child.biome());
|
||||
ObjectSettings declared = biomeObjects.getOrDefault(named, biomeObjects.get(parent));
|
||||
return FloatingWorld.surfaceObjects(Optional.ofNullable(declared));
|
||||
}
|
||||
|
||||
int of(FloatingChildBiome child, ResourceId parent) {
|
||||
int reach = 0;
|
||||
reach = Math.max(reach, placementRadius(child.floatingObjects()));
|
||||
@@ -434,8 +455,7 @@ public final class FloatingObjectPlacing {
|
||||
reach = Math.max(reach, placementRadius(child.topObjectOverrides()));
|
||||
reach = Math.max(reach, placementRadius(child.bottomObjectOverrides()));
|
||||
try {
|
||||
ResourceId target = child.biome().isBlank() ? parent : host.biome(child.biome()).orElse(parent);
|
||||
List<ObjectPlacement> surface = child.inheritObjects() ? FloatingWorld.surfaceObjects(objects, target) : List.of();
|
||||
List<ObjectPlacement> surface = child.inheritObjects() ? inheritedSurfaceObjects(child, parent) : List.of();
|
||||
reach = Math.max(reach, placementRadius(ResolvedFloatingChild.topObjects(child, surface)));
|
||||
reach = Math.max(reach, placementRadius(ResolvedFloatingChild.bottomObjects(child)));
|
||||
} catch (Throwable e) {
|
||||
|
||||
@@ -54,7 +54,7 @@ public final class ObjectLocating implements ObjectsAt {
|
||||
if (!placesObject(declaration.settings().objects(), resources, object)) {
|
||||
continue;
|
||||
}
|
||||
(declaration.level() == Level.BIOME ? biomes : regions).add(resources.idOf(declaration.key()));
|
||||
(declaration.level() == Level.BIOME ? biomes : regions).add(declaration.id());
|
||||
}
|
||||
return new PlacedBy(biomes, regions);
|
||||
}
|
||||
|
||||
@@ -46,17 +46,19 @@ public final class ObjectPlacing {
|
||||
/** A guess draws from the biome's objects before the region's, as placing does. */
|
||||
private static final Level[] GUESSED_LEVELS = {Level.BIOME, Level.REGION};
|
||||
|
||||
private final PackWorld world;
|
||||
private final ObjectHost host;
|
||||
private final ModuleLog log;
|
||||
|
||||
private ObjectPlacing(ObjectHost host, ModuleLog log) {
|
||||
this.host = host;
|
||||
this.log = log;
|
||||
private ObjectPlacing(PackWorld world) {
|
||||
this.world = world;
|
||||
this.host = world.extension(ObjectHost.class).orElseThrow();
|
||||
this.log = world.log();
|
||||
}
|
||||
|
||||
/** The object placing of {@code world}. */
|
||||
public static ObjectPlacing of(PackWorld world) {
|
||||
return world.state(ObjectPlacing.class, generating -> new ObjectPlacing(generating.extension(ObjectHost.class).orElseThrow(), generating.log()));
|
||||
return world.state(ObjectPlacing.class, ObjectPlacing::new);
|
||||
}
|
||||
|
||||
/** Places what originates in the chunk {@code context} generates. */
|
||||
@@ -69,7 +71,7 @@ public final class ObjectPlacing {
|
||||
RNG rng = host.chunkRandom(chunkX, chunkZ);
|
||||
int centerX = (chunkX << CHUNK_SHIFT) + CHUNK_CENTER_OFFSET_BLOCKS;
|
||||
int centerZ = (chunkZ << CHUNK_SHIFT) + CHUNK_CENTER_OFFSET_BLOCKS;
|
||||
SettingsStack<ObjectSettings> declared = host.columnSettings().at(ObjectSettings.class, centerX, centerZ);
|
||||
SettingsStack<ObjectSettings> declared = world.running().orElseThrow().settings().at(ObjectSettings.class, centerX, centerZ);
|
||||
Set<String> keys = new HashSet<>();
|
||||
for (Level level : GUESSED_LEVELS) {
|
||||
declared.level(level).ifPresent(settings -> guessFrom(settings, rng, chunkX, chunkZ, keys));
|
||||
|
||||
@@ -24,8 +24,7 @@ import art.arcane.iris.builtin.objects.ObjectPlacement;
|
||||
import art.arcane.iris.builtin.objects.ObjectSettings;
|
||||
import art.arcane.iris.builtin.objects.ProceduralObjectSettings;
|
||||
import art.arcane.iris.builtin.objects.ProceduralPlacement;
|
||||
import art.arcane.iris.builtin.IrisSeed;
|
||||
import art.arcane.iris.builtin.IrisSeeds;
|
||||
import art.arcane.iris.builtin.IrisSeedPurposes;
|
||||
import art.arcane.iris.engine.object.procedural.ResolvedProceduralObjects;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.config.Level;
|
||||
@@ -44,13 +43,15 @@ final class ObjectWarmUp {
|
||||
private static final long ROOT_SEED_SALT = 7777L;
|
||||
private static final Level[] WARMED_LEVELS = {Level.BIOME, Level.REGION};
|
||||
|
||||
private final PackWorld world;
|
||||
private final ObjectHost host;
|
||||
private final RNG root;
|
||||
private int warmed;
|
||||
|
||||
ObjectWarmUp(PackWorld world) {
|
||||
this.world = world;
|
||||
this.host = world.extension(ObjectHost.class).orElseThrow();
|
||||
this.root = new RNG(world.extension(IrisSeeds.class).orElseThrow().seed(IrisSeed.COMPONENT) + ROOT_SEED_SALT);
|
||||
this.root = new RNG(world.seed(IrisSeedPurposes.COMPONENT) + ROOT_SEED_SALT);
|
||||
}
|
||||
|
||||
void warm() {
|
||||
@@ -71,7 +72,7 @@ final class ObjectWarmUp {
|
||||
}
|
||||
|
||||
private static <F extends com.volmit.IrisFeature> List<Declaration<F>> byKey(List<Declaration<F>> declarations) {
|
||||
return declarations.stream().sorted(Comparator.comparing(Declaration::key)).toList();
|
||||
return declarations.stream().sorted(Comparator.comparing(Declaration::id)).toList();
|
||||
}
|
||||
|
||||
private void warmPlacements(List<ObjectPlacement> placements) {
|
||||
@@ -83,7 +84,7 @@ final class ObjectWarmUp {
|
||||
}
|
||||
|
||||
private void warmProcedural(ProceduralObjectSettings settings) {
|
||||
for (ProceduralPlacement placement : ResolvedProceduralObjects.of(host, settings)) {
|
||||
for (ProceduralPlacement placement : ResolvedProceduralObjects.of(world, settings)) {
|
||||
placement.variant(root.nextParallelRNG(warmed++));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ final class PlacementReach {
|
||||
|
||||
private int ofProcedural(ProceduralObjectSettings settings) {
|
||||
int radius = 0;
|
||||
for (ProceduralPlacement placement : ResolvedProceduralObjects.of(host, settings)) {
|
||||
for (ProceduralPlacement placement : ResolvedProceduralObjects.resolve(settings, host)) {
|
||||
for (PlaceableObject variant : placement.variants()) {
|
||||
radius = Math.max(radius, of(new ObjectSize(variant.width(), variant.height(), variant.depth()), placement));
|
||||
}
|
||||
|
||||
@@ -28,13 +28,16 @@ import art.arcane.iris.builtin.objects.ProceduralObjectSettings;
|
||||
import art.arcane.iris.builtin.objects.TreeGrowthSettings;
|
||||
import art.arcane.iris.builtin.objects.TreeMode;
|
||||
import art.arcane.iris.builtin.objects.tree.Tree;
|
||||
import art.arcane.iris.engine.loot.BlockBiomes;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.placement.PlacedBlock;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.service.SaplingGrowth;
|
||||
import com.volmit.geometry.BlockPosition;
|
||||
import com.volmit.world.PackWorld;
|
||||
import com.volmit.world.RunningWorld;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
@@ -55,12 +58,13 @@ public final class TreeGrowing implements SaplingGrowth {
|
||||
@Override
|
||||
public Optional<Growth> grow(PackWorld world, Sapling sapling, Surroundings surroundings) {
|
||||
ObjectHost host = world.extension(ObjectHost.class).orElseThrow();
|
||||
RunningWorld running = world.running().orElseThrow();
|
||||
BlockPosition at = sapling.at();
|
||||
TreeGrowthSettings growth = treeGrowth(host, at);
|
||||
TreeGrowthSettings growth = treeGrowth(running, at);
|
||||
if (!growth.enabled()) {
|
||||
return Optional.empty();
|
||||
}
|
||||
Optional<ObjectPlacement> placement = pickPlacement(host, growth, sapling);
|
||||
Optional<ObjectPlacement> placement = pickPlacement(running, growth, sapling);
|
||||
if (placement.isEmpty()) {
|
||||
return Optional.empty();
|
||||
}
|
||||
@@ -70,7 +74,7 @@ public final class TreeGrowing implements SaplingGrowth {
|
||||
return Optional.empty();
|
||||
}
|
||||
PlaceableObject object = tree.get();
|
||||
GrowthSink sink = new GrowthSink(surroundings, host);
|
||||
GrowthSink sink = new GrowthSink(surroundings, running.layout().fluidHeight());
|
||||
BlockPosition center = sapling.center();
|
||||
host.placeInto(object, center.x(), center.y() + object.height() / 2, center.z(), placement.get(), sink, RNG.r);
|
||||
return Optional.of(new Growth(world.resources().idOf(object.key()), sink.placed()));
|
||||
@@ -94,19 +98,18 @@ public final class TreeGrowing implements SaplingGrowth {
|
||||
return keys.stream().map(world.resources()::idOf).collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
private static TreeGrowthSettings treeGrowth(ObjectHost host, BlockPosition at) {
|
||||
return host.columnSettings().at(TreeGrowthSettings.class, at.x(), at.z()).dimension().orElseGet(TreeGrowthSettings::new);
|
||||
private static TreeGrowthSettings treeGrowth(RunningWorld running, BlockPosition at) {
|
||||
return running.settings().at(TreeGrowthSettings.class, at.x(), at.z()).dimension().orElseGet(TreeGrowthSettings::new);
|
||||
}
|
||||
|
||||
/** One placement, picked at random, of the tree placements that grow {@code sapling}'s species. */
|
||||
private static Optional<ObjectPlacement> pickPlacement(ObjectHost host, TreeGrowthSettings growth, Sapling sapling) {
|
||||
private static Optional<ObjectPlacement> pickPlacement(RunningWorld running, TreeGrowthSettings growth, Sapling sapling) {
|
||||
List<ObjectPlacement> placements = new ArrayList<>();
|
||||
BlockPosition at = sapling.at();
|
||||
ResourceId biome = host.biomeAt(at.x(), at.y(), at.z());
|
||||
host.biomeDeclaration(biome, ObjectSettings.class).ifPresent(settings -> placements.addAll(matching(settings, sapling.species())));
|
||||
BlockBiomes.declaredAt(running, ObjectSettings.class, at).ifPresent(settings -> placements.addAll(matching(settings, sapling.species())));
|
||||
if (growth.mode() == TreeMode.ALL || placements.isEmpty()) {
|
||||
ResourceId region = host.regionAt(at.x(), at.z());
|
||||
host.regionDeclaration(region, ObjectSettings.class).ifPresent(settings -> placements.addAll(matching(settings, sapling.species())));
|
||||
running.settings().at(ObjectSettings.class, at.x(), at.z()).level(Level.REGION)
|
||||
.ifPresent(settings -> placements.addAll(matching(settings, sapling.species())));
|
||||
}
|
||||
if (placements.isEmpty()) {
|
||||
return Optional.empty();
|
||||
@@ -153,12 +156,12 @@ public final class TreeGrowing implements SaplingGrowth {
|
||||
/** Places an object into a list of blocks, reading the world around the sapling through the host. */
|
||||
private static final class GrowthSink implements ObjectSink {
|
||||
private final Surroundings surroundings;
|
||||
private final ObjectHost host;
|
||||
private final int fluidHeight;
|
||||
private final List<PlacedBlock> placed = new ArrayList<>();
|
||||
|
||||
private GrowthSink(Surroundings surroundings, ObjectHost host) {
|
||||
private GrowthSink(Surroundings surroundings, int fluidHeight) {
|
||||
this.surroundings = surroundings;
|
||||
this.host = host;
|
||||
this.fluidHeight = fluidHeight;
|
||||
}
|
||||
|
||||
private List<PlacedBlock> placed() {
|
||||
@@ -182,7 +185,7 @@ public final class TreeGrowing implements SaplingGrowth {
|
||||
|
||||
@Override
|
||||
public int fluidHeight() {
|
||||
return host.fluidHeight();
|
||||
return fluidHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,8 +18,7 @@
|
||||
|
||||
package art.arcane.iris.engine.modifier;
|
||||
|
||||
import art.arcane.iris.builtin.IrisSeed;
|
||||
import art.arcane.iris.builtin.IrisSeeds;
|
||||
import art.arcane.iris.builtin.IrisSeedPurposes;
|
||||
import art.arcane.iris.builtin.IrisStages;
|
||||
import art.arcane.iris.builtin.MatterMantle;
|
||||
import art.arcane.iris.builtin.carve.CarvingBiomeSettings;
|
||||
@@ -115,7 +114,7 @@ public final class CarveModule implements IrisModule {
|
||||
/** What the carvers need of the world, from the dimension's settings and the first terrain they see (constant for the world). */
|
||||
private static CarveWorld carveWorld(PackWorld world, TerrainSampler terrain) {
|
||||
int lavaHeight = dimensionSetting(world, CaveLavaHeightSettings.class, CaveLavaHeightSettings::height, CaveLavaHeightSettings.DEFAULT_HEIGHT);
|
||||
return new CarveWorld(world.resources().noise(), world.extension(IrisSeeds.class).orElseThrow().seed(IrisSeed.CARVE),
|
||||
return new CarveWorld(world.resources().noise(), world.seed(IrisSeedPurposes.CARVE),
|
||||
terrain.bounds().maxY(), terrain.fluidHeight(), lavaHeight,
|
||||
world.minWorldY());
|
||||
}
|
||||
|
||||
@@ -17,8 +17,7 @@
|
||||
*/
|
||||
package art.arcane.iris.engine.modifier;
|
||||
|
||||
import art.arcane.iris.builtin.IrisSeed;
|
||||
import art.arcane.iris.builtin.IrisSeeds;
|
||||
import art.arcane.iris.builtin.IrisSeedPurposes;
|
||||
import art.arcane.iris.builtin.deposit.DepositGenerator;
|
||||
import art.arcane.iris.builtin.deposit.DepositHeightDistribution;
|
||||
import art.arcane.iris.builtin.deposit.DepositPlacementScope;
|
||||
@@ -77,7 +76,7 @@ final class DepositPlacer {
|
||||
private final Map<ResourceId, Optional<BiomeIdentity>> biomeIdentities = new ConcurrentHashMap<>();
|
||||
|
||||
DepositPlacer(PackWorld world) {
|
||||
this.rng = new RNG(world.extension(IrisSeeds.class).orElseThrow().seed(IrisSeed.DEPOSIT));
|
||||
this.rng = new RNG(world.seed(IrisSeedPurposes.DEPOSIT));
|
||||
this.resources = world.resources();
|
||||
this.registry = resources.blocks();
|
||||
this.log = world.log();
|
||||
|
||||
@@ -18,8 +18,7 @@
|
||||
|
||||
package art.arcane.iris.engine.modifier;
|
||||
|
||||
import art.arcane.iris.builtin.IrisSeed;
|
||||
import art.arcane.iris.builtin.IrisSeeds;
|
||||
import art.arcane.iris.builtin.IrisSeedPurposes;
|
||||
import art.arcane.iris.builtin.decorant.DecorantSettings;
|
||||
import art.arcane.iris.builtin.decorant.DecorationPart;
|
||||
import art.arcane.iris.builtin.floating.FloatingBottomPaletteMode;
|
||||
@@ -82,7 +81,7 @@ final class FloatingIslands {
|
||||
|
||||
FloatingIslands(PackWorld world, ModuleLog log) {
|
||||
this.world = FloatingWorld.of(world);
|
||||
this.rng = new RNG(world.extension(IrisSeeds.class).orElseThrow().seed(IrisSeed.TERRAIN) ^ ISLAND_RANDOM_SALT);
|
||||
this.rng = new RNG(world.seed(IrisSeedPurposes.TERRAIN) ^ ISLAND_RANDOM_SALT);
|
||||
this.biomeLayers = BiomeLayers.of(world);
|
||||
this.log = log;
|
||||
}
|
||||
@@ -450,7 +449,7 @@ final class FloatingIslands {
|
||||
this.explosion = PaletteExplosion.of(settings, context.centreX(), context.centreZ());
|
||||
TerrainSampler terrain = context.terrain();
|
||||
this.slope = (x, z) -> terrain.column((int) x, (int) z).slope();
|
||||
this.boundarySampler = new FloatingIslandBoundarySampler(world.host()::surfaceBiome);
|
||||
this.boundarySampler = new FloatingIslandBoundarySampler(world::surfaceBiome);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,8 +18,7 @@
|
||||
|
||||
package art.arcane.iris.engine.modifier;
|
||||
|
||||
import art.arcane.iris.builtin.IrisSeed;
|
||||
import art.arcane.iris.builtin.IrisSeeds;
|
||||
import art.arcane.iris.builtin.IrisSeedPurposes;
|
||||
import art.arcane.iris.builtin.post.PostProcessingSlabsSettings;
|
||||
import art.arcane.iris.builtin.post.PostProcessingWallsSettings;
|
||||
import art.arcane.iris.builtin.terrain.LayerBlocks;
|
||||
@@ -82,7 +81,7 @@ final class SurfaceSmoothing {
|
||||
this.terrain = context.terrain();
|
||||
this.settings = context.settings();
|
||||
this.layerBlocks = LayerBlocks.of(context.world());
|
||||
this.postRandom = new RNG(context.world().extension(IrisSeeds.class).orElseThrow().seed(IrisSeed.POST));
|
||||
this.postRandom = new RNG(context.world().seed(IrisSeedPurposes.POST));
|
||||
this.originX = context.originX();
|
||||
this.originZ = context.originZ();
|
||||
this.planeWidth = blocks.width() + 2;
|
||||
|
||||
+16
-4
@@ -29,8 +29,12 @@ import art.arcane.iris.engine.object.procedural.fungi.ResolvedFungus;
|
||||
import art.arcane.iris.engine.object.procedural.ruin.ResolvedRuin;
|
||||
import art.arcane.iris.engine.object.procedural.tree.ResolvedTree;
|
||||
|
||||
import com.volmit.world.PackWorld;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
/** The procedural objects a region or biome declares, each made placeable once per world, in the order the settings list them. */
|
||||
@@ -38,12 +42,15 @@ public final class ResolvedProceduralObjects {
|
||||
private ResolvedProceduralObjects() {
|
||||
}
|
||||
|
||||
/** The placements {@code settings} declare in the world of {@code host}, resolved the first time a world asks. */
|
||||
public static List<ProceduralPlacement> of(ObjectHost host, ProceduralObjectSettings settings) {
|
||||
return host.procedural(settings, declared -> resolve(declared, host));
|
||||
/** The placements {@code settings} declare in {@code world}, resolved the first time the world asks. */
|
||||
public static List<ProceduralPlacement> of(PackWorld world, ProceduralObjectSettings settings) {
|
||||
ObjectHost host = world.extension(ObjectHost.class).orElseThrow();
|
||||
return world.state(ResolvedByDeclaration.class, ignored -> new ResolvedByDeclaration()).placements
|
||||
.computeIfAbsent(settings, declared -> resolve(declared, host));
|
||||
}
|
||||
|
||||
static List<ProceduralPlacement> resolve(ProceduralObjectSettings settings, ObjectHost host) {
|
||||
/** The placements {@code settings} declare, resolved anew, for work outside any world such as working out the pack's reach. */
|
||||
public static List<ProceduralPlacement> resolve(ProceduralObjectSettings settings, ObjectHost host) {
|
||||
List<ProceduralPlacement> all = new ArrayList<>();
|
||||
for (Tree tree : settings.trees()) {
|
||||
all.add(new ResolvedTree(tree, host));
|
||||
@@ -62,4 +69,9 @@ public final class ResolvedProceduralObjects {
|
||||
all.add(resolve.apply(entry, host));
|
||||
}
|
||||
}
|
||||
|
||||
/** A world's resolved placements, by the settings that declare them. */
|
||||
private static final class ResolvedByDeclaration {
|
||||
private final Map<ProceduralObjectSettings, List<ProceduralPlacement>> placements = new ConcurrentHashMap<>();
|
||||
}
|
||||
}
|
||||
@@ -18,8 +18,7 @@
|
||||
|
||||
package art.arcane.iris.engine.object.terrain.carving;
|
||||
|
||||
import art.arcane.iris.builtin.IrisSeed;
|
||||
import art.arcane.iris.builtin.IrisSeeds;
|
||||
import art.arcane.iris.builtin.IrisSeedPurposes;
|
||||
import art.arcane.iris.builtin.carve.CarvingEntry;
|
||||
import art.arcane.iris.builtin.carve.CarvingSettings;
|
||||
import com.volmit.ModuleLog;
|
||||
@@ -60,7 +59,7 @@ public final class CarvingResolver {
|
||||
this.resources = world.resources();
|
||||
this.log = world.log();
|
||||
this.minHeight = world.minWorldY();
|
||||
this.childSeed = world.extension(IrisSeeds.class).orElseThrow().seed(IrisSeed.CARVE) ^ CHILD_SEED_SALT;
|
||||
this.childSeed = world.seed(IrisSeedPurposes.CARVE) ^ CHILD_SEED_SALT;
|
||||
this.entries = declared.stream().filter(Objects::nonNull).map(ResolvedCarvingEntry::new).toList();
|
||||
this.index = indexById(entries);
|
||||
}
|
||||
|
||||
+1
-1
@@ -342,7 +342,7 @@ public final class FloatingIslandSample {
|
||||
}
|
||||
double altNoise = altitudeCng.sample(wx, wz);
|
||||
double altClamped = Math.max(0, Math.min(1, altNoise));
|
||||
int worldMin = world.minHeight();
|
||||
int worldMin = world.minWorldY();
|
||||
int minAlt = Math.max(0, entry.settings().minHeightAboveSurface() - worldMin);
|
||||
int maxAlt = Math.max(minAlt, entry.settings().maxHeightAboveSurface() - worldMin);
|
||||
int baseY = minAlt + (int) Math.round(altClamped * (maxAlt - minAlt));
|
||||
|
||||
@@ -18,8 +18,7 @@
|
||||
|
||||
package art.arcane.iris.engine.object.terrain.floating;
|
||||
|
||||
import art.arcane.iris.builtin.IrisSeed;
|
||||
import art.arcane.iris.builtin.IrisSeeds;
|
||||
import art.arcane.iris.builtin.IrisSeedPurposes;
|
||||
import art.arcane.iris.builtin.carve.CarvingEntry;
|
||||
import art.arcane.iris.builtin.carve.CarvingSettings;
|
||||
import art.arcane.iris.builtin.carve.CaveProfile;
|
||||
@@ -31,8 +30,11 @@ import art.arcane.iris.builtin.objects.ObjectHost;
|
||||
import art.arcane.iris.builtin.objects.ObjectPlacement;
|
||||
import art.arcane.iris.builtin.objects.ObjectSettings;
|
||||
import com.volmit.noise.NoiseFactory;
|
||||
import com.volmit.resource.PackResources;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.world.PackBiome;
|
||||
import com.volmit.world.PackWorld;
|
||||
import com.volmit.world.RunningWorld;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -40,29 +42,32 @@ import java.util.Optional;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* What the floating islands of one world are made from: the world's hosts, noise and seeds, the floating children each
|
||||
* biome declares, and the {@link ResolvedFloatingChild} of every child met, one per decoded entry. One per world ({@link #of}).
|
||||
* What the floating islands of one world are made from: the world's hosts, layout, noise and seeds, the floating children
|
||||
* each biome declares, and the {@link ResolvedFloatingChild} of every child met, one per decoded entry. One per world
|
||||
* ({@link #of}).
|
||||
*/
|
||||
public final class FloatingWorld {
|
||||
private static final long BASE_SEED_SALT = 0x5EED_F107_00F1B10CL;
|
||||
|
||||
private final FloatingHost host;
|
||||
private final ObjectHost objects;
|
||||
private final NoiseFactory noise;
|
||||
private final PackResources resources;
|
||||
private final RunningWorld running;
|
||||
private final long baseSeed;
|
||||
private final long carveSeed;
|
||||
private final int minHeight;
|
||||
private final int minWorldY;
|
||||
private final List<CarvingEntry> dimensionCarving;
|
||||
private final Map<FloatingChildBiome, ResolvedFloatingChild> resolved = new ConcurrentHashMap<>();
|
||||
|
||||
FloatingWorld(FloatingHost host, ObjectHost objects, NoiseFactory noise, long terrainSeed, long carveSeed, int minHeight,
|
||||
List<CarvingEntry> dimensionCarving) {
|
||||
FloatingWorld(FloatingHost host, ObjectHost objects, PackResources resources, RunningWorld running, long terrainSeed,
|
||||
long carveSeed, int minWorldY, List<CarvingEntry> dimensionCarving) {
|
||||
this.host = host;
|
||||
this.objects = objects;
|
||||
this.noise = noise;
|
||||
this.resources = resources;
|
||||
this.running = running;
|
||||
this.baseSeed = terrainSeed ^ BASE_SEED_SALT;
|
||||
this.carveSeed = carveSeed;
|
||||
this.minHeight = minHeight;
|
||||
this.minWorldY = minWorldY;
|
||||
this.dimensionCarving = List.copyOf(dimensionCarving);
|
||||
}
|
||||
|
||||
@@ -72,10 +77,9 @@ public final class FloatingWorld {
|
||||
}
|
||||
|
||||
private static FloatingWorld create(PackWorld world) {
|
||||
IrisSeeds seeds = world.extension(IrisSeeds.class).orElseThrow();
|
||||
return new FloatingWorld(world.extension(FloatingHost.class).orElseThrow(), world.extension(ObjectHost.class).orElseThrow(),
|
||||
world.resources().noise(), seeds.seed(IrisSeed.TERRAIN), seeds.seed(IrisSeed.CARVE), world.minWorldY(),
|
||||
dimensionCarvingOf(world));
|
||||
world.resources(), world.running().orElseThrow(), world.seed(IrisSeedPurposes.TERRAIN), world.seed(IrisSeedPurposes.CARVE),
|
||||
world.minWorldY(), dimensionCarvingOf(world));
|
||||
}
|
||||
|
||||
private static List<CarvingEntry> dimensionCarvingOf(PackWorld world) {
|
||||
@@ -93,7 +97,7 @@ public final class FloatingWorld {
|
||||
}
|
||||
|
||||
public NoiseFactory noise() {
|
||||
return noise;
|
||||
return resources.noise();
|
||||
}
|
||||
|
||||
/** The seed every island's noise and column random derive from. */
|
||||
@@ -105,19 +109,29 @@ public final class FloatingWorld {
|
||||
return carveSeed;
|
||||
}
|
||||
|
||||
/** The platform's Y of the dimension's bottom. */
|
||||
public int minHeight() {
|
||||
return minHeight;
|
||||
/** The Y in the world of the dimension's bottom block. */
|
||||
public int minWorldY() {
|
||||
return minWorldY;
|
||||
}
|
||||
|
||||
/** The biome of the column's surface, the biome an island grows from; any column of the world. */
|
||||
public ResourceId surfaceBiome(int worldX, int worldZ) {
|
||||
return running.layout().surfaceBiome(worldX, worldZ);
|
||||
}
|
||||
|
||||
/** The biome the pack names {@code key}; empty when the pack has none. */
|
||||
public Optional<ResourceId> biome(String key) {
|
||||
return resources.find(PackResources.BIOMES, resources.idOf(key)).map(PackBiome::id);
|
||||
}
|
||||
|
||||
/** The floating children {@code biome} declares, in the order it lists them; none when it declares none. */
|
||||
public List<FloatingChildBiome> declaredBy(ResourceId biome) {
|
||||
return objects.biomeDeclaration(biome, FloatingChildSettings.class).map(FloatingChildSettings::children).orElse(List.of());
|
||||
return running.settings().declaredBy(biome, FloatingChildSettings.class).map(FloatingChildSettings::children).orElse(List.of());
|
||||
}
|
||||
|
||||
/** Whether {@code biome} samples every floating child on its own and unions their islands instead of picking one per column. */
|
||||
public boolean merges(ResourceId biome) {
|
||||
return objects.biomeDeclaration(biome, MergeFloatingChildrenSettings.class).map(MergeFloatingChildrenSettings::merge).orElse(false);
|
||||
return running.settings().declaredBy(biome, MergeFloatingChildrenSettings.class).map(MergeFloatingChildrenSettings::merge).orElse(false);
|
||||
}
|
||||
|
||||
public ResolvedFloatingChild resolve(FloatingChildBiome settings) {
|
||||
@@ -129,8 +143,13 @@ public final class FloatingWorld {
|
||||
}
|
||||
|
||||
/** The surface object placements {@code biome} declares. */
|
||||
public static List<ObjectPlacement> surfaceObjects(ObjectHost objects, ResourceId biome) {
|
||||
return objects.biomeDeclaration(biome, ObjectSettings.class).map(ObjectSettings::objects).orElse(List.of()).stream()
|
||||
public List<ObjectPlacement> surfaceObjects(ResourceId biome) {
|
||||
return surfaceObjects(running.settings().declaredBy(biome, ObjectSettings.class));
|
||||
}
|
||||
|
||||
/** The surface object placements of the declared object settings; none when nothing is declared. */
|
||||
public static List<ObjectPlacement> surfaceObjects(Optional<ObjectSettings> declared) {
|
||||
return declared.map(ObjectSettings::objects).orElse(List.of()).stream()
|
||||
.filter(placement -> placement.carvingSupport().supportsSurface())
|
||||
.toList();
|
||||
}
|
||||
@@ -148,6 +167,6 @@ public final class FloatingWorld {
|
||||
|
||||
/** The cave profile {@code biome} declares; null when it declares none. */
|
||||
CaveProfile caveProfile(ResourceId biome) {
|
||||
return objects.biomeDeclaration(biome, CaveProfile.class).orElse(null);
|
||||
return running.settings().declaredBy(biome, CaveProfile.class).orElse(null);
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -141,14 +141,14 @@ public final class ResolvedFloatingChild {
|
||||
String carving = settings.carving();
|
||||
Optional<CarvingEntry> entry = world.dimensionCarving(carving);
|
||||
if (entry.isEmpty()) {
|
||||
return world.host().biome(carving);
|
||||
return world.biome(carving);
|
||||
}
|
||||
String biomeKey = entry.get().biome().trim();
|
||||
return biomeKey.isEmpty() ? Optional.empty() : world.host().biome(biomeKey);
|
||||
return biomeKey.isEmpty() ? Optional.empty() : world.biome(biomeKey);
|
||||
}
|
||||
|
||||
public KList<ObjectPlacement> resolveTopObjects(ResourceId target) {
|
||||
List<ObjectPlacement> surface = settings.inheritObjects() && target != null ? FloatingWorld.surfaceObjects(world.objects(), target) : List.of();
|
||||
List<ObjectPlacement> surface = settings.inheritObjects() && target != null ? world.surfaceObjects(target) : List.of();
|
||||
return topObjects(settings, surface);
|
||||
}
|
||||
|
||||
@@ -193,6 +193,6 @@ public final class ResolvedFloatingChild {
|
||||
if (settings.biome().isBlank()) {
|
||||
return parent;
|
||||
}
|
||||
return namedBiome.aquire(() -> world.host().biome(settings.biome())).orElse(parent);
|
||||
return namedBiome.aquire(() -> world.biome(settings.biome())).orElse(parent);
|
||||
}
|
||||
}
|
||||
@@ -18,21 +18,22 @@
|
||||
|
||||
package art.arcane.iris.engine.spawn;
|
||||
|
||||
import art.arcane.iris.builtin.LiveWorld;
|
||||
import art.arcane.iris.builtin.LiveWorld.Level;
|
||||
import art.arcane.iris.builtin.LiveWorld.Sky;
|
||||
import art.arcane.iris.builtin.spawn.AmbientEffect;
|
||||
import art.arcane.iris.builtin.spawn.EffectCommands;
|
||||
import art.arcane.iris.builtin.spawn.EffectSettings;
|
||||
import art.arcane.iris.builtin.spawn.SpawnCommand;
|
||||
import art.arcane.iris.engine.loot.BlockBiomes;
|
||||
import art.arcane.iris.engine.loot.PlatformKeys;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.ModuleLog;
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.entity.EntitySpec;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.service.AmbientEffects;
|
||||
import com.volmit.geometry.BlockPosition;
|
||||
import com.volmit.world.PackWorld;
|
||||
import com.volmit.world.RunningWorld;
|
||||
import com.volmit.world.RunningWorld.Sky;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -45,18 +46,18 @@ import java.util.Optional;
|
||||
public final class AmbientEffecting implements AmbientEffects {
|
||||
@Override
|
||||
public List<Effect> due(PackWorld world, BlockPosition at) {
|
||||
LiveWorld live = world.extension(LiveWorld.class).orElseThrow();
|
||||
RunningWorld running = world.running().orElseThrow();
|
||||
EffectTimers timers = world.state(EffectTimers.class, ignored -> new EffectTimers());
|
||||
Optional<Sky> sky = live.sky();
|
||||
Optional<Sky> sky = running.sky();
|
||||
|
||||
List<Effect> due = new ArrayList<>();
|
||||
addDue(due, effectsOf(live, Level.REGION, at), timers, sky, world.log());
|
||||
addDue(due, effectsOf(live, Level.BIOME, at), timers, sky, world.log());
|
||||
addDue(due, effectsOf(running.settings().at(EffectSettings.class, at.x(), at.z()).level(Level.REGION)), timers, sky, world.log());
|
||||
addDue(due, effectsOf(BlockBiomes.declaredAt(running, EffectSettings.class, at)), timers, sky, world.log());
|
||||
return due;
|
||||
}
|
||||
|
||||
private static List<AmbientEffect> effectsOf(LiveWorld live, Level level, BlockPosition at) {
|
||||
return live.settings(EffectSettings.class, level, at.x(), at.y(), at.z()).map(EffectSettings::effects).orElse(List.of());
|
||||
private static List<AmbientEffect> effectsOf(Optional<EffectSettings> declared) {
|
||||
return declared.map(EffectSettings::effects).orElse(List.of());
|
||||
}
|
||||
|
||||
private static void addDue(List<Effect> due, List<AmbientEffect> effects, EffectTimers timers, Optional<Sky> sky, ModuleLog log) {
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package art.arcane.iris.engine.spawn;
|
||||
|
||||
import art.arcane.iris.builtin.LiveWorld.Sky;
|
||||
import art.arcane.iris.builtin.loot.LootEntry;
|
||||
import art.arcane.iris.builtin.spawn.AmbientEffect;
|
||||
import art.arcane.iris.builtin.spawn.EntityDefinition;
|
||||
@@ -35,6 +34,7 @@ import com.volmit.item.ItemDrop;
|
||||
import com.volmit.resource.ContentKey;
|
||||
import com.volmit.resource.PackResources;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.world.RunningWorld.Sky;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -18,13 +18,11 @@
|
||||
|
||||
package art.arcane.iris.engine.spawn;
|
||||
|
||||
import art.arcane.iris.builtin.IrisSeed;
|
||||
import art.arcane.iris.builtin.IrisSeeds;
|
||||
import art.arcane.iris.builtin.LiveWorld;
|
||||
import art.arcane.iris.builtin.LiveWorld.Level;
|
||||
import art.arcane.iris.builtin.IrisSeedPurposes;
|
||||
import art.arcane.iris.builtin.loot.LootResolver;
|
||||
import art.arcane.iris.builtin.spawn.EntityDefinition;
|
||||
import art.arcane.iris.builtin.spawn.EntitySpawn;
|
||||
import art.arcane.iris.builtin.spawn.SpawnCooldowns;
|
||||
import art.arcane.iris.builtin.spawn.SpawnMarker;
|
||||
import art.arcane.iris.builtin.spawn.SpawnSurface;
|
||||
import art.arcane.iris.builtin.spawn.Spawner;
|
||||
@@ -35,13 +33,17 @@ import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.math.PowerOfTwoCoordinates;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import art.arcane.volmlib.util.scheduling.ChronoLatch;
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.config.Range;
|
||||
import com.volmit.config.SettingsStack;
|
||||
import com.volmit.entity.EntitySpec;
|
||||
import com.volmit.resource.PackResources;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.service.EntitySpawns;
|
||||
import com.volmit.geometry.BlockPosition;
|
||||
import com.volmit.world.BiomeKind;
|
||||
import com.volmit.world.PackWorld;
|
||||
import com.volmit.world.RunningWorld;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -62,7 +64,6 @@ public final class EntitySpawning implements EntitySpawns {
|
||||
private static final String CAVE_CEILING_MARKER = "cave_ceiling";
|
||||
private static final int AIR_ABOVE_MARKER = 1;
|
||||
private static final long COOLDOWN_CLEANUP_INTERVAL_MILLISECONDS = 60_000L;
|
||||
private static final int LAYOUT_QUESTION_HEIGHT = 0;
|
||||
|
||||
@Override
|
||||
public Optional<Plan> plan(PackWorld world, Site site) {
|
||||
@@ -81,7 +82,7 @@ public final class EntitySpawning implements EntitySpawns {
|
||||
String spawnerKey = plan.spawner().path();
|
||||
Spawner spawner = SpawnResources.spawner(world.resources(), spawnerKey);
|
||||
if (spawner != null) {
|
||||
SpawnerGate.spawned(spawnerKey, spawner, world.extension(LiveWorld.class).orElseThrow(), plan.chunkX(), plan.chunkZ());
|
||||
SpawnerGate.of(world).spawned(spawnerKey, spawner, plan.chunkX(), plan.chunkZ());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,25 +123,27 @@ public final class EntitySpawning implements EntitySpawns {
|
||||
return;
|
||||
}
|
||||
PackResources resources = world.resources();
|
||||
world.extension(LiveWorld.class).orElseThrow().spawnCooldowns().forgetExpired(key -> {
|
||||
world.extension(SpawnCooldowns.class).orElseThrow().forgetExpired(key -> {
|
||||
Spawner spawner = SpawnResources.spawner(resources, key);
|
||||
return spawner == null ? -1L : spawner.maximumRate().interval();
|
||||
});
|
||||
}
|
||||
|
||||
private Optional<Plan> planChunk(PackWorld world, Chunk chunk) {
|
||||
LiveWorld live = world.extension(LiveWorld.class).orElseThrow();
|
||||
Predicate<KeyedSpawner> canSpawn = keyed -> SpawnerGate.canSpawn(keyed.key(), keyed.spawner(), live, chunk.chunkX(), chunk.chunkZ());
|
||||
RunningWorld running = world.running().orElseThrow();
|
||||
SpawnerGate gate = SpawnerGate.of(world);
|
||||
Predicate<KeyedSpawner> canSpawn = keyed -> gate.canSpawn(keyed.key(), keyed.spawner(), chunk.chunkX(), chunk.chunkZ());
|
||||
int blockX = PowerOfTwoCoordinates.chunkToBlock(chunk.chunkX());
|
||||
int blockZ = PowerOfTwoCoordinates.chunkToBlock(chunk.chunkZ());
|
||||
LiveWorld.BiomeKind centreKind = live.surfaceKind(blockX + BLOCKS_TO_CHUNK_CENTRE, blockZ + BLOCKS_TO_CHUNK_CENTRE);
|
||||
BiomeKind centreKind = running.layout().surfaceKind(blockX + BLOCKS_TO_CHUNK_CENTRE, blockZ + BLOCKS_TO_CHUNK_CENTRE);
|
||||
SettingsStack<SpawnerSettings> column = running.settings().at(SpawnerSettings.class, blockX, blockZ);
|
||||
|
||||
List<KeyedSpawner> candidates = Stream.concat(
|
||||
shuffled(world, live, Level.DIMENSION, blockX, blockZ).stream()
|
||||
shuffled(world, column.dimension()).stream()
|
||||
.filter(canSpawn).filter(keyed -> SpawnerGate.suits(keyed.spawner(), centreKind)),
|
||||
Stream.concat(
|
||||
shuffled(world, live, Level.REGION, blockX, blockZ).stream().filter(canSpawn),
|
||||
shuffled(world, live, Level.SURFACE_BIOME, blockX, blockZ).stream().filter(canSpawn)))
|
||||
shuffled(world, column.level(Level.REGION)).stream().filter(canSpawn),
|
||||
shuffled(world, column.level(Level.BIOME)).stream().filter(canSpawn)))
|
||||
.filter(keyed -> chunk.livingEntities() < keyed.spawner().maxEntitiesPerChunk())
|
||||
.toList();
|
||||
|
||||
@@ -149,17 +152,17 @@ public final class EntitySpawning implements EntitySpawns {
|
||||
if (chosen == null) {
|
||||
return Optional.empty();
|
||||
}
|
||||
return planChunkSpawn(world, live, chunk, chosen);
|
||||
return planChunkSpawn(world, running, chunk, chosen);
|
||||
}
|
||||
|
||||
private Optional<Plan> planChunkSpawn(PackWorld world, LiveWorld live, Chunk chunk, Candidate chosen) {
|
||||
private Optional<Plan> planChunkSpawn(PackWorld world, RunningWorld running, Chunk chunk, Candidate chosen) {
|
||||
EntitySpawn spawn = chosen.spawn();
|
||||
int count = LootResolver.inclusive(RNG.r, spawn.minSpawns(), spawn.maxSpawns());
|
||||
List<Attempt> attempts = new ArrayList<>();
|
||||
for (int i = 0; i < count; i++) {
|
||||
int x = (chunk.chunkX() * CHUNK_SIZE) + RNG.r.i(CHUNK_SIZE);
|
||||
int z = (chunk.chunkZ() * CHUNK_SIZE) + RNG.r.i(CHUNK_SIZE);
|
||||
BlockPosition at = spawnPosition(live, chosen.spawner(), chunk.chunkX(), chunk.chunkZ(), x, z);
|
||||
BlockPosition at = spawnPosition(running, chosen.spawner(), chunk.chunkX(), chunk.chunkZ(), x, z);
|
||||
if (at != null) {
|
||||
addAttempt(attempts, world, chosen, at, true);
|
||||
}
|
||||
@@ -168,18 +171,18 @@ public final class EntitySpawning implements EntitySpawns {
|
||||
}
|
||||
|
||||
/** Where a spawner of its group puts an entity at the column; null when it has no place for one. */
|
||||
private static BlockPosition spawnPosition(LiveWorld live, Spawner spawner, int chunkX, int chunkZ, int x, int z) {
|
||||
int height = live.highestBlock(x, z, true);
|
||||
int heightWithFluid = live.highestBlock(x, z, false);
|
||||
private static BlockPosition spawnPosition(RunningWorld running, Spawner spawner, int chunkX, int chunkZ, int x, int z) {
|
||||
int height = running.highestBlock(x, z, true);
|
||||
int heightWithFluid = running.highestBlock(x, z, false);
|
||||
return switch (spawner.group()) {
|
||||
case NORMAL -> new BlockPosition(x, heightWithFluid + 1, z);
|
||||
case CAVE -> caveSpawnPosition(live, chunkX, chunkZ);
|
||||
case CAVE -> caveSpawnPosition(running, chunkX, chunkZ);
|
||||
case UNDERWATER, BEACH -> new BlockPosition(x, RNG.r.i(height + 1, heightWithFluid), z);
|
||||
};
|
||||
}
|
||||
|
||||
static BlockPosition caveSpawnPosition(LiveWorld live, int chunkX, int chunkZ) {
|
||||
KList<BlockPosition> floors = new KList<>(live.caveFloors(chunkX, chunkZ));
|
||||
static BlockPosition caveSpawnPosition(RunningWorld running, int chunkX, int chunkZ) {
|
||||
KList<BlockPosition> floors = new KList<>(running.caveFloors(chunkX, chunkZ));
|
||||
BlockPosition floor = floors.getRandom(RNG.r);
|
||||
return floor == null ? null : new BlockPosition(floor.x(), floor.y() + AIR_ABOVE_MARKER, floor.z());
|
||||
}
|
||||
@@ -201,8 +204,7 @@ public final class EntitySpawning implements EntitySpawns {
|
||||
BlockPosition position = marker.position();
|
||||
int chunkX = PowerOfTwoCoordinates.blockToChunkFloor(position.x());
|
||||
int chunkZ = PowerOfTwoCoordinates.blockToChunkFloor(position.z());
|
||||
LiveWorld live = world.extension(LiveWorld.class).orElseThrow();
|
||||
if (!SpawnerGate.canSpawn(spawnerKey, spawner, live, chunkX, chunkZ)) {
|
||||
if (!SpawnerGate.of(world).canSpawn(spawnerKey, spawner, chunkX, chunkZ)) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@@ -236,9 +238,9 @@ public final class EntitySpawning implements EntitySpawns {
|
||||
}
|
||||
|
||||
private static EntityResolution resolution(PackWorld world) {
|
||||
LiveWorld live = world.extension(LiveWorld.class).orElseThrow();
|
||||
LootItems items = new LootItems(world.resources().items(), live.studio(), world.log());
|
||||
return new EntityResolution(world.resources(), items, live.sky(), world.state(EffectTimers.class, ignored -> new EffectTimers()),
|
||||
RunningWorld running = world.running().orElseThrow();
|
||||
LootItems items = new LootItems(world.resources().items(), running.debug(), world.log());
|
||||
return new EntityResolution(world.resources(), items, running.sky(), world.state(EffectTimers.class, ignored -> new EffectTimers()),
|
||||
world.log());
|
||||
}
|
||||
|
||||
@@ -251,9 +253,8 @@ public final class EntitySpawning implements EntitySpawns {
|
||||
}
|
||||
|
||||
/** The spawners the dimension, region or surface biome at the column lists, in a random order. */
|
||||
private static List<KeyedSpawner> shuffled(PackWorld world, LiveWorld live, Level level, int x, int z) {
|
||||
List<String> keys = live.settings(SpawnerSettings.class, level, x, LAYOUT_QUESTION_HEIGHT, z)
|
||||
.map(SpawnerSettings::spawners).orElse(List.of());
|
||||
private static List<KeyedSpawner> shuffled(PackWorld world, Optional<SpawnerSettings> declared) {
|
||||
List<String> keys = declared.map(SpawnerSettings::spawners).orElse(List.of());
|
||||
return new KList<>(SpawnResources.spawners(world.resources(), keys)).shuffleCopy(RNG.r);
|
||||
}
|
||||
|
||||
@@ -274,7 +275,7 @@ public final class EntitySpawning implements EntitySpawns {
|
||||
private final RNG rng;
|
||||
|
||||
private EntityRandom(PackWorld world) {
|
||||
this.rng = new RNG(world.extension(IrisSeeds.class).orElseThrow().seed(IrisSeed.ENTITY));
|
||||
this.rng = new RNG(world.seed(IrisSeedPurposes.ENTITY));
|
||||
}
|
||||
|
||||
private RNG rng() {
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
|
||||
package art.arcane.iris.engine.spawn;
|
||||
|
||||
import art.arcane.iris.builtin.LiveWorld.Sky;
|
||||
import art.arcane.iris.builtin.spawn.SpawnTimeBlock;
|
||||
import art.arcane.iris.builtin.spawn.SpawnWeather;
|
||||
import com.volmit.world.RunningWorld.Sky;
|
||||
|
||||
/** The time of day and the weather a command or spawner of the pack asks for, checked against a world's sky. */
|
||||
final class SpawnConditions {
|
||||
|
||||
@@ -18,21 +18,26 @@
|
||||
|
||||
package art.arcane.iris.engine.spawn;
|
||||
|
||||
import art.arcane.iris.builtin.LiveWorld;
|
||||
import art.arcane.iris.builtin.LiveWorld.BiomeKind;
|
||||
import art.arcane.iris.builtin.LiveWorld.Sky;
|
||||
import art.arcane.iris.builtin.spawn.SpawnRate;
|
||||
import art.arcane.iris.builtin.spawn.SpawnCooldowns;
|
||||
import art.arcane.iris.builtin.spawn.SpawnRate;
|
||||
import art.arcane.iris.builtin.spawn.Spawner;
|
||||
import com.volmit.world.BiomeKind;
|
||||
import com.volmit.world.PackWorld;
|
||||
import com.volmit.world.RunningWorld.Sky;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Whether a spawner may fire: in a biome of the kind its group wants, in the time and weather it asks for, and not
|
||||
* more often than its rates allow. The rates count in the world's data, by the key the pack names the spawner by.
|
||||
*
|
||||
* @param sky the world's time and weather when the gate was made; empty while the platform has not loaded the world
|
||||
* @param cooldowns when the world's spawners last fired
|
||||
*/
|
||||
final class SpawnerGate {
|
||||
private SpawnerGate() {
|
||||
record SpawnerGate(Optional<Sky> sky, SpawnCooldowns cooldowns) {
|
||||
/** The gate of the running world, with its time and weather now. */
|
||||
static SpawnerGate of(PackWorld world) {
|
||||
return new SpawnerGate(world.running().orElseThrow().sky(), world.extension(SpawnCooldowns.class).orElseThrow());
|
||||
}
|
||||
|
||||
/** Whether a spawner of this group fires in a biome of {@code kind}. */
|
||||
@@ -60,40 +65,39 @@ final class SpawnerGate {
|
||||
}
|
||||
|
||||
/** Whether the spawner may fire in the chunk now. */
|
||||
static boolean canSpawn(String key, Spawner spawner, LiveWorld live, int chunkX, int chunkZ) {
|
||||
if (!canSpawn(key, spawner, live)) {
|
||||
boolean canSpawn(String key, Spawner spawner, int chunkX, int chunkZ) {
|
||||
if (!canSpawn(key, spawner)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
SpawnRate rate = spawner.maximumRatePerChunk();
|
||||
return rate.isInfinite() || live.spawnCooldowns().canSpawnInChunk(chunkX, chunkZ, key, rate.interval());
|
||||
return rate.isInfinite() || cooldowns.canSpawnInChunk(chunkX, chunkZ, key, rate.interval());
|
||||
}
|
||||
|
||||
/** Counts a spawn of the spawner in the chunk against its rates. */
|
||||
static void spawned(String key, Spawner spawner, LiveWorld live, int chunkX, int chunkZ) {
|
||||
spawned(key, spawner, live);
|
||||
void spawned(String key, Spawner spawner, int chunkX, int chunkZ) {
|
||||
spawned(key, spawner);
|
||||
if (spawner.maximumRatePerChunk().isInfinite()) {
|
||||
return;
|
||||
}
|
||||
|
||||
live.spawnCooldowns().spawnedInChunk(chunkX, chunkZ, key);
|
||||
cooldowns.spawnedInChunk(chunkX, chunkZ, key);
|
||||
}
|
||||
|
||||
private static boolean canSpawn(String key, Spawner spawner, LiveWorld live) {
|
||||
Optional<Sky> sky = live.sky();
|
||||
private boolean canSpawn(String key, Spawner spawner) {
|
||||
if (sky.isEmpty() || !suits(spawner, sky.get())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
SpawnRate rate = spawner.maximumRate();
|
||||
return rate.isInfinite() || live.spawnCooldowns().canSpawn(key, rate.interval());
|
||||
return rate.isInfinite() || cooldowns.canSpawn(key, rate.interval());
|
||||
}
|
||||
|
||||
private static void spawned(String key, Spawner spawner, LiveWorld live) {
|
||||
private void spawned(String key, Spawner spawner) {
|
||||
if (spawner.maximumRate().isInfinite()) {
|
||||
return;
|
||||
}
|
||||
|
||||
live.spawnCooldowns().spawned(key);
|
||||
cooldowns.spawned(key);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user