Modules log through the ModuleLog of their context, world or registry instead of IrisLogging; helpers without one take it from their caller

This commit is contained in:
piexel committed 2026-10-10 14:25:32 +02:00
1 parent db0f8a9186
commit fb92f88ab1
34 files changed
+270 -224

No files matched your search

@@ -55,6 +55,7 @@ import com.volmit.FeatureRegistry;
import com.volmit.IrisModule; import com.volmit.IrisModule;
import com.volmit.ModuleInfo; import com.volmit.ModuleInfo;
import com.volmit.ModuleLifecycle; import com.volmit.ModuleLifecycle;
import com.volmit.ModuleLog;
import com.volmit.stage.ChunkStageContext; import com.volmit.stage.ChunkStageContext;
import com.volmit.stage.StageGraph; import com.volmit.stage.StageGraph;
import com.volmit.world.PackWorld; import com.volmit.world.PackWorld;
@@ -103,7 +104,8 @@ public final class TerrainModule implements IrisModule, ModuleLifecycle {
private static void shape(ChunkStageContext context) { private static void shape(ChunkStageContext context) {
IrisChunk chunk = IrisChunk.current(); IrisChunk chunk = IrisChunk.current();
chunk.state(TerrainShaper.class, TerrainShaper::new).shape(chunk.originX(), chunk.originZ(), chunk.blocks(), chunk.context()); ModuleLog log = context.log();
chunk.state(TerrainShaper.class, generating -> new TerrainShaper(generating, log)).shape(chunk.originX(), chunk.originZ(), chunk.blocks(), chunk.context());
} }
/** What shaping terrain keeps for one engine runtime: the terrain stream's random. */ /** What shaping terrain keeps for one engine runtime: the terrain stream's random. */
@@ -116,8 +118,8 @@ public final class TerrainModule implements IrisModule, ModuleLifecycle {
private final TerrainOres ores; private final TerrainOres ores;
private final RNG rng; private final RNG rng;
TerrainShaper(Engine engine) { TerrainShaper(Engine engine, ModuleLog log) {
this(engine, TerrainPalettes.of(engine), BiomeLayers.of(engine), TerrainOres.of(engine)); this(engine, TerrainPalettes.of(engine), BiomeLayers.of(engine, log), TerrainOres.of(engine));
} }
TerrainShaper(Engine engine, TerrainPalettes palettes, BiomeLayers layers, TerrainOres ores) { TerrainShaper(Engine engine, TerrainPalettes palettes, BiomeLayers layers, TerrainOres ores) {
@@ -24,6 +24,7 @@ import art.arcane.iris.builtin.decorant.Decorator;
import art.arcane.iris.core.modules.IrisPackWorld; import art.arcane.iris.core.modules.IrisPackWorld;
import art.arcane.iris.engine.framework.Engine; import art.arcane.iris.engine.framework.Engine;
import art.arcane.iris.engine.object.world.biome.IrisBiome; import art.arcane.iris.engine.object.world.biome.IrisBiome;
import com.volmit.ModuleLog;
import com.volmit.world.PackWorld; import com.volmit.world.PackWorld;
import java.util.ArrayList; import java.util.ArrayList;
@@ -48,16 +49,22 @@ public final class BiomeDecorators {
private static final long INDEX_SEED_FACTOR = 0xC2B2AE3D27D4EB4FL; private static final long INDEX_SEED_FACTOR = 0xC2B2AE3D27D4EB4FL;
private final Engine engine; private final Engine engine;
private final ModuleLog log;
private final Map<DecorantSettings, Map<DecorationPart, ResolvedDecorator[]>> decorators = new ConcurrentHashMap<>(); private final Map<DecorantSettings, Map<DecorationPart, ResolvedDecorator[]>> decorators = new ConcurrentHashMap<>();
private volatile Double busiestBiomeLoad; private volatile Double busiestBiomeLoad;
/** @param world a world of an Iris engine */ /** @param world a world of an Iris engine */
BiomeDecorators(PackWorld world) { BiomeDecorators(PackWorld world) {
this(IrisPackWorld.of(world).engine()); this(IrisPackWorld.of(world).engine(), world.log());
} }
BiomeDecorators(Engine engine) { BiomeDecorators(Engine engine) {
this(engine, engine.getGeneration().world().log());
}
BiomeDecorators(Engine engine, ModuleLog log) {
this.engine = engine; this.engine = engine;
this.log = log;
} }
/** The world {@code engine} generates now. */ /** The world {@code engine} generates now. */
@@ -70,6 +77,11 @@ public final class BiomeDecorators {
return world.state(BiomeDecorators.class, BiomeDecorators::new); return world.state(BiomeDecorators.class, BiomeDecorators::new);
} }
/** The log of the module that decorates, which the decorators write to. */
ModuleLog log() {
return log;
}
/** Whether the biome declares any decorator. */ /** Whether the biome declares any decorator. */
public boolean hasDecorators(IrisBiome biome) { public boolean hasDecorators(IrisBiome biome) {
DecorantSettings settings = settingsOf(biome); DecorantSettings settings = settingsOf(biome);
@@ -158,7 +170,7 @@ public final class BiomeDecorators {
if (decorator == null) { if (decorator == null) {
continue; continue;
} }
ResolvedDecorator resolved = ResolvedDecorator.of(decorator, engine, decoratorSeed(biomeKey, index)); ResolvedDecorator resolved = ResolvedDecorator.of(decorator, engine, decoratorSeed(biomeKey, index), log);
staging.computeIfAbsent(decorator.partOf(), part -> new ArrayList<>()).add(resolved); staging.computeIfAbsent(decorator.partOf(), part -> new ArrayList<>()).add(resolved);
} }
@@ -22,11 +22,11 @@ import art.arcane.iris.builtin.decorant.DecorationPart;
import art.arcane.iris.engine.mantle.EngineMantle; import art.arcane.iris.engine.mantle.EngineMantle;
import art.arcane.iris.engine.object.procedural.IrisProceduralBlocks; import art.arcane.iris.engine.object.procedural.IrisProceduralBlocks;
import art.arcane.iris.platform.bukkit.BukkitBlockState; import art.arcane.iris.platform.bukkit.BukkitBlockState;
import art.arcane.iris.spi.IrisLogging;
import art.arcane.iris.spi.PlatformBlockState; import art.arcane.iris.spi.PlatformBlockState;
import art.arcane.iris.util.common.data.B; import art.arcane.iris.util.common.data.B;
import art.arcane.iris.util.project.hunk.Hunk; import art.arcane.iris.util.project.hunk.Hunk;
import art.arcane.volmlib.util.math.RNG; import art.arcane.volmlib.util.math.RNG;
import com.volmit.ModuleLog;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockSupport; import org.bukkit.block.BlockSupport;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
@@ -68,7 +68,7 @@ final class DecoratorCore {
} }
/** The decorator of {@code bucket} that decorates the column, drawing from {@code colRng} to choose between those whose chance noise passes. */ /** The decorator of {@code bucket} that decorates the column, drawing from {@code colRng} to choose between those whose chance noise passes. */
static ResolvedDecorator pickDecorator(ResolvedDecorator[] bucket, RNG colRng, double realX, double realZ) { static ResolvedDecorator pickDecorator(ResolvedDecorator[] bucket, RNG colRng, double realX, double realZ, ModuleLog log) {
ResolvedDecorator picked = null; ResolvedDecorator picked = null;
int count = 0; int count = 0;
@@ -81,7 +81,7 @@ final class DecoratorCore {
} }
} }
} catch (Throwable e) { } catch (Throwable e) {
IrisLogging.reportError(e); log.error("A decorator failed to pick for the column", e);
} }
} }
@@ -99,7 +99,7 @@ final class DecoratorCore {
static void placeSurfaceSingle(ResolvedDecorator decorator, static void placeSurfaceSingle(ResolvedDecorator decorator,
int x, int z, int realX, int height, int realZ, int x, int z, int realX, int height, int realZ,
Hunk<PlatformBlockState> data, Hunk<PlatformBlockState> data,
boolean underwater, boolean caveSkipFluid, EngineMantle mantle) { boolean underwater, boolean caveSkipFluid, EngineMantle mantle, ModuleLog log) {
if (height < 0 || height >= data.getHeight()) { if (height < 0 || height >= data.getHeight()) {
return; return;
} }
@@ -140,7 +140,7 @@ final class DecoratorCore {
data.set(x, lowerY, z, lower); data.set(x, lowerY, z, lower);
data.set(x, upperY, z, upper); data.set(x, upperY, z, upper);
} catch (Throwable e) { } catch (Throwable e) {
IrisLogging.reportError(e); log.error("Failed to place a two-block plant", e);
} }
return; return;
} }
@@ -291,7 +291,7 @@ final class DecoratorCore {
static void placeFloatingSimple(ResolvedDecorator decorator, static void placeFloatingSimple(ResolvedDecorator decorator,
int xf, int zf, int realX, int realZ, int xf, int zf, int realX, int realZ,
int height, int max, Hunk<PlatformBlockState> data) { int height, int max, Hunk<PlatformBlockState> data, ModuleLog log) {
PlatformBlockState bd = decorator.pickBlock(realX, realZ); PlatformBlockState bd = decorator.pickBlock(realX, realZ);
if (bd == null) { if (bd == null) {
return; return;
@@ -311,7 +311,7 @@ final class DecoratorCore {
data.set(xf, lowerY, zf, lower); data.set(xf, lowerY, zf, lower);
data.set(xf, upperY, zf, upper); data.set(xf, upperY, zf, upper);
} catch (Throwable e) { } catch (Throwable e) {
IrisLogging.reportError(e); log.error("Failed to place a two-block plant", e);
} }
return; return;
} }
@@ -36,7 +36,8 @@ public class FloatingDecorator {
int xf, int zf, int realX, int realZ, int xf, int zf, int realX, int realZ,
int height, int max, Hunk<PlatformBlockState> data, RNG rng, int height, int max, Hunk<PlatformBlockState> data, RNG rng,
Runnable candidatesNullCallback) { Runnable candidatesNullCallback) {
ResolvedDecorator decorator = DecoratorCore.pickDecorator(BiomeDecorators.of(engine).decorators(target, part), rng, realX, realZ); BiomeDecorators decorators = BiomeDecorators.of(engine);
ResolvedDecorator decorator = DecoratorCore.pickDecorator(decorators.decorators(target, part), rng, realX, realZ, decorators.log());
if (decorator == null) { if (decorator == null) {
candidatesNullCallback.run(); candidatesNullCallback.run();
@@ -44,7 +45,7 @@ public class FloatingDecorator {
} }
if (!decorator.isStacking()) { if (!decorator.isStacking()) {
DecoratorCore.placeFloatingSimple(decorator, xf, zf, realX, realZ, height, max, data); DecoratorCore.placeFloatingSimple(decorator, xf, zf, realX, realZ, height, max, data, decorators.log());
return max > 1 ? 1 : 0; return max > 1 ? 1 : 0;
} }
@@ -45,7 +45,7 @@ public class IrisCeilingDecorator extends IrisEngineDecorator {
Hunk<PlatformBlockState> data, IrisBiome biome, InferredType inferredType, int height, int max) { Hunk<PlatformBlockState> data, IrisBiome biome, InferredType inferredType, int height, int max) {
boolean caveSkipFluid = IrisSurfaceDecorator.skipsFluid(inferredType); boolean caveSkipFluid = IrisSurfaceDecorator.skipsFluid(inferredType);
RNG rng = getRNG(realX, realZ); RNG rng = getRNG(realX, realZ);
ResolvedDecorator decorator = DecoratorCore.pickDecorator(decorators.decorators(biome, getPart()), rng, realX, realZ); ResolvedDecorator decorator = DecoratorCore.pickDecorator(decorators.decorators(biome, getPart()), rng, realX, realZ, decorators.log());
if (decorator == null) { if (decorator == null) {
return; return;
@@ -36,7 +36,7 @@ public class IrisSeaFloorDecorator extends IrisEngineDecorator {
public void decorate(int x, int z, int realX, int realX1, int realX_1, int realZ, int realZ1, int realZ_1, public void decorate(int x, int z, int realX, int realX1, int realX_1, int realZ, int realZ1, int realZ_1,
Hunk<PlatformBlockState> data, IrisBiome biome, int height, int max) { Hunk<PlatformBlockState> data, IrisBiome biome, int height, int max) {
RNG rng = getRNG(realX, realZ); RNG rng = getRNG(realX, realZ);
ResolvedDecorator decorator = DecoratorCore.pickDecorator(decorators.decorators(biome, getPart()), rng, realX, realZ); ResolvedDecorator decorator = DecoratorCore.pickDecorator(decorators.decorators(biome, getPart()), rng, realX, realZ, decorators.log());
if (decorator == null) { if (decorator == null) {
return; return;
@@ -36,7 +36,7 @@ public class IrisSeaSurfaceDecorator extends IrisEngineDecorator {
public void decorate(int x, int z, int realX, int realX1, int realX_1, int realZ, int realZ1, int realZ_1, public void decorate(int x, int z, int realX, int realX1, int realX_1, int realZ, int realZ1, int realZ_1,
Hunk<PlatformBlockState> data, IrisBiome biome, int height, int max) { Hunk<PlatformBlockState> data, IrisBiome biome, int height, int max) {
RNG rng = getRNG(realX, realZ); RNG rng = getRNG(realX, realZ);
ResolvedDecorator decorator = DecoratorCore.pickDecorator(decorators.decorators(biome, getPart()), rng, realX, realZ); ResolvedDecorator decorator = DecoratorCore.pickDecorator(decorators.decorators(biome, getPart()), rng, realX, realZ, decorators.log());
if (decorator == null) { if (decorator == null) {
return; return;
@@ -50,7 +50,7 @@ public class IrisShoreLineDecorator extends IrisEngineDecorator {
} }
RNG rng = getRNG(realX, realZ); RNG rng = getRNG(realX, realZ);
ResolvedDecorator decorator = DecoratorCore.pickDecorator(decorators.decorators(biome, getPart()), rng, realX, realZ); ResolvedDecorator decorator = DecoratorCore.pickDecorator(decorators.decorators(biome, getPart()), rng, realX, realZ, decorators.log());
if (decorator == null) { if (decorator == null) {
return; return;
@@ -58,7 +58,7 @@ public class IrisSurfaceDecorator extends IrisEngineDecorator {
boolean underwater = isUnderwater(inferredType, height, fluidHeight); boolean underwater = isUnderwater(inferredType, height, fluidHeight);
boolean caveSkipFluid = skipsFluid(inferredType); boolean caveSkipFluid = skipsFluid(inferredType);
RNG rng = getRNG(realX, realZ); RNG rng = getRNG(realX, realZ);
ResolvedDecorator decorator = DecoratorCore.pickDecorator(decorators.decorators(biome, getPart()), rng, realX, realZ); ResolvedDecorator decorator = DecoratorCore.pickDecorator(decorators.decorators(biome, getPart()), rng, realX, realZ, decorators.log());
if (decorator == null || !isSlopeValid(decorator, realX, realZ)) { if (decorator == null || !isSlopeValid(decorator, realX, realZ)) {
return; return;
@@ -75,7 +75,7 @@ public class IrisSurfaceDecorator extends IrisEngineDecorator {
} }
DecoratorCore.placeSurfaceSingle(decorator, x, z, realX, height, realZ, DecoratorCore.placeSurfaceSingle(decorator, x, z, realX, height, realZ,
data, underwater, caveSkipFluid, getEngine().getMantle()); data, underwater, caveSkipFluid, getEngine().getMantle(), decorators.log());
} }
static boolean isUnderwater(InferredType inferredType, int height, int fluidHeight) { static boolean isUnderwater(InferredType inferredType, int height, int fluidHeight) {
@@ -23,9 +23,9 @@ import art.arcane.iris.builtin.decorant.Decorator;
import art.arcane.iris.engine.data.cache.AtomicCache; import art.arcane.iris.engine.data.cache.AtomicCache;
import art.arcane.iris.engine.framework.Engine; import art.arcane.iris.engine.framework.Engine;
import art.arcane.iris.engine.object.world.biome.IrisBiome; import art.arcane.iris.engine.object.world.biome.IrisBiome;
import art.arcane.iris.spi.IrisLogging;
import art.arcane.iris.spi.PlatformBlockState; import art.arcane.iris.spi.PlatformBlockState;
import art.arcane.iris.util.common.data.B; import art.arcane.iris.util.common.data.B;
import com.volmit.ModuleLog;
import com.volmit.block.BlockRegistry; import com.volmit.block.BlockRegistry;
import com.volmit.block.BlockSpec; import com.volmit.block.BlockSpec;
import com.volmit.noise.NoiseFactory; import com.volmit.noise.NoiseFactory;
@@ -57,6 +57,7 @@ final class ResolvedDecorator {
private final AtomicCache<NoiseSampler> chanceNoise = new AtomicCache<>(); private final AtomicCache<NoiseSampler> chanceNoise = new AtomicCache<>();
private final AtomicCache<NoiseSampler> varianceNoise = new AtomicCache<>(); private final AtomicCache<NoiseSampler> varianceNoise = new AtomicCache<>();
private final AtomicCache<NoiseSampler> heightNoise = new AtomicCache<>(); private final AtomicCache<NoiseSampler> heightNoise = new AtomicCache<>();
private final ModuleLog log;
/** /**
* @param blocks the palette as the platform's blocks, each repeated by its weight * @param blocks the palette as the platform's blocks, each repeated by its weight
@@ -64,9 +65,11 @@ final class ResolvedDecorator {
* @param forceBlock the block it forces onto the surface, or null * @param forceBlock the block it forces onto the surface, or null
* @param whitelist the blocks it may only be placed onto; ignored unless the decorator has a whitelist * @param whitelist the blocks it may only be placed onto; ignored unless the decorator has a whitelist
* @param blacklist the blocks it is never placed onto; ignored unless the decorator has a blacklist * @param blacklist the blocks it is never placed onto; ignored unless the decorator has a blacklist
* @param log the log of the module that decorates
*/ */
ResolvedDecorator(Decorator settings, long seed, NoiseFactory noise, List<PlatformBlockState> blocks, List<PlatformBlockState> topBlocks, ResolvedDecorator(Decorator settings, long seed, NoiseFactory noise, List<PlatformBlockState> blocks, List<PlatformBlockState> topBlocks,
PlatformBlockState forceBlock, List<PlatformBlockState> whitelist, List<PlatformBlockState> blacklist) { PlatformBlockState forceBlock, List<PlatformBlockState> whitelist, List<PlatformBlockState> blacklist,
ModuleLog log) {
this.settings = settings; this.settings = settings;
this.seed = seed; this.seed = seed;
this.noise = noise; this.noise = noise;
@@ -77,15 +80,16 @@ final class ResolvedDecorator {
this.forceBlock = forceBlock; this.forceBlock = forceBlock;
this.whitelist = whitelist.toArray(new PlatformBlockState[0]); this.whitelist = whitelist.toArray(new PlatformBlockState[0]);
this.blacklist = blacklist.toArray(new PlatformBlockState[0]); this.blacklist = blacklist.toArray(new PlatformBlockState[0]);
this.log = log;
} }
/** {@code settings} ready for {@code engine}: its blocks resolved through the pack, its noise seeded from {@code seed}. */ /** {@code settings} ready for {@code engine}: its blocks resolved through the pack, its noise seeded from {@code seed}. */
static ResolvedDecorator of(Decorator settings, Engine engine, long seed) { static ResolvedDecorator of(Decorator settings, Engine engine, long seed, ModuleLog log) {
var resources = engine.getData().getPackResources(); var resources = engine.getData().getPackResources();
BlockRegistry registry = resources.blocks(); BlockRegistry registry = resources.blocks();
PlatformBlockState forced = settings.forceBlock().map(spec -> platformState(registry, spec)).orElse(null); PlatformBlockState forced = settings.forceBlock().map(spec -> platformState(registry, spec)).orElse(null);
return new ResolvedDecorator(settings, seed, resources.noise(), weighted(registry, settings.palette()), return new ResolvedDecorator(settings, seed, resources.noise(), weighted(registry, settings.palette()),
weighted(registry, settings.topPalette()), forced, each(registry, settings.whitelist()), each(registry, settings.blacklist())); weighted(registry, settings.topPalette()), forced, each(registry, settings.whitelist()), each(registry, settings.blacklist()), log);
} }
private static PlatformBlockState platformState(BlockRegistry registry, BlockSpec spec) { private static PlatformBlockState platformState(BlockRegistry registry, BlockSpec spec) {
@@ -195,7 +199,7 @@ final class ResolvedDecorator {
/** The block of the palette at the position, for decorations that fill a column block by block; null when the palette has no block. */ /** The block of the palette at the position, for decorations that fill a column block by block; null when the palette has no block. */
PlatformBlockState blockAt(IrisBiome biome, double x, double y, double z) { PlatformBlockState blockAt(IrisBiome biome, double x, double y, double z) {
if (blocks.isEmpty()) { if (blocks.isEmpty()) {
IrisLogging.warnOnce("decorator-empty:" + biome.getName(), "Empty Block Data for " + biome.getName()); log.warnOnce("decorator-empty:" + biome.getName(), "Empty Block Data for " + biome.getName());
return null; return null;
} }
@@ -39,8 +39,10 @@ import art.arcane.iris.engine.object.structure.vanilla.NativeStructureSuppressio
import art.arcane.iris.engine.object.structure.StructureDistribution; import art.arcane.iris.engine.object.structure.StructureDistribution;
import art.arcane.volmlib.util.collection.KList; import art.arcane.volmlib.util.collection.KList;
import art.arcane.volmlib.util.math.RNG; import art.arcane.volmlib.util.math.RNG;
import art.arcane.iris.core.modules.IrisModuleHost;
import com.github.benmanes.caffeine.cache.Cache; import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine; import com.github.benmanes.caffeine.cache.Caffeine;
import com.volmit.ModuleLog;
import it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap; import it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap;
import java.util.ArrayList; import java.util.ArrayList;
@@ -509,14 +511,14 @@ public final class IrisStructureLocator {
throw new IllegalStateException("Iris structure placement references missing structure '" throw new IllegalStateException("Iris structure placement references missing structure '"
+ selectedKey + "'"); + selectedKey + "'");
} }
StructureGraphCompilation compilation = StructureGraphCatalog.compile(engine.getData(), structure); StructureGraphCompilation compilation = StructureGraphCatalog.compile(engine.getData(), structure, IrisModuleHost.hostLog());
if (!compilation.isAssemblyViable()) { if (!compilation.isAssemblyViable()) {
throw new IllegalStateException("Iris structure '" + selectedKey throw new IllegalStateException("Iris structure '" + selectedKey
+ "' has no runtime-viable assembly graph"); + "' has no runtime-viable assembly graph");
} }
StructureAssembler assembler = StructureAssembler.forData( StructureAssembler assembler = StructureAssembler.forData(
engine.getData(), structure, new IrisPosition(originX, baseY, originZ)); engine.getData(), structure, new IrisPosition(originX, baseY, originZ), IrisModuleHost.hostLog());
StructureAssemblyResult assembly = assembler.assemble(rng); StructureAssemblyResult assembly = assembler.assemble(rng);
if (!requirePlacementOutput(placement, selectedKey, cx, cz, if (!requirePlacementOutput(placement, selectedKey, cx, cz,
assembly.hasOutput(), "runtime assembly produced " + assembly.status() + ": " + assembly.detail())) { assembly.hasOutput(), "runtime assembly produced " + assembly.status() + ": " + assembly.detail())) {
@@ -1118,17 +1120,18 @@ public final class IrisStructureLocator {
private static PlacementIndex build(Engine engine) { private static PlacementIndex build(Engine engine) {
IrisData data = engine.getData(); IrisData data = engine.getData();
ModuleLog log = IrisModuleHost.hostLog();
Set<String> loadKeys = new LinkedHashSet<>(); Set<String> loadKeys = new LinkedHashSet<>();
Set<String> normalizedLoadKeys = new LinkedHashSet<>(); Set<String> normalizedLoadKeys = new LinkedHashSet<>();
Set<String> vanillaAliases = new LinkedHashSet<>(); Set<String> vanillaAliases = new LinkedHashSet<>();
Set<String> suppressedVanillaSources = new LinkedHashSet<>(); Set<String> suppressedVanillaSources = new LinkedHashSet<>();
List<IrisStructurePlacement> placements = new ArrayList<>(); List<IrisStructurePlacement> placements = new ArrayList<>();
collect(engine.getDimension().getStructures(), data, loadKeys, normalizedLoadKeys, vanillaAliases, collect(engine.getDimension().getStructures(), data, log, loadKeys, normalizedLoadKeys, vanillaAliases,
suppressedVanillaSources, placements, true); suppressedVanillaSources, placements, true);
KList<IrisRegion> regions = engine.getDimension().getAllRegions(engine); KList<IrisRegion> regions = engine.getDimension().getAllRegions(engine);
if (regions != null) { if (regions != null) {
for (IrisRegion region : regions) { for (IrisRegion region : regions) {
collect(region == null ? null : region.getStructures(), data, collect(region == null ? null : region.getStructures(), data, log,
loadKeys, normalizedLoadKeys, vanillaAliases, loadKeys, normalizedLoadKeys, vanillaAliases,
suppressedVanillaSources, placements, false); suppressedVanillaSources, placements, false);
} }
@@ -1136,7 +1139,7 @@ public final class IrisStructureLocator {
KList<IrisBiome> biomes = engine.getDimension().getReachableBiomes(engine); KList<IrisBiome> biomes = engine.getDimension().getReachableBiomes(engine);
if (biomes != null) { if (biomes != null) {
for (IrisBiome biome : biomes) { for (IrisBiome biome : biomes) {
collect(biome == null ? null : biome.getStructures(), data, collect(biome == null ? null : biome.getStructures(), data, log,
loadKeys, normalizedLoadKeys, vanillaAliases, loadKeys, normalizedLoadKeys, vanillaAliases,
suppressedVanillaSources, placements, false); suppressedVanillaSources, placements, false);
} }
@@ -1165,7 +1168,7 @@ public final class IrisStructureLocator {
return Collections.unmodifiableSet(nativeKeys); return Collections.unmodifiableSet(nativeKeys);
} }
private static void collect(KList<IrisStructurePlacement> source, IrisData data, Set<String> loadKeys, private static void collect(KList<IrisStructurePlacement> source, IrisData data, ModuleLog log, Set<String> loadKeys,
Set<String> normalizedLoadKeys, Set<String> vanillaAliases, Set<String> normalizedLoadKeys, Set<String> vanillaAliases,
Set<String> suppressedVanillaSources, Set<String> suppressedVanillaSources,
List<IrisStructurePlacement> placements, boolean allowNativeSuppression) { List<IrisStructurePlacement> placements, boolean allowNativeSuppression) {
@@ -1230,7 +1233,7 @@ public final class IrisStructureLocator {
throw new IllegalStateException("REPLACE_SOURCE structure '" + structureKey throw new IllegalStateException("REPLACE_SOURCE structure '" + structureKey
+ "' must declare a valid namespaced vanillaSource"); + "' must declare a valid namespaced vanillaSource");
} }
if (!StructureGraphCatalog.guaranteesRuntimeOutput(data, structure)) { if (!StructureGraphCatalog.guaranteesRuntimeOutput(data, structure, log)) {
throw new IllegalStateException("REPLACE_SOURCE structure '" + structureKey throw new IllegalStateException("REPLACE_SOURCE structure '" + structureKey
+ "' is not runtime-viable; native generation will not be used as a fallback"); + "' is not runtime-viable; native generation will not be used as a fallback");
} }
@@ -45,6 +45,7 @@ import art.arcane.iris.engine.object.structure.jigsaw.JigsawJoint;
import art.arcane.volmlib.util.collection.KList; import art.arcane.volmlib.util.collection.KList;
import art.arcane.volmlib.util.math.RNG; import art.arcane.volmlib.util.math.RNG;
import com.volmit.ModuleLog;
import java.util.ArrayDeque; import java.util.ArrayDeque;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
@@ -89,11 +90,11 @@ public final class StructureAssembler {
? this.structure.getMaxSizeChunks() * 16 : 0; ? this.structure.getMaxSizeChunks() * 16 : 0;
} }
public static StructureAssembler forData(IrisData data, IrisStructure structure, IrisPosition origin) { public static StructureAssembler forData(IrisData data, IrisStructure structure, IrisPosition origin, ModuleLog log) {
IrisData activeData = Objects.requireNonNull(data, "Structure assembly data must not be null"); IrisData activeData = Objects.requireNonNull(data, "Structure assembly data must not be null");
IrisStructure activeStructure = Objects.requireNonNull( IrisStructure activeStructure = Objects.requireNonNull(
structure, "Structure assembly structure must not be null"); structure, "Structure assembly structure must not be null");
return forCompilation(StructureGraphCatalog.compile(activeData, activeStructure), origin); return forCompilation(StructureGraphCatalog.compile(activeData, activeStructure, log), origin);
} }
public static StructureAssembler forResolver(StructureGraphResolver resolver, IrisStructure structure, public static StructureAssembler forResolver(StructureGraphResolver resolver, IrisStructure structure,
@@ -5,11 +5,11 @@ import art.arcane.iris.core.modules.IrisPackResources;
import art.arcane.iris.engine.framework.StructureAssembler; import art.arcane.iris.engine.framework.StructureAssembler;
import art.arcane.iris.engine.object.value.IrisPosition; import art.arcane.iris.engine.object.value.IrisPosition;
import art.arcane.iris.engine.object.structure.IrisStructure; import art.arcane.iris.engine.object.structure.IrisStructure;
import art.arcane.iris.spi.IrisLogging;
import art.arcane.volmlib.util.math.RNG; import art.arcane.volmlib.util.math.RNG;
import com.github.benmanes.caffeine.cache.Cache; import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine; import com.github.benmanes.caffeine.cache.Caffeine;
import com.volmit.ModuleLog;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
@@ -30,35 +30,35 @@ public final class StructureGraphCatalog {
private StructureGraphCatalog() { private StructureGraphCatalog() {
} }
public static StructureGraphCompilation compile(IrisData data, IrisStructure structure) { public static StructureGraphCompilation compile(IrisData data, IrisStructure structure, ModuleLog log) {
IrisData activeData = Objects.requireNonNull(data); IrisData activeData = Objects.requireNonNull(data);
IrisStructure activeStructure = Objects.requireNonNull(structure); IrisStructure activeStructure = Objects.requireNonNull(structure);
String structureKey = activeStructure.getLoadKey(); String structureKey = activeStructure.getLoadKey();
if (structureKey == null || structureKey.isBlank()) { if (structureKey == null || structureKey.isBlank()) {
return compileAndReport(activeData, activeStructure); return compileAndReport(activeData, activeStructure, log);
} }
ConcurrentMap<String, StructureGraphCompilation> catalog = CACHE.get( ConcurrentMap<String, StructureGraphCompilation> catalog = CACHE.get(
activeData.getPackResources(), ignored -> new ConcurrentHashMap<>()); activeData.getPackResources(), ignored -> new ConcurrentHashMap<>());
return catalog.computeIfAbsent(structureKey, ignored -> compileAndReport(activeData, activeStructure)); return catalog.computeIfAbsent(structureKey, ignored -> compileAndReport(activeData, activeStructure, log));
} }
public static boolean guaranteesRuntimeOutput(IrisData data, IrisStructure structure) { public static boolean guaranteesRuntimeOutput(IrisData data, IrisStructure structure, ModuleLog log) {
IrisData activeData = Objects.requireNonNull(data); IrisData activeData = Objects.requireNonNull(data);
IrisStructure activeStructure = Objects.requireNonNull(structure); IrisStructure activeStructure = Objects.requireNonNull(structure);
if (!compile(activeData, activeStructure).guaranteesAssemblyOutput()) { if (!compile(activeData, activeStructure, log).guaranteesAssemblyOutput()) {
return false; return false;
} }
String structureKey = activeStructure.getLoadKey(); String structureKey = activeStructure.getLoadKey();
if (structureKey == null || structureKey.isBlank()) { if (structureKey == null || structureKey.isBlank()) {
return sampleRuntimeAssembly(activeData, activeStructure); return sampleRuntimeAssembly(activeData, activeStructure, log);
} }
ConcurrentMap<String, Boolean> catalog = RUNTIME_OUTPUT.get( ConcurrentMap<String, Boolean> catalog = RUNTIME_OUTPUT.get(
activeData.getPackResources(), ignored -> new ConcurrentHashMap<>()); activeData.getPackResources(), ignored -> new ConcurrentHashMap<>());
return catalog.computeIfAbsent( return catalog.computeIfAbsent(
structureKey, ignored -> sampleRuntimeAssembly(activeData, activeStructure)); structureKey, ignored -> sampleRuntimeAssembly(activeData, activeStructure, log));
} }
private static StructureGraphCompilation compileAndReport(IrisData data, IrisStructure structure) { private static StructureGraphCompilation compileAndReport(IrisData data, IrisStructure structure, ModuleLog log) {
StructureGraphCompilation compilation = StructureGraphCompiler.compile( StructureGraphCompilation compilation = StructureGraphCompiler.compile(
structure, StructureGraphResolver.forData(data)); structure, StructureGraphResolver.forData(data));
String structureKey = structure.getLoadKey() == null || structure.getLoadKey().isBlank() String structureKey = structure.getLoadKey() == null || structure.getLoadKey().isBlank()
@@ -66,29 +66,29 @@ public final class StructureGraphCatalog {
for (StructureGraphDiagnostic diagnostic : compilation.getDiagnostics()) { for (StructureGraphDiagnostic diagnostic : compilation.getDiagnostics()) {
String message = "[StructureGraph:" + structureKey + "] " + diagnostic.message(); String message = "[StructureGraph:" + structureKey + "] " + diagnostic.message();
if (diagnostic.severity() == StructureGraphDiagnostic.Severity.ERROR) { if (diagnostic.severity() == StructureGraphDiagnostic.Severity.ERROR) {
IrisLogging.error(message); log.error(message, null);
} else { } else {
IrisLogging.warn(message); log.warn(message);
} }
} }
if (!compilation.isAssemblyViable()) { if (!compilation.isAssemblyViable()) {
IrisLogging.error("[StructureGraph:" + structureKey log.error("[StructureGraph:" + structureKey
+ "] Graph rejected because deterministic assembly did not complete."); + "] Graph rejected because deterministic assembly did not complete.", null);
} }
return compilation; return compilation;
} }
private static boolean sampleRuntimeAssembly(IrisData data, IrisStructure structure) { private static boolean sampleRuntimeAssembly(IrisData data, IrisStructure structure, ModuleLog log) {
for (long seed : RUNTIME_SAMPLE_SEEDS) { for (long seed : RUNTIME_SAMPLE_SEEDS) {
try { try {
StructureAssembler assembler = StructureAssembler.forData( StructureAssembler assembler = StructureAssembler.forData(
data, structure, new IrisPosition(0, 64, 0)); data, structure, new IrisPosition(0, 64, 0), log);
StructureAssemblyResult result = assembler.assemble(new RNG(seed)); StructureAssemblyResult result = assembler.assemble(new RNG(seed));
if (!result.hasOutput()) { if (!result.hasOutput()) {
return false; return false;
} }
} catch (Throwable e) { } catch (Throwable e) {
IrisLogging.reportError(e); log.error("Failed to sample the runtime assembly of a structure", e);
return false; return false;
} }
} }
@@ -90,7 +90,7 @@ public final class StructureFitting {
private void prepare() { private void prepare() {
vacuumFoundations = SurfaceFitting.prepareSurfaceStructures(blocks, area, starts, surfaceHeight, vacuumFoundations = SurfaceFitting.prepareSurfaceStructures(blocks, area, starts, surfaceHeight,
SurfaceFitting.MAX_SURFACE_TEMPLATE_CELLS); SurfaceFitting.MAX_SURFACE_TEMPLATE_CELLS, fit.log());
TerrainIntegration.prepareTerrain(blocks, area, starts, fit.seed(), this::naturalBlock, this::paletteBlock); TerrainIntegration.prepareTerrain(blocks, area, starts, fit.seed(), this::naturalBlock, this::paletteBlock);
RigidSupport.bridgeRigidPieceSupport(blocks, area, starts); RigidSupport.bridgeRigidPieceSupport(blocks, area, starts);
} }
@@ -20,7 +20,7 @@ package art.arcane.iris.engine.framework.structure.fit;
import art.arcane.iris.builtin.structure.StructureTerrainMode; import art.arcane.iris.builtin.structure.StructureTerrainMode;
import art.arcane.iris.engine.object.placement.IrisObjectVacuum; import art.arcane.iris.engine.object.placement.IrisObjectVacuum;
import art.arcane.iris.spi.IrisLogging; import com.volmit.ModuleLog;
import com.volmit.block.BlockState; import com.volmit.block.BlockState;
import com.volmit.vanilla.StructureStep; import com.volmit.vanilla.StructureStep;
import com.volmit.vanilla.TemplateCells; import com.volmit.vanilla.TemplateCells;
@@ -66,16 +66,17 @@ final class SurfaceFitting {
} }
static VacuumFoundationPlan prepareSurfaceStructures(FitBlocks blocks, Box area, List<FitStart> starts, static VacuumFoundationPlan prepareSurfaceStructures(FitBlocks blocks, Box area, List<FitStart> starts,
IntBinaryOperator surfaceHeight, int maximumTemplateCells) { IntBinaryOperator surfaceHeight, int maximumTemplateCells,
ModuleLog log) {
if (starts.isEmpty()) { if (starts.isEmpty()) {
return VacuumFoundationPlan.EMPTY; return VacuumFoundationPlan.EMPTY;
} }
Objects.requireNonNull(surfaceHeight, "Surface structure terrain fitting requires an Iris height resolver"); Objects.requireNonNull(surfaceHeight, "Surface structure terrain fitting requires an Iris height resolver");
List<SurfaceAnchor> anchors = collectSourceSurfaceAnchors(blocks, area, starts, maximumTemplateCells); List<SurfaceAnchor> anchors = collectSourceSurfaceAnchors(blocks, area, starts, maximumTemplateCells, log);
if (!anchors.isEmpty()) { if (!anchors.isEmpty()) {
fitSurfaceTerrain(blocks, area, anchors, surfaceHeight); fitSurfaceTerrain(blocks, area, anchors, surfaceHeight);
} }
VacuumFootprint vacuum = collectVacuumFootprint(blocks, area, starts, maximumTemplateCells); VacuumFootprint vacuum = collectVacuumFootprint(blocks, area, starts, maximumTemplateCells, log);
if (!vacuum.anchors().isEmpty()) { if (!vacuum.anchors().isEmpty()) {
fitVacuumTerrain(blocks, area, vacuum, surfaceHeight); fitVacuumTerrain(blocks, area, vacuum, surfaceHeight);
} }
@@ -208,7 +209,7 @@ final class SurfaceFitting {
} }
private static List<SurfaceAnchor> collectSourceSurfaceAnchors(FitBlocks blocks, Box area, List<FitStart> starts, private static List<SurfaceAnchor> collectSourceSurfaceAnchors(FitBlocks blocks, Box area, List<FitStart> starts,
int maximumTemplateCells) { int maximumTemplateCells, ModuleLog log) {
Box influenceArea = area.widened(SURFACE_TERRAIN_RADIUS); Box influenceArea = area.widened(SURFACE_TERRAIN_RADIUS);
List<SurfaceAnchor> anchors = new ArrayList<>(); List<SurfaceAnchor> anchors = new ArrayList<>();
Set<Object> seenStarts = Collections.newSetFromMap(new IdentityHashMap<>()); Set<Object> seenStarts = Collections.newSetFromMap(new IdentityHashMap<>());
@@ -228,7 +229,7 @@ final class SurfaceFitting {
} catch (TemplateBudgetExceeded ignored) { } catch (TemplateBudgetExceeded ignored) {
budgetExceeded = true; budgetExceeded = true;
warnBudget(WARNED_SOURCE_BUDGET, start, "SOURCE", warnBudget(WARNED_SOURCE_BUDGET, start, "SOURCE",
"skipping remaining processed footprints for this start"); "skipping remaining processed footprints for this start", log);
} }
} }
for (BlockPosition junction : piece.junctions()) { for (BlockPosition junction : piece.junctions()) {
@@ -263,15 +264,15 @@ final class SurfaceFitting {
} }
} }
private static void warnBudget(Set<String> warned, FitStart start, String mode, String consequence) { private static void warnBudget(Set<String> warned, FitStart start, String mode, String consequence, ModuleLog log) {
if (warned.add(start.structureId())) { if (warned.add(start.structureId())) {
IrisLogging.warn("Native structure " + mode + " fitting for '" + start.structureId() log.warn("Native structure " + mode + " fitting for '" + start.structureId()
+ "' exceeded its bounded template budget; " + consequence); + "' exceeded its bounded template budget; " + consequence);
} }
} }
private static VacuumFootprint collectVacuumFootprint(FitBlocks blocks, Box area, List<FitStart> starts, private static VacuumFootprint collectVacuumFootprint(FitBlocks blocks, Box area, List<FitStart> starts,
int maximumTemplateCells) { int maximumTemplateCells, ModuleLog log) {
Box influenceArea = area.widened(SURFACE_TERRAIN_RADIUS); Box influenceArea = area.widened(SURFACE_TERRAIN_RADIUS);
Map<Long, VacuumAnchor> anchors = new HashMap<>(); Map<Long, VacuumAnchor> anchors = new HashMap<>();
Map<Long, Integer> columnCaps = new HashMap<>(); Map<Long, Integer> columnCaps = new HashMap<>();
@@ -316,7 +317,7 @@ final class SurfaceFitting {
} }
} }
} catch (TemplateBudgetExceeded ignored) { } catch (TemplateBudgetExceeded ignored) {
warnBudget(WARNED_VACUUM_BUDGET, start, "VACUUM", "using jigsaw junction smoothing for oversized starts"); warnBudget(WARNED_VACUUM_BUDGET, start, "VACUUM", "using jigsaw junction smoothing for oversized starts", log);
continue; continue;
} }
targetAnchors.forEach((column, anchor) -> anchors.merge(column, anchor, SurfaceFitting::preferredVacuumAnchor)); targetAnchors.forEach((column, anchor) -> anchors.merge(column, anchor, SurfaceFitting::preferredVacuumAnchor));
@@ -82,7 +82,7 @@ public final class LootGiving implements Loot {
private static PlacementLoot placementLoot(PackWorld world, Engine engine) { private static PlacementLoot placementLoot(PackWorld world, Engine engine) {
PlatformLootTables platformTables = world.state(PlatformLootTables.class, ignored -> new PlatformLootTables()); PlatformLootTables platformTables = world.state(PlatformLootTables.class, ignored -> new PlatformLootTables());
return new PlacementLoot(engine.getData(), platformTables::keys, lootSeed(engine)); return new PlacementLoot(engine.getData(), platformTables::keys, lootSeed(engine), world.log());
} }
private static IrisObjectPlacement placementAt(Engine engine, int x, int relativeY, int z) { private static IrisObjectPlacement placementAt(Engine engine, int x, int relativeY, int z) {
@@ -21,10 +21,10 @@ package art.arcane.iris.engine.loot;
import art.arcane.iris.core.loader.IrisData; import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.engine.framework.LootResolver; import art.arcane.iris.engine.framework.LootResolver;
import art.arcane.iris.engine.object.loot.IObjectLoot; import art.arcane.iris.engine.object.loot.IObjectLoot;
import art.arcane.iris.spi.IrisLogging;
import art.arcane.iris.spi.IrisPlatforms; import art.arcane.iris.spi.IrisPlatforms;
import art.arcane.iris.spi.PlatformBlockState; import art.arcane.iris.spi.PlatformBlockState;
import art.arcane.volmlib.util.math.RNG; import art.arcane.volmlib.util.math.RNG;
import com.volmit.ModuleLog;
import com.volmit.service.Loot; import com.volmit.service.Loot;
import java.util.ArrayList; import java.util.ArrayList;
@@ -46,12 +46,14 @@ final class PlacementLoot {
private final IrisData data; private final IrisData data;
private final Supplier<Set<String>> platformTables; private final Supplier<Set<String>> platformTables;
private final long lootSeed; 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 */ /** @param platformTables the keys of the loot tables the platform has, asked for only when a placement names one */
PlacementLoot(IrisData data, Supplier<Set<String>> platformTables, long lootSeed) { PlacementLoot(IrisData data, Supplier<Set<String>> platformTables, long lootSeed, ModuleLog log) {
this.data = data; this.data = data;
this.platformTables = platformTables; this.platformTables = platformTables;
this.lootSeed = lootSeed; this.lootSeed = lootSeed;
this.log = log;
} }
/** The platform's loot table keys, which a placement may name, in the form a placement names them. */ /** The platform's loot table keys, which a placement may name, in the form a placement names them. */
@@ -81,7 +83,7 @@ final class PlacementLoot {
} }
Loot.Source source = sourceOf.apply(entry.getName()); Loot.Source source = sourceOf.apply(entry.getName());
if (source == null) { if (source == null) {
IrisLogging.warn("Couldn't find loot table " + entry.getName()); log.warn("Couldn't find loot table " + entry.getName());
continue; continue;
} }
candidates.add(entry, data, new Candidate(source, entry.getWeight())); candidates.add(entry, data, new Candidate(source, entry.getWeight()));
@@ -27,6 +27,7 @@ import art.arcane.iris.engine.object.terrain.floating.FloatingChildren;
import art.arcane.iris.engine.object.terrain.floating.FloatingIslandBoundarySampler; import art.arcane.iris.engine.object.terrain.floating.FloatingIslandBoundarySampler;
import art.arcane.iris.engine.object.terrain.floating.FloatingIslandSample; import art.arcane.iris.engine.object.terrain.floating.FloatingIslandSample;
import art.arcane.iris.engine.object.world.biome.IrisBiome; import art.arcane.iris.engine.object.world.biome.IrisBiome;
import com.volmit.ModuleLog;
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.longs.LongOpenHashSet; import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@@ -39,13 +40,15 @@ final class FloatingIslandSampleResolver implements IslandObjectPlacer.SamplePro
private final FloatingIslandBoundarySampler boundarySampler; private final FloatingIslandBoundarySampler boundarySampler;
private final Long2ObjectOpenHashMap<FloatingIslandSample> sampleCache; private final Long2ObjectOpenHashMap<FloatingIslandSample> sampleCache;
private final LongOpenHashSet resolvedSamples; private final LongOpenHashSet resolvedSamples;
private final ModuleLog log;
FloatingIslandSampleResolver(EngineMantle engineMantle, FloatingIslandBoundarySampler boundarySampler) { FloatingIslandSampleResolver(EngineMantle engineMantle, FloatingIslandBoundarySampler boundarySampler, ModuleLog log) {
this.data = engineMantle.getData(); this.data = engineMantle.getData();
this.engine = engineMantle.getEngine(); this.engine = engineMantle.getEngine();
this.chunkHeight = engine.getHeight(); this.chunkHeight = engine.getHeight();
this.baseSeed = engine.getSeedManager().getTerrain() ^ FloatingIslands.FLOATING_BASE_SEED_SALT; this.baseSeed = engine.getSeedManager().getTerrain() ^ FloatingIslands.FLOATING_BASE_SEED_SALT;
this.boundarySampler = boundarySampler; this.boundarySampler = boundarySampler;
this.log = log;
this.sampleCache = new Long2ObjectOpenHashMap<>(); this.sampleCache = new Long2ObjectOpenHashMap<>();
this.resolvedSamples = new LongOpenHashSet(); this.resolvedSamples = new LongOpenHashSet();
} }
@@ -61,7 +64,7 @@ final class FloatingIslandSampleResolver implements IslandObjectPlacer.SamplePro
resolvedSamples.add(key); resolvedSamples.add(key);
return null; return null;
} }
FloatingIslandSample sample = FloatingIslandSample.sample(parent, x, z, chunkHeight, baseSeed, data, engine, boundarySampler); FloatingIslandSample sample = FloatingIslandSample.sample(parent, x, z, chunkHeight, baseSeed, data, engine, boundarySampler, log);
resolvedSamples.add(key); resolvedSamples.add(key);
if (sample != null) { if (sample != null) {
sampleCache.put(key, sample); sampleCache.put(key, sample);
@@ -35,7 +35,6 @@ import art.arcane.iris.engine.object.prefab.IrisObject;
import art.arcane.iris.engine.object.prefab.IrisObjectRotation; import art.arcane.iris.engine.object.prefab.IrisObjectRotation;
import art.arcane.iris.engine.object.prefab.IrisObjectTranslate; import art.arcane.iris.engine.object.prefab.IrisObjectTranslate;
import art.arcane.iris.engine.object.procedural.IrisProceduralBlocks; import art.arcane.iris.engine.object.procedural.IrisProceduralBlocks;
import art.arcane.iris.spi.IrisLogging;
import art.arcane.iris.spi.PlatformBlockState; import art.arcane.iris.spi.PlatformBlockState;
import art.arcane.iris.util.common.data.B; import art.arcane.iris.util.common.data.B;
import art.arcane.iris.util.common.math.IrisBlockVector; import art.arcane.iris.util.common.math.IrisBlockVector;
@@ -44,6 +43,7 @@ import art.arcane.volmlib.util.collection.KList;
import art.arcane.volmlib.util.documentation.ChunkCoordinates; import art.arcane.volmlib.util.documentation.ChunkCoordinates;
import art.arcane.volmlib.util.math.RNG; import art.arcane.volmlib.util.math.RNG;
import com.volmit.ModuleLog;
import java.io.File; import java.io.File;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
@@ -62,9 +62,11 @@ public class FloatingObjectPlacing {
private static final IrisObjectRotation ROTATION_NONE = IrisObjectRotation.of(0, 0, 0); private static final IrisObjectRotation ROTATION_NONE = IrisObjectRotation.of(0, 0, 0);
private final Engine engine; private final Engine engine;
private final ModuleLog log;
public FloatingObjectPlacing(Engine engine) { public FloatingObjectPlacing(Engine engine, ModuleLog log) {
this.engine = engine; this.engine = engine;
this.log = log;
} }
/** Places what originates in the chunk at chunk coordinates {@code x}, {@code z} into {@code writer}. */ /** Places what originates in the chunk at chunk coordinates {@code x}, {@code z} into {@code writer}. */
@@ -74,7 +76,7 @@ public class FloatingObjectPlacing {
int minX = x << 4; int minX = x << 4;
int minZ = z << 4; int minZ = z << 4;
RNG chunkRng = new RNG(Cache.key(x, z) + engine.getSeedManager().getMantle() + 0x0FA710BEL); RNG chunkRng = new RNG(Cache.key(x, z) + engine.getSeedManager().getMantle() + 0x0FA710BEL);
FloatingIslandSampleResolver sampleResolver = new FloatingIslandSampleResolver(engine.getMantle(), context.getFloatingIslandBoundarySampler()); FloatingIslandSampleResolver sampleResolver = new FloatingIslandSampleResolver(engine.getMantle(), context.getFloatingIslandBoundarySampler(), log);
FloatingIslandSample.clearChunkMemo(); FloatingIslandSample.clearChunkMemo();
@@ -212,7 +214,7 @@ public class FloatingObjectPlacing {
} }
}, null, data); }, null, data);
} catch (Throwable e) { } catch (Throwable e) {
IrisLogging.reportError(e); log.error("Failed to place a floating object", e);
} }
} }
} }
@@ -297,7 +299,7 @@ public class FloatingObjectPlacing {
} }
} catch (Throwable e) { } catch (Throwable e) {
transaction.discard(); transaction.discard();
IrisLogging.reportError(e); log.error("Failed to place an anchored floating object", e);
} }
} }
} }
@@ -399,7 +401,7 @@ public class FloatingObjectPlacing {
} }
} catch (Throwable e) { } catch (Throwable e) {
transaction.discard(); transaction.discard();
IrisLogging.reportError(e); log.error("Failed to place an inverted floating object", e);
} }
} }
} }
@@ -559,12 +561,12 @@ public class FloatingObjectPlacing {
maxObjectExtent = Math.max(maxObjectExtent, computePlacementRadius(entry.resolveBottomObjects(target), data, sizeCache, warnedLargeObjects)); maxObjectExtent = Math.max(maxObjectExtent, computePlacementRadius(entry.resolveBottomObjects(target), data, sizeCache, warnedLargeObjects));
} }
} catch (Throwable e) { } catch (Throwable e) {
IrisLogging.reportError(e); log.error("Failed to work out the reach of a floating biome's objects", e);
} }
} }
} }
} catch (Throwable e) { } catch (Throwable e) {
IrisLogging.reportError(e); log.error("Failed to work out the reach of the floating biomes' objects", e);
} }
return maxObjectExtent; return maxObjectExtent;
} }
@@ -593,11 +595,11 @@ public class FloatingObjectPlacing {
} }
int reach = ObjectPlacing.calculatePlacementReach(size, placement); int reach = ObjectPlacing.calculatePlacementReach(size, placement);
if (reach > 128 && warnedLargeObjects.add(objectKey)) { if (reach > 128 && warnedLargeObjects.add(objectKey)) {
IrisLogging.warn("Floating object " + objectKey + " has a large placement reach (" + reach + " blocks) and may increase memory usage!"); log.warn("Floating object " + objectKey + " has a large placement reach (" + reach + " blocks) and may increase memory usage!");
} }
radius = Math.max(radius, reach); radius = Math.max(radius, reach);
} catch (Throwable e) { } catch (Throwable e) {
IrisLogging.reportError(e); log.error("Failed to size a floating object", e);
} }
} }
} }
@@ -22,8 +22,8 @@ import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.engine.framework.Engine; import art.arcane.iris.engine.framework.Engine;
import art.arcane.iris.engine.object.placement.IObjectPlacer; import art.arcane.iris.engine.object.placement.IObjectPlacer;
import art.arcane.iris.engine.object.prefab.TileData; import art.arcane.iris.engine.object.prefab.TileData;
import art.arcane.iris.spi.IrisLogging;
import art.arcane.iris.spi.PlatformBlockState; import art.arcane.iris.spi.PlatformBlockState;
import com.volmit.ModuleLog;
final class GoldenDebugObjectPlacer implements IObjectPlacer { final class GoldenDebugObjectPlacer implements IObjectPlacer {
private static final int[] GOLDEN_DEBUG_TARGET = parseGoldenDebugTarget(resolveGoldenDebugSpec()); private static final int[] GOLDEN_DEBUG_TARGET = parseGoldenDebugTarget(resolveGoldenDebugSpec());
@@ -31,10 +31,12 @@ final class GoldenDebugObjectPlacer implements IObjectPlacer {
private final IObjectPlacer delegate; private final IObjectPlacer delegate;
private final String tag; private final String tag;
private final ModuleLog log;
GoldenDebugObjectPlacer(IObjectPlacer delegate, String tag) { GoldenDebugObjectPlacer(IObjectPlacer delegate, String tag, ModuleLog log) {
this.delegate = delegate; this.delegate = delegate;
this.tag = tag; this.tag = tag;
this.log = log;
} }
private static String resolveGoldenDebugSpec() { private static String resolveGoldenDebugSpec() {
@@ -77,14 +79,14 @@ final class GoldenDebugObjectPlacer implements IObjectPlacer {
@Override @Override
public int getHighest(int x, int z, IrisData data) { public int getHighest(int x, int z, IrisData data) {
int result = delegate.getHighest(x, z, data); int result = delegate.getHighest(x, z, data);
IrisLogging.debug("Goldendebug query: tag=" + tag + " getHighest(" + x + "," + z + ")=" + result); log.debug("Goldendebug query: tag=" + tag + " getHighest(" + x + "," + z + ")=" + result);
return result; return result;
} }
@Override @Override
public int getHighest(int x, int z, IrisData data, boolean ignoreFluid) { public int getHighest(int x, int z, IrisData data, boolean ignoreFluid) {
int result = delegate.getHighest(x, z, data, ignoreFluid); int result = delegate.getHighest(x, z, data, ignoreFluid);
IrisLogging.debug("Goldendebug query: tag=" + tag + " getHighest(" + x + "," + z + ",ignoreFluid=" + ignoreFluid + ")=" + result); log.debug("Goldendebug query: tag=" + tag + " getHighest(" + x + "," + z + ",ignoreFluid=" + ignoreFluid + ")=" + result);
return result; return result;
} }
@@ -106,7 +108,7 @@ final class GoldenDebugObjectPlacer implements IObjectPlacer {
@Override @Override
public boolean isCarved(int x, int y, int z) { public boolean isCarved(int x, int y, int z) {
boolean result = delegate.isCarved(x, y, z); boolean result = delegate.isCarved(x, y, z);
IrisLogging.debug("Goldendebug query: tag=" + tag + " isCarved(" + x + "," + y + "," + z + ")=" + result); log.debug("Goldendebug query: tag=" + tag + " isCarved(" + x + "," + y + "," + z + ")=" + result);
return result; return result;
} }
@@ -118,7 +120,7 @@ final class GoldenDebugObjectPlacer implements IObjectPlacer {
@Override @Override
public boolean isSolid(int x, int y, int z) { public boolean isSolid(int x, int y, int z) {
boolean result = delegate.isSolid(x, y, z); boolean result = delegate.isSolid(x, y, z);
IrisLogging.debug("Goldendebug query: tag=" + tag + " isSolid(" + x + "," + y + "," + z + ")=" + result); log.debug("Goldendebug query: tag=" + tag + " isSolid(" + x + "," + y + "," + z + ")=" + result);
return result; return result;
} }
@@ -36,7 +36,7 @@ import java.util.Set;
public final class ObjectLocating implements ObjectsAt { public final class ObjectLocating implements ObjectsAt {
@Override @Override
public Set<String> objectsAt(PackWorld world, int chunkX, int chunkZ) { public Set<String> objectsAt(PackWorld world, int chunkX, int chunkZ) {
return ObjectModule.placing(engine(world)).guess(chunkX, chunkZ); return ObjectModule.placing(engine(world), world.log()).guess(chunkX, chunkZ);
} }
@Override @Override
@@ -35,6 +35,7 @@ import com.volmit.FeatureRegistry;
import com.volmit.IrisModule; import com.volmit.IrisModule;
import com.volmit.ModuleInfo; import com.volmit.ModuleInfo;
import com.volmit.ModuleLifecycle; import com.volmit.ModuleLifecycle;
import com.volmit.ModuleLog;
import com.volmit.config.PackSettings; import com.volmit.config.PackSettings;
import com.volmit.service.ObjectsAt; import com.volmit.service.ObjectsAt;
import com.volmit.service.SaplingGrowth; import com.volmit.service.SaplingGrowth;
@@ -53,6 +54,8 @@ import com.volmit.world.PackWorld;
public final class ObjectModule implements IrisModule, ModuleLifecycle { public final class ObjectModule implements IrisModule, ModuleLifecycle {
private static final String VERSION = "built-in"; private static final String VERSION = "built-in";
private ModuleLog log;
@Override @Override
public ModuleInfo info() { public ModuleInfo info() {
return ModuleInfo.of("iris:objects", "Objects", VERSION); return ModuleInfo.of("iris:objects", "Objects", VERSION);
@@ -60,11 +63,12 @@ public final class ObjectModule implements IrisModule, ModuleLifecycle {
@Override @Override
public void install(StageGraph graph) { public void install(StageGraph graph) {
graph.define(IrisStages.Objects.PLACE).requires(IrisStages.Carve.CAVES).reach(ObjectModule::reach).run(ObjectModule::place); graph.define(IrisStages.Objects.PLACE).requires(IrisStages.Carve.CAVES).reach(this::reach).run(ObjectModule::place);
} }
@Override @Override
public void register(FeatureRegistry registry) { public void register(FeatureRegistry registry) {
log = registry.log();
registry.registerService(ObjectsAt.class, new ObjectLocating()); registry.registerService(ObjectsAt.class, new ObjectLocating());
registry.registerService(SaplingGrowth.class, new TreeGrowing()); registry.registerService(SaplingGrowth.class, new TreeGrowing());
registry.registerHeldType(TreeCanopy.class); registry.registerHeldType(TreeCanopy.class);
@@ -85,15 +89,15 @@ public final class ObjectModule implements IrisModule, ModuleLifecycle {
private static void place(MantleStageContext context) { private static void place(MantleStageContext context) {
IrisMantleChunk chunk = IrisMantleChunk.current(); IrisMantleChunk chunk = IrisMantleChunk.current();
placing(chunk.engine()).place(chunk.writer(), chunk.chunkX(), chunk.chunkZ(), chunk.context()); placing(chunk.engine(), context.log()).place(chunk.writer(), chunk.chunkX(), chunk.chunkZ(), chunk.context());
} }
private static int reach(PackSettings settings) { private int reach(PackSettings settings) {
return placing(IrisPackSettings.of(settings).engine()).reach(); return placing(IrisPackSettings.of(settings).engine(), log).reach();
} }
/** The engine runtime's object placing, which the module's {@link ObjectsAt} also asks. */ /** The engine runtime's object placing, which the module's {@link ObjectsAt} also asks; {@code log} is the module's. */
public static ObjectPlacing placing(Engine engine) { public static ObjectPlacing placing(Engine engine, ModuleLog log) {
return engine.getGeneration().state(ObjectPlacing.class, ObjectPlacing::new); return engine.getGeneration().state(ObjectPlacing.class, generating -> new ObjectPlacing(generating, log));
} }
} }
@@ -47,7 +47,6 @@ import art.arcane.iris.engine.object.procedural.IrisProceduralObjects;
import art.arcane.iris.engine.object.procedural.IrisProceduralPlacement; import art.arcane.iris.engine.object.procedural.IrisProceduralPlacement;
import art.arcane.iris.engine.object.procedural.tree.IrisProceduralTree; import art.arcane.iris.engine.object.procedural.tree.IrisProceduralTree;
import art.arcane.iris.engine.object.world.region.IrisRegion; 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.collection.KList;
import art.arcane.volmlib.util.collection.KMap; import art.arcane.volmlib.util.collection.KMap;
import art.arcane.volmlib.util.collection.KSet; import art.arcane.volmlib.util.collection.KSet;
@@ -59,6 +58,7 @@ import art.arcane.volmlib.util.matter.MatterCavern;
import art.arcane.volmlib.util.matter.MatterStructurePOI; import art.arcane.volmlib.util.matter.MatterStructurePOI;
import art.arcane.iris.util.project.noise.CNG; import art.arcane.iris.util.project.noise.CNG;
import art.arcane.iris.util.project.noise.NoiseType; import art.arcane.iris.util.project.noise.NoiseType;
import com.volmit.ModuleLog;
import it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap; import it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap;
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
import art.arcane.iris.spi.PlatformBlockState; import art.arcane.iris.spi.PlatformBlockState;
@@ -87,18 +87,20 @@ public class ObjectPlacing {
private static final Set<String> MISSING_LOAD_KEY_WARNED = ConcurrentHashMap.newKeySet(); private static final Set<String> MISSING_LOAD_KEY_WARNED = ConcurrentHashMap.newKeySet();
private final Engine engine; private final Engine engine;
private final ModuleLog log;
public ObjectPlacing(Engine engine) { public ObjectPlacing(Engine engine, ModuleLog log) {
this.engine = engine; this.engine = engine;
this.log = log;
} }
private static String placementMarker(IrisObject object, int id, String context) { private String placementMarker(IrisObject object, int id, String context) {
String key = object == null ? null : object.getLoadKey(); String key = object == null ? null : object.getLoadKey();
if (key == null || key.isEmpty() || key.equals("null")) { if (key == null || key.isEmpty() || key.equals("null")) {
String fingerprint = context + "|" + (object == null ? "<null>" : object.getClass().getSimpleName()); String fingerprint = context + "|" + (object == null ? "<null>" : object.getClass().getSimpleName());
if (MISSING_LOAD_KEY_WARNED.add(fingerprint)) { if (MISSING_LOAD_KEY_WARNED.add(fingerprint)) {
java.io.File file = object == null ? null : object.getLoadFile(); java.io.File file = object == null ? null : object.getLoadFile();
IrisLogging.warn("Skipping placement marker write: IrisObject has no loadKey (context=" + context log.warn("Skipping placement marker write: IrisObject has no loadKey (context=" + context
+ ", file=" + (file == null ? "<unknown>" : file.getPath()) + "). " + ", file=" + (file == null ? "<unknown>" : file.getPath()) + "). "
+ "This would previously produce 'Couldn't find Object: null' warnings on chunk reload."); + "This would previously produce 'Couldn't find Object: null' warnings on chunk reload.");
} }
@@ -137,7 +139,7 @@ public class ObjectPlacing {
carvedBlocks++; carvedBlocks++;
} }
} }
IrisLogging.debug("Cave object diag: chunk=" + x + "," + z log.debug("Cave object diag: chunk=" + x + "," + z
+ " surfaceBiome=" + surfaceBiome.getLoadKey() + " surfaceBiome=" + surfaceBiome.getLoadKey()
+ " caveBiome=" + caveBiome.getLoadKey() + " caveBiome=" + caveBiome.getLoadKey()
+ " surfaceY=" + surfaceY + " surfaceY=" + surfaceY
@@ -148,7 +150,7 @@ public class ObjectPlacing {
+ " sameBiome=" + (caveBiome == surfaceBiome || java.util.Objects.equals(caveBiome.getLoadKey(), surfaceBiome.getLoadKey()))); + " sameBiome=" + (caveBiome == surfaceBiome || java.util.Objects.equals(caveBiome.getLoadKey(), surfaceBiome.getLoadKey())));
} }
if (traceRegen) { if (traceRegen) {
IrisLogging.debug("Regen object layer start: chunk=" + x + "," + z log.debug("Regen object layer start: chunk=" + x + "," + z
+ " surfaceBiome=" + surfaceBiome.getLoadKey() + " surfaceBiome=" + surfaceBiome.getLoadKey()
+ " caveBiome=" + caveBiome.getLoadKey() + " caveBiome=" + caveBiome.getLoadKey()
+ " region=" + region.getLoadKey() + " region=" + region.getLoadKey()
@@ -165,7 +167,7 @@ public class ObjectPlacing {
placeUpperObjects(writer, rng, x, z, xxx, zzz, surfaceY, upperCtx, dimension, complex, traceRegen); placeUpperObjects(writer, rng, x, z, xxx, zzz, surfaceY, upperCtx, dimension, complex, traceRegen);
} }
if (traceRegen) { if (traceRegen) {
IrisLogging.debug("Regen object layer done: chunk=" + x + "," + z log.debug("Regen object layer done: chunk=" + x + "," + z
+ " biomeSurfacePlacersChecked=" + summary.biomeSurfacePlacersChecked() + " biomeSurfacePlacersChecked=" + summary.biomeSurfacePlacersChecked()
+ " biomeSurfacePlacersTriggered=" + summary.biomeSurfacePlacersTriggered() + " biomeSurfacePlacersTriggered=" + summary.biomeSurfacePlacersTriggered()
+ " biomeCavePlacersChecked=" + summary.biomeCavePlacersChecked() + " biomeCavePlacersChecked=" + summary.biomeCavePlacersChecked()
@@ -245,7 +247,7 @@ public class ObjectPlacing {
biomeSurfaceChecked++; biomeSurfaceChecked++;
boolean chance = rng.chance(i.getChance() + rng.d(-0.005, 0.005)); boolean chance = rng.chance(i.getChance() + rng.d(-0.005, 0.005));
if (traceRegen) { if (traceRegen) {
IrisLogging.debug("Regen object placer chance: chunk=" + x + "," + z log.debug("Regen object placer chance: chunk=" + x + "," + z
+ " scope=biome-surface" + " scope=biome-surface"
+ " chanceResult=" + chance + " chanceResult=" + chance
+ " chanceBase=" + i.getChance() + " chanceBase=" + i.getChance()
@@ -263,10 +265,9 @@ public class ObjectPlacing {
errors += result.errors(); errors += result.errors();
} catch (Throwable e) { } catch (Throwable e) {
errors++; errors++;
IrisLogging.reportError(e); log.error("Failed to place objects in the following biome: " + surfaceBiome.getName(), e);
IrisLogging.error("Failed to place objects in the following biome: " + surfaceBiome.getName()); log.error("Object(s) " + i.getPlace().toString(", ") + " (" + e.getClass().getSimpleName() + ").", null);
IrisLogging.error("Object(s) " + i.getPlace().toString(", ") + " (" + e.getClass().getSimpleName() + ")."); log.error("Are these objects missing?", null);
IrisLogging.error("Are these objects missing?");
} }
} }
} }
@@ -278,7 +279,7 @@ public class ObjectPlacing {
biomeCaveChecked++; biomeCaveChecked++;
boolean chance = rng.chance(i.getChance()); boolean chance = rng.chance(i.getChance());
if (traceRegen) { if (traceRegen) {
IrisLogging.debug("Regen object placer chance: chunk=" + x + "," + z log.debug("Regen object placer chance: chunk=" + x + "," + z
+ " scope=biome-cave" + " scope=biome-cave"
+ " chanceResult=" + chance + " chanceResult=" + chance
+ " chanceBase=" + i.getChance() + " chanceBase=" + i.getChance()
@@ -296,10 +297,9 @@ public class ObjectPlacing {
errors += result.errors(); errors += result.errors();
} catch (Throwable e) { } catch (Throwable e) {
errors++; errors++;
IrisLogging.reportError(e); log.error("Failed to place cave objects in the following biome: " + caveBiome.getName(), e);
IrisLogging.error("Failed to place cave objects in the following biome: " + caveBiome.getName()); log.error("Object(s) " + i.getPlace().toString(", ") + " (" + e.getClass().getSimpleName() + ").", null);
IrisLogging.error("Object(s) " + i.getPlace().toString(", ") + " (" + e.getClass().getSimpleName() + ")."); log.error("Are these objects missing?", null);
IrisLogging.error("Are these objects missing?");
} }
} }
} }
@@ -308,7 +308,7 @@ public class ObjectPlacing {
regionSurfaceChecked++; regionSurfaceChecked++;
boolean chance = rng.chance(i.getChance() + rng.d(-0.005, 0.005)); boolean chance = rng.chance(i.getChance() + rng.d(-0.005, 0.005));
if (traceRegen) { if (traceRegen) {
IrisLogging.debug("Regen object placer chance: chunk=" + x + "," + z log.debug("Regen object placer chance: chunk=" + x + "," + z
+ " scope=region-surface" + " scope=region-surface"
+ " chanceResult=" + chance + " chanceResult=" + chance
+ " chanceBase=" + i.getChance() + " chanceBase=" + i.getChance()
@@ -326,10 +326,9 @@ public class ObjectPlacing {
errors += result.errors(); errors += result.errors();
} catch (Throwable e) { } catch (Throwable e) {
errors++; errors++;
IrisLogging.reportError(e); log.error("Failed to place objects in the following region: " + region.getName(), e);
IrisLogging.error("Failed to place objects in the following region: " + region.getName()); log.error("Object(s) " + i.getPlace().toString(", ") + " (" + e.getClass().getSimpleName() + ").", null);
IrisLogging.error("Object(s) " + i.getPlace().toString(", ") + " (" + e.getClass().getSimpleName() + ")."); log.error("Are these objects missing?", null);
IrisLogging.error("Are these objects missing?");
} }
} }
} }
@@ -341,7 +340,7 @@ public class ObjectPlacing {
regionCaveChecked++; regionCaveChecked++;
boolean chance = rng.chance(i.getChance()); boolean chance = rng.chance(i.getChance());
if (traceRegen) { if (traceRegen) {
IrisLogging.debug("Regen object placer chance: chunk=" + x + "," + z log.debug("Regen object placer chance: chunk=" + x + "," + z
+ " scope=region-cave" + " scope=region-cave"
+ " chanceResult=" + chance + " chanceResult=" + chance
+ " chanceBase=" + i.getChance() + " chanceBase=" + i.getChance()
@@ -359,10 +358,9 @@ public class ObjectPlacing {
errors += result.errors(); errors += result.errors();
} catch (Throwable e) { } catch (Throwable e) {
errors++; errors++;
IrisLogging.reportError(e); log.error("Failed to place cave objects in the following region: " + region.getName(), e);
IrisLogging.error("Failed to place cave objects in the following region: " + region.getName()); log.error("Object(s) " + i.getPlace().toString(", ") + " (" + e.getClass().getSimpleName() + ").", null);
IrisLogging.error("Object(s) " + i.getPlace().toString(", ") + " (" + e.getClass().getSimpleName() + ")."); log.error("Are these objects missing?", null);
IrisLogging.error("Are these objects missing?");
} }
} }
} }
@@ -419,7 +417,7 @@ public class ObjectPlacing {
boolean treePlacement = p instanceof IrisProceduralTree; boolean treePlacement = p instanceof IrisProceduralTree;
boolean chancePassed = passesProceduralChance(rng, p.getChance()); boolean chancePassed = passesProceduralChance(rng, p.getChance());
if (golden) { if (golden) {
IrisLogging.debug("Goldendebug procedural chance: chunk=" + x + "," + z log.debug("Goldendebug procedural chance: chunk=" + x + "," + z
+ " scope=" + scope + " scope=" + scope
+ " placement=" + p.getName() + " placement=" + p.getName()
+ " passed=" + chancePassed); + " passed=" + chancePassed);
@@ -438,13 +436,13 @@ public class ObjectPlacing {
int minDepthBelowSurface = resolveObjectMinDepthBelowSurface(caveProfile); int minDepthBelowSurface = resolveObjectMinDepthBelowSurface(caveProfile);
int anchorSearchAttempts = resolveAnchorSearchAttempts(caveProfile); int anchorSearchAttempts = resolveAnchorSearchAttempts(caveProfile);
IObjectPlacer basePlacer = p.isPlausible() ? new DecayControlPlacer(writer) : writer; IObjectPlacer basePlacer = p.isPlausible() ? new DecayControlPlacer(writer) : writer;
IObjectPlacer placer = golden ? new GoldenDebugObjectPlacer(basePlacer, scope + "/" + p.getName()) : basePlacer; IObjectPlacer placer = golden ? new GoldenDebugObjectPlacer(basePlacer, scope + "/" + p.getName(), log) : basePlacer;
int density = Math.max(1, p.getDensity()); int density = Math.max(1, p.getDensity());
for (int i = 0; i < density; i++) { for (int i = 0; i < density; i++) {
IrisObject variant = p.getVariantObject(engine.getData(), rng); IrisObject variant = p.getVariantObject(engine.getData(), rng);
if (variant == null) { if (variant == null) {
if (golden) { if (golden) {
IrisLogging.debug("Goldendebug procedural pick: chunk=" + x + "," + z log.debug("Goldendebug procedural pick: chunk=" + x + "," + z
+ " placement=" + p.getName() + " placement=" + p.getName()
+ " densityIndex=" + i + " densityIndex=" + i
+ " variant=null"); + " variant=null");
@@ -469,7 +467,7 @@ public class ObjectPlacing {
} }
if (carving && caveAnchor == null) { if (carving && caveAnchor == null) {
if (golden) { if (golden) {
IrisLogging.debug("Goldendebug procedural cave anchor rejected: chunk=" + x + "," + z log.debug("Goldendebug procedural cave anchor rejected: chunk=" + x + "," + z
+ " placement=" + p.getName() + " placement=" + p.getName()
+ " minDepthBelowSurface=" + minDepthBelowSurface); + " minDepthBelowSurface=" + minDepthBelowSurface);
} }
@@ -480,7 +478,7 @@ public class ObjectPlacing {
int id = rng.i(0, Integer.MAX_VALUE); int id = rng.i(0, Integer.MAX_VALUE);
if (golden) { if (golden) {
KList<IrisObject> pool = p.getVariantObjects(engine.getData()); KList<IrisObject> pool = p.getVariantObjects(engine.getData());
IrisLogging.debug("Goldendebug procedural pick: chunk=" + x + "," + z log.debug("Goldendebug procedural pick: chunk=" + x + "," + z
+ " placement=" + p.getName() + " placement=" + p.getName()
+ " densityIndex=" + i + " densityIndex=" + i
+ " variant=" + variant.getLoadKey() + " variant=" + variant.getLoadKey()
@@ -496,7 +494,7 @@ public class ObjectPlacing {
if (carving) { if (carving) {
int caveFloorY = caveAnchor.y(); int caveFloorY = caveAnchor.y();
if (golden) { if (golden) {
IrisLogging.debug("Goldendebug procedural caveFloor: chunk=" + x + "," + z log.debug("Goldendebug procedural caveFloor: chunk=" + x + "," + z
+ " placement=" + p.getName() + " placement=" + p.getName()
+ " xx=" + xx + " xx=" + xx
+ " zz=" + zz + " zz=" + zz
@@ -530,7 +528,7 @@ public class ObjectPlacing {
}, null, engine.getData()); }, null, engine.getData());
} }
if (golden) { if (golden) {
IrisLogging.debug("Goldendebug procedural result: chunk=" + x + "," + z log.debug("Goldendebug procedural result: chunk=" + x + "," + z
+ " placement=" + p.getName() + " placement=" + p.getName()
+ " variant=" + variant.getLoadKey() + " variant=" + variant.getLoadKey()
+ " xx=" + xx + " xx=" + xx
@@ -539,8 +537,7 @@ public class ObjectPlacing {
+ " commit=" + commitResult); + " commit=" + commitResult);
} }
} catch (Throwable e) { } catch (Throwable e) {
IrisLogging.reportError(e); log.error("Failed to place procedural object '" + p.getName() + "' in " + scope, e);
IrisLogging.error("Failed to place procedural object '" + p.getName() + "' in " + scope);
} }
} }
} }
@@ -670,7 +667,7 @@ public class ObjectPlacing {
if (v == null) { if (v == null) {
nullObjects++; nullObjects++;
if (traceRegen) { if (traceRegen) {
IrisLogging.debug("Regen object placement null object: chunk=" + chunkX + "," + chunkZ log.debug("Regen object placement null object: chunk=" + chunkX + "," + chunkZ
+ " scope=" + scope + " scope=" + scope
+ " densityIndex=" + i + " densityIndex=" + i
+ " density=" + density + " density=" + density
@@ -683,9 +680,9 @@ public class ObjectPlacing {
IrisObjectPlacement effectivePlacement = resolveEffectivePlacement(objectPlacement, v); IrisObjectPlacement effectivePlacement = resolveEffectivePlacement(objectPlacement, v);
boolean treePlacement = isTreePlacement(v, effectivePlacement); boolean treePlacement = isTreePlacement(v, effectivePlacement);
int id = rng.i(0, Integer.MAX_VALUE); int id = rng.i(0, Integer.MAX_VALUE);
IObjectPlacer placePlacer = golden ? new GoldenDebugObjectPlacer(writer, scope + "/" + v.getLoadKey()) : writer; IObjectPlacer placePlacer = golden ? new GoldenDebugObjectPlacer(writer, scope + "/" + v.getLoadKey(), log) : writer;
if (golden) { if (golden) {
IrisLogging.debug("Goldendebug object attempt: chunk=" + chunkX + "," + chunkZ log.debug("Goldendebug object attempt: chunk=" + chunkX + "," + chunkZ
+ " scope=" + scope + " scope=" + scope
+ " object=" + v.getLoadKey() + " object=" + v.getLoadKey()
+ " densityIndex=" + i + " densityIndex=" + i
@@ -714,7 +711,7 @@ public class ObjectPlacing {
} }
if (golden) { if (golden) {
IrisLogging.debug("Goldendebug object result: chunk=" + chunkX + "," + chunkZ log.debug("Goldendebug object result: chunk=" + chunkX + "," + chunkZ
+ " scope=" + scope + " scope=" + scope
+ " object=" + v.getLoadKey() + " object=" + v.getLoadKey()
+ " resultY=" + result + " resultY=" + result
@@ -722,7 +719,7 @@ public class ObjectPlacing {
} }
if (traceRegen) { if (traceRegen) {
IrisLogging.debug("Regen object placement result: chunk=" + chunkX + "," + chunkZ log.debug("Regen object placement result: chunk=" + chunkX + "," + chunkZ
+ " scope=" + scope + " scope=" + scope
+ " object=" + v.getLoadKey() + " object=" + v.getLoadKey()
+ " resultY=" + result + " resultY=" + result
@@ -734,13 +731,12 @@ public class ObjectPlacing {
} }
} catch (Throwable e) { } catch (Throwable e) {
errors++; errors++;
IrisLogging.reportError(e); log.error("Regen object placement exception: chunk=" + chunkX + "," + chunkZ
IrisLogging.error("Regen object placement exception: chunk=" + chunkX + "," + chunkZ
+ " scope=" + scope + " scope=" + scope
+ " object=" + v.getLoadKey() + " object=" + v.getLoadKey()
+ " densityIndex=" + i + " densityIndex=" + i
+ " density=" + density + " density=" + density
+ " error=" + e.getClass().getSimpleName() + ":" + e.getMessage()); + " error=" + e.getClass().getSimpleName() + ":" + e.getMessage(), e);
} }
} }
@@ -808,7 +804,7 @@ public class ObjectPlacing {
if (object == null) { if (object == null) {
nullObjects++; nullObjects++;
if (traceRegen) { if (traceRegen) {
IrisLogging.debug("Regen cave object placement null object: chunk=" + metricChunkX + "," + metricChunkZ log.debug("Regen cave object placement null object: chunk=" + metricChunkX + "," + metricChunkZ
+ " scope=" + scope + " scope=" + scope
+ " densityIndex=" + i + " densityIndex=" + i
+ " density=" + density + " density=" + density
@@ -922,7 +918,7 @@ public class ObjectPlacing {
} }
if (traceRegen) { if (traceRegen) {
IrisLogging.debug("Regen cave object placement result: chunk=" + metricChunkX + "," + metricChunkZ log.debug("Regen cave object placement result: chunk=" + metricChunkX + "," + metricChunkZ
+ " scope=" + scope + " scope=" + scope
+ " object=" + object.getLoadKey() + " object=" + object.getLoadKey()
+ " resultY=" + result + " resultY=" + result
@@ -935,13 +931,12 @@ public class ObjectPlacing {
} }
} catch (Throwable e) { } catch (Throwable e) {
errors++; errors++;
IrisLogging.reportError(e); log.error("Regen cave object placement exception: chunk=" + metricChunkX + "," + metricChunkZ
IrisLogging.error("Regen cave object placement exception: chunk=" + metricChunkX + "," + metricChunkZ
+ " scope=" + scope + " scope=" + scope
+ " object=" + object.getLoadKey() + " object=" + object.getLoadKey()
+ " densityIndex=" + i + " densityIndex=" + i
+ " density=" + density + " density=" + density
+ " error=" + e.getClass().getSimpleName() + ":" + e.getMessage()); + " error=" + e.getClass().getSimpleName() + ":" + e.getMessage(), e);
logCaveReject( logCaveReject(
scope, scope,
"EXCEPTION", "EXCEPTION",
@@ -993,9 +988,8 @@ public class ObjectPlacing {
try { try {
placeUpperObject(writer, rng, chunkX, chunkZ, i, upperCtx, dimension, complex, forcePlace, traceRegen, "upper-biome-surface"); placeUpperObject(writer, rng, chunkX, chunkZ, i, upperCtx, dimension, complex, forcePlace, traceRegen, "upper-biome-surface");
} catch (Throwable e) { } catch (Throwable e) {
IrisLogging.reportError(e); log.error("Failed to place upper-dimension objects in biome " + upperBiome.getName()
IrisLogging.error("Failed to place upper-dimension objects in biome " + upperBiome.getName() + ": " + i.getPlace().toString(", ") + " (" + e.getClass().getSimpleName() + ")", e);
+ ": " + i.getPlace().toString(", ") + " (" + e.getClass().getSimpleName() + ")");
} }
} }
} }
@@ -1008,9 +1002,8 @@ public class ObjectPlacing {
try { try {
placeUpperObject(writer, rng, chunkX, chunkZ, i, upperCtx, dimension, complex, forcePlace, traceRegen, "upper-region-surface"); placeUpperObject(writer, rng, chunkX, chunkZ, i, upperCtx, dimension, complex, forcePlace, traceRegen, "upper-region-surface");
} catch (Throwable e) { } catch (Throwable e) {
IrisLogging.reportError(e); log.error("Failed to place upper-dimension objects in region " + upperRegion.getName()
IrisLogging.error("Failed to place upper-dimension objects in region " + upperRegion.getName() + ": " + i.getPlace().toString(", ") + " (" + e.getClass().getSimpleName() + ")", e);
+ ": " + i.getPlace().toString(", ") + " (" + e.getClass().getSimpleName() + ")");
} }
} }
} }
@@ -1081,7 +1074,7 @@ public class ObjectPlacing {
}, null, engine.getData()); }, null, engine.getData());
if (traceRegen) { if (traceRegen) {
IrisLogging.debug("Upper object placement: chunk=" + chunkX + "," + chunkZ log.debug("Upper object placement: chunk=" + chunkX + "," + chunkZ
+ " scope=" + scope + " scope=" + scope
+ " object=" + v.getLoadKey() + " object=" + v.getLoadKey()
+ " anchorY=" + anchorY + " anchorY=" + anchorY
@@ -1140,7 +1133,7 @@ public class ObjectPlacing {
int suppressed = state.suppressed.getAndSet(0); int suppressed = state.suppressed.getAndSet(0);
String anchorYText = anchorY == null ? "none" : String.valueOf(anchorY); String anchorYText = anchorY == null ? "none" : String.valueOf(anchorY);
String errorText = error == null ? "none" : error.getClass().getSimpleName() + ":" + String.valueOf(error.getMessage()); String errorText = error == null ? "none" : error.getClass().getSimpleName() + ":" + String.valueOf(error.getMessage());
IrisLogging.debug("Cave object reject: scope=" + scope log.debug("Cave object reject: scope=" + scope
+ " reason=" + reason + " reason=" + reason
+ " chunk=" + chunkX + "," + chunkZ + " chunk=" + chunkX + "," + chunkZ
+ " object=" + objectKey + " object=" + objectKey
@@ -1496,11 +1489,11 @@ public class ObjectPlacing {
} }
int reach = calculatePlacementReach(size, placement); int reach = calculatePlacementReach(size, placement);
if (reach > 128 && warnedLargeObjects.add(objectKey)) { if (reach > 128 && warnedLargeObjects.add(objectKey)) {
IrisLogging.warn("Object " + objectKey + " has a large placement reach (" + reach + " blocks) and may increase memory usage!"); log.warn("Object " + objectKey + " has a large placement reach (" + reach + " blocks) and may increase memory usage!");
} }
radius = Math.max(radius, reach); radius = Math.max(radius, reach);
} catch (Throwable e) { } catch (Throwable e) {
IrisLogging.reportError(e); log.error("Failed to work out the reach of an object placement", e);
} }
} }
} }
@@ -1586,7 +1579,7 @@ public class ObjectPlacing {
try { try {
return IrisObject.sampleSize(engine.getData().getObjectLoader().findFile(objectKey)); return IrisObject.sampleSize(engine.getData().getObjectLoader().findFile(objectKey));
} catch (IOException e) { } catch (IOException e) {
IrisLogging.reportError(e); log.error("Failed to size an object", e);
} }
return null; return null;
@@ -35,6 +35,7 @@ import com.volmit.FeatureRegistry;
import com.volmit.IrisModule; import com.volmit.IrisModule;
import com.volmit.ModuleInfo; import com.volmit.ModuleInfo;
import com.volmit.ModuleLifecycle; import com.volmit.ModuleLifecycle;
import com.volmit.ModuleLog;
import com.volmit.config.PackSettings; import com.volmit.config.PackSettings;
import com.volmit.service.StructureLocator; import com.volmit.service.StructureLocator;
import com.volmit.service.VanillaStructures; import com.volmit.service.VanillaStructures;
@@ -63,6 +64,8 @@ import com.volmit.world.PackWorld;
public final class StructureModule implements IrisModule, ModuleLifecycle { public final class StructureModule implements IrisModule, ModuleLifecycle {
private static final String VERSION = "built-in"; private static final String VERSION = "built-in";
private ModuleLog log;
@Override @Override
public ModuleInfo info() { public ModuleInfo info() {
return ModuleInfo.of("iris:structure", "Structures", VERSION); return ModuleInfo.of("iris:structure", "Structures", VERSION);
@@ -71,11 +74,12 @@ public final class StructureModule implements IrisModule, ModuleLifecycle {
@Override @Override
public void install(StageGraph graph) { public void install(StageGraph graph) {
graph.define(IrisStages.Structure.PLACE).requires(IrisStages.Objects.PLACE).softAfter(IrisStages.Floating.OBJECTS.ref()) graph.define(IrisStages.Structure.PLACE).requires(IrisStages.Objects.PLACE).softAfter(IrisStages.Floating.OBJECTS.ref())
.reach(StructureModule::reach).run(StructureModule::place); .reach(this::reach).run(StructureModule::place);
} }
@Override @Override
public void register(FeatureRegistry registry) { public void register(FeatureRegistry registry) {
log = registry.log();
registry.registerSettings(StructureSettings.class); registry.registerSettings(StructureSettings.class);
StructureResources.kinds().forEach(registry::registerResourceKind); StructureResources.kinds().forEach(registry::registerResourceKind);
registry.registerValidator(new StructureValidator()); registry.registerValidator(new StructureValidator());
@@ -95,14 +99,14 @@ public final class StructureModule implements IrisModule, ModuleLifecycle {
private static void place(MantleStageContext context) { private static void place(MantleStageContext context) {
IrisMantleChunk chunk = IrisMantleChunk.current(); IrisMantleChunk chunk = IrisMantleChunk.current();
placing(chunk.engine()).place(chunk.writer(), chunk.chunkX(), chunk.chunkZ(), chunk.context()); placing(chunk.engine(), context.log()).place(chunk.writer(), chunk.chunkX(), chunk.chunkZ(), chunk.context());
} }
private static int reach(PackSettings settings) { private int reach(PackSettings settings) {
return placing(IrisPackSettings.of(settings).engine()).reach(); return placing(IrisPackSettings.of(settings).engine(), log).reach();
} }
private static StructurePlacing placing(Engine engine) { private static StructurePlacing placing(Engine engine, ModuleLog log) {
return engine.getGeneration().state(StructurePlacing.class, StructurePlacing::new); return engine.getGeneration().state(StructurePlacing.class, generating -> new StructurePlacing(generating, log));
} }
} }
@@ -39,11 +39,11 @@ import art.arcane.iris.engine.object.structure.IrisStructure;
import art.arcane.iris.builtin.structure.StructureCarveShape; import art.arcane.iris.builtin.structure.StructureCarveShape;
import art.arcane.iris.engine.object.structure.IrisStructurePlacement; import art.arcane.iris.engine.object.structure.IrisStructurePlacement;
import art.arcane.iris.builtin.structure.StructureStilts; import art.arcane.iris.builtin.structure.StructureStilts;
import com.volmit.ModuleLog;
import com.volmit.block.PaletteSampler; import com.volmit.block.PaletteSampler;
import com.volmit.block.PaletteSpec; import com.volmit.block.PaletteSpec;
import art.arcane.iris.builtin.structure.StructureTerrain; import art.arcane.iris.builtin.structure.StructureTerrain;
import art.arcane.iris.builtin.structure.StructureTerrainMode; import art.arcane.iris.builtin.structure.StructureTerrainMode;
import art.arcane.iris.spi.IrisLogging;
import art.arcane.iris.spi.PlatformBlockState; import art.arcane.iris.spi.PlatformBlockState;
import art.arcane.iris.util.common.data.B; import art.arcane.iris.util.common.data.B;
import art.arcane.iris.util.common.math.IrisBlockVector; import art.arcane.iris.util.common.math.IrisBlockVector;
@@ -72,9 +72,11 @@ public class StructurePlacing {
private static final MatterCavern CARVE_CAVERN = new MatterCavern(true, "", (byte) 3); private static final MatterCavern CARVE_CAVERN = new MatterCavern(true, "", (byte) 3);
private final Engine engine; private final Engine engine;
private final ModuleLog log;
public StructurePlacing(Engine engine) { public StructurePlacing(Engine engine, ModuleLog log) {
this.engine = engine; this.engine = engine;
this.log = log;
} }
/** Places what originates in the chunk at chunk coordinates {@code x}, {@code z} into {@code writer}. */ /** Places what originates in the chunk at chunk coordinates {@code x}, {@code z} into {@code writer}. */
@@ -99,7 +101,7 @@ public class StructurePlacing {
boolean trace = IrisSettings.get().getGeneral().isDebug(); boolean trace = IrisSettings.get().getGeneral().isDebug();
if (trace) { if (trace) {
IrisLogging.debug("[StructTrace] ORIGIN chunk=" + cx + "," + cz + " structures=" + placement.getStructures() log.debug("[StructTrace] ORIGIN chunk=" + cx + "," + cz + " structures=" + placement.getStructures()
+ " anchor=" + placement.resolvedAnchor() + " band=" + placement.getMinHeight() + ".." + placement.getMaxHeight()); + " anchor=" + placement.resolvedAnchor() + " band=" + placement.getMinHeight() + ".." + placement.getMaxHeight());
} }
@@ -112,7 +114,7 @@ public class StructurePlacing {
RNG rng = resolved.rng(); RNG rng = resolved.rng();
int baseY = resolved.baseY(); int baseY = resolved.baseY();
if (trace) { if (trace) {
IrisLogging.debug("[StructTrace] ASSEMBLED chunk=" + cx + "," + cz + " key=" + key + " baseY=" + baseY + " pieces=" + pieces.size()); log.debug("[StructTrace] ASSEMBLED chunk=" + cx + "," + cz + " key=" + key + " baseY=" + baseY + " pieces=" + pieces.size());
} }
if (!placement.isAnchoredUnderground()) { if (!placement.isAnchoredUnderground()) {
@@ -319,7 +321,7 @@ public class StructurePlacing {
} }
if (IrisSettings.get().getGeneral().isDebug()) { if (IrisSettings.get().getGeneral().isDebug()) {
IrisLogging.info("Overbore carving structure cavern: shape=" + shape + " pieces=" + pieces.size() log.info("Overbore carving structure cavern: shape=" + shape + " pieces=" + pieces.size()
+ " footprint=" + footprint.width() + "x" + footprint.depth() + " footprint=" + footprint.width() + "x" + footprint.depth()
+ " margin=" + margin + " head=" + head + " floorCut=" + floorCut + " work=" + work); + " margin=" + margin + " head=" + head + " floorCut=" + floorCut + " work=" + work);
} }
@@ -31,6 +31,7 @@ import art.arcane.iris.engine.mantle.components.CaveCarving;
import art.arcane.iris.engine.object.world.dimension.IrisDimension; import art.arcane.iris.engine.object.world.dimension.IrisDimension;
import com.volmit.IrisModule; import com.volmit.IrisModule;
import com.volmit.ModuleInfo; import com.volmit.ModuleInfo;
import com.volmit.ModuleLog;
import com.volmit.service.CaveBiomes; import com.volmit.service.CaveBiomes;
import com.volmit.stage.ChunkStageContext; import com.volmit.stage.ChunkStageContext;
import com.volmit.stage.MantleStageContext; import com.volmit.stage.MantleStageContext;
@@ -82,7 +83,8 @@ public final class CarveModule implements IrisModule {
if (chunk.bypassesMantleStages()) { if (chunk.bypassesMantleStages()) {
return; return;
} }
chunk.state(CaveApplying.class, CaveApplying::new).apply(chunk.originX() >> CHUNK_SHIFT, chunk.originZ() >> CHUNK_SHIFT, ModuleLog log = context.log();
chunk.state(CaveApplying.class, generating -> new CaveApplying(generating, log)).apply(chunk.originX() >> CHUNK_SHIFT, chunk.originZ() >> CHUNK_SHIFT,
chunk.blocks(), chunk.multicore(), chunk.context()); chunk.blocks(), chunk.multicore(), chunk.context());
} }
@@ -44,6 +44,7 @@ import art.arcane.volmlib.util.matter.Matter;
import art.arcane.volmlib.util.matter.MatterCavern; import art.arcane.volmlib.util.matter.MatterCavern;
import art.arcane.volmlib.util.matter.slices.MarkerMatter; import art.arcane.volmlib.util.matter.slices.MarkerMatter;
import art.arcane.volmlib.util.scheduling.PrecisionStopwatch; import art.arcane.volmlib.util.scheduling.PrecisionStopwatch;
import com.volmit.ModuleLog;
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
import lombok.Data; import lombok.Data;
import art.arcane.iris.spi.PlatformBlockState; import art.arcane.iris.spi.PlatformBlockState;
@@ -72,11 +73,11 @@ public class CaveApplying {
private final IrisSurfaceDecorator surfaceDecorator; private final IrisSurfaceDecorator surfaceDecorator;
private final IrisCeilingDecorator ceilingDecorator; private final IrisCeilingDecorator ceilingDecorator;
public CaveApplying(Engine engine) { public CaveApplying(Engine engine, ModuleLog log) {
this.engine = engine; this.engine = engine;
rng = new RNG(engine.getSeedManager().getCarve()); rng = new RNG(engine.getSeedManager().getCarve());
decorators = BiomeDecorators.of(engine); decorators = BiomeDecorators.of(engine);
layers = BiomeLayers.of(engine); layers = BiomeLayers.of(engine, log);
palettes = TerrainPalettes.of(engine); palettes = TerrainPalettes.of(engine);
surfaceDecorator = new IrisSurfaceDecorator(engine); surfaceDecorator = new IrisSurfaceDecorator(engine);
ceilingDecorator = new IrisCeilingDecorator(engine); ceilingDecorator = new IrisCeilingDecorator(engine);
@@ -38,7 +38,6 @@ import art.arcane.iris.engine.terrain.BiomeLayers;
import art.arcane.iris.engine.terrain.ResolvedLayer; import art.arcane.iris.engine.terrain.ResolvedLayer;
import art.arcane.iris.builtin.decorant.DecorationPart; import art.arcane.iris.builtin.decorant.DecorationPart;
import art.arcane.iris.engine.object.world.dimension.IrisDimension; import art.arcane.iris.engine.object.world.dimension.IrisDimension;
import art.arcane.iris.spi.IrisLogging;
import art.arcane.iris.util.common.data.B; import art.arcane.iris.util.common.data.B;
import art.arcane.iris.util.project.context.ChunkContext; import art.arcane.iris.util.project.context.ChunkContext;
import art.arcane.iris.util.project.hunk.Hunk; import art.arcane.iris.util.project.hunk.Hunk;
@@ -51,6 +50,7 @@ import art.arcane.volmlib.util.scheduling.PrecisionStopwatch;
import art.arcane.iris.spi.IrisPlatforms; import art.arcane.iris.spi.IrisPlatforms;
import art.arcane.iris.spi.PlatformBlockState; import art.arcane.iris.spi.PlatformBlockState;
import com.volmit.ModuleLog;
import java.util.IdentityHashMap; import java.util.IdentityHashMap;
import static art.arcane.iris.engine.mantle.EngineMantle.AIR; import static art.arcane.iris.engine.mantle.EngineMantle.AIR;
@@ -68,6 +68,7 @@ public class FloatingIslands {
private final RNG rng; private final RNG rng;
private final EngineDecorator seaSurfaceDecorator; private final EngineDecorator seaSurfaceDecorator;
private final BiomeLayers biomeLayers; private final BiomeLayers biomeLayers;
private final ModuleLog log;
private KList<PlatformBlockState> generateBottomPaletteLayers(ResolvedFloatingChild entry, IrisDimension dimension, double wx, double wz, RNG random, int paletteDepth, IrisData data, IrisComplex complex) { private KList<PlatformBlockState> generateBottomPaletteLayers(ResolvedFloatingChild entry, IrisDimension dimension, double wx, double wz, RNG random, int paletteDepth, IrisData data, IrisComplex complex) {
if (entry == null || entry.settings().bottomPaletteMode() != FloatingBottomPaletteMode.CUSTOM || entry.settings().bottomPalette() == null || entry.settings().bottomPalette().isEmpty()) { if (entry == null || entry.settings().bottomPaletteMode() != FloatingBottomPaletteMode.CUSTOM || entry.settings().bottomPalette() == null || entry.settings().bottomPalette().isEmpty()) {
@@ -108,7 +109,7 @@ public class FloatingIslands {
try { try {
generated.add(layer.get(random.nextParallelRNG(i + j), (wx + j) / layer.zoom(), j, (wz - j) / layer.zoom())); generated.add(layer.get(random.nextParallelRNG(i + j), (wx + j) / layer.zoom(), j, (wz - j) / layer.zoom()));
} catch (Throwable e) { } catch (Throwable e) {
IrisLogging.reportError(e); log.error("Failed to pick a block of a floating island's palette", e);
} }
} }
@@ -207,11 +208,12 @@ public class FloatingIslands {
} }
} }
public FloatingIslands(Engine engine) { public FloatingIslands(Engine engine, ModuleLog log) {
this.engine = engine; this.engine = engine;
this.log = log;
rng = new RNG(engine.getSeedManager().getTerrain() ^ 0x7EB0A73F1DCE514DL); rng = new RNG(engine.getSeedManager().getTerrain() ^ 0x7EB0A73F1DCE514DL);
seaSurfaceDecorator = new IrisSeaSurfaceDecorator(engine); seaSurfaceDecorator = new IrisSeaSurfaceDecorator(engine);
biomeLayers = BiomeLayers.of(engine); biomeLayers = BiomeLayers.of(engine, log);
} }
/** Fills the islands' solids into the chunk whose first block is {@code x}, {@code z}. */ /** Fills the islands' solids into the chunk whose first block is {@code x}, {@code z}. */
@@ -233,7 +235,7 @@ public class FloatingIslands {
if (parent == null || FloatingChildren.declaredBy(parent).isEmpty()) { if (parent == null || FloatingChildren.declaredBy(parent).isEmpty()) {
continue; continue;
} }
FloatingIslandSample sample = FloatingIslandSample.sampleMemoized(parent, wx, wz, chunkHeight, baseSeed, data, engine, boundarySampler); FloatingIslandSample sample = FloatingIslandSample.sampleMemoized(parent, wx, wz, chunkHeight, baseSeed, data, engine, boundarySampler, log);
if (sample == null) { if (sample == null) {
continue; continue;
} }
@@ -318,7 +320,7 @@ public class FloatingIslands {
if (parent == null || FloatingChildren.declaredBy(parent).isEmpty()) { if (parent == null || FloatingChildren.declaredBy(parent).isEmpty()) {
continue; continue;
} }
FloatingIslandSample sample = FloatingIslandSample.sampleMemoized(parent, wx, wz, chunkHeight, baseSeed, data, engine, boundarySampler); FloatingIslandSample sample = FloatingIslandSample.sampleMemoized(parent, wx, wz, chunkHeight, baseSeed, data, engine, boundarySampler, log);
if (sample == null) { if (sample == null) {
continue; continue;
} }
@@ -338,7 +340,7 @@ public class FloatingIslands {
RNG colRng = rng.nextParallelRNG((int) FloatingIslandSample.columnSeed(baseSeed, wx, wz)); RNG colRng = rng.nextParallelRNG((int) FloatingIslandSample.columnSeed(baseSeed, wx, wz));
FloatingDecorator.decorateColumn(engine, target, DecorationPart.NONE, xf, zf, wx, wz, topY, max, output, colRng, NOOP_DECORATION_MISS); FloatingDecorator.decorateColumn(engine, target, DecorationPart.NONE, xf, zf, wx, wz, topY, max, output, colRng, NOOP_DECORATION_MISS);
} catch (Throwable e) { } catch (Throwable e) {
IrisLogging.reportError(e); log.error("Failed to decorate the top of a floating island", e);
} }
} }
} }
@@ -370,7 +372,7 @@ public class FloatingIslands {
try { try {
seaSurfaceDecorator.decorate(xf, zf, wx, wx + 1, wx - 1, wz, wz + 1, wz - 1, output, target, fluidTopY, chunkHeight); seaSurfaceDecorator.decorate(xf, zf, wx, wx + 1, wx - 1, wz, wz + 1, wz - 1, output, target, fluidTopY, chunkHeight);
} catch (Throwable e) { } catch (Throwable e) {
IrisLogging.reportError(e); log.error("Failed to decorate the sea surface of a floating island", e);
} }
} }
} }
@@ -402,7 +404,7 @@ public class FloatingIslands {
engine.getMantle().getMantle().set(wx, y, wz, matter); engine.getMantle().getMantle().set(wx, y, wz, matter);
} }
} catch (Throwable e) { } catch (Throwable e) {
IrisLogging.reportError(e); log.error("Failed to write the sky biomes of a floating island", e);
} }
} }
@@ -29,6 +29,7 @@ import art.arcane.iris.engine.framework.Engine;
import art.arcane.iris.engine.mantle.components.FloatingObjectPlacing; import art.arcane.iris.engine.mantle.components.FloatingObjectPlacing;
import com.volmit.IrisModule; import com.volmit.IrisModule;
import com.volmit.ModuleInfo; import com.volmit.ModuleInfo;
import com.volmit.ModuleLog;
import com.volmit.config.PackSettings; import com.volmit.config.PackSettings;
import com.volmit.stage.ChunkStageContext; import com.volmit.stage.ChunkStageContext;
import com.volmit.stage.MantleStageContext; import com.volmit.stage.MantleStageContext;
@@ -44,6 +45,8 @@ import com.volmit.stage.StageGraph;
public final class FloatingModule implements IrisModule { public final class FloatingModule implements IrisModule {
private static final String VERSION = "built-in"; private static final String VERSION = "built-in";
private ModuleLog log;
@Override @Override
public ModuleInfo info() { public ModuleInfo info() {
return ModuleInfo.of("iris:floating", "Floating islands", VERSION); return ModuleInfo.of("iris:floating", "Floating islands", VERSION);
@@ -51,13 +54,14 @@ public final class FloatingModule implements IrisModule {
@Override @Override
public void register(FeatureRegistry registry) { public void register(FeatureRegistry registry) {
log = registry.log();
registry.registerSettings(FloatingChildSettings.class); registry.registerSettings(FloatingChildSettings.class);
registry.registerSettings(MergeFloatingChildrenSettings.class); registry.registerSettings(MergeFloatingChildrenSettings.class);
} }
@Override @Override
public void install(StageGraph graph) { public void install(StageGraph graph) {
graph.define(IrisStages.Floating.OBJECTS).softAfter(IrisStages.Objects.PLACE.ref()).reach(FloatingModule::objectReach) graph.define(IrisStages.Floating.OBJECTS).softAfter(IrisStages.Objects.PLACE.ref()).reach(this::objectReach)
.run(FloatingModule::objects); .run(FloatingModule::objects);
// Ordering only: iris:post ships in the built-ins jar, which a pack may not have. // Ordering only: iris:post ships in the built-ins jar, which a pack may not have.
graph.define(IrisStages.Floating.SOLIDS).softAfter(IrisStages.Post.SMOOTH.ref()).run(FloatingModule::solids); graph.define(IrisStages.Floating.SOLIDS).softAfter(IrisStages.Post.SMOOTH.ref()).run(FloatingModule::solids);
@@ -66,28 +70,28 @@ public final class FloatingModule implements IrisModule {
private static void objects(MantleStageContext context) { private static void objects(MantleStageContext context) {
IrisMantleChunk chunk = IrisMantleChunk.current(); IrisMantleChunk chunk = IrisMantleChunk.current();
objectPlacing(chunk.engine()).place(chunk.writer(), chunk.chunkX(), chunk.chunkZ(), chunk.context()); objectPlacing(chunk.engine(), context.log()).place(chunk.writer(), chunk.chunkX(), chunk.chunkZ(), chunk.context());
} }
private static int objectReach(PackSettings settings) { private int objectReach(PackSettings settings) {
return objectPlacing(IrisPackSettings.of(settings).engine()).reach(); return objectPlacing(IrisPackSettings.of(settings).engine(), log).reach();
} }
private static void solids(ChunkStageContext context) { private static void solids(ChunkStageContext context) {
IrisChunk chunk = IrisChunk.current(); IrisChunk chunk = IrisChunk.current();
islands(chunk).fillSolids(chunk.originX(), chunk.originZ(), chunk.blocks(), chunk.multicore(), chunk.context()); islands(chunk, context.log()).fillSolids(chunk.originX(), chunk.originZ(), chunk.blocks(), chunk.multicore(), chunk.context());
} }
private static void decorate(ChunkStageContext context) { private static void decorate(ChunkStageContext context) {
IrisChunk chunk = IrisChunk.current(); IrisChunk chunk = IrisChunk.current();
islands(chunk).decorateColumns(chunk.originX(), chunk.originZ(), chunk.blocks(), chunk.multicore(), chunk.context()); islands(chunk, context.log()).decorateColumns(chunk.originX(), chunk.originZ(), chunk.blocks(), chunk.multicore(), chunk.context());
} }
private static FloatingObjectPlacing objectPlacing(Engine engine) { private static FloatingObjectPlacing objectPlacing(Engine engine, ModuleLog log) {
return engine.getGeneration().state(FloatingObjectPlacing.class, FloatingObjectPlacing::new); return engine.getGeneration().state(FloatingObjectPlacing.class, generating -> new FloatingObjectPlacing(generating, log));
} }
private static FloatingIslands islands(IrisChunk chunk) { private static FloatingIslands islands(IrisChunk chunk, ModuleLog log) {
return chunk.state(FloatingIslands.class, FloatingIslands::new); return chunk.state(FloatingIslands.class, generating -> new FloatingIslands(generating, log));
} }
} }
@@ -28,10 +28,10 @@ import art.arcane.iris.engine.framework.Engine;
import art.arcane.iris.engine.framework.NativeStructureVolume; import art.arcane.iris.engine.framework.NativeStructureVolume;
import art.arcane.iris.engine.framework.PlacedObject; import art.arcane.iris.engine.framework.PlacedObject;
import art.arcane.iris.engine.object.prefab.IrisObject; import art.arcane.iris.engine.object.prefab.IrisObject;
import art.arcane.iris.spi.IrisLogging;
import art.arcane.volmlib.util.collection.KList; import art.arcane.volmlib.util.collection.KList;
import com.volmit.IrisModule; import com.volmit.IrisModule;
import com.volmit.ModuleInfo; import com.volmit.ModuleInfo;
import com.volmit.ModuleLog;
import com.volmit.block.BlockState; import com.volmit.block.BlockState;
import com.volmit.object.ObjectBlock; import com.volmit.object.ObjectBlock;
import com.volmit.stage.PlacementStageContext; import com.volmit.stage.PlacementStageContext;
@@ -87,7 +87,7 @@ public final class ValidateModule implements IrisModule {
int y = context.output(IrisStages.Anchor.HEIGHT).y(); int y = context.output(IrisStages.Anchor.HEIGHT).y();
boolean sampled = placement.requestedY() < 0; boolean sampled = placement.requestedY() < 0;
if (sampled && config.getCarvingSupport().supportsSurface() && isOnBedrock(prepared, y)) { if (sampled && config.getCarvingSupport().supportsSurface() && isOnBedrock(prepared, y)) {
warnImplausibleBedrockPlacement(placement, config, y); warnImplausibleBedrockPlacement(placement, config, y, context.log());
context.reject("bedrock-anchor"); context.reject("bedrock-anchor");
return; return;
} }
@@ -239,7 +239,7 @@ public final class ValidateModule implements IrisModule {
return false; return false;
} }
private static void warnImplausibleBedrockPlacement(IrisPlacement placement, IrisObjectPlacement config, int y) { private static void warnImplausibleBedrockPlacement(IrisPlacement placement, IrisObjectPlacement config, int y, ModuleLog log) {
String key = placement.object().getLoadKey(); String key = placement.object().getLoadKey();
String fingerprint = (key == null ? "<null>" : key) + "|" + config.getMode(); String fingerprint = (key == null ? "<null>" : key) + "|" + config.getMode();
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
@@ -248,7 +248,7 @@ public final class ValidateModule implements IrisModule {
return; return;
} }
IMPLAUSIBLE_BEDROCK_WARNS.put(fingerprint, now); IMPLAUSIBLE_BEDROCK_WARNS.put(fingerprint, now);
IrisLogging.warn("Implausible object placement rejected: " log.warn("Implausible object placement rejected: "
+ (key == null ? "<no loadKey>" : key) + (key == null ? "<no loadKey>" : key)
+ " resolved anchorY=" + y + " at (" + placement.x() + "," + placement.z() + ") mode=" + config.getMode() + " resolved anchorY=" + y + " at (" + placement.x() + "," + placement.z() + ") mode=" + config.getMode()
+ " carving=" + config.getCarvingSupport() + " carving=" + config.getCarvingSupport()
@@ -23,9 +23,9 @@ import art.arcane.iris.engine.object.terrain.carving.IrisCaveProfileSampler;
import art.arcane.iris.engine.object.world.biome.IrisBiome; import art.arcane.iris.engine.object.world.biome.IrisBiome;
import art.arcane.iris.core.loader.IrisData; import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.engine.framework.Engine; import art.arcane.iris.engine.framework.Engine;
import art.arcane.iris.spi.IrisLogging;
import art.arcane.iris.util.project.noise.CNG; import art.arcane.iris.util.project.noise.CNG;
import art.arcane.volmlib.util.collection.KList; import art.arcane.volmlib.util.collection.KList;
import com.volmit.ModuleLog;
import it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap; import it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap;
import java.util.Arrays; import java.util.Arrays;
@@ -78,13 +78,13 @@ public final class FloatingIslandSample {
FOOTPRINT_MEMO.get().clear(); FOOTPRINT_MEMO.get().clear();
} }
public static FloatingIslandSample sampleMemoized(IrisBiome parent, int wx, int wz, int chunkHeight, long baseSeed, IrisData data, Engine engine, FloatingIslandBoundarySampler boundarySampler) { public static FloatingIslandSample sampleMemoized(IrisBiome parent, int wx, int wz, int chunkHeight, long baseSeed, IrisData data, Engine engine, FloatingIslandBoundarySampler boundarySampler, ModuleLog log) {
long key = (((long) wx) << 32) ^ (wz & 0xFFFFFFFFL); long key = (((long) wx) << 32) ^ (wz & 0xFFFFFFFFL);
HashMap<Long, FloatingIslandSample> memo = CHUNK_MEMO.get(); HashMap<Long, FloatingIslandSample> memo = CHUNK_MEMO.get();
if (memo.containsKey(key)) { if (memo.containsKey(key)) {
return memo.get(key); return memo.get(key);
} }
FloatingIslandSample result = sample(parent, wx, wz, chunkHeight, baseSeed, data, engine, boundarySampler); FloatingIslandSample result = sample(parent, wx, wz, chunkHeight, baseSeed, data, engine, boundarySampler, log);
memo.put(key, result); memo.put(key, result);
return result; return result;
} }
@@ -94,10 +94,10 @@ public final class FloatingIslandSample {
return null; return null;
} }
private static void warnNullCng(String styleField, IrisBiome parent) { private static void warnNullCng(String styleField, IrisBiome parent, ModuleLog log) {
if (NULL_CNG_WARNED.compareAndSet(false, true)) { if (NULL_CNG_WARNED.compareAndSet(false, true)) {
String biomeKey = parent == null ? "<unknown>" : parent.getLoadKey(); String biomeKey = parent == null ? "<unknown>" : parent.getLoadKey();
IrisLogging.warn("Floating child biome on " + biomeKey + " has a null CNG for " + styleField log.warn("Floating child biome on " + biomeKey + " has a null CNG for " + styleField
+ " (style factory returned null or AtomicCache swallowed an exception); skipping floating sampling until pack is fixed"); + " (style factory returned null or AtomicCache swallowed an exception); skipping floating sampling until pack is fixed");
} }
} }
@@ -176,41 +176,41 @@ public final class FloatingIslandSample {
} }
private static int maximumEdgeFieldWidth(KList<ResolvedFloatingChild> entries, long baseSeed, private static int maximumEdgeFieldWidth(KList<ResolvedFloatingChild> entries, long baseSeed,
IrisData data, IrisBiome parent) { IrisData data, IrisBiome parent, ModuleLog log) {
int maximumWidth = FloatingIslandEdgeProfile.MIN_WIDTH; int maximumWidth = FloatingIslandEdgeProfile.MIN_WIDTH;
for (ResolvedFloatingChild entry : entries) { for (ResolvedFloatingChild entry : entries) {
FloatingIslandEdgeProfile profile = resolveEdgeProfile(entry, baseSeed, data, parent); FloatingIslandEdgeProfile profile = resolveEdgeProfile(entry, baseSeed, data, parent, log);
maximumWidth = Math.max(maximumWidth, profile.fieldWidth()); maximumWidth = Math.max(maximumWidth, profile.fieldWidth());
} }
return maximumWidth; return maximumWidth;
} }
private static FloatingIslandEdgeProfile resolveEdgeProfile(ResolvedFloatingChild entry, long baseSeed, private static FloatingIslandEdgeProfile resolveEdgeProfile(ResolvedFloatingChild entry, long baseSeed,
IrisData data, IrisBiome parent) { IrisData data, IrisBiome parent, ModuleLog log) {
FloatingIslandEdgeProfile profile = entry.getEdgeTaperProfile(baseSeed, data); FloatingIslandEdgeProfile profile = entry.getEdgeTaperProfile(baseSeed, data);
if (profile != null) { if (profile != null) {
return profile; return profile;
} }
warnNullCng("edgeTaperVariationStyle", parent); warnNullCng("edgeTaperVariationStyle", parent, log);
return FloatingIslandEdgeProfile.DEFAULT; return FloatingIslandEdgeProfile.DEFAULT;
} }
public static FloatingIslandSample sample(IrisBiome parent, int wx, int wz, int chunkHeight, long baseSeed, IrisData data, Engine engine, FloatingIslandBoundarySampler boundarySampler) { public static FloatingIslandSample sample(IrisBiome parent, int wx, int wz, int chunkHeight, long baseSeed, IrisData data, Engine engine, FloatingIslandBoundarySampler boundarySampler, ModuleLog log) {
List<FloatingChildBiome> settings = FloatingChildren.declaredBy(parent); List<FloatingChildBiome> settings = FloatingChildren.declaredBy(parent);
if (settings.isEmpty()) { if (settings.isEmpty()) {
return reject(REJECT_NO_ENTRIES); return reject(REJECT_NO_ENTRIES);
} }
KList<ResolvedFloatingChild> entries = new KList<>(FloatingChildren.of(data).of(settings)); KList<ResolvedFloatingChild> entries = new KList<>(FloatingChildren.of(data).of(settings));
return sample(parent, entries, wx, wz, chunkHeight, baseSeed, data, engine, boundarySampler); return sample(parent, entries, wx, wz, chunkHeight, baseSeed, data, engine, boundarySampler, log);
} }
static FloatingIslandSample sample(IrisBiome parent, KList<ResolvedFloatingChild> entries, int wx, int wz, int chunkHeight, long baseSeed, IrisData data, Engine engine, FloatingIslandBoundarySampler boundarySampler) { static FloatingIslandSample sample(IrisBiome parent, KList<ResolvedFloatingChild> entries, int wx, int wz, int chunkHeight, long baseSeed, IrisData data, Engine engine, FloatingIslandBoundarySampler boundarySampler, ModuleLog log) {
int boundaryFieldWidth = maximumEdgeFieldWidth(entries, baseSeed, data, parent); int boundaryFieldWidth = maximumEdgeFieldWidth(entries, baseSeed, data, parent, log);
int parentBoundaryDistance = boundarySampler.edgeDistance(parent, wx, wz, boundaryFieldWidth); int parentBoundaryDistance = boundarySampler.edgeDistance(parent, wx, wz, boundaryFieldWidth);
if (FloatingChildren.merges(parent)) { if (FloatingChildren.merges(parent)) {
return sampleMerged(parent, entries, wx, wz, chunkHeight, baseSeed, data, engine, boundarySampler, return sampleMerged(parent, entries, wx, wz, chunkHeight, baseSeed, data, engine, boundarySampler,
parentBoundaryDistance, boundaryFieldWidth); parentBoundaryDistance, boundaryFieldWidth, log);
} }
ResolvedFloatingChild entry; ResolvedFloatingChild entry;
@@ -221,7 +221,7 @@ public final class FloatingIslandSample {
ResolvedFloatingChild reference = entries.getFirst(); ResolvedFloatingChild reference = entries.getFirst();
CNG picker = reference.getPickerCng(baseSeed, data); CNG picker = reference.getPickerCng(baseSeed, data);
if (picker == null) { if (picker == null) {
warnNullCng("pickerStyle", parent); warnNullCng("pickerStyle", parent, log);
return reject(REJECT_NO_PICK); return reject(REJECT_NO_PICK);
} }
FloatingIslandBoundarySampler.OwnershipSample ownership = boundarySampler.ownership( FloatingIslandBoundarySampler.OwnershipSample ownership = boundarySampler.ownership(
@@ -234,20 +234,20 @@ public final class FloatingIslandSample {
} }
return sampleEntry(parent, entry, wx, wz, chunkHeight, baseSeed, data, engine, boundarySampler, return sampleEntry(parent, entry, wx, wz, chunkHeight, baseSeed, data, engine, boundarySampler,
parentBoundaryDistance, ownershipBoundaryDistance); parentBoundaryDistance, ownershipBoundaryDistance, log);
} }
private static FloatingIslandSample sampleMerged(IrisBiome parent, KList<ResolvedFloatingChild> entries, private static FloatingIslandSample sampleMerged(IrisBiome parent, KList<ResolvedFloatingChild> entries,
int wx, int wz, int chunkHeight, long baseSeed, IrisData data, int wx, int wz, int chunkHeight, long baseSeed, IrisData data,
Engine engine, FloatingIslandBoundarySampler boundarySampler, Engine engine, FloatingIslandBoundarySampler boundarySampler,
int parentBoundaryDistance, int boundaryFieldWidth) { int parentBoundaryDistance, int boundaryFieldWidth, ModuleLog log) {
KList<FloatingIslandSample> samples = new KList<>(); KList<FloatingIslandSample> samples = new KList<>();
int minY = Integer.MAX_VALUE; int minY = Integer.MAX_VALUE;
int maxY = Integer.MIN_VALUE; int maxY = Integer.MIN_VALUE;
for (ResolvedFloatingChild entry : entries) { for (ResolvedFloatingChild entry : entries) {
FloatingIslandSample sample = sampleEntry(parent, entry, wx, wz, chunkHeight, baseSeed, data, engine, FloatingIslandSample sample = sampleEntry(parent, entry, wx, wz, chunkHeight, baseSeed, data, engine,
boundarySampler, parentBoundaryDistance, boundaryFieldWidth + 1); boundarySampler, parentBoundaryDistance, boundaryFieldWidth + 1, log);
if (sample == null) { if (sample == null) {
continue; continue;
} }
@@ -311,11 +311,11 @@ public final class FloatingIslandSample {
private static FloatingIslandSample sampleEntry(IrisBiome parent, ResolvedFloatingChild entry, int wx, int wz, private static FloatingIslandSample sampleEntry(IrisBiome parent, ResolvedFloatingChild entry, int wx, int wz,
int chunkHeight, long baseSeed, IrisData data, Engine engine, int chunkHeight, long baseSeed, IrisData data, Engine engine,
FloatingIslandBoundarySampler boundarySampler, FloatingIslandBoundarySampler boundarySampler,
int parentBoundaryDistance, int ownershipBoundaryDistance) { int parentBoundaryDistance, int ownershipBoundaryDistance, ModuleLog log) {
FloatingIslandEdgeProfile edgeProfile = resolveEdgeProfile(entry, baseSeed, data, parent); FloatingIslandEdgeProfile edgeProfile = resolveEdgeProfile(entry, baseSeed, data, parent, log);
CNG footprintCng = entry.getFootprintCng(baseSeed, data); CNG footprintCng = entry.getFootprintCng(baseSeed, data);
if (footprintCng == null) { if (footprintCng == null) {
warnNullCng("footprintStyle", parent); warnNullCng("footprintStyle", parent, log);
return reject(REJECT_NO_SEED); return reject(REJECT_NO_SEED);
} }
double threshold = Math.max(0, Math.min(1, entry.settings().footprintThreshold())); double threshold = Math.max(0, Math.min(1, entry.settings().footprintThreshold()));
@@ -341,7 +341,7 @@ public final class FloatingIslandSample {
CNG altitudeCng = entry.getAltitudeCng(baseSeed, data); CNG altitudeCng = entry.getAltitudeCng(baseSeed, data);
if (altitudeCng == null) { if (altitudeCng == null) {
warnNullCng("altitudeStyle", parent); warnNullCng("altitudeStyle", parent, log);
return reject(REJECT_NO_SEED); return reject(REJECT_NO_SEED);
} }
double altNoise = altitudeCng.noise(wx, wz); double altNoise = altitudeCng.noise(wx, wz);
@@ -352,12 +352,12 @@ public final class FloatingIslandSample {
int baseY = minAlt + (int) Math.round(altClamped * (maxAlt - minAlt)); int baseY = minAlt + (int) Math.round(altClamped * (maxAlt - minAlt));
IrisBiome target = entry.getRealBiome(parent, data); IrisBiome target = entry.getRealBiome(parent, data);
int fullTopHeight = computeTopHeight(entry, target, engine, baseSeed, wx, wz, data); int fullTopHeight = computeTopHeight(entry, target, engine, baseSeed, wx, wz, data, log);
int topH = roundedEdgeHeight(fullTopHeight, edgeFade); int topH = roundedEdgeHeight(fullTopHeight, edgeFade);
CNG bottomCng = entry.getBottomCng(baseSeed, data); CNG bottomCng = entry.getBottomCng(baseSeed, data);
if (bottomCng == null) { if (bottomCng == null) {
warnNullCng("bottomStyle", parent); warnNullCng("bottomStyle", parent, log);
return reject(REJECT_NO_SEED); return reject(REJECT_NO_SEED);
} }
double bottomNoise = bottomCng.noise(wx, wz); double bottomNoise = bottomCng.noise(wx, wz);
@@ -775,7 +775,7 @@ public final class FloatingIslandSample {
} }
} }
private static int computeTopHeight(ResolvedFloatingChild entry, IrisBiome target, Engine engine, long baseSeed, int wx, int wz, IrisData data) { private static int computeTopHeight(ResolvedFloatingChild entry, IrisBiome target, Engine engine, long baseSeed, int wx, int wz, IrisData data, ModuleLog log) {
int maxTopHeight = Math.max(0, entry.settings().maxTopHeight()); int maxTopHeight = Math.max(0, entry.settings().maxTopHeight());
if (maxTopHeight == 0) { if (maxTopHeight == 0) {
return 0; return 0;
@@ -785,7 +785,7 @@ public final class FloatingIslandSample {
case NOISE -> { case NOISE -> {
CNG topCng = entry.getTopShapeCng(baseSeed, data); CNG topCng = entry.getTopShapeCng(baseSeed, data);
if (topCng == null) { if (topCng == null) {
warnNullCng("topShapeStyle", null); warnNullCng("topShapeStyle", null, log);
yield maxTopHeight / 2; yield maxTopHeight / 2;
} }
double n = topCng.noise(wx, wz); double n = topCng.noise(wx, wz);
@@ -83,7 +83,7 @@ final class IrisBiomeColorRenderer {
} }
case LAYER_LOAD -> { case LAYER_LOAD -> {
return biome.getCacheColorLayerLoad().aquire(() -> { return biome.getCacheColorLayerLoad().aquire(() -> {
BiomeLayers layers = BiomeLayers.of(engine); BiomeLayers layers = BiomeLayers.of(engine, engine.getGeneration().world().log());
return Color.getHSBColor(0.625f, (float) (BiomeLayers.layersOf(biome).size() / layers.busiestLayerCount(engine)), 1f); return Color.getHSBColor(0.625f, (float) (BiomeLayers.layersOf(biome).size() / layers.busiestLayerCount(engine)), 1f);
}); });
} }
@@ -34,7 +34,6 @@ import art.arcane.iris.engine.object.value.IrisPosition;
import art.arcane.iris.engine.object.world.biome.IrisBiome; import art.arcane.iris.engine.object.world.biome.IrisBiome;
import art.arcane.iris.engine.object.world.region.IrisRegion; import art.arcane.iris.engine.object.world.region.IrisRegion;
import art.arcane.iris.engine.spawn.SpawnResources.KeyedSpawner; import art.arcane.iris.engine.spawn.SpawnResources.KeyedSpawner;
import art.arcane.iris.spi.IrisLogging;
import art.arcane.iris.util.common.scheduling.J; import art.arcane.iris.util.common.scheduling.J;
import art.arcane.volmlib.util.collection.KList; import art.arcane.volmlib.util.collection.KList;
import art.arcane.volmlib.util.math.PowerOfTwoCoordinates; import art.arcane.volmlib.util.math.PowerOfTwoCoordinates;
@@ -108,7 +107,7 @@ public final class EntitySpawning implements EntitySpawns {
List<String> spawners = new ArrayList<>(); List<String> spawners = new ArrayList<>();
for (String key : marker.spawners()) { for (String key : marker.spawners()) {
if (SpawnResources.spawner(engine.getData(), key) == null) { if (SpawnResources.spawner(engine.getData(), key) == null) {
IrisLogging.error("Cannot load spawner: " + key + " for marker " + tag); world.log().error("Cannot load spawner: " + key + " for marker " + tag, null);
continue; continue;
} }
spawners.add(key); spawners.add(key);
@@ -216,7 +215,7 @@ public final class EntitySpawning implements EntitySpawns {
private void addAttempt(List<Attempt> attempts, PackWorld world, Engine engine, Candidate candidate, BlockPosition at, boolean checkSurface) { private void addAttempt(List<Attempt> attempts, PackWorld world, Engine engine, Candidate candidate, BlockPosition at, boolean checkSurface) {
EntityDefinition entity = SpawnResources.entity(engine.getData(), candidate.spawn().entity()); EntityDefinition entity = SpawnResources.entity(engine.getData(), candidate.spawn().entity());
if (entity == null) { if (entity == null) {
IrisLogging.debug(" You are trying to spawn an entity that does not exist!"); world.log().debug(" You are trying to spawn an entity that does not exist!");
return; return;
} }
@@ -35,13 +35,13 @@ import art.arcane.iris.engine.framework.Engine;
import art.arcane.iris.engine.object.noise.NoiseStyle; import art.arcane.iris.engine.object.noise.NoiseStyle;
import art.arcane.iris.engine.object.world.biome.IrisBiome; import art.arcane.iris.engine.object.world.biome.IrisBiome;
import art.arcane.iris.engine.object.world.dimension.IrisDimension; import art.arcane.iris.engine.object.world.dimension.IrisDimension;
import art.arcane.iris.spi.IrisLogging;
import art.arcane.iris.spi.PlatformBlockState; import art.arcane.iris.spi.PlatformBlockState;
import art.arcane.iris.util.common.data.B; import art.arcane.iris.util.common.data.B;
import art.arcane.iris.util.project.noise.CNG; import art.arcane.iris.util.project.noise.CNG;
import art.arcane.volmlib.util.collection.KList; import art.arcane.volmlib.util.collection.KList;
import art.arcane.volmlib.util.math.RNG; import art.arcane.volmlib.util.math.RNG;
import com.volmit.ModuleLog;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
@@ -67,20 +67,22 @@ public final class BiomeLayers {
} }
private final Supplier<LayerBlocks> layerBlocks; private final Supplier<LayerBlocks> layerBlocks;
private final ModuleLog log;
private final Map<PaletteLayer, ResolvedLayer> resolved = new ConcurrentHashMap<>(); private final Map<PaletteLayer, ResolvedLayer> resolved = new ConcurrentHashMap<>();
private final Map<LayersSettings, AtomicCache<KList<CNG>>> surfaceHeights = new ConcurrentHashMap<>(); private final Map<LayersSettings, AtomicCache<KList<CNG>>> surfaceHeights = new ConcurrentHashMap<>();
private final Map<SeaLayersSettings, AtomicCache<KList<CNG>>> seaHeights = new ConcurrentHashMap<>(); private final Map<SeaLayersSettings, AtomicCache<KList<CNG>>> seaHeights = new ConcurrentHashMap<>();
private volatile Double busiestBiomeLayerCount; private volatile Double busiestBiomeLayerCount;
/** The layers of the world {@code engine} generates now. */ /** The layers of the world {@code engine} generates now, reporting failures to {@code log}. */
public static BiomeLayers of(Engine engine) { public static BiomeLayers of(Engine engine, ModuleLog log) {
return engine.getGeneration().state(BiomeLayers.class, return engine.getGeneration().state(BiomeLayers.class,
generating -> new BiomeLayers(() -> LayerBlocks.of(generating.getGeneration().world()))); generating -> new BiomeLayers(() -> LayerBlocks.of(generating.getGeneration().world()), log));
} }
/** The layers of a world whose layer blocks {@code layerBlocks} gives, asked for when a layer first picks a block. */ /** The layers of a world whose layer blocks {@code layerBlocks} gives, asked for when a layer first picks a block. */
public BiomeLayers(Supplier<LayerBlocks> layerBlocks) { public BiomeLayers(Supplier<LayerBlocks> layerBlocks, ModuleLog log) {
this.layerBlocks = layerBlocks; this.layerBlocks = layerBlocks;
this.log = log;
} }
/** {@code layer} ready for this world; its block picks are the world's {@link LayerBlocks}. */ /** {@code layer} ready for this world; its block picks are the world's {@link LayerBlocks}. */
@@ -272,7 +274,7 @@ public final class BiomeLayers {
try { try {
blocks.add(layer.get(random, index + j, (wx + j) / zoom, j, (wz - j) / zoom)); blocks.add(layer.get(random, index + j, (wx + j) / zoom, j, (wz - j) / zoom));
} catch (Throwable e) { } catch (Throwable e) {
IrisLogging.reportError(e); log.error("A biome layer failed to pick a block", e);
} }
} }