mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 00:34:19 +00:00
Merge branch 'wave2/c' into feat/irisapi-host
# Conflicts: # core/src/test/java/art/arcane/iris/engine/decorator/IrisShoreLineDecoratorTest.java
This commit is contained in:
commit
45d967b76f
27 files changed
+848
-377
No files matched your search
@@ -35,6 +35,8 @@ import java.util.List;
|
||||
*/
|
||||
final class PackBiomeLayerValidator {
|
||||
private static final int DEFAULT_LAYER_COUNT = 1;
|
||||
private static final String DECORANT_SETTINGS = "iris:decorant";
|
||||
private static final String DECORATORS = "decorators";
|
||||
|
||||
private PackBiomeLayerValidator() {
|
||||
}
|
||||
@@ -79,10 +81,18 @@ final class PackBiomeLayerValidator {
|
||||
for (File biomeFile : biomeFiles) {
|
||||
String biomeKey = PackValidationIo.deriveKey(biomesFolder, biomeFile);
|
||||
JSONObject biome = PackValidationIo.readJson(biomeFile);
|
||||
if (biome == null || !biome.has("decorators") || biome.isNull("decorators")) {
|
||||
if (biome == null || !biome.has(DECORANT_SETTINGS) || biome.isNull(DECORANT_SETTINGS)) {
|
||||
continue;
|
||||
}
|
||||
JSONArray decorators = biome.optJSONArray("decorators");
|
||||
JSONObject decorant = biome.optJSONObject(DECORANT_SETTINGS);
|
||||
if (decorant == null) {
|
||||
blockingErrors.add("Biome '" + biomeKey + "' " + DECORANT_SETTINGS + " must be an object.");
|
||||
continue;
|
||||
}
|
||||
if (!decorant.has(DECORATORS) || decorant.isNull(DECORATORS)) {
|
||||
continue;
|
||||
}
|
||||
JSONArray decorators = decorant.optJSONArray(DECORATORS);
|
||||
if (decorators == null) {
|
||||
blockingErrors.add("Biome '" + biomeKey + "' decorators must be an array.");
|
||||
continue;
|
||||
|
||||
@@ -58,6 +58,6 @@ record EngineRuntime(
|
||||
nextBiomeMaxes);
|
||||
}
|
||||
|
||||
record BiomeMaxes(double objectDensity, double layerDensity, double decoratorDensity) {
|
||||
record BiomeMaxes(double objectDensity, double layerDensity) {
|
||||
}
|
||||
}
|
||||
@@ -30,7 +30,6 @@ import art.arcane.iris.engine.framework.EngineWorldManager;
|
||||
import art.arcane.iris.engine.framework.EngineWorldManagerProvider;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import art.arcane.iris.engine.object.terrain.IrisBiomePaletteLayer;
|
||||
import art.arcane.iris.engine.object.decoration.IrisDecorator;
|
||||
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
||||
import art.arcane.iris.spi.IrisLogging;
|
||||
import art.arcane.iris.spi.IrisServices;
|
||||
@@ -199,7 +198,6 @@ final class EngineRuntimeBuilder {
|
||||
BiomeMaxes computeBiomeMaxes() {
|
||||
double objectDensity = 0D;
|
||||
double layerDensity = 0D;
|
||||
double decoratorDensity = 0D;
|
||||
for (IrisBiome i : engine.getDimension().getReachableBiomes(engine)) {
|
||||
double density = 0;
|
||||
|
||||
@@ -210,20 +208,13 @@ final class EngineRuntimeBuilder {
|
||||
objectDensity = Math.max(objectDensity, density);
|
||||
density = 0;
|
||||
|
||||
for (IrisDecorator j : i.getDecorators()) {
|
||||
density += Math.max(j.getStackMax(), 1) * j.getChance();
|
||||
}
|
||||
|
||||
decoratorDensity = Math.max(decoratorDensity, density);
|
||||
density = 0;
|
||||
|
||||
for (IrisBiomePaletteLayer j : i.getLayers()) {
|
||||
density++;
|
||||
}
|
||||
|
||||
layerDensity = Math.max(layerDensity, density);
|
||||
}
|
||||
return new BiomeMaxes(objectDensity, layerDensity, decoratorDensity);
|
||||
return new BiomeMaxes(objectDensity, layerDensity);
|
||||
}
|
||||
|
||||
void restoreRuntimeAfterFailedTransition(EngineRuntime previous) {
|
||||
|
||||
@@ -23,20 +23,18 @@ import java.util.concurrent.CompletionException;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
/**
|
||||
* Whether the engine's worlds have warmed their generation caches, which generation waits for. The first world is warmed
|
||||
* by engine initialisation: the host's caches ({@link GenerationCacheWarmer}), then the modules' warm-up
|
||||
* ({@link com.volmit.ModuleLifecycle#warmUp}). Worlds started after that, by a hotload or an in-place restart, only have
|
||||
* the modules' warm-up; each one adds a warm-up that generation also waits for.
|
||||
* Whether the engine's worlds have warmed their generation caches, which generation waits for. Every world is warmed by
|
||||
* the modules' warm-up ({@link com.volmit.ModuleLifecycle#warmUp}): the first by engine initialisation, the ones started
|
||||
* after that, by a hotload or an in-place restart, each adding a warm-up that generation also waits for.
|
||||
*/
|
||||
final class GenerationCacheWarmGate {
|
||||
private final CompletableFuture<Void> firstWorld = new CompletableFuture<>();
|
||||
private final AtomicReference<CompletableFuture<Void>> restartedWorlds = new AtomicReference<>(CompletableFuture.completedFuture(null));
|
||||
|
||||
/** Runs both warm-ups on this thread, the host's first; the first world is warm once both returned. A failure leaves it failed. */
|
||||
void warmFirstWorld(Runnable hostWarmUp, Runnable moduleWarmUp) {
|
||||
/** Runs the warm-up on this thread; the first world is warm once it returned. A failure leaves it failed. */
|
||||
void warmFirstWorld(Runnable warmUp) {
|
||||
try {
|
||||
hostWarmUp.run();
|
||||
moduleWarmUp.run();
|
||||
warmUp.run();
|
||||
firstWorld.complete(null);
|
||||
} catch (RuntimeException | Error failure) {
|
||||
firstWorld.completeExceptionally(failure);
|
||||
|
||||
@@ -1,127 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit 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;
|
||||
|
||||
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import art.arcane.iris.engine.object.decoration.IrisDecorator;
|
||||
import art.arcane.iris.engine.object.terrain.deposit.IrisOreGenerator;
|
||||
import art.arcane.iris.engine.object.procedural.IrisProceduralObjects;
|
||||
import art.arcane.iris.engine.object.procedural.IrisProceduralPlacement;
|
||||
import art.arcane.iris.engine.object.world.region.IrisRegion;
|
||||
import art.arcane.iris.spi.IrisLogging;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.math.M;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
public final class GenerationCacheWarmer {
|
||||
private GenerationCacheWarmer() {
|
||||
}
|
||||
|
||||
public static void warm(Engine engine) {
|
||||
long start = M.ms();
|
||||
IrisData data = engine.getData();
|
||||
RNG root = new RNG(engine.getSeedManager().getComponent() + 7777L);
|
||||
int[] counter = {0};
|
||||
|
||||
try {
|
||||
KList<IrisBiome> biomes = engine.getAllBiomes();
|
||||
biomes.sort(Comparator.comparing(IrisBiome::getLoadKey));
|
||||
for (IrisBiome biome : biomes) {
|
||||
warmPlacements(biome.getObjects(), root, counter, data, engine);
|
||||
warmDecorators(biome.getDecorators(), root, counter, data);
|
||||
warmOres(biome.getOres(), root, counter, data);
|
||||
warmProcedural(biome.getProceduralObjects(), root, counter, data);
|
||||
}
|
||||
|
||||
KList<IrisRegion> regions = engine.getDimension().getAllRegions(engine);
|
||||
regions.sort(Comparator.comparing(IrisRegion::getLoadKey));
|
||||
for (IrisRegion region : regions) {
|
||||
warmPlacements(region.getObjects(), root, counter, data, engine);
|
||||
warmOres(region.getOres(), root, counter, data);
|
||||
warmProcedural(region.getProceduralObjects(), root, counter, data);
|
||||
}
|
||||
|
||||
warmOres(engine.getDimension().getOres(), root, counter, data);
|
||||
} catch (Throwable e) {
|
||||
IrisLogging.reportError(e);
|
||||
IrisLogging.warn("Generation cache warm pass failed: " + e.getMessage());
|
||||
}
|
||||
|
||||
IrisLogging.debug("[IrisEngine timing] cache warm " + counter[0] + " configs=" + (M.ms() - start) + "ms");
|
||||
}
|
||||
|
||||
private static void warmPlacements(KList<IrisObjectPlacement> placements, RNG root, int[] counter,
|
||||
IrisData data, Engine engine) {
|
||||
if (placements == null) {
|
||||
return;
|
||||
}
|
||||
for (IrisObjectPlacement placement : placements) {
|
||||
if (placement == null) {
|
||||
continue;
|
||||
}
|
||||
RNG rng = root.nextParallelRNG(counter[0]++);
|
||||
placement.getSurfaceWarp(rng, data, engine);
|
||||
placement.getDensity(rng, 0, 0, data);
|
||||
}
|
||||
}
|
||||
|
||||
private static void warmDecorators(KList<IrisDecorator> decorators, RNG root, int[] counter, IrisData data) {
|
||||
if (decorators == null) {
|
||||
return;
|
||||
}
|
||||
for (IrisDecorator decorator : decorators) {
|
||||
if (decorator == null) {
|
||||
continue;
|
||||
}
|
||||
RNG rng = root.nextParallelRNG(counter[0]++);
|
||||
decorator.getHeightGenerator(rng, data);
|
||||
decorator.getGenerator(rng, data);
|
||||
decorator.getVarianceGenerator(rng, data);
|
||||
}
|
||||
}
|
||||
|
||||
private static void warmOres(KList<IrisOreGenerator> ores, RNG root, int[] counter, IrisData data) {
|
||||
if (ores == null) {
|
||||
return;
|
||||
}
|
||||
for (IrisOreGenerator ore : ores) {
|
||||
if (ore == null) {
|
||||
continue;
|
||||
}
|
||||
ore.warm(root.nextParallelRNG(counter[0]++), data);
|
||||
}
|
||||
}
|
||||
|
||||
private static void warmProcedural(IrisProceduralObjects procedural, RNG root, int[] counter, IrisData data) {
|
||||
if (procedural == null) {
|
||||
return;
|
||||
}
|
||||
for (IrisProceduralPlacement placement : procedural.getAllPlacements()) {
|
||||
if (placement == null) {
|
||||
continue;
|
||||
}
|
||||
placement.getVariantObject(data, root.nextParallelRNG(counter[0]++));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,8 +25,6 @@ import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.image.IrisImageMapRuntime;
|
||||
import art.arcane.iris.engine.object.world.biome.InferredType;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import art.arcane.iris.engine.object.decoration.IrisDecorationPart;
|
||||
import art.arcane.iris.engine.object.decoration.IrisDecorator;
|
||||
import art.arcane.iris.engine.object.terrain.IrisGenerator;
|
||||
import art.arcane.iris.engine.object.noise.IrisInterpolator;
|
||||
import art.arcane.iris.engine.object.world.region.IrisRegion;
|
||||
@@ -118,13 +116,6 @@ public class IrisComplex implements DataProvider {
|
||||
private ProceduralStream<Double> heightFluidStream;
|
||||
private ProceduralStream<Double> slopeStream;
|
||||
private ProceduralStream<Integer> topSurfaceStream;
|
||||
private ProceduralStream<IrisDecorator> terrainSurfaceDecoration;
|
||||
private ProceduralStream<IrisDecorator> terrainCeilingDecoration;
|
||||
private ProceduralStream<IrisDecorator> terrainCaveSurfaceDecoration;
|
||||
private ProceduralStream<IrisDecorator> terrainCaveCeilingDecoration;
|
||||
private ProceduralStream<IrisDecorator> seaSurfaceDecoration;
|
||||
private ProceduralStream<IrisDecorator> seaFloorDecoration;
|
||||
private ProceduralStream<IrisDecorator> shoreSurfaceDecoration;
|
||||
private ProceduralStream<PlatformBlockState> rockStream;
|
||||
private ProceduralStream<PlatformBlockState> fluidStream;
|
||||
private IrisBiome focusBiome;
|
||||
@@ -286,20 +277,6 @@ public class IrisComplex implements DataProvider {
|
||||
heightFluidStream = heightStream.contextInjecting(engine, (c, x, z) -> c.getHeight().getDouble(x, z))
|
||||
.max(fluidHeight).cache2DDouble("heightFluidStream", engine, cacheSize);
|
||||
maxHeightStream = ProceduralStream.ofDouble((x, z) -> height);
|
||||
terrainSurfaceDecoration = trueBiomeStream.contextInjecting(engine, (c, x, z) -> c.getBiome().get(x, z))
|
||||
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.NONE)).cache2D("terrainSurfaceDecoration", engine, cacheSize);
|
||||
terrainCeilingDecoration = trueBiomeStream.contextInjecting(engine, (c, x, z) -> c.getBiome().get(x, z))
|
||||
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.CEILING)).cache2D("terrainCeilingDecoration", engine, cacheSize);
|
||||
terrainCaveSurfaceDecoration = caveBiomeStream.contextInjecting(engine, (c, x, z) -> c.getCave().get(x, z))
|
||||
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.NONE)).cache2D("terrainCaveSurfaceDecoration", engine, cacheSize);
|
||||
terrainCaveCeilingDecoration = caveBiomeStream.contextInjecting(engine, (c, x, z) -> c.getCave().get(x, z))
|
||||
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.CEILING)).cache2D("terrainCaveCeilingDecoration", engine, cacheSize);
|
||||
shoreSurfaceDecoration = trueBiomeStream.contextInjecting(engine, (c, x, z) -> c.getBiome().get(x, z))
|
||||
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.SHORE_LINE)).cache2D("shoreSurfaceDecoration", engine, cacheSize);
|
||||
seaSurfaceDecoration = trueBiomeStream.contextInjecting(engine, (c, x, z) -> c.getBiome().get(x, z))
|
||||
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.SEA_SURFACE)).cache2D("seaSurfaceDecoration", engine, cacheSize);
|
||||
seaFloorDecoration = trueBiomeStream.contextInjecting(engine, (c, x, z) -> c.getBiome().get(x, z))
|
||||
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.SEA_FLOOR)).cache2D("seaFloorDecoration", engine, cacheSize);
|
||||
baseBiomeIDStream = trueBiomeStream.contextInjecting(engine, (c, x, z) -> c.getBiome().get(x, z))
|
||||
.convertAware2D((b, x, z) -> {
|
||||
UUID d = regionIDStream.get(x, z);
|
||||
@@ -352,24 +329,6 @@ public class IrisComplex implements DataProvider {
|
||||
return region;
|
||||
}
|
||||
|
||||
private IrisDecorator decorateFor(IrisBiome b, double x, double z, IrisDecorationPart part) {
|
||||
RNG rngc = new RNG(Cache.key(((int) x), ((int) z)));
|
||||
|
||||
for (IrisDecorator i : b.getDecorators()) {
|
||||
if (!i.getPartOf().equals(part)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
PlatformBlockState block = i.getBlockData(b, rngc, x, z, data);
|
||||
|
||||
if (block != null) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private IrisBiome fixBiomeType(Double height, IrisBiome biome, IrisRegion region, Double x, Double z, double fluidHeight) {
|
||||
IrisBiome resolved = resolveSurfaceBiome(
|
||||
height,
|
||||
|
||||
@@ -263,9 +263,8 @@ public class IrisEngine implements Engine {
|
||||
|
||||
/**
|
||||
* Warms the modules' caches of a world that started after the engine initialised: the one a hotload built, or the
|
||||
* one an in-place restart replaced. The first world is warmed by initialisation, together with
|
||||
* {@link GenerationCacheWarmer}. Same mode as there: studio warms in the background, server worlds before this
|
||||
* returns, and generation waits for it either way.
|
||||
* one an in-place restart replaced. The first world is warmed by initialisation. Same mode as there: studio warms in
|
||||
* the background, server worlds before this returns, and generation waits for it either way.
|
||||
*/
|
||||
void warmRestartedWorld() {
|
||||
if (!initializationMode.warmGenerationCaches()) {
|
||||
@@ -320,7 +319,7 @@ public class IrisEngine implements Engine {
|
||||
private void warmGenerationCaches(long phaseStartedAtNanos) {
|
||||
long startedAtMillis = M.ms();
|
||||
try {
|
||||
generationCacheWarm.warmFirstWorld(() -> GenerationCacheWarmer.warm(this), this::warmModules);
|
||||
generationCacheWarm.warmFirstWorld(this::warmModules);
|
||||
} finally {
|
||||
IrisLogging.debug("[IrisEngine timing] cache warm total=" + (M.ms() - startedAtMillis) + "ms");
|
||||
logStudioInitializationPhase("generation_cache_warm", phaseStartedAtNanos, false);
|
||||
@@ -602,12 +601,6 @@ public class IrisEngine implements Engine {
|
||||
return current == null ? 0D : current.biomeMaxes().layerDensity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxBiomeDecoratorDensity() {
|
||||
EngineRuntime current = runtime;
|
||||
return current == null ? 0D : current.biomeMaxes().decoratorDensity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isClosed() {
|
||||
return closed;
|
||||
|
||||
@@ -129,8 +129,6 @@ public interface Engine extends DataProvider, Fallible, BlockUpdater, Renderer,
|
||||
|
||||
double getMaxBiomeObjectDensity();
|
||||
|
||||
double getMaxBiomeDecoratorDensity();
|
||||
|
||||
double getMaxBiomeLayerDensity();
|
||||
|
||||
boolean isClosed();
|
||||
|
||||
Reference in new issue
Block a user