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.ModuleInfo;
import com.volmit.ModuleLifecycle;
import com.volmit.ModuleLog;
import com.volmit.stage.ChunkStageContext;
import com.volmit.stage.StageGraph;
import com.volmit.world.PackWorld;
@@ -103,7 +104,8 @@ public final class TerrainModule implements IrisModule, ModuleLifecycle {
private static void shape(ChunkStageContext context) {
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. */
@@ -116,8 +118,8 @@ public final class TerrainModule implements IrisModule, ModuleLifecycle {
private final TerrainOres ores;
private final RNG rng;
TerrainShaper(Engine engine) {
this(engine, TerrainPalettes.of(engine), BiomeLayers.of(engine), TerrainOres.of(engine));
TerrainShaper(Engine engine, ModuleLog log) {
this(engine, TerrainPalettes.of(engine), BiomeLayers.of(engine, log), TerrainOres.of(engine));
}
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.engine.framework.Engine;
import art.arcane.iris.engine.object.world.biome.IrisBiome;
import com.volmit.ModuleLog;
import com.volmit.world.PackWorld;
import java.util.ArrayList;
@@ -48,16 +49,22 @@ public final class BiomeDecorators {
private static final long INDEX_SEED_FACTOR = 0xC2B2AE3D27D4EB4FL;
private final Engine engine;
private final ModuleLog log;
private final Map<DecorantSettings, Map<DecorationPart, ResolvedDecorator[]>> decorators = new ConcurrentHashMap<>();
private volatile Double busiestBiomeLoad;
/** @param world a world of an Iris engine */
BiomeDecorators(PackWorld world) {
this(IrisPackWorld.of(world).engine());
this(IrisPackWorld.of(world).engine(), world.log());
}
BiomeDecorators(Engine engine) {
this(engine, engine.getGeneration().world().log());
}
BiomeDecorators(Engine engine, ModuleLog log) {
this.engine = engine;
this.log = log;
}
/** The world {@code engine} generates now. */
@@ -70,6 +77,11 @@ public final class BiomeDecorators {
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. */
public boolean hasDecorators(IrisBiome biome) {
DecorantSettings settings = settingsOf(biome);
@@ -158,7 +170,7 @@ public final class BiomeDecorators {
if (decorator == null) {
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);
}
@@ -22,11 +22,11 @@ import art.arcane.iris.builtin.decorant.DecorationPart;
import art.arcane.iris.engine.mantle.EngineMantle;
import art.arcane.iris.engine.object.procedural.IrisProceduralBlocks;
import art.arcane.iris.platform.bukkit.BukkitBlockState;
import art.arcane.iris.spi.IrisLogging;
import art.arcane.iris.spi.PlatformBlockState;
import art.arcane.iris.util.common.data.B;
import art.arcane.iris.util.project.hunk.Hunk;
import art.arcane.volmlib.util.math.RNG;
import com.volmit.ModuleLog;
import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockSupport;
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. */
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;
int count = 0;
@@ -81,7 +81,7 @@ final class DecoratorCore {
}
}
} 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,
int x, int z, int realX, int height, int realZ,
Hunk<PlatformBlockState> data,
boolean underwater, boolean caveSkipFluid, EngineMantle mantle) {
boolean underwater, boolean caveSkipFluid, EngineMantle mantle, ModuleLog log) {
if (height < 0 || height >= data.getHeight()) {
return;
}
@@ -140,7 +140,7 @@ final class DecoratorCore {
data.set(x, lowerY, z, lower);
data.set(x, upperY, z, upper);
} catch (Throwable e) {
IrisLogging.reportError(e);
log.error("Failed to place a two-block plant", e);
}
return;
}
@@ -291,7 +291,7 @@ final class DecoratorCore {
static void placeFloatingSimple(ResolvedDecorator decorator,
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);
if (bd == null) {
return;
@@ -311,7 +311,7 @@ final class DecoratorCore {
data.set(xf, lowerY, zf, lower);
data.set(xf, upperY, zf, upper);
} catch (Throwable e) {
IrisLogging.reportError(e);
log.error("Failed to place a two-block plant", e);
}
return;
}
@@ -36,7 +36,8 @@ public class FloatingDecorator {
int xf, int zf, int realX, int realZ,
int height, int max, Hunk<PlatformBlockState> data, RNG rng,
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) {
candidatesNullCallback.run();
@@ -44,7 +45,7 @@ public class FloatingDecorator {
}
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;
}
@@ -45,7 +45,7 @@ public class IrisCeilingDecorator extends IrisEngineDecorator {
Hunk<PlatformBlockState> data, IrisBiome biome, InferredType inferredType, int height, int max) {
boolean caveSkipFluid = IrisSurfaceDecorator.skipsFluid(inferredType);
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) {
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,
Hunk<PlatformBlockState> data, IrisBiome biome, int height, int max) {
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) {
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,
Hunk<PlatformBlockState> data, IrisBiome biome, int height, int max) {
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) {
return;
@@ -50,7 +50,7 @@ public class IrisShoreLineDecorator extends IrisEngineDecorator {
}
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) {
return;
@@ -58,7 +58,7 @@ public class IrisSurfaceDecorator extends IrisEngineDecorator {
boolean underwater = isUnderwater(inferredType, height, fluidHeight);
boolean caveSkipFluid = skipsFluid(inferredType);
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)) {
return;
@@ -75,7 +75,7 @@ public class IrisSurfaceDecorator extends IrisEngineDecorator {
}
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) {
@@ -23,9 +23,9 @@ import art.arcane.iris.builtin.decorant.Decorator;
import art.arcane.iris.engine.data.cache.AtomicCache;
import art.arcane.iris.engine.framework.Engine;
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.util.common.data.B;
import com.volmit.ModuleLog;
import com.volmit.block.BlockRegistry;
import com.volmit.block.BlockSpec;
import com.volmit.noise.NoiseFactory;
@@ -57,6 +57,7 @@ final class ResolvedDecorator {
private final AtomicCache<NoiseSampler> chanceNoise = new AtomicCache<>();
private final AtomicCache<NoiseSampler> varianceNoise = 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
@@ -64,9 +65,11 @@ final class ResolvedDecorator {
* @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 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,
PlatformBlockState forceBlock, List<PlatformBlockState> whitelist, List<PlatformBlockState> blacklist) {
PlatformBlockState forceBlock, List<PlatformBlockState> whitelist, List<PlatformBlockState> blacklist,
ModuleLog log) {
this.settings = settings;
this.seed = seed;
this.noise = noise;
@@ -77,15 +80,16 @@ final class ResolvedDecorator {
this.forceBlock = forceBlock;
this.whitelist = whitelist.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}. */
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();
BlockRegistry registry = resources.blocks();
PlatformBlockState forced = settings.forceBlock().map(spec -> platformState(registry, spec)).orElse(null);
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) {
@@ -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. */
PlatformBlockState blockAt(IrisBiome biome, double x, double y, double z) {
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;
}
@@ -39,8 +39,10 @@ import art.arcane.iris.engine.object.structure.vanilla.NativeStructureSuppressio
import art.arcane.iris.engine.object.structure.StructureDistribution;
import art.arcane.volmlib.util.collection.KList;
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.Caffeine;
import com.volmit.ModuleLog;
import it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap;
import java.util.ArrayList;
@@ -509,14 +511,14 @@ public final class IrisStructureLocator {
throw new IllegalStateException("Iris structure placement references missing structure '"
+ selectedKey + "'");
}
StructureGraphCompilation compilation = StructureGraphCatalog.compile(engine.getData(), structure);
StructureGraphCompilation compilation = StructureGraphCatalog.compile(engine.getData(), structure, IrisModuleHost.hostLog());
if (!compilation.isAssemblyViable()) {
throw new IllegalStateException("Iris structure '" + selectedKey
+ "' has no runtime-viable assembly graph");
}
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);
if (!requirePlacementOutput(placement, selectedKey, cx, cz,
assembly.hasOutput(), "runtime assembly produced " + assembly.status() + ": " + assembly.detail())) {
@@ -1118,17 +1120,18 @@ public final class IrisStructureLocator {
private static PlacementIndex build(Engine engine) {
IrisData data = engine.getData();
ModuleLog log = IrisModuleHost.hostLog();
Set<String> loadKeys = new LinkedHashSet<>();
Set<String> normalizedLoadKeys = new LinkedHashSet<>();
Set<String> vanillaAliases = new LinkedHashSet<>();
Set<String> suppressedVanillaSources = new LinkedHashSet<>();
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);
KList<IrisRegion> regions = engine.getDimension().getAllRegions(engine);
if (regions != null) {
for (IrisRegion region : regions) {
collect(region == null ? null : region.getStructures(), data,
collect(region == null ? null : region.getStructures(), data, log,
loadKeys, normalizedLoadKeys, vanillaAliases,
suppressedVanillaSources, placements, false);
}
@@ -1136,7 +1139,7 @@ public final class IrisStructureLocator {
KList<IrisBiome> biomes = engine.getDimension().getReachableBiomes(engine);
if (biomes != null) {
for (IrisBiome biome : biomes) {
collect(biome == null ? null : biome.getStructures(), data,
collect(biome == null ? null : biome.getStructures(), data, log,
loadKeys, normalizedLoadKeys, vanillaAliases,
suppressedVanillaSources, placements, false);
}
@@ -1165,7 +1168,7 @@ public final class IrisStructureLocator {
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> suppressedVanillaSources,
List<IrisStructurePlacement> placements, boolean allowNativeSuppression) {
@@ -1230,7 +1233,7 @@ public final class IrisStructureLocator {
throw new IllegalStateException("REPLACE_SOURCE structure '" + structureKey
+ "' must declare a valid namespaced vanillaSource");
}
if (!StructureGraphCatalog.guaranteesRuntimeOutput(data, structure)) {
if (!StructureGraphCatalog.guaranteesRuntimeOutput(data, structure, log)) {
throw new IllegalStateException("REPLACE_SOURCE structure '" + structureKey
+ "' 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.math.RNG;
import com.volmit.ModuleLog;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
@@ -89,11 +90,11 @@ public final class StructureAssembler {
? 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");
IrisStructure activeStructure = Objects.requireNonNull(
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,
@@ -5,11 +5,11 @@ import art.arcane.iris.core.modules.IrisPackResources;
import art.arcane.iris.engine.framework.StructureAssembler;
import art.arcane.iris.engine.object.value.IrisPosition;
import art.arcane.iris.engine.object.structure.IrisStructure;
import art.arcane.iris.spi.IrisLogging;
import art.arcane.volmlib.util.math.RNG;
import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
import com.volmit.ModuleLog;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
@@ -30,35 +30,35 @@ public final class 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);
IrisStructure activeStructure = Objects.requireNonNull(structure);
String structureKey = activeStructure.getLoadKey();
if (structureKey == null || structureKey.isBlank()) {
return compileAndReport(activeData, activeStructure);
return compileAndReport(activeData, activeStructure, log);
}
ConcurrentMap<String, StructureGraphCompilation> catalog = CACHE.get(
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);
IrisStructure activeStructure = Objects.requireNonNull(structure);
if (!compile(activeData, activeStructure).guaranteesAssemblyOutput()) {
if (!compile(activeData, activeStructure, log).guaranteesAssemblyOutput()) {
return false;
}
String structureKey = activeStructure.getLoadKey();
if (structureKey == null || structureKey.isBlank()) {
return sampleRuntimeAssembly(activeData, activeStructure);
return sampleRuntimeAssembly(activeData, activeStructure, log);
}
ConcurrentMap<String, Boolean> catalog = RUNTIME_OUTPUT.get(
activeData.getPackResources(), ignored -> new ConcurrentHashMap<>());
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(
structure, StructureGraphResolver.forData(data));
String structureKey = structure.getLoadKey() == null || structure.getLoadKey().isBlank()
@@ -66,29 +66,29 @@ public final class StructureGraphCatalog {
for (StructureGraphDiagnostic diagnostic : compilation.getDiagnostics()) {
String message = "[StructureGraph:" + structureKey + "] " + diagnostic.message();
if (diagnostic.severity() == StructureGraphDiagnostic.Severity.ERROR) {
IrisLogging.error(message);
log.error(message, null);
} else {
IrisLogging.warn(message);
log.warn(message);
}
}
if (!compilation.isAssemblyViable()) {
IrisLogging.error("[StructureGraph:" + structureKey
+ "] Graph rejected because deterministic assembly did not complete.");
log.error("[StructureGraph:" + structureKey
+ "] Graph rejected because deterministic assembly did not complete.", null);
}
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) {
try {
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));
if (!result.hasOutput()) {
return false;
}
} catch (Throwable e) {
IrisLogging.reportError(e);
log.error("Failed to sample the runtime assembly of a structure", e);
return false;
}
}
@@ -90,7 +90,7 @@ public final class StructureFitting {
private void prepare() {
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);
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.engine.object.placement.IrisObjectVacuum;
import art.arcane.iris.spi.IrisLogging;
import com.volmit.ModuleLog;
import com.volmit.block.BlockState;
import com.volmit.vanilla.StructureStep;
import com.volmit.vanilla.TemplateCells;
@@ -66,16 +66,17 @@ final class SurfaceFitting {
}
static VacuumFoundationPlan prepareSurfaceStructures(FitBlocks blocks, Box area, List<FitStart> starts,
IntBinaryOperator surfaceHeight, int maximumTemplateCells) {
IntBinaryOperator surfaceHeight, int maximumTemplateCells,
ModuleLog log) {
if (starts.isEmpty()) {
return VacuumFoundationPlan.EMPTY;
}
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()) {
fitSurfaceTerrain(blocks, area, anchors, surfaceHeight);
}
VacuumFootprint vacuum = collectVacuumFootprint(blocks, area, starts, maximumTemplateCells);
VacuumFootprint vacuum = collectVacuumFootprint(blocks, area, starts, maximumTemplateCells, log);
if (!vacuum.anchors().isEmpty()) {
fitVacuumTerrain(blocks, area, vacuum, surfaceHeight);
}
@@ -208,7 +209,7 @@ final class SurfaceFitting {
}
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);
List<SurfaceAnchor> anchors = new ArrayList<>();
Set<Object> seenStarts = Collections.newSetFromMap(new IdentityHashMap<>());
@@ -228,7 +229,7 @@ final class SurfaceFitting {
} catch (TemplateBudgetExceeded ignored) {
budgetExceeded = true;
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()) {
@@ -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())) {
IrisLogging.warn("Native structure " + mode + " fitting for '" + start.structureId()
log.warn("Native structure " + mode + " fitting for '" + start.structureId()
+ "' exceeded its bounded template budget; " + consequence);
}
}
private static VacuumFootprint collectVacuumFootprint(FitBlocks blocks, Box area, List<FitStart> starts,
int maximumTemplateCells) {
int maximumTemplateCells, ModuleLog log) {
Box influenceArea = area.widened(SURFACE_TERRAIN_RADIUS);
Map<Long, VacuumAnchor> anchors = new HashMap<>();
Map<Long, Integer> columnCaps = new HashMap<>();
@@ -316,7 +317,7 @@ final class SurfaceFitting {
}
}
} 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;
}
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) {
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) {
@@ -21,10 +21,10 @@ package art.arcane.iris.engine.loot;
import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.engine.framework.LootResolver;
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.PlatformBlockState;
import art.arcane.volmlib.util.math.RNG;
import com.volmit.ModuleLog;
import com.volmit.service.Loot;
import java.util.ArrayList;
@@ -46,12 +46,14 @@ final class PlacementLoot {
private final IrisData data;
private final Supplier<Set<String>> platformTables;
private final long lootSeed;
private final ModuleLog log;
/** @param platformTables the keys of the loot tables the platform has, asked for only when a placement names one */
PlacementLoot(IrisData data, Supplier<Set<String>> platformTables, long lootSeed) {
PlacementLoot(IrisData data, Supplier<Set<String>> platformTables, long lootSeed, ModuleLog log) {
this.data = data;
this.platformTables = platformTables;
this.lootSeed = lootSeed;
this.log = log;
}
/** 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());
if (source == null) {
IrisLogging.warn("Couldn't find loot table " + entry.getName());
log.warn("Couldn't find loot table " + entry.getName());
continue;
}
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.FloatingIslandSample;
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.LongOpenHashSet;
import org.jetbrains.annotations.Nullable;
@@ -39,13 +40,15 @@ final class FloatingIslandSampleResolver implements IslandObjectPlacer.SamplePro
private final FloatingIslandBoundarySampler boundarySampler;
private final Long2ObjectOpenHashMap<FloatingIslandSample> sampleCache;
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.engine = engineMantle.getEngine();
this.chunkHeight = engine.getHeight();
this.baseSeed = engine.getSeedManager().getTerrain() ^ FloatingIslands.FLOATING_BASE_SEED_SALT;
this.boundarySampler = boundarySampler;
this.log = log;
this.sampleCache = new Long2ObjectOpenHashMap<>();
this.resolvedSamples = new LongOpenHashSet();
}
@@ -61,7 +64,7 @@ final class FloatingIslandSampleResolver implements IslandObjectPlacer.SamplePro
resolvedSamples.add(key);
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);
if (sample != null) {
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.IrisObjectTranslate;
import art.arcane.iris.engine.object.procedural.IrisProceduralBlocks;
import art.arcane.iris.spi.IrisLogging;
import art.arcane.iris.spi.PlatformBlockState;
import art.arcane.iris.util.common.data.B;
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.math.RNG;
import com.volmit.ModuleLog;
import java.io.File;
import java.util.HashMap;
import java.util.HashSet;
@@ -62,9 +62,11 @@ public class FloatingObjectPlacing {
private static final IrisObjectRotation ROTATION_NONE = IrisObjectRotation.of(0, 0, 0);
private final Engine engine;
private final ModuleLog log;
public FloatingObjectPlacing(Engine engine) {
public FloatingObjectPlacing(Engine engine, ModuleLog log) {
this.engine = engine;
this.log = log;
}
/** 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 minZ = z << 4;
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();
@@ -212,7 +214,7 @@ public class FloatingObjectPlacing {
}
}, null, data);
} 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) {
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) {
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));
}
} catch (Throwable e) {
IrisLogging.reportError(e);
log.error("Failed to work out the reach of a floating biome's objects", e);
}
}
}
} catch (Throwable e) {
IrisLogging.reportError(e);
log.error("Failed to work out the reach of the floating biomes' objects", e);
}
return maxObjectExtent;
}
@@ -593,11 +595,11 @@ public class FloatingObjectPlacing {
}
int reach = ObjectPlacing.calculatePlacementReach(size, placement);
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);
} 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.object.placement.IObjectPlacer;
import art.arcane.iris.engine.object.prefab.TileData;
import art.arcane.iris.spi.IrisLogging;
import art.arcane.iris.spi.PlatformBlockState;
import com.volmit.ModuleLog;
final class GoldenDebugObjectPlacer implements IObjectPlacer {
private static final int[] GOLDEN_DEBUG_TARGET = parseGoldenDebugTarget(resolveGoldenDebugSpec());
@@ -31,10 +31,12 @@ final class GoldenDebugObjectPlacer implements IObjectPlacer {
private final IObjectPlacer delegate;
private final String tag;
private final ModuleLog log;
GoldenDebugObjectPlacer(IObjectPlacer delegate, String tag) {
GoldenDebugObjectPlacer(IObjectPlacer delegate, String tag, ModuleLog log) {
this.delegate = delegate;
this.tag = tag;
this.log = log;
}
private static String resolveGoldenDebugSpec() {
@@ -77,14 +79,14 @@ final class GoldenDebugObjectPlacer implements IObjectPlacer {
@Override
public int getHighest(int x, int z, IrisData 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;
}
@Override
public int getHighest(int x, int z, IrisData data, boolean 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;
}
@@ -106,7 +108,7 @@ final class GoldenDebugObjectPlacer implements IObjectPlacer {
@Override
public boolean isCarved(int x, int y, int 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;
}
@@ -118,7 +120,7 @@ final class GoldenDebugObjectPlacer implements IObjectPlacer {
@Override
public boolean isSolid(int x, int y, int 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;
}
@@ -36,7 +36,7 @@ import java.util.Set;
public final class ObjectLocating implements ObjectsAt {
@Override
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
@@ -35,6 +35,7 @@ import com.volmit.FeatureRegistry;
import com.volmit.IrisModule;
import com.volmit.ModuleInfo;
import com.volmit.ModuleLifecycle;
import com.volmit.ModuleLog;
import com.volmit.config.PackSettings;
import com.volmit.service.ObjectsAt;
import com.volmit.service.SaplingGrowth;
@@ -53,6 +54,8 @@ import com.volmit.world.PackWorld;
public final class ObjectModule implements IrisModule, ModuleLifecycle {
private static final String VERSION = "built-in";
private ModuleLog log;
@Override
public ModuleInfo info() {
return ModuleInfo.of("iris:objects", "Objects", VERSION);
@@ -60,11 +63,12 @@ public final class ObjectModule implements IrisModule, ModuleLifecycle {
@Override
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
public void register(FeatureRegistry registry) {
log = registry.log();
registry.registerService(ObjectsAt.class, new ObjectLocating());
registry.registerService(SaplingGrowth.class, new TreeGrowing());
registry.registerHeldType(TreeCanopy.class);
@@ -85,15 +89,15 @@ public final class ObjectModule implements IrisModule, ModuleLifecycle {
private static void place(MantleStageContext context) {
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) {
return placing(IrisPackSettings.of(settings).engine()).reach();
private int reach(PackSettings settings) {
return placing(IrisPackSettings.of(settings).engine(), log).reach();
}
/** The engine runtime's object placing, which the module's {@link ObjectsAt} also asks. */
public static ObjectPlacing placing(Engine engine) {
return engine.getGeneration().state(ObjectPlacing.class, ObjectPlacing::new);
/** 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, ModuleLog log) {
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.tree.IrisProceduralTree;
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.KMap;
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.iris.util.project.noise.CNG;
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.Long2ObjectOpenHashMap;
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 final Engine engine;
private final ModuleLog log;
public ObjectPlacing(Engine engine) {
public ObjectPlacing(Engine engine, ModuleLog log) {
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();
if (key == null || key.isEmpty() || key.equals("null")) {
String fingerprint = context + "|" + (object == null ? "<null>" : object.getClass().getSimpleName());
if (MISSING_LOAD_KEY_WARNED.add(fingerprint)) {
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()) + "). "
+ "This would previously produce 'Couldn't find Object: null' warnings on chunk reload.");
}
@@ -137,7 +139,7 @@ public class ObjectPlacing {
carvedBlocks++;
}
}
IrisLogging.debug("Cave object diag: chunk=" + x + "," + z
log.debug("Cave object diag: chunk=" + x + "," + z
+ " surfaceBiome=" + surfaceBiome.getLoadKey()
+ " caveBiome=" + caveBiome.getLoadKey()
+ " surfaceY=" + surfaceY
@@ -148,7 +150,7 @@ public class ObjectPlacing {
+ " sameBiome=" + (caveBiome == surfaceBiome || java.util.Objects.equals(caveBiome.getLoadKey(), surfaceBiome.getLoadKey())));
}
if (traceRegen) {
IrisLogging.debug("Regen object layer start: chunk=" + x + "," + z
log.debug("Regen object layer start: chunk=" + x + "," + z
+ " surfaceBiome=" + surfaceBiome.getLoadKey()
+ " caveBiome=" + caveBiome.getLoadKey()
+ " region=" + region.getLoadKey()
@@ -165,7 +167,7 @@ public class ObjectPlacing {
placeUpperObjects(writer, rng, x, z, xxx, zzz, surfaceY, upperCtx, dimension, complex, traceRegen);
}
if (traceRegen) {
IrisLogging.debug("Regen object layer done: chunk=" + x + "," + z
log.debug("Regen object layer done: chunk=" + x + "," + z
+ " biomeSurfacePlacersChecked=" + summary.biomeSurfacePlacersChecked()
+ " biomeSurfacePlacersTriggered=" + summary.biomeSurfacePlacersTriggered()
+ " biomeCavePlacersChecked=" + summary.biomeCavePlacersChecked()
@@ -245,7 +247,7 @@ public class ObjectPlacing {
biomeSurfaceChecked++;
boolean chance = rng.chance(i.getChance() + rng.d(-0.005, 0.005));
if (traceRegen) {
IrisLogging.debug("Regen object placer chance: chunk=" + x + "," + z
log.debug("Regen object placer chance: chunk=" + x + "," + z
+ " scope=biome-surface"
+ " chanceResult=" + chance
+ " chanceBase=" + i.getChance()
@@ -263,10 +265,9 @@ public class ObjectPlacing {
errors += result.errors();
} catch (Throwable e) {
errors++;
IrisLogging.reportError(e);
IrisLogging.error("Failed to place objects in the following biome: " + surfaceBiome.getName());
IrisLogging.error("Object(s) " + i.getPlace().toString(", ") + " (" + e.getClass().getSimpleName() + ").");
IrisLogging.error("Are these objects missing?");
log.error("Failed to place objects in the following biome: " + surfaceBiome.getName(), e);
log.error("Object(s) " + i.getPlace().toString(", ") + " (" + e.getClass().getSimpleName() + ").", null);
log.error("Are these objects missing?", null);
}
}
}
@@ -278,7 +279,7 @@ public class ObjectPlacing {
biomeCaveChecked++;
boolean chance = rng.chance(i.getChance());
if (traceRegen) {
IrisLogging.debug("Regen object placer chance: chunk=" + x + "," + z
log.debug("Regen object placer chance: chunk=" + x + "," + z
+ " scope=biome-cave"
+ " chanceResult=" + chance
+ " chanceBase=" + i.getChance()
@@ -296,10 +297,9 @@ public class ObjectPlacing {
errors += result.errors();
} catch (Throwable e) {
errors++;
IrisLogging.reportError(e);
IrisLogging.error("Failed to place cave objects in the following biome: " + caveBiome.getName());
IrisLogging.error("Object(s) " + i.getPlace().toString(", ") + " (" + e.getClass().getSimpleName() + ").");
IrisLogging.error("Are these objects missing?");
log.error("Failed to place cave objects in the following biome: " + caveBiome.getName(), e);
log.error("Object(s) " + i.getPlace().toString(", ") + " (" + e.getClass().getSimpleName() + ").", null);
log.error("Are these objects missing?", null);
}
}
}
@@ -308,7 +308,7 @@ public class ObjectPlacing {
regionSurfaceChecked++;
boolean chance = rng.chance(i.getChance() + rng.d(-0.005, 0.005));
if (traceRegen) {
IrisLogging.debug("Regen object placer chance: chunk=" + x + "," + z
log.debug("Regen object placer chance: chunk=" + x + "," + z
+ " scope=region-surface"
+ " chanceResult=" + chance
+ " chanceBase=" + i.getChance()
@@ -326,10 +326,9 @@ public class ObjectPlacing {
errors += result.errors();
} catch (Throwable e) {
errors++;
IrisLogging.reportError(e);
IrisLogging.error("Failed to place objects in the following region: " + region.getName());
IrisLogging.error("Object(s) " + i.getPlace().toString(", ") + " (" + e.getClass().getSimpleName() + ").");
IrisLogging.error("Are these objects missing?");
log.error("Failed to place objects in the following region: " + region.getName(), e);
log.error("Object(s) " + i.getPlace().toString(", ") + " (" + e.getClass().getSimpleName() + ").", null);
log.error("Are these objects missing?", null);
}
}
}
@@ -341,7 +340,7 @@ public class ObjectPlacing {
regionCaveChecked++;
boolean chance = rng.chance(i.getChance());
if (traceRegen) {
IrisLogging.debug("Regen object placer chance: chunk=" + x + "," + z
log.debug("Regen object placer chance: chunk=" + x + "," + z
+ " scope=region-cave"
+ " chanceResult=" + chance
+ " chanceBase=" + i.getChance()
@@ -359,10 +358,9 @@ public class ObjectPlacing {
errors += result.errors();
} catch (Throwable e) {
errors++;
IrisLogging.reportError(e);
IrisLogging.error("Failed to place cave objects in the following region: " + region.getName());
IrisLogging.error("Object(s) " + i.getPlace().toString(", ") + " (" + e.getClass().getSimpleName() + ").");
IrisLogging.error("Are these objects missing?");
log.error("Failed to place cave objects in the following region: " + region.getName(), e);
log.error("Object(s) " + i.getPlace().toString(", ") + " (" + e.getClass().getSimpleName() + ").", null);
log.error("Are these objects missing?", null);
}
}
}
@@ -419,7 +417,7 @@ public class ObjectPlacing {
boolean treePlacement = p instanceof IrisProceduralTree;
boolean chancePassed = passesProceduralChance(rng, p.getChance());
if (golden) {
IrisLogging.debug("Goldendebug procedural chance: chunk=" + x + "," + z
log.debug("Goldendebug procedural chance: chunk=" + x + "," + z
+ " scope=" + scope
+ " placement=" + p.getName()
+ " passed=" + chancePassed);
@@ -438,13 +436,13 @@ public class ObjectPlacing {
int minDepthBelowSurface = resolveObjectMinDepthBelowSurface(caveProfile);
int anchorSearchAttempts = resolveAnchorSearchAttempts(caveProfile);
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());
for (int i = 0; i < density; i++) {
IrisObject variant = p.getVariantObject(engine.getData(), rng);
if (variant == null) {
if (golden) {
IrisLogging.debug("Goldendebug procedural pick: chunk=" + x + "," + z
log.debug("Goldendebug procedural pick: chunk=" + x + "," + z
+ " placement=" + p.getName()
+ " densityIndex=" + i
+ " variant=null");
@@ -469,7 +467,7 @@ public class ObjectPlacing {
}
if (carving && caveAnchor == null) {
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()
+ " minDepthBelowSurface=" + minDepthBelowSurface);
}
@@ -480,7 +478,7 @@ public class ObjectPlacing {
int id = rng.i(0, Integer.MAX_VALUE);
if (golden) {
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()
+ " densityIndex=" + i
+ " variant=" + variant.getLoadKey()
@@ -496,7 +494,7 @@ public class ObjectPlacing {
if (carving) {
int caveFloorY = caveAnchor.y();
if (golden) {
IrisLogging.debug("Goldendebug procedural caveFloor: chunk=" + x + "," + z
log.debug("Goldendebug procedural caveFloor: chunk=" + x + "," + z
+ " placement=" + p.getName()
+ " xx=" + xx
+ " zz=" + zz
@@ -530,7 +528,7 @@ public class ObjectPlacing {
}, null, engine.getData());
}
if (golden) {
IrisLogging.debug("Goldendebug procedural result: chunk=" + x + "," + z
log.debug("Goldendebug procedural result: chunk=" + x + "," + z
+ " placement=" + p.getName()
+ " variant=" + variant.getLoadKey()
+ " xx=" + xx
@@ -539,8 +537,7 @@ public class ObjectPlacing {
+ " commit=" + commitResult);
}
} catch (Throwable e) {
IrisLogging.reportError(e);
IrisLogging.error("Failed to place procedural object '" + p.getName() + "' in " + scope);
log.error("Failed to place procedural object '" + p.getName() + "' in " + scope, e);
}
}
}
@@ -670,7 +667,7 @@ public class ObjectPlacing {
if (v == null) {
nullObjects++;
if (traceRegen) {
IrisLogging.debug("Regen object placement null object: chunk=" + chunkX + "," + chunkZ
log.debug("Regen object placement null object: chunk=" + chunkX + "," + chunkZ
+ " scope=" + scope
+ " densityIndex=" + i
+ " density=" + density
@@ -683,9 +680,9 @@ public class ObjectPlacing {
IrisObjectPlacement effectivePlacement = resolveEffectivePlacement(objectPlacement, v);
boolean treePlacement = isTreePlacement(v, effectivePlacement);
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) {
IrisLogging.debug("Goldendebug object attempt: chunk=" + chunkX + "," + chunkZ
log.debug("Goldendebug object attempt: chunk=" + chunkX + "," + chunkZ
+ " scope=" + scope
+ " object=" + v.getLoadKey()
+ " densityIndex=" + i
@@ -714,7 +711,7 @@ public class ObjectPlacing {
}
if (golden) {
IrisLogging.debug("Goldendebug object result: chunk=" + chunkX + "," + chunkZ
log.debug("Goldendebug object result: chunk=" + chunkX + "," + chunkZ
+ " scope=" + scope
+ " object=" + v.getLoadKey()
+ " resultY=" + result
@@ -722,7 +719,7 @@ public class ObjectPlacing {
}
if (traceRegen) {
IrisLogging.debug("Regen object placement result: chunk=" + chunkX + "," + chunkZ
log.debug("Regen object placement result: chunk=" + chunkX + "," + chunkZ
+ " scope=" + scope
+ " object=" + v.getLoadKey()
+ " resultY=" + result
@@ -734,13 +731,12 @@ public class ObjectPlacing {
}
} catch (Throwable e) {
errors++;
IrisLogging.reportError(e);
IrisLogging.error("Regen object placement exception: chunk=" + chunkX + "," + chunkZ
log.error("Regen object placement exception: chunk=" + chunkX + "," + chunkZ
+ " scope=" + scope
+ " object=" + v.getLoadKey()
+ " densityIndex=" + i
+ " 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) {
nullObjects++;
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
+ " densityIndex=" + i
+ " density=" + density
@@ -922,7 +918,7 @@ public class ObjectPlacing {
}
if (traceRegen) {
IrisLogging.debug("Regen cave object placement result: chunk=" + metricChunkX + "," + metricChunkZ
log.debug("Regen cave object placement result: chunk=" + metricChunkX + "," + metricChunkZ
+ " scope=" + scope
+ " object=" + object.getLoadKey()
+ " resultY=" + result
@@ -935,13 +931,12 @@ public class ObjectPlacing {
}
} catch (Throwable e) {
errors++;
IrisLogging.reportError(e);
IrisLogging.error("Regen cave object placement exception: chunk=" + metricChunkX + "," + metricChunkZ
log.error("Regen cave object placement exception: chunk=" + metricChunkX + "," + metricChunkZ
+ " scope=" + scope
+ " object=" + object.getLoadKey()
+ " densityIndex=" + i
+ " density=" + density
+ " error=" + e.getClass().getSimpleName() + ":" + e.getMessage());
+ " error=" + e.getClass().getSimpleName() + ":" + e.getMessage(), e);
logCaveReject(
scope,
"EXCEPTION",
@@ -993,9 +988,8 @@ public class ObjectPlacing {
try {
placeUpperObject(writer, rng, chunkX, chunkZ, i, upperCtx, dimension, complex, forcePlace, traceRegen, "upper-biome-surface");
} catch (Throwable e) {
IrisLogging.reportError(e);
IrisLogging.error("Failed to place upper-dimension objects in biome " + upperBiome.getName()
+ ": " + i.getPlace().toString(", ") + " (" + e.getClass().getSimpleName() + ")");
log.error("Failed to place upper-dimension objects in biome " + upperBiome.getName()
+ ": " + i.getPlace().toString(", ") + " (" + e.getClass().getSimpleName() + ")", e);
}
}
}
@@ -1008,9 +1002,8 @@ public class ObjectPlacing {
try {
placeUpperObject(writer, rng, chunkX, chunkZ, i, upperCtx, dimension, complex, forcePlace, traceRegen, "upper-region-surface");
} catch (Throwable e) {
IrisLogging.reportError(e);
IrisLogging.error("Failed to place upper-dimension objects in region " + upperRegion.getName()
+ ": " + i.getPlace().toString(", ") + " (" + e.getClass().getSimpleName() + ")");
log.error("Failed to place upper-dimension objects in region " + upperRegion.getName()
+ ": " + i.getPlace().toString(", ") + " (" + e.getClass().getSimpleName() + ")", e);
}
}
}
@@ -1081,7 +1074,7 @@ public class ObjectPlacing {
}, null, engine.getData());
if (traceRegen) {
IrisLogging.debug("Upper object placement: chunk=" + chunkX + "," + chunkZ
log.debug("Upper object placement: chunk=" + chunkX + "," + chunkZ
+ " scope=" + scope
+ " object=" + v.getLoadKey()
+ " anchorY=" + anchorY
@@ -1140,7 +1133,7 @@ public class ObjectPlacing {
int suppressed = state.suppressed.getAndSet(0);
String anchorYText = anchorY == null ? "none" : String.valueOf(anchorY);
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
+ " chunk=" + chunkX + "," + chunkZ
+ " object=" + objectKey
@@ -1496,11 +1489,11 @@ public class ObjectPlacing {
}
int reach = calculatePlacementReach(size, placement);
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);
} 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 {
return IrisObject.sampleSize(engine.getData().getObjectLoader().findFile(objectKey));
} catch (IOException e) {
IrisLogging.reportError(e);
log.error("Failed to size an object", e);
}
return null;
@@ -35,6 +35,7 @@ import com.volmit.FeatureRegistry;
import com.volmit.IrisModule;
import com.volmit.ModuleInfo;
import com.volmit.ModuleLifecycle;
import com.volmit.ModuleLog;
import com.volmit.config.PackSettings;
import com.volmit.service.StructureLocator;
import com.volmit.service.VanillaStructures;
@@ -63,6 +64,8 @@ import com.volmit.world.PackWorld;
public final class StructureModule implements IrisModule, ModuleLifecycle {
private static final String VERSION = "built-in";
private ModuleLog log;
@Override
public ModuleInfo info() {
return ModuleInfo.of("iris:structure", "Structures", VERSION);
@@ -71,11 +74,12 @@ public final class StructureModule implements IrisModule, ModuleLifecycle {
@Override
public void install(StageGraph graph) {
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
public void register(FeatureRegistry registry) {
log = registry.log();
registry.registerSettings(StructureSettings.class);
StructureResources.kinds().forEach(registry::registerResourceKind);
registry.registerValidator(new StructureValidator());
@@ -95,14 +99,14 @@ public final class StructureModule implements IrisModule, ModuleLifecycle {
private static void place(MantleStageContext context) {
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) {
return placing(IrisPackSettings.of(settings).engine()).reach();
private int reach(PackSettings settings) {
return placing(IrisPackSettings.of(settings).engine(), log).reach();
}
private static StructurePlacing placing(Engine engine) {
return engine.getGeneration().state(StructurePlacing.class, StructurePlacing::new);
private static StructurePlacing placing(Engine engine, ModuleLog log) {
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.engine.object.structure.IrisStructurePlacement;
import art.arcane.iris.builtin.structure.StructureStilts;
import com.volmit.ModuleLog;
import com.volmit.block.PaletteSampler;
import com.volmit.block.PaletteSpec;
import art.arcane.iris.builtin.structure.StructureTerrain;
import art.arcane.iris.builtin.structure.StructureTerrainMode;
import art.arcane.iris.spi.IrisLogging;
import art.arcane.iris.spi.PlatformBlockState;
import art.arcane.iris.util.common.data.B;
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 final Engine engine;
private final ModuleLog log;
public StructurePlacing(Engine engine) {
public StructurePlacing(Engine engine, ModuleLog log) {
this.engine = engine;
this.log = log;
}
/** 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();
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());
}
@@ -112,7 +114,7 @@ public class StructurePlacing {
RNG rng = resolved.rng();
int baseY = resolved.baseY();
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()) {
@@ -319,7 +321,7 @@ public class StructurePlacing {
}
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()
+ " 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 com.volmit.IrisModule;
import com.volmit.ModuleInfo;
import com.volmit.ModuleLog;
import com.volmit.service.CaveBiomes;
import com.volmit.stage.ChunkStageContext;
import com.volmit.stage.MantleStageContext;
@@ -82,7 +83,8 @@ public final class CarveModule implements IrisModule {
if (chunk.bypassesMantleStages()) {
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());
}
@@ -44,6 +44,7 @@ import art.arcane.volmlib.util.matter.Matter;
import art.arcane.volmlib.util.matter.MatterCavern;
import art.arcane.volmlib.util.matter.slices.MarkerMatter;
import art.arcane.volmlib.util.scheduling.PrecisionStopwatch;
import com.volmit.ModuleLog;
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
import lombok.Data;
import art.arcane.iris.spi.PlatformBlockState;
@@ -72,11 +73,11 @@ public class CaveApplying {
private final IrisSurfaceDecorator surfaceDecorator;
private final IrisCeilingDecorator ceilingDecorator;
public CaveApplying(Engine engine) {
public CaveApplying(Engine engine, ModuleLog log) {
this.engine = engine;
rng = new RNG(engine.getSeedManager().getCarve());
decorators = BiomeDecorators.of(engine);
layers = BiomeLayers.of(engine);
layers = BiomeLayers.of(engine, log);
palettes = TerrainPalettes.of(engine);
surfaceDecorator = new IrisSurfaceDecorator(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.builtin.decorant.DecorationPart;
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.project.context.ChunkContext;
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.PlatformBlockState;
import com.volmit.ModuleLog;
import java.util.IdentityHashMap;
import static art.arcane.iris.engine.mantle.EngineMantle.AIR;
@@ -68,6 +68,7 @@ public class FloatingIslands {
private final RNG rng;
private final EngineDecorator seaSurfaceDecorator;
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) {
if (entry == null || entry.settings().bottomPaletteMode() != FloatingBottomPaletteMode.CUSTOM || entry.settings().bottomPalette() == null || entry.settings().bottomPalette().isEmpty()) {
@@ -108,7 +109,7 @@ public class FloatingIslands {
try {
generated.add(layer.get(random.nextParallelRNG(i + j), (wx + j) / layer.zoom(), j, (wz - j) / layer.zoom()));
} 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.log = log;
rng = new RNG(engine.getSeedManager().getTerrain() ^ 0x7EB0A73F1DCE514DL);
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}. */
@@ -233,7 +235,7 @@ public class FloatingIslands {
if (parent == null || FloatingChildren.declaredBy(parent).isEmpty()) {
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) {
continue;
}
@@ -318,7 +320,7 @@ public class FloatingIslands {
if (parent == null || FloatingChildren.declaredBy(parent).isEmpty()) {
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) {
continue;
}
@@ -338,7 +340,7 @@ public class FloatingIslands {
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);
} 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 {
seaSurfaceDecorator.decorate(xf, zf, wx, wx + 1, wx - 1, wz, wz + 1, wz - 1, output, target, fluidTopY, chunkHeight);
} 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);
}
} 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 com.volmit.IrisModule;
import com.volmit.ModuleInfo;
import com.volmit.ModuleLog;
import com.volmit.config.PackSettings;
import com.volmit.stage.ChunkStageContext;
import com.volmit.stage.MantleStageContext;
@@ -44,6 +45,8 @@ import com.volmit.stage.StageGraph;
public final class FloatingModule implements IrisModule {
private static final String VERSION = "built-in";
private ModuleLog log;
@Override
public ModuleInfo info() {
return ModuleInfo.of("iris:floating", "Floating islands", VERSION);
@@ -51,13 +54,14 @@ public final class FloatingModule implements IrisModule {
@Override
public void register(FeatureRegistry registry) {
log = registry.log();
registry.registerSettings(FloatingChildSettings.class);
registry.registerSettings(MergeFloatingChildrenSettings.class);
}
@Override
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);
// 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);
@@ -66,28 +70,28 @@ public final class FloatingModule implements IrisModule {
private static void objects(MantleStageContext context) {
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) {
return objectPlacing(IrisPackSettings.of(settings).engine()).reach();
private int objectReach(PackSettings settings) {
return objectPlacing(IrisPackSettings.of(settings).engine(), log).reach();
}
private static void solids(ChunkStageContext context) {
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) {
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) {
return engine.getGeneration().state(FloatingObjectPlacing.class, FloatingObjectPlacing::new);
private static FloatingObjectPlacing objectPlacing(Engine engine, ModuleLog log) {
return engine.getGeneration().state(FloatingObjectPlacing.class, generating -> new FloatingObjectPlacing(generating, log));
}
private static FloatingIslands islands(IrisChunk chunk) {
return chunk.state(FloatingIslands.class, FloatingIslands::new);
private static FloatingIslands islands(IrisChunk chunk, ModuleLog log) {
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.PlacedObject;
import art.arcane.iris.engine.object.prefab.IrisObject;
import art.arcane.iris.spi.IrisLogging;
import art.arcane.volmlib.util.collection.KList;
import com.volmit.IrisModule;
import com.volmit.ModuleInfo;
import com.volmit.ModuleLog;
import com.volmit.block.BlockState;
import com.volmit.object.ObjectBlock;
import com.volmit.stage.PlacementStageContext;
@@ -87,7 +87,7 @@ public final class ValidateModule implements IrisModule {
int y = context.output(IrisStages.Anchor.HEIGHT).y();
boolean sampled = placement.requestedY() < 0;
if (sampled && config.getCarvingSupport().supportsSurface() && isOnBedrock(prepared, y)) {
warnImplausibleBedrockPlacement(placement, config, y);
warnImplausibleBedrockPlacement(placement, config, y, context.log());
context.reject("bedrock-anchor");
return;
}
@@ -239,7 +239,7 @@ public final class ValidateModule implements IrisModule {
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 fingerprint = (key == null ? "<null>" : key) + "|" + config.getMode();
long now = System.currentTimeMillis();
@@ -248,7 +248,7 @@ public final class ValidateModule implements IrisModule {
return;
}
IMPLAUSIBLE_BEDROCK_WARNS.put(fingerprint, now);
IrisLogging.warn("Implausible object placement rejected: "
log.warn("Implausible object placement rejected: "
+ (key == null ? "<no loadKey>" : key)
+ " resolved anchorY=" + y + " at (" + placement.x() + "," + placement.z() + ") mode=" + config.getMode()
+ " 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.core.loader.IrisData;
import art.arcane.iris.engine.framework.Engine;
import art.arcane.iris.spi.IrisLogging;
import art.arcane.iris.util.project.noise.CNG;
import art.arcane.volmlib.util.collection.KList;
import com.volmit.ModuleLog;
import it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap;
import java.util.Arrays;
@@ -78,13 +78,13 @@ public final class FloatingIslandSample {
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);
HashMap<Long, FloatingIslandSample> memo = CHUNK_MEMO.get();
if (memo.containsKey(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);
return result;
}
@@ -94,10 +94,10 @@ public final class FloatingIslandSample {
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)) {
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");
}
}
@@ -176,41 +176,41 @@ public final class FloatingIslandSample {
}
private static int maximumEdgeFieldWidth(KList<ResolvedFloatingChild> entries, long baseSeed,
IrisData data, IrisBiome parent) {
IrisData data, IrisBiome parent, ModuleLog log) {
int maximumWidth = FloatingIslandEdgeProfile.MIN_WIDTH;
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());
}
return maximumWidth;
}
private static FloatingIslandEdgeProfile resolveEdgeProfile(ResolvedFloatingChild entry, long baseSeed,
IrisData data, IrisBiome parent) {
IrisData data, IrisBiome parent, ModuleLog log) {
FloatingIslandEdgeProfile profile = entry.getEdgeTaperProfile(baseSeed, data);
if (profile != null) {
return profile;
}
warnNullCng("edgeTaperVariationStyle", parent);
warnNullCng("edgeTaperVariationStyle", parent, log);
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);
if (settings.isEmpty()) {
return reject(REJECT_NO_ENTRIES);
}
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) {
int boundaryFieldWidth = maximumEdgeFieldWidth(entries, baseSeed, data, parent);
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, log);
int parentBoundaryDistance = boundarySampler.edgeDistance(parent, wx, wz, boundaryFieldWidth);
if (FloatingChildren.merges(parent)) {
return sampleMerged(parent, entries, wx, wz, chunkHeight, baseSeed, data, engine, boundarySampler,
parentBoundaryDistance, boundaryFieldWidth);
parentBoundaryDistance, boundaryFieldWidth, log);
}
ResolvedFloatingChild entry;
@@ -221,7 +221,7 @@ public final class FloatingIslandSample {
ResolvedFloatingChild reference = entries.getFirst();
CNG picker = reference.getPickerCng(baseSeed, data);
if (picker == null) {
warnNullCng("pickerStyle", parent);
warnNullCng("pickerStyle", parent, log);
return reject(REJECT_NO_PICK);
}
FloatingIslandBoundarySampler.OwnershipSample ownership = boundarySampler.ownership(
@@ -234,20 +234,20 @@ public final class FloatingIslandSample {
}
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,
int wx, int wz, int chunkHeight, long baseSeed, IrisData data,
Engine engine, FloatingIslandBoundarySampler boundarySampler,
int parentBoundaryDistance, int boundaryFieldWidth) {
int parentBoundaryDistance, int boundaryFieldWidth, ModuleLog log) {
KList<FloatingIslandSample> samples = new KList<>();
int minY = Integer.MAX_VALUE;
int maxY = Integer.MIN_VALUE;
for (ResolvedFloatingChild entry : entries) {
FloatingIslandSample sample = sampleEntry(parent, entry, wx, wz, chunkHeight, baseSeed, data, engine,
boundarySampler, parentBoundaryDistance, boundaryFieldWidth + 1);
boundarySampler, parentBoundaryDistance, boundaryFieldWidth + 1, log);
if (sample == null) {
continue;
}
@@ -311,11 +311,11 @@ public final class FloatingIslandSample {
private static FloatingIslandSample sampleEntry(IrisBiome parent, ResolvedFloatingChild entry, int wx, int wz,
int chunkHeight, long baseSeed, IrisData data, Engine engine,
FloatingIslandBoundarySampler boundarySampler,
int parentBoundaryDistance, int ownershipBoundaryDistance) {
FloatingIslandEdgeProfile edgeProfile = resolveEdgeProfile(entry, baseSeed, data, parent);
int parentBoundaryDistance, int ownershipBoundaryDistance, ModuleLog log) {
FloatingIslandEdgeProfile edgeProfile = resolveEdgeProfile(entry, baseSeed, data, parent, log);
CNG footprintCng = entry.getFootprintCng(baseSeed, data);
if (footprintCng == null) {
warnNullCng("footprintStyle", parent);
warnNullCng("footprintStyle", parent, log);
return reject(REJECT_NO_SEED);
}
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);
if (altitudeCng == null) {
warnNullCng("altitudeStyle", parent);
warnNullCng("altitudeStyle", parent, log);
return reject(REJECT_NO_SEED);
}
double altNoise = altitudeCng.noise(wx, wz);
@@ -352,12 +352,12 @@ public final class FloatingIslandSample {
int baseY = minAlt + (int) Math.round(altClamped * (maxAlt - minAlt));
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);
CNG bottomCng = entry.getBottomCng(baseSeed, data);
if (bottomCng == null) {
warnNullCng("bottomStyle", parent);
warnNullCng("bottomStyle", parent, log);
return reject(REJECT_NO_SEED);
}
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());
if (maxTopHeight == 0) {
return 0;
@@ -785,7 +785,7 @@ public final class FloatingIslandSample {
case NOISE -> {
CNG topCng = entry.getTopShapeCng(baseSeed, data);
if (topCng == null) {
warnNullCng("topShapeStyle", null);
warnNullCng("topShapeStyle", null, log);
yield maxTopHeight / 2;
}
double n = topCng.noise(wx, wz);
@@ -83,7 +83,7 @@ final class IrisBiomeColorRenderer {
}
case LAYER_LOAD -> {
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);
});
}
@@ -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.region.IrisRegion;
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.volmlib.util.collection.KList;
import art.arcane.volmlib.util.math.PowerOfTwoCoordinates;
@@ -108,7 +107,7 @@ public final class EntitySpawning implements EntitySpawns {
List<String> spawners = new ArrayList<>();
for (String key : marker.spawners()) {
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;
}
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) {
EntityDefinition entity = SpawnResources.entity(engine.getData(), candidate.spawn().entity());
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;
}
@@ -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.world.biome.IrisBiome;
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.util.common.data.B;
import art.arcane.iris.util.project.noise.CNG;
import art.arcane.volmlib.util.collection.KList;
import art.arcane.volmlib.util.math.RNG;
import com.volmit.ModuleLog;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@@ -67,20 +67,22 @@ public final class BiomeLayers {
}
private final Supplier<LayerBlocks> layerBlocks;
private final ModuleLog log;
private final Map<PaletteLayer, ResolvedLayer> resolved = new ConcurrentHashMap<>();
private final Map<LayersSettings, AtomicCache<KList<CNG>>> surfaceHeights = new ConcurrentHashMap<>();
private final Map<SeaLayersSettings, AtomicCache<KList<CNG>>> seaHeights = new ConcurrentHashMap<>();
private volatile Double busiestBiomeLayerCount;
/** The layers of the world {@code engine} generates now. */
public static BiomeLayers of(Engine engine) {
/** The layers of the world {@code engine} generates now, reporting failures to {@code log}. */
public static BiomeLayers of(Engine engine, ModuleLog log) {
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. */
public BiomeLayers(Supplier<LayerBlocks> layerBlocks) {
public BiomeLayers(Supplier<LayerBlocks> layerBlocks, ModuleLog log) {
this.layerBlocks = layerBlocks;
this.log = log;
}
/** {@code layer} ready for this world; its block picks are the world's {@link LayerBlocks}. */
@@ -272,7 +274,7 @@ public final class BiomeLayers {
try {
blocks.add(layer.get(random, index + j, (wx + j) / zoom, j, (wz - j) / zoom));
} catch (Throwable e) {
IrisLogging.reportError(e);
log.error("A biome layer failed to pick a block", e);
}
}