Merge branch 'wave3b/g' into feat/irisapi-host

This commit is contained in:
piexel committed 2026-10-10 15:07:18 +02:00
commit d741bb5119
40 files changed
+925 -120

No files matched your search

@@ -18,6 +18,7 @@
package art.arcane.iris.core.commands;
import art.arcane.iris.core.modules.StructureAssemblies;
import art.arcane.iris.engine.framework.structure.StructureResources;
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
import art.arcane.iris.Iris;
@@ -305,7 +306,7 @@ public class CommandStructure implements DirectorExecutor {
sender().sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_STRUCTURE_NO_IRIS_STRUCTURE_THIS_PACK, MessageArgument.untrusted("structure", structure)));
return;
}
StructureAssembler assembler = StructureAssembler.forData(
StructureAssembler assembler = StructureAssemblies.forData(
data, s, new IrisPosition(0, 64, 0));
StructureAssemblyResult assembly = assembler.assemble(new RNG(1234));
List<PlacedStructurePiece> pieces = assembly.pieces();
@@ -344,7 +345,7 @@ public class CommandStructure implements DirectorExecutor {
return;
}
Location loc = player().getLocation();
StructureAssembler assembler = StructureAssembler.forData(
StructureAssembler assembler = StructureAssemblies.forData(
data, s, new IrisPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
RNG rng = new RNG((long) loc.getBlockX() * 341873128712L + loc.getBlockZ());
StructureAssemblyResult assembly = assembler.assemble(rng);
@@ -18,6 +18,7 @@
package art.arcane.iris.modded.command;
import art.arcane.iris.core.modules.StructureAssemblies;
import art.arcane.iris.engine.framework.structure.StructureResources;
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
import art.arcane.iris.modded.ModdedIrisLog;
@@ -145,7 +146,7 @@ public final class ModdedStructureCommands {
IrisModdedCommands.fail(source, IrisLanguage.plain(ModdedCommandMessages.MODDED_STRUCTURE_COMMANDS_NO_IRIS_STRUCTURE_THIS_PACK, MessageArgument.untrusted("key", key)));
return 0;
}
StructureAssembler assembler = StructureAssembler.forData(
StructureAssembler assembler = StructureAssemblies.forData(
data, structure, new IrisPosition(0, 64, 0));
StructureAssemblyResult assembly = assembler.assemble(new RNG(1234));
List<PlacedStructurePiece> pieces = assembly.pieces();
@@ -188,7 +189,7 @@ public final class ModdedStructureCommands {
int originX = player.blockPosition().getX();
int originY = player.blockPosition().getY();
int originZ = player.blockPosition().getZ();
StructureAssembler assembler = StructureAssembler.forData(
StructureAssembler assembler = StructureAssemblies.forData(
data, structure, new IrisPosition(originX, originY, originZ));
RNG rng = new RNG((long) originX * 341873128712L + originZ);
StructureAssemblyResult assembly = assembler.assemble(rng);
@@ -0,0 +1,125 @@
/*
* Iris is a World Generator for Minecraft Servers
* Copyright (c) 2026 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.core.modules;
import art.arcane.iris.builtin.IrisStages;
import art.arcane.iris.engine.framework.Engine;
import art.arcane.iris.engine.object.world.biome.IrisBiome;
import art.arcane.iris.engine.object.world.biome.custom.IrisBiomeCustom;
import art.arcane.iris.spi.IrisPlatform;
import art.arcane.iris.spi.IrisPlatforms;
import art.arcane.iris.spi.PlatformBiome;
import art.arcane.iris.util.project.context.ChunkContext;
import art.arcane.iris.util.project.context.ChunkedDataCache;
import art.arcane.iris.util.project.hunk.Hunk;
import art.arcane.volmlib.util.collection.KMap;
import art.arcane.volmlib.util.mantle.runtime.Mantle;
import art.arcane.volmlib.util.math.RNG;
import art.arcane.volmlib.util.matter.Matter;
import art.arcane.volmlib.util.matter.MatterBiomeInject;
import art.arcane.volmlib.util.matter.slices.BiomeInjectMatter;
import art.arcane.volmlib.util.scheduling.PrecisionStopwatch;
import com.volmit.IrisModule;
import com.volmit.ModuleInfo;
import com.volmit.stage.ChunkStageContext;
import com.volmit.stage.StageGraph;
/**
* Module {@code iris:biome}: writes each column's biome into the chunk's biome hunk, a custom biome under the
* dimension's namespace, and records the biome id in the mantle for platforms that inject biomes later.
*/
public final class BiomeModule implements IrisModule {
private static final String VERSION = "built-in";
@Override
public ModuleInfo info() {
return ModuleInfo.of("iris:biome", "Biomes", VERSION);
}
@Override
public void install(StageGraph graph) {
graph.define(IrisStages.Biome.WRITE).run(BiomeModule::write);
}
private static void write(ChunkStageContext context) {
IrisChunk chunk = IrisChunk.current();
chunk.state(BiomeWriter.class, BiomeWriter::new).write(chunk.originX(), chunk.originZ(), chunk.biomes(), chunk.context());
}
/** What writing biomes keeps for one engine runtime: the biome stream's random and the platform biomes resolved so far. */
static final class BiomeWriter {
private final Engine engine;
private final RNG rng;
private final KMap<String, ResolvedBiome> resolvedBiomes = new KMap<>();
BiomeWriter(Engine engine) {
this.engine = engine;
this.rng = new RNG(engine.getSeedManager().getBiome());
}
/** A partial biome write fails the chunk: a chunk flagged done with default biomes would keep them forever. */
void write(int originX, int originZ, Hunk<PlatformBiome> biomes, ChunkContext context) {
PrecisionStopwatch stopwatch = PrecisionStopwatch.start();
Mantle<Matter> mantle = engine.getMantle().getMantle();
ChunkedDataCache<IrisBiome> biomeCache = context.getBiome();
for (int localX = 0; localX < biomes.getWidth(); localX++) {
for (int localZ = 0; localZ < biomes.getDepth(); localZ++) {
int worldX = originX + localX;
int worldZ = originZ + localZ;
ResolvedBiome resolved = resolve(keyOf(biomeCache.get(localX, localZ), worldX, worldZ));
if (resolved.biome() != null) {
biomes.set(localX, 0, localZ, localX, biomes.getHeight() - 1, localZ, resolved.biome());
}
mantle.set(worldX, 0, worldZ, resolved.matter());
}
}
engine.getMetrics().getBiome().put(stopwatch.getMilliseconds());
}
private String keyOf(IrisBiome biome, int worldX, int worldZ) {
if (!biome.isCustom()) {
return biome.getSkyBiomeKey(rng, engine, worldX, 0, worldZ);
}
IrisBiomeCustom custom = biome.getCustomBiome(rng, engine, worldX, 0, worldZ);
return engine.getDimension().getLoadKey() + ":" + custom.getId();
}
/**
* The registry lookup and the biome id depend only on the key, so the pair is cached instead of paying two
* string-keyed lookups per column. Unresolved biomes are never cached, so a biome registered later still
* resolves.
*/
private ResolvedBiome resolve(String key) {
ResolvedBiome cached = key == null ? null : resolvedBiomes.get(key);
if (cached != null) {
return cached;
}
IrisPlatform platform = IrisPlatforms.get();
PlatformBiome biome = platform.registries().biome(key);
ResolvedBiome resolved = new ResolvedBiome(biome, BiomeInjectMatter.get(platform.biomeWriter().biomeIdFor(key)));
if (key != null && biome != null) {
resolvedBiomes.put(key, resolved);
}
return resolved;
}
}
private record ResolvedBiome(PlatformBiome biome, MatterBiomeInject matter) {
}
}
@@ -0,0 +1,118 @@
/*
* Iris is a World Generator for Minecraft Servers
* Copyright (c) 2026 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.core.modules;
import art.arcane.iris.builtin.IrisStages;
import art.arcane.iris.core.link.Identifier;
import art.arcane.iris.engine.framework.Engine;
import art.arcane.iris.spi.PlatformBlockState;
import art.arcane.iris.util.common.parallel.BurstExecutor;
import art.arcane.iris.util.common.parallel.MultiBurst;
import art.arcane.iris.util.project.hunk.Hunk;
import art.arcane.volmlib.util.mantle.flag.MantleFlag;
import art.arcane.volmlib.util.mantle.runtime.MantleChunk;
import art.arcane.volmlib.util.matter.Matter;
import com.volmit.IrisModule;
import com.volmit.ModuleInfo;
import com.volmit.stage.ChunkStageContext;
import com.volmit.stage.StageGraph;
/**
* Module {@code iris:custom}: records the chunk's content-plugin blocks for the server to place later: each
* custom block's placement key goes into the mantle and the block itself is replaced by its base state. Skipped
* while maintenance regeneration bypasses the mantle.
*/
public final class CustomModule implements IrisModule {
private static final String VERSION = "built-in";
private static final int CHUNK_SHIFT = 4;
private static final int SECTION_MASK = 15;
@Override
public ModuleInfo info() {
return ModuleInfo.of("iris:custom", "Custom blocks", VERSION);
}
@Override
public void install(StageGraph graph) {
// Ordering only: iris:perfection ships in the built-ins jar, which a pack may not have.
graph.define(IrisStages.Custom.BLOCKS).softAfter(IrisStages.Perfection.SURFACE.ref()).run(CustomModule::record);
}
private static void record(ChunkStageContext context) {
IrisChunk chunk = IrisChunk.current();
if (chunk.bypassesMantleStages()) {
return;
}
chunk.state(CustomBlockRecording.class, CustomBlockRecording::new).record(chunk.originX(), chunk.originZ(), chunk.blocks(), chunk.multicore());
}
/** Moves the custom blocks of a chunk into the mantle for one engine runtime. */
static final class CustomBlockRecording {
private final Engine engine;
CustomBlockRecording(Engine engine) {
this.engine = engine;
}
/** Records the custom blocks of the chunk whose first block is {@code x}, {@code z}, when its mantle chunk is flagged as having some. */
void record(int x, int z, Hunk<PlatformBlockState> output, boolean multicore) {
MantleChunk<Matter> mc = engine.getMantle().getMantle().getChunk(x >> CHUNK_SHIFT, z >> CHUNK_SHIFT);
if (!mc.isFlagged(MantleFlag.CUSTOM_ACTIVE)) {
return;
}
mc.use();
BurstExecutor burst = MultiBurst.burst.burst(output.getHeight());
burst.setMulticore(multicore);
// complete() must run before release() even when queueing throws — detached burst
// tasks must never write into a released chunk, and a lost permit wedges close().
try {
for (int y = 0; y < output.getHeight(); y++) {
int finalY = y;
burst.queue(() -> {
for (int rX = 0; rX < output.getWidth(); rX++) {
for (int rZ = 0; rZ < output.getDepth(); rZ++) {
PlatformBlockState b = output.get(rX, finalY, rZ);
if (b == null || !b.isCustom()) {
continue;
}
String placementKey = b.deferredPlacementKey();
PlatformBlockState baseState = b.placementBaseState();
if (placementKey == null || baseState == null) {
continue;
}
mc.getOrCreate(finalY >> CHUNK_SHIFT)
.slice(Identifier.class)
.set(rX, finalY & SECTION_MASK, rZ, Identifier.fromString(placementKey));
output.set(rX, finalY, rZ, baseState);
}
}
});
}
} finally {
try {
burst.complete();
} finally {
mc.release();
}
}
}
}
}
@@ -18,7 +18,11 @@
package art.arcane.iris.core.modules;
import art.arcane.iris.core.IrisSettings;
import art.arcane.iris.spi.IrisLogging;
import art.arcane.iris.spi.IrisPlatforms;
import com.volmit.ModuleLog;
import com.volmit.host.ModuleLogs;
import java.text.MessageFormat;
import java.util.ResourceBundle;
@@ -29,20 +33,40 @@ import java.util.ResourceBundle;
* looks up on the system class loader, where a plugin's classes are not.
*/
final class IrisApiLogger implements System.Logger {
private static final String HOST_MODULE_LABEL = "iris";
private static final ModuleLog HOST_LOG = ModuleLogs.labelled(HOST_MODULE_LABEL, new IrisApiLogger(HOST_MODULE_LABEL));
private final String name;
IrisApiLogger(String name) {
this.name = name;
}
/** The log of Iris itself, for the world code that is not any module's. */
static ModuleLog hostLog() {
return HOST_LOG;
}
@Override
public String getName() {
return name;
}
/** Modules' debug lines follow Iris's debug setting, as Iris's own debug lines do. */
@Override
public boolean isLoggable(Level level) {
return level != Level.OFF;
if (level == Level.OFF) {
return false;
}
if (level == Level.DEBUG || level == Level.TRACE) {
return isDebugEnabled();
}
return true;
}
private static boolean isDebugEnabled() {
boolean settingsAvailable = IrisSettings.settings != null || IrisPlatforms.isBound();
return settingsAvailable && IrisSettings.get().getGeneral().isDebug();
}
@Override
@@ -19,7 +19,6 @@
package art.arcane.iris.core.modules;
import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.engine.actuator.BiomeModule;
import art.arcane.iris.engine.actuator.DecorantModule;
import art.arcane.iris.engine.actuator.TerrainModule;
import art.arcane.iris.engine.loot.LootModule;
@@ -27,12 +26,12 @@ import art.arcane.iris.engine.mantle.components.ObjectModule;
import art.arcane.iris.engine.spawn.SpawnModule;
import art.arcane.iris.engine.mantle.components.StructureModule;
import art.arcane.iris.engine.modifier.CarveModule;
import art.arcane.iris.engine.modifier.CustomModule;
import art.arcane.iris.engine.modifier.DepositModule;
import art.arcane.iris.engine.modifier.FloatingModule;
import art.arcane.iris.engine.object.placement.PlacementModules;
import art.arcane.iris.spi.IrisPlatforms;
import com.volmit.IrisModule;
import com.volmit.ModuleLog;
import com.volmit.host.ModuleHost;
import com.volmit.host.PackModules;
@@ -59,6 +58,12 @@ public final class IrisModuleHost {
public static final List<String> SHARED_LIBRARY_PACKAGES = List.of("art.arcane.volmlib", "com.google.gson");
/** Every package pack modules may use besides the IrisApi. {@code exposedHostPackages} in IrisModule's build lists the same. */
public static final List<String> EXPOSED_PACKAGES = Stream.concat(Stream.of(BUILT_IN_API_PACKAGE), SHARED_LIBRARY_PACKAGES.stream()).toList();
/**
* The ids of the built-in modules that ship in the built-ins jar ({@code iris-builtins.jar}, listed in
* {@code IrisModule/builtin-modules.txt}) instead of being compiled into Iris. A pack loads them from its {@code modules}
* folder, and {@link MissingBuiltInModules} warns when it loads none; a test keeps this equal to the jar's list.
*/
public static final List<String> JAR_MODULE_IDS = List.of("iris:post", "iris:perfection", "iris:matter");
/** Iris's pack object model: built-in settings may hold these classes, which Iris reads and describes itself. */
public static final String HOST_TYPE_PACKAGE = "art.arcane.iris.engine.object";
private static final String[] JAR_COPY_FOLDER = {"cache", "module-jars"};
@@ -71,14 +76,24 @@ public final class IrisModuleHost {
return Holder.HOST;
}
/** The modules every pack loads before its own: Iris's built-in features, placement and the chunk generation every world runs. */
/** The modules every pack loads before its own: Iris's own, placement and the chunk generation every world runs. */
public static List<IrisModule> builtInModules() {
return Stream.concat(PlacementModules.all().stream(), generationModules().stream()).toList();
return Stream.of(hostModules(), PlacementModules.all(), generationModules()).flatMap(List::stream).toList();
}
/** Modules that are Iris itself, not features: they write the layout's platform biomes and record the platform's custom blocks. A pack never replaces them and the built-ins jar does not hold them. */
private static List<IrisModule> hostModules() {
return List.of(new BiomeModule(), new CustomModule());
}
private static List<IrisModule> generationModules() {
return List.of(new BiomeModule(), new TerrainModule(), new CarveModule(), new ObjectModule(), new StructureModule(),
new FloatingModule(), new DepositModule(), new DecorantModule(), new CustomModule(), new LootModule(), new SpawnModule());
return List.of(new TerrainModule(), new CarveModule(), new ObjectModule(), new StructureModule(),
new FloatingModule(), new DepositModule(), new DecorantModule(), new LootModule(), new SpawnModule());
}
/** Iris's own log, labelled {@code [iris]}, for host code that calls module classes outside any module's stage, service or hook. */
public static ModuleLog hostLog() {
return IrisApiLogger.hostLog();
}
/** Whether {@code type} is one of Iris's own classes that built-in settings may hold. */
@@ -21,9 +21,12 @@ package art.arcane.iris.core.modules;
import art.arcane.iris.builtin.IrisSeed;
import art.arcane.iris.engine.framework.Engine;
import art.arcane.iris.engine.framework.SeedManager;
import com.volmit.ModuleLog;
import com.volmit.config.PackSettings;
import com.volmit.host.WorldStates;
import com.volmit.world.PackWorld;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Function;
/**
@@ -35,11 +38,21 @@ import java.util.function.Function;
public final class IrisPackWorld implements PackWorld, IrisSeed.Source {
private final Engine engine;
private final IrisPackResources resources;
private final WorldStates states = new WorldStates();
private final WorldStates states;
private final ModuleLog log;
private final Map<ModuleLog, IrisPackWorld> viewsByLog;
IrisPackWorld(Engine engine) {
this(engine, engine.getData().getPackResources(), new WorldStates(), IrisApiLogger.hostLog(), new ConcurrentHashMap<>());
}
private IrisPackWorld(Engine engine, IrisPackResources resources, WorldStates states, ModuleLog log,
Map<ModuleLog, IrisPackWorld> viewsByLog) {
this.engine = engine;
this.resources = engine.getData().getPackResources();
this.resources = resources;
this.states = states;
this.log = log;
this.viewsByLog = viewsByLog;
}
/** Iris's own view of {@code world}, which Iris hands to every stage, service and lifecycle hook. */
@@ -75,6 +88,17 @@ public final class IrisPackWorld implements PackWorld, IrisSeed.Source {
return states.state(type, () -> create.apply(this));
}
@Override
public ModuleLog log() {
return log;
}
/** One view per log, since the services ask for a module's view on every call. */
@Override
public IrisPackWorld withLog(ModuleLog log) {
return viewsByLog.computeIfAbsent(log, moduleLog -> new IrisPackWorld(engine, resources, states, moduleLog, viewsByLog));
}
@Override
public long seed(IrisSeed seed) {
SeedManager seeds = engine.getSeedManager();
@@ -0,0 +1,49 @@
/*
* Iris is a World Generator for Minecraft Servers
* Copyright (c) 2026 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.core.modules;
import com.volmit.host.DiscoveredModule;
import java.io.File;
import java.util.Collection;
import java.util.Optional;
/**
* Notices a pack that loads without the built-in modules jar. Such a pack still loads and generates, but quietly without
* what the jar's modules do, so the owner is told once, with the fix.
*/
final class MissingBuiltInModules {
static final String JAR_NAME = "iris-builtins.jar";
private MissingBuiltInModules() {
}
/** What to tell the owner of {@code packFolder} whose pack loaded {@code packModules}; empty when the built-ins jar is there. */
static Optional<String> warning(File packFolder, Collection<DiscoveredModule> packModules) {
boolean builtInsLoaded = packModules.stream()
.map(module -> module.info().id().toString())
.anyMatch(IrisModuleHost.JAR_MODULE_IDS::contains);
if (builtInsLoaded) {
return Optional.empty();
}
return Optional.of("Pack " + packFolder.getName() + " loads without the built-in modules (" + JAR_NAME + "): its chunks get"
+ " no objects or structures, no surface smoothing and no clean-up of floating decorations. Copy " + JAR_NAME
+ " into " + new File(packFolder, PackModuleSet.MODULES_FOLDER).getPath() + " to fix it.");
}
}
@@ -21,6 +21,7 @@ package art.arcane.iris.core.modules;
import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.engine.framework.Engine;
import com.volmit.host.FeatureCatalog;
import com.volmit.host.ServiceRegistration;
import com.volmit.entity.EntitySpec;
import com.volmit.item.ItemDrop;
import com.volmit.service.AmbientEffects;
@@ -50,36 +51,60 @@ public final class ModuleServices {
private ModuleServices() {
}
/** One provider of a service and the world as its module sees it, whose log is the module's own. */
private record Provider<S>(S service, PackWorld world) {
}
/** Every provider of {@code service}, in the catalog's order, each with {@code world} scoped to its module. */
private static <S> List<Provider<S>> providers(IrisData data, Class<S> service, PackWorld world) {
List<Provider<S>> providers = new ArrayList<>();
for (ServiceRegistration registration : catalog(data).registrations(service)) {
providers.add(new Provider<>(service.cast(registration.provider()), registration.scope(world)));
}
return providers;
}
private static <S> List<Provider<S>> providers(Engine engine, Class<S> service) {
return providers(engine.getData(), service, engine.getGeneration().world());
}
private static <S> Optional<Provider<S>> firstProvider(Engine engine, Class<S> service) {
List<ServiceRegistration> registrations = catalog(engine.getData()).registrations(service);
if (registrations.isEmpty()) {
return Optional.empty();
}
ServiceRegistration first = registrations.get(0);
return Optional.of(new Provider<>(service.cast(first.provider()), first.scope(engine.getGeneration().world())));
}
/** The pack biome key the module that decides cave biomes puts at the position, whatever the regions say; empty where it overrides nothing. {@code y} is the height above the dimension's bottom. */
public static Optional<String> overriddenCaveBiome(Engine engine, int x, int y, int z) {
return catalog(engine.getData()).service(CaveBiomes.class)
.flatMap(provider -> provider.overriddenBiome(engine.getGeneration().world(), x, y, z));
return firstProvider(engine, CaveBiomes.class)
.flatMap(provider -> provider.service().overriddenBiome(provider.world(), x, y, z));
}
/** How many blocks below the surface the caves of the pack biome {@code biomeKey} begin; 0 where nothing limits them. */
public static int caveMinDepthBelowSurface(Engine engine, String biomeKey) {
return catalog(engine.getData()).service(CaveBiomes.class)
.map(provider -> provider.minDepthBelowSurface(engine.getGeneration().world(), biomeKey))
return firstProvider(engine, CaveBiomes.class)
.map(provider -> provider.service().minDepthBelowSurface(provider.world(), biomeKey))
.orElse(0);
}
/** The objects every module would place in the chunk at {@code chunkX}, {@code chunkZ}, guessed without generating it. */
public static Set<String> objectsAt(Engine engine, int chunkX, int chunkZ) {
PackWorld world = engine.getGeneration().world();
Set<String> keys = new LinkedHashSet<>();
for (ObjectsAt provider : catalog(engine.getData()).services(ObjectsAt.class)) {
keys.addAll(provider.objectsAt(world, chunkX, chunkZ));
for (Provider<ObjectsAt> provider : providers(engine, ObjectsAt.class)) {
keys.addAll(provider.service().objectsAt(provider.world(), chunkX, chunkZ));
}
return keys;
}
/** The biomes and regions of the engine's layout that every module says place the object {@code objectKey}. */
public static ObjectsAt.PlacedBy objectPlacers(Engine engine, String objectKey) {
PackWorld world = engine.getGeneration().world();
Set<String> biomes = new LinkedHashSet<>();
Set<String> regions = new LinkedHashSet<>();
for (ObjectsAt provider : catalog(engine.getData()).services(ObjectsAt.class)) {
ObjectsAt.PlacedBy placedBy = provider.placedBy(world, objectKey);
for (Provider<ObjectsAt> provider : providers(engine, ObjectsAt.class)) {
ObjectsAt.PlacedBy placedBy = provider.service().placedBy(provider.world(), objectKey);
biomes.addAll(placedBy.biomes());
regions.addAll(placedBy.regions());
}
@@ -88,31 +113,28 @@ public final class ModuleServices {
/** The loot tables the modules say the container at {@code site} draws from, in module order. */
public static List<Loot.Source> lootTables(Engine engine, Loot.Site site) {
PackWorld world = engine.getGeneration().world();
List<Loot.Source> tables = new ArrayList<>();
for (Loot provider : catalog(engine.getData()).services(Loot.class)) {
tables.addAll(provider.tables(world, site));
for (Provider<Loot> provider : providers(engine, Loot.class)) {
tables.addAll(provider.service().tables(provider.world(), site));
}
return tables;
}
/** The items loot table {@code key} gives at {@code site}, from the module that knows the table. */
public static List<ItemDrop> lootItems(Engine engine, Loot.Site site, String key) {
PackWorld world = engine.getGeneration().world();
List<ItemDrop> items = new ArrayList<>();
for (Loot provider : catalog(engine.getData()).services(Loot.class)) {
items.addAll(provider.items(world, site, key));
for (Provider<Loot> provider : providers(engine, Loot.class)) {
items.addAll(provider.service().items(provider.world(), site, key));
}
return items;
}
/** What the modules drop for the broken block, put together. */
public static BlockDrops.Result blockDrops(Engine engine, BlockDrops.Broken broken) {
PackWorld world = engine.getGeneration().world();
List<ItemDrop> drops = new ArrayList<>();
boolean replacesVanillaDrops = false;
for (BlockDrops provider : catalog(engine.getData()).services(BlockDrops.class)) {
BlockDrops.Result result = provider.drops(world, broken);
for (Provider<BlockDrops> provider : providers(engine, BlockDrops.class)) {
BlockDrops.Result result = provider.service().drops(provider.world(), broken);
drops.addAll(result.drops());
replacesVanillaDrops |= result.replacesVanillaDrops();
}
@@ -121,9 +143,8 @@ public final class ModuleServices {
/** The tree grown by the first module that grows one for {@code sapling}; empty leaves the growth to the platform. */
public static Optional<SaplingGrowth.Growth> growSapling(Engine engine, SaplingGrowth.Sapling sapling, SaplingGrowth.Surroundings surroundings) {
PackWorld world = engine.getGeneration().world();
for (SaplingGrowth provider : catalog(engine.getData()).services(SaplingGrowth.class)) {
Optional<SaplingGrowth.Growth> growth = provider.grow(world, sapling, surroundings);
for (Provider<SaplingGrowth> provider : providers(engine, SaplingGrowth.class)) {
Optional<SaplingGrowth.Growth> growth = provider.service().grow(provider.world(), sapling, surroundings);
if (growth.isPresent()) {
return growth;
}
@@ -133,11 +154,10 @@ public final class ModuleServices {
/** The objects every module places as trees. */
public static SaplingGrowth.TreeObjects treeObjects(Engine engine) {
PackWorld world = engine.getGeneration().world();
Set<String> objects = new LinkedHashSet<>();
Set<String> procedural = new LinkedHashSet<>();
for (SaplingGrowth provider : catalog(engine.getData()).services(SaplingGrowth.class)) {
SaplingGrowth.TreeObjects trees = provider.treeObjects(world);
for (Provider<SaplingGrowth> provider : providers(engine, SaplingGrowth.class)) {
SaplingGrowth.TreeObjects trees = provider.service().treeObjects(provider.world());
objects.addAll(trees.objects());
procedural.addAll(trees.procedural());
}
@@ -146,11 +166,10 @@ public final class ModuleServices {
/** What the first module with something to spawn at {@code site} plans; empty when none does. */
public static Optional<PlannedSpawn> planSpawn(Engine engine, EntitySpawns.Site site) {
PackWorld world = engine.getGeneration().world();
for (EntitySpawns provider : catalog(engine.getData()).services(EntitySpawns.class)) {
Optional<EntitySpawns.Plan> plan = provider.plan(world, site);
for (Provider<EntitySpawns> provider : providers(engine, EntitySpawns.class)) {
Optional<EntitySpawns.Plan> plan = provider.service().plan(provider.world(), site);
if (plan.isPresent()) {
return Optional.of(new PlannedSpawn(provider, world, plan.get()));
return Optional.of(new PlannedSpawn(provider.service(), provider.world(), plan.get()));
}
}
return Optional.empty();
@@ -158,9 +177,8 @@ public final class ModuleServices {
/** The entity {@code key} as the first module that knows it would spawn it. */
public static Optional<EntitySpec> entity(Engine engine, String key) {
PackWorld world = engine.getGeneration().world();
for (EntitySpawns provider : catalog(engine.getData()).services(EntitySpawns.class)) {
Optional<EntitySpec> entity = provider.entity(world, key);
for (Provider<EntitySpawns> provider : providers(engine, EntitySpawns.class)) {
Optional<EntitySpec> entity = provider.service().entity(provider.world(), key);
if (entity.isPresent()) {
return entity;
}
@@ -170,9 +188,8 @@ public final class ModuleServices {
/** What the first module that knows the marker {@code tag} says it does. */
public static Optional<EntitySpawns.MarkerRule> markerRule(Engine engine, String tag) {
PackWorld world = engine.getGeneration().world();
for (EntitySpawns provider : catalog(engine.getData()).services(EntitySpawns.class)) {
Optional<EntitySpawns.MarkerRule> rule = provider.marker(world, tag);
for (Provider<EntitySpawns> provider : providers(engine, EntitySpawns.class)) {
Optional<EntitySpawns.MarkerRule> rule = provider.service().marker(provider.world(), tag);
if (rule.isPresent()) {
return rule;
}
@@ -182,10 +199,9 @@ public final class ModuleServices {
/** The ambient effects every module says are due for a player standing at {@code at}, in module order. */
public static List<AmbientEffects.Effect> ambientEffects(Engine engine, BlockPosition at) {
PackWorld world = engine.getGeneration().world();
List<AmbientEffects.Effect> effects = new ArrayList<>();
for (AmbientEffects provider : catalog(engine.getData()).services(AmbientEffects.class)) {
effects.addAll(provider.due(world, at));
for (Provider<AmbientEffects> provider : providers(engine, AmbientEffects.class)) {
effects.addAll(provider.service().due(provider.world(), at));
}
return effects;
}
@@ -208,10 +224,9 @@ public final class ModuleServices {
/** The keys of the structures the world's modules place and can locate. */
public static Set<String> locatableStructures(Engine engine) {
PackWorld world = engine.getGeneration().world();
Set<String> keys = new LinkedHashSet<>();
for (StructureLocator provider : catalog(engine.getData()).services(StructureLocator.class)) {
keys.addAll(provider.locatable(world));
for (Provider<StructureLocator> provider : providers(engine, StructureLocator.class)) {
keys.addAll(provider.service().locatable(provider.world()));
}
return keys;
}
@@ -226,9 +241,8 @@ public final class ModuleServices {
* can locate it, in the world's own coordinates; not found when none can.
*/
public static StructureSearch locateStructure(Engine engine, String key, int fromX, int fromZ, int maxRadiusChunks) {
PackWorld world = engine.getGeneration().world();
LocateResult result = structureLocatorOf(engine, key)
.map(provider -> provider.locate(world, key, fromX, fromZ, maxRadiusChunks))
.map(provider -> provider.service().locate(provider.world(), key, fromX, fromZ, maxRadiusChunks))
.orElse(LocateResult.NOT_FOUND);
return StructureSearch.of(result, engine);
}
@@ -256,14 +270,13 @@ public final class ModuleServices {
}
/** The first provider, in the catalog's order, whose locatable structures hold {@code key}. */
private static Optional<StructureLocator> structureLocatorOf(Engine engine, String key) {
private static Optional<Provider<StructureLocator>> structureLocatorOf(Engine engine, String key) {
if (key == null || key.isBlank()) {
return Optional.empty();
}
PackWorld world = engine.getGeneration().world();
String wanted = normalized(key);
for (StructureLocator provider : catalog(engine.getData()).services(StructureLocator.class)) {
if (provider.locatable(world).stream().map(ModuleServices::normalized).anyMatch(wanted::equals)) {
for (Provider<StructureLocator> provider : providers(engine, StructureLocator.class)) {
if (provider.service().locatable(provider.world()).stream().map(ModuleServices::normalized).anyMatch(wanted::equals)) {
return Optional.of(provider);
}
}
@@ -43,6 +43,7 @@ import com.volmit.vanilla.StructureFit;
import com.volmit.vanilla.StructureStep;
import com.volmit.vanilla.TemplateCells;
import com.volmit.vanilla.TerrainAdaptation;
import com.volmit.ModuleLog;
import com.volmit.world.BlockAccess;
import com.volmit.world.BlockPosition;
import com.volmit.world.PackWorld;
@@ -96,17 +97,21 @@ public final class ModuleStructureFitting implements NativeStructureFitting {
@Override
public <S> Session beforePieces(NativeFitChunk<S> chunk) {
ChunkFit<S> fit = new ChunkFit<>(chunk, world);
for (ServiceRegistration registration : providers) {
ModuleVanillaStructures.ask(registration, "fitting structures into chunk " + fit.chunkName(), provider -> {
List<ChunkFit<S>> fits = providers.stream()
.<ChunkFit<S>>map(registration -> new ChunkFit<>(chunk, () -> registration.scope(world.get()), registration.module().log()))
.toList();
for (int index = 0; index < providers.size(); index++) {
ChunkFit<S> fit = fits.get(index);
ModuleVanillaStructures.ask(providers.get(index), "fitting structures into chunk " + fit.chunkName(), provider -> {
provider.beforePieces(fit);
return Boolean.TRUE;
});
}
return startIndex -> {
StructureFit.Start placed = fit.starts().get(startIndex);
for (ServiceRegistration registration : providers) {
ModuleVanillaStructures.ask(registration, "fitting " + placed.structure() + " into chunk " + fit.chunkName(),
for (int index = 0; index < providers.size(); index++) {
ChunkFit<S> fit = fits.get(index);
StructureFit.Start placed = fit.starts().get(startIndex);
ModuleVanillaStructures.ask(providers.get(index), "fitting " + placed.structure() + " into chunk " + fit.chunkName(),
provider -> {
provider.afterPieces(fit, placed);
return Boolean.TRUE;
@@ -145,13 +150,15 @@ public final class ModuleStructureFitting implements NativeStructureFitting {
private static final class ChunkFit<S> implements StructureFit {
private final NativeFitChunk<S> chunk;
private final Supplier<PackWorld> world;
private final ModuleLog log;
private final Access<S> blocks;
private final List<StructureFit.Start> starts;
private final Map<Class<?>, Object> states = new HashMap<>();
private ChunkFit(NativeFitChunk<S> chunk, Supplier<PackWorld> world) {
private ChunkFit(NativeFitChunk<S> chunk, Supplier<PackWorld> world, ModuleLog log) {
this.chunk = chunk;
this.world = world;
this.log = log;
this.blocks = new Access<>(chunk);
List<StructureFit.Start> converted = new ArrayList<>(chunk.starts().size());
for (NativeFitStart<S> start : chunk.starts()) {
@@ -169,6 +176,11 @@ public final class ModuleStructureFitting implements NativeStructureFitting {
return world.get();
}
@Override
public ModuleLog log() {
return log;
}
@Override
public long seed() {
return chunk.seed();
@@ -88,11 +88,11 @@ public final class ModuleVanillaStructures {
* as the host's plans: world heights, the platform's jigsaw changes and the modules' memos.
*/
public static List<NativeStructureStartPlan> startsAt(Engine engine, int chunkX, int chunkZ) {
StartContext context = new StartContext(engine.getGeneration().world(),
new IrisTerrainSampler(engine, new PackResourceIds(engine.getData().getDataFolder()),
chunkX << 4, chunkZ << 4, START_TERRAIN_REACH_BLOCKS));
TerrainSampler terrain = new IrisTerrainSampler(engine, new PackResourceIds(engine.getData().getDataFolder()),
chunkX << 4, chunkZ << 4, START_TERRAIN_REACH_BLOCKS);
List<NativeStructureStartPlan> plans = new ArrayList<>();
for (ServiceRegistration registration : providersOf(engine.getData())) {
StartContext context = new StartContext(registration.scope(engine.getGeneration().world()), terrain);
for (VanillaStructureStart start : ask(registration, "placing starts in chunk " + chunkX + "," + chunkZ,
provider -> provider.starts(chunkX, chunkZ, context))) {
plans.add(plan(registration.module(), start, chunkX, chunkZ, engine.getMinHeight()));
@@ -37,8 +37,9 @@ import java.util.function.Supplier;
public final class PackModuleSet implements AutoCloseable {
private enum State { NOT_LOADED, LOADED, FAILED, CLOSED }
private static final String MODULES_FOLDER = "modules";
static final String MODULES_FOLDER = "modules";
private static final String JAR_EXTENSION = ".jar";
private static final String MISSING_BUILT_INS_KEY = "missing-built-in-modules:";
private final File packFolder;
private final Supplier<Gson> irisGson;
@@ -113,6 +114,7 @@ public final class PackModuleSet implements AutoCloseable {
pack = loaded;
settings = new ModuleSettingsDecoder(loaded.catalog(), packFolder.toPath(), irisGson);
state = State.LOADED;
warnWhenBuiltInModulesAreMissing(loaded);
} catch (RuntimeException loadFailure) {
failure = new PackModulesException(packFolder, loadFailure);
state = State.FAILED;
@@ -121,6 +123,11 @@ public final class PackModuleSet implements AutoCloseable {
}
}
private void warnWhenBuiltInModulesAreMissing(LoadedPack loaded) {
MissingBuiltInModules.warning(packFolder, loaded.packModules())
.ifPresent(warning -> IrisLogging.warnOnce(MISSING_BUILT_INS_KEY + packFolder.getAbsolutePath(), "%s", warning));
}
/** Each module jar's name, size and modification time, in name order. */
private List<String> jarFingerprint() {
File[] jars = new File(packFolder, MODULES_FOLDER).listFiles(file -> file.isFile() && file.getName().endsWith(JAR_EXTENSION));
@@ -0,0 +1,38 @@
/*
* Iris is a World Generator for Minecraft Servers
* Copyright (c) 2026 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.core.modules;
import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.engine.framework.StructureAssembler;
import art.arcane.iris.engine.object.structure.IrisStructure;
import art.arcane.iris.engine.object.value.IrisPosition;
/**
* Structure assembly for Iris's own tools, the commands and studio, which run outside any module's stage, service or hook and so
* log as Iris itself.
*/
public final class StructureAssemblies {
private StructureAssemblies() {
}
/** The assembler of {@code structure}, compiled from the pack {@code data} serves, for a start at {@code origin}. */
public static StructureAssembler forData(IrisData data, IrisStructure structure, IrisPosition origin) {
return StructureAssembler.forData(data, structure, origin, IrisModuleHost.hostLog());
}
}
@@ -2,6 +2,7 @@ package art.arcane.iris.core.service;
import art.arcane.iris.engine.framework.structure.StructureResources;
import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.core.modules.StructureAssemblies;
import art.arcane.iris.core.nms.INMS;
import art.arcane.iris.core.runtime.InPlaceChunkRegenerator;
import art.arcane.iris.core.runtime.jigsaw.JigsawPlanarArchetype;
@@ -2476,7 +2477,7 @@ public final class JigsawStudioService implements IrisService, JigsawStudioMenuC
if (structure == null) {
throw new IOException("The active structure resource no longer exists");
}
StructureAssembler assembler = StructureAssembler.forData(
StructureAssembler assembler = StructureAssemblies.forData(
request.source(), structure, origin);
StructureAssemblyResult assembly = assembler.assemble(new RNG(seed));
if (!assembly.hasOutput()) {
@@ -8,6 +8,8 @@ import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Stream;
import static org.junit.Assert.assertEquals;
@@ -155,6 +157,9 @@ public class DiagnosticSeverityPolicyTest {
assertLoggedWith("core/pregenerator/IrisPregenerator.java", "Pregen finished: ", "notice");
}
/** The last logging call before a message: Iris's static front door, or a module's own log. */
private static final Pattern LOGGING_CALL = Pattern.compile("(?:IrisLogging\\.|\\blog\\.|\\blog\\(\\)\\.)(\\w+)");
private static void assertLoggedWith(String relativePath, String fragment, String expectedMethod) {
String source;
try {
@@ -173,14 +178,13 @@ public class DiagnosticSeverityPolicyTest {
}
private static String loggingMethodBefore(String source, int at, String relativePath, String fragment) {
int call = source.lastIndexOf("IrisLogging.", at);
assertTrue(relativePath + " @ \"" + fragment + "\" is not logged through IrisLogging", call >= 0);
int start = call + "IrisLogging.".length();
int end = start;
while (end < source.length() && Character.isJavaIdentifierPart(source.charAt(end))) {
end++;
String method = null;
Matcher calls = LOGGING_CALL.matcher(source.substring(0, at));
while (calls.find()) {
method = calls.group(1);
}
return source.substring(start, end);
assertTrue(relativePath + " @ \"" + fragment + "\" is not logged through IrisLogging or a ModuleLog", method != null);
return method;
}
private static String read(String relativePath) throws IOException {
@@ -1,4 +1,4 @@
package art.arcane.iris.engine.actuator;
package art.arcane.iris.core.modules;
import art.arcane.iris.engine.framework.Engine;
import art.arcane.iris.engine.framework.EngineMetrics;
@@ -66,6 +66,17 @@ public class BuiltInModulesJarTest {
}
}
@Test
public void theIdsIrisLooksForAreTheOnesTheJarProvides() throws IOException {
Path pack = BuiltInPack.newPackFolder(folder);
BuiltInModulesJar.writeInto(pack);
try (LoadedPack loaded = loadWithStandIns(pack)) {
List<String> provided = loaded.packModules().stream().map(module -> module.info().id().toString()).toList();
assertEquals(provided, IrisModuleHost.JAR_MODULE_IDS);
}
}
@Test
public void theJarsModulesGenerateWhatTheirCompiledInCopiesGenerate() throws IOException {
Path pack = BuiltInPack.newPackFolder(folder);
@@ -1,4 +1,4 @@
package art.arcane.iris.engine.modifier;
package art.arcane.iris.core.modules;
import art.arcane.iris.core.IrisSettings;
import art.arcane.iris.core.link.Identifier;
@@ -0,0 +1,69 @@
/*
* Iris is a World Generator for Minecraft Servers
* Copyright (c) 2026 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.core.modules;
import com.volmit.IrisModule;
import com.volmit.ModuleInfo;
import com.volmit.host.DiscoveredModule;
import com.volmit.stage.StageGraph;
import org.junit.Test;
import java.io.File;
import java.util.List;
import java.util.Optional;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
public class MissingBuiltInModulesTest {
private static final File PACK = new File("packs", "overworld");
@Test
public void aPackWithNoModulesIsToldWhichJarToCopyWhere() {
String warning = MissingBuiltInModules.warning(PACK, List.of()).orElseThrow();
assertTrue(warning, warning.startsWith("Pack overworld loads without the built-in modules (iris-builtins.jar)"));
assertTrue(warning, warning.contains("Copy iris-builtins.jar into " + new File(PACK, "modules").getPath() + " to fix it."));
}
@Test
public void aPackWithOnlyOtherModulesIsToldToo() {
assertTrue(MissingBuiltInModules.warning(PACK, List.of(module("pack:ruins"))).isPresent());
}
@Test
public void anyOfTheJarsModulesCountsAsHavingTheJar() {
for (String id : IrisModuleHost.JAR_MODULE_IDS) {
assertEquals(id, Optional.empty(), MissingBuiltInModules.warning(PACK, List.of(module("pack:ruins"), module(id))));
}
}
private static DiscoveredModule module(String id) {
return DiscoveredModule.builtIn(new IrisModule() {
@Override
public ModuleInfo info() {
return ModuleInfo.of(id, "Stand-in " + id, "test");
}
@Override
public void install(StageGraph graph) {
}
});
}
}
@@ -0,0 +1,178 @@
/*
* Iris is a World Generator for Minecraft Servers
* Copyright (c) 2026 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.core.modules;
import art.arcane.iris.builtin.IrisSeed;
import art.arcane.iris.core.IrisSettings;
import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.engine.framework.Engine;
import art.arcane.iris.engine.framework.SeedManager;
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
import art.arcane.iris.spi.IrisPlatforms;
import com.volmit.ModuleLog;
import com.volmit.host.ModuleLogs;
import com.volmit.world.PackWorld;
import org.junit.After;
import org.junit.Assume;
import org.junit.Before;
import org.junit.Test;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.nio.charset.StandardCharsets;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
/**
* A module's log is written to Iris's log with the module's id in front, follows Iris's debug setting and reports a failure like
* Iris's own; the world a module is handed carries the module's log.
*/
public class ModuleLogTest {
private static final String MODULE = "iris:decorant";
private static final long POST_SEED = 9L;
private final ByteArrayOutputStream out = new ByteArrayOutputStream();
private final ByteArrayOutputStream err = new ByteArrayOutputStream();
private PrintStream originalOut;
private PrintStream originalErr;
private IrisSettings originalSettings;
private IrisSettings settings;
@Before
public void captureTheProcessStreamsIrisLogsToWhenNoPlatformIsBound() {
Assume.assumeFalse("a platform is bound, so the log does not go to the process streams", IrisPlatforms.isBound());
originalOut = System.out;
originalErr = System.err;
originalSettings = IrisSettings.settings;
System.setOut(new PrintStream(out, true, StandardCharsets.UTF_8));
System.setErr(new PrintStream(err, true, StandardCharsets.UTF_8));
settings = new IrisSettings();
IrisSettings.settings = settings;
}
@After
public void restoreTheProcessStreams() {
if (originalOut == null) {
return;
}
System.setOut(originalOut);
System.setErr(originalErr);
IrisSettings.settings = originalSettings;
}
@Test
public void everyLevelCarriesTheModulesIdAndKeepsItsSeverity() {
settings.getGeneral().debug = true;
ModuleLog log = log();
log.debug("shown for debugging");
log.info("started");
log.warn("unusual");
log.error("failed", null);
assertTrue(out(), out().contains("[Iris/DEBUG] [iris:decorant] shown for debugging"));
assertTrue(out(), out().contains("[Iris/INFO] [iris:decorant] started"));
assertTrue(err(), err().contains("[Iris/WARN] [iris:decorant] unusual"));
assertTrue(err(), err().contains("[Iris/ERROR] [iris:decorant] failed"));
}
@Test
public void debugFollowsIrisDebugSetting() {
ModuleLog log = log();
settings.getGeneral().debug = false;
log.debug("while off");
settings.getGeneral().debug = true;
log.debug("while on");
assertFalse(out(), out().contains("while off"));
assertTrue(out(), out().contains("while on"));
}
@Test
public void anErrorWithACauseIsReportedLikeIrisReportsItsOwnFailures() {
log().error("Failed to place a plant", new IllegalStateException("boom"));
assertTrue(err(), err().contains("[Iris/ERROR] [iris:decorant] Failed to place a plant"));
assertTrue(err(), err().contains("java.lang.IllegalStateException: boom"));
}
@Test
public void warnOnceWarnsOnceAndDebugsAfterwards() {
settings.getGeneral().debug = false;
ModuleLog log = log();
log.warnOnce("empty:plains", "Empty block data for plains");
log.warnOnce("empty:plains", "Empty block data for plains");
assertEquals(err(), 1, err().split("Empty block data for plains", -1).length - 1);
assertFalse(out(), out().contains("Empty block data"));
}
@Test
public void aWorldViewCarriesTheModulesLogAndSharesTheWorldsState() {
Engine engine = mock(Engine.class);
when(engine.getData()).thenReturn(mock(IrisData.class));
when(engine.getDimension()).thenReturn(new IrisDimension());
SeedManager seeds = mock(SeedManager.class);
when(seeds.getPost()).thenReturn(POST_SEED);
when(engine.getSeedManager()).thenReturn(seeds);
IrisPackWorld world = new IrisPackWorld(engine);
ModuleLog decorant = log();
PackWorld view = world.withLog(decorant);
assertSame(decorant, view.log());
assertSame("one view per module", view, world.withLog(decorant));
assertSame(view, view.withLog(decorant));
assertSame("state is the world's", world.state(Marker.class, ignored -> new Marker()), view.state(Marker.class, ignored -> new Marker()));
assertSame("Iris's own code still reaches the engine through a view", engine, IrisPackWorld.of(view).engine());
assertEquals("and its seeds", POST_SEED, IrisSeed.POST.of(view));
}
@Test
public void theWorldItselfLogsAsIris() {
Engine engine = mock(Engine.class);
when(engine.getData()).thenReturn(mock(IrisData.class));
new IrisPackWorld(engine).log().warn("host line");
assertTrue(err(), err().contains("[Iris/WARN] [iris] host line"));
}
private static ModuleLog log() {
return ModuleLogs.labelled(MODULE, new IrisApiLogger("test"));
}
private String out() {
return out.toString(StandardCharsets.UTF_8);
}
private String err() {
return err.toString(StandardCharsets.UTF_8);
}
private static final class Marker {
}
}
@@ -25,6 +25,7 @@ import art.arcane.iris.engine.framework.SeedManager;
import com.volmit.FeatureRegistry;
import com.volmit.IrisModule;
import com.volmit.ModuleInfo;
import com.volmit.ModuleLog;
import com.volmit.host.LoadedPack;
import com.volmit.host.ModuleHost;
import com.volmit.resource.PackResources;
@@ -60,6 +61,7 @@ public class ModuleServicesTest {
public TemporaryFolder folder = new TemporaryFolder();
private final List<String> searches = new ArrayList<>();
private final List<String> logOwners = new ArrayList<>();
private LoadedPack pack;
private IrisData data;
private Engine engine;
@@ -87,9 +89,11 @@ public class ModuleServicesTest {
@Override
public void register(FeatureRegistry registry) {
ModuleLog registeredLog = registry.log();
registry.registerService(ObjectsAt.class, new ObjectsAt() {
@Override
public Set<String> objectsAt(PackWorld world, int chunkX, int chunkZ) {
logOwners.add(id + (world.log() == registeredLog ? " has its own log" : " has another module's log"));
return Set.of(object + "@" + chunkX + "," + chunkZ);
}
@@ -151,6 +155,13 @@ public class ModuleServicesTest {
assertEquals(List.of("tree@3,-4", "bush@3,-4", "rock@3,-4"), List.copyOf(ModuleServices.objectsAt(engine, 3, -4)));
}
@Test
public void everyModuleIsAskedWithAWorldCarryingItsOwnLog() {
ModuleServices.objectsAt(engine, 0, 0);
assertEquals(List.of("test:alpha has its own log", "test:beta has its own log", "test:zeta has its own log"), logOwners);
}
@Test
public void objectPlacersCombineTheBiomesAndRegionsOfEveryModule() {
ObjectsAt.PlacedBy placers = ModuleServices.objectPlacers(engine, "trees/oak");
@@ -18,16 +18,22 @@
package art.arcane.iris.core.modules;
import art.arcane.iris.spi.IrisPlatforms;
import com.google.gson.Gson;
import org.junit.Assume;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import java.io.File;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
@@ -60,4 +66,57 @@ public class PackModuleSetTest {
assertTrue(first.getMessage(), first.getMessage().startsWith("Pack broken cannot load its modules: "));
modules.close();
}
@Test
public void aPackWithoutTheBuiltInsJarIsToldHowToGetThem() throws IOException {
File pack = folder.newFolder("without-builtins");
String warnings = warningsWhile(() -> new PackModuleSet(pack, Gson::new).pack());
assertTrue(warnings, warnings.contains("[Iris/WARN] Pack without-builtins loads without the built-in modules (iris-builtins.jar)"));
assertTrue(warnings, warnings.contains("Copy iris-builtins.jar into " + new File(pack, "modules").getPath()));
}
@Test
public void aPackIsToldOnceHoweverOftenItLoadsAndAWorldCopyOfItIsToldToo() throws IOException {
File pack = folder.newFolder("original");
File worldCopy = folder.newFolder("world", "iris", "pack");
String warnings = warningsWhile(() -> {
new PackModuleSet(pack, Gson::new).pack();
new PackModuleSet(pack, Gson::new).pack();
new PackModuleSet(worldCopy, Gson::new).pack();
});
assertEquals(warnings, 1, occurrences(warnings, "Pack original loads without"));
assertEquals(warnings, 1, occurrences(warnings, "Pack pack loads without"));
}
@Test
public void aPackWithTheBuiltInsJarIsNotWarned() throws IOException {
File pack = folder.newFolder("with-builtins");
BuiltInModulesJar.writeInto(pack.toPath());
String warnings = warningsWhile(() -> assertFalse(new PackModuleSet(pack, Gson::new).pack().packModules().isEmpty()));
assertFalse(warnings, warnings.contains("built-in modules"));
}
/** What Iris's log said at WARN while {@code load} ran: with no platform bound it goes to the error stream. */
private static String warningsWhile(Runnable load) {
Assume.assumeFalse("a platform is bound, so the log does not go to the error stream", IrisPlatforms.isBound());
PrintStream original = System.err;
ByteArrayOutputStream captured = new ByteArrayOutputStream();
System.setErr(new PrintStream(captured, true, StandardCharsets.UTF_8));
try {
load.run();
} finally {
System.setErr(original);
}
return captured.toString(StandardCharsets.UTF_8);
}
private static int occurrences(String text, String fragment) {
return text.split(java.util.regex.Pattern.quote(fragment), -1).length - 1;
}
}
@@ -106,6 +106,10 @@ public class GenerationCacheWarmGateTest {
return new EngineGeneration(engine);
}
/** Worlds the modules are handed are views of the generation's world, so they are told apart by what they share. */
private static final class WorldMarker {
}
@Test
public void generationWaitsForAModulesSlowWarmUp() throws Exception {
GenerationCacheWarmGate gate = new GenerationCacheWarmGate();
@@ -126,7 +130,9 @@ public class GenerationCacheWarmGateTest {
warmUp.get(WAIT_SECONDS, TimeUnit.SECONDS);
generating.get(WAIT_SECONDS, TimeUnit.SECONDS);
assertFalse(gate.isPending());
assertSame("the module warmed the world it started", generation.world(), module.warmed);
assertSame("the module warmed the world it started",
generation.world().state(WorldMarker.class, ignored -> new WorldMarker()),
module.warmed.state(WorldMarker.class, ignored -> new WorldMarker()));
} finally {
module.release.countDown();
background.shutdownNow();
@@ -18,6 +18,7 @@ import art.arcane.iris.spi.PlatformBlockState;
import art.arcane.iris.util.project.stream.ProceduralStream;
import art.arcane.volmlib.util.collection.KList;
import art.arcane.volmlib.util.math.RNG;
import com.volmit.host.ModuleLogs;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -131,7 +132,7 @@ public class TerrainLayersPinTest {
RNG rng = new RNG(TERRAIN_SEED);
IrisBiome biome = new IrisBiome();
biome.setModuleSettings(TerrainTestSettings.of(biomeJson));
BiomeLayers layers = new BiomeLayers(TestLayerBlocks.of(data.getPackResources()));
BiomeLayers layers = new BiomeLayers(TestLayerBlocks.of(data.getPackResources()), ModuleLogs.discarding());
for (int x = -COLUMN_RANGE; x < COLUMN_RANGE; x += COLUMN_STEP_X) {
for (int z = -COLUMN_RANGE; z < COLUMN_RANGE; z += COLUMN_STEP_Z) {
transcript.append('|').append(keys(layers.generateLayers(biome, dimension, x, z, rng, 14, 70 + Math.floorMod(x + z, 9), data, complex)));
@@ -15,6 +15,7 @@ import art.arcane.iris.engine.object.world.biome.IrisBiome;
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
import art.arcane.volmlib.util.collection.KList;
import com.google.gson.Gson;
import com.volmit.host.ModuleLogs;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -65,7 +66,7 @@ public class BiomeDecoratorsTest {
bare = mock(IrisBiome.class);
when(bare.getLoadKey()).thenReturn("bare");
when(bare.getModuleSettings()).thenReturn(ModuleSettings.NONE);
decorators = new BiomeDecorators(engine);
decorators = new BiomeDecorators(engine, ModuleLogs.discarding());
}
@After
@@ -104,7 +105,7 @@ public class BiomeDecoratorsTest {
assertEquals("biome meadow, index 2", DECORATOR_SEED + "meadow".hashCode() * 0x9E3779B97F4A7C15L + 2 * 0xC2B2AE3D27D4EB4FL, second);
assertNotEquals(first, second);
assertEquals("another build of the same world draws the same seeds", first,
seedOf(new BiomeDecorators(engine).decorators(meadow, DecorationPart.NONE)[0]));
seedOf(new BiomeDecorators(engine, ModuleLogs.discarding()).decorators(meadow, DecorationPart.NONE)[0]));
}
@Test
@@ -4,6 +4,7 @@ import art.arcane.iris.builtin.decorant.DecorationPart;
import art.arcane.iris.spi.PlatformBlockState;
import art.arcane.iris.util.project.hunk.Hunk;
import art.arcane.volmlib.util.math.RNG;
import com.volmit.host.ModuleLogs;
import org.bukkit.block.BlockSupport;
import org.bukkit.block.data.BlockData;
import org.junit.Test;
@@ -61,7 +62,7 @@ public class DecoratorCoreTest {
@Test
public void pickDecorator_emptyBucket_returnsNull() {
ResolvedDecorator result = DecoratorCore.pickDecorator(new ResolvedDecorator[0], new RNG(2L), 0.0, 0.0);
ResolvedDecorator result = DecoratorCore.pickDecorator(new ResolvedDecorator[0], new RNG(2L), 0.0, 0.0, ModuleLogs.discarding());
assertNull(result);
}
@@ -70,7 +71,7 @@ public class DecoratorCoreTest {
ResolvedDecorator d = mock(ResolvedDecorator.class);
when(d.passesChanceGate(anyDouble(), anyDouble())).thenReturn(false);
ResolvedDecorator result = DecoratorCore.pickDecorator(new ResolvedDecorator[]{d}, new RNG(2L), 0.0, 0.0);
ResolvedDecorator result = DecoratorCore.pickDecorator(new ResolvedDecorator[]{d}, new RNG(2L), 0.0, 0.0, ModuleLogs.discarding());
assertNull(result);
}
@@ -80,7 +81,7 @@ public class DecoratorCoreTest {
when(d.passesChanceGate(anyDouble(), anyDouble())).thenReturn(true);
for (int t = 0; t < 50; t++) {
ResolvedDecorator result = DecoratorCore.pickDecorator(new ResolvedDecorator[]{d}, new RNG(t * 13L + 7), 0.0, 0.0);
ResolvedDecorator result = DecoratorCore.pickDecorator(new ResolvedDecorator[]{d}, new RNG(t * 13L + 7), 0.0, 0.0, ModuleLogs.discarding());
assertSame(d, result);
}
}
@@ -99,7 +100,7 @@ public class DecoratorCoreTest {
int trials = 2000;
for (int t = 0; t < trials; t++) {
ResolvedDecorator picked = DecoratorCore.pickDecorator(decorators, new RNG(t * 31L + 3), 0.0, 0.0);
ResolvedDecorator picked = DecoratorCore.pickDecorator(decorators, new RNG(t * 31L + 3), 0.0, 0.0, ModuleLogs.discarding());
assertNotNull(picked);
for (int i = 0; i < n; i++) {
if (picked == decorators[i]) {
@@ -281,7 +282,7 @@ public class DecoratorCoreTest {
output.set(0, 2, 0, occupied);
DecoratorCore.placeSurfaceSingle(
decorator, 0, 0, 0, 0, 0, output, false, false, null);
decorator, 0, 0, 0, 0, 0, output, false, false, null, ModuleLogs.discarding());
assertSame(air, output.get(0, 1, 0));
assertSame(occupied, output.get(0, 2, 0));
@@ -300,7 +301,7 @@ public class DecoratorCoreTest {
output.set(0, 2, 0, occupied);
DecoratorCore.placeFloatingSimple(
decorator, 0, 0, 0, 0, 0, 3, output);
decorator, 0, 0, 0, 0, 0, 3, output, ModuleLogs.discarding());
assertSame(air, output.get(0, 1, 0));
assertSame(occupied, output.get(0, 2, 0));
@@ -324,7 +325,7 @@ public class DecoratorCoreTest {
output.set(0, 2, 0, upperAir);
DecoratorCore.placeSurfaceSingle(
decorator, 0, 0, 0, 0, 0, output, false, false, null);
decorator, 0, 0, 0, 0, 0, output, false, false, null, ModuleLogs.discarding());
assertSame(lower, output.get(0, 1, 0));
assertSame(upper, output.get(0, 2, 0));
@@ -344,7 +345,7 @@ public class DecoratorCoreTest {
output.set(0, 1, 0, air);
DecoratorCore.placeSurfaceSingle(
decorator, 0, 0, 0, 0, 0, output, false, false, null);
decorator, 0, 0, 0, 0, 0, output, false, false, null, ModuleLogs.discarding());
assertSame(air, output.get(0, 1, 0));
}
@@ -365,7 +366,7 @@ public class DecoratorCoreTest {
output.set(0, 1, 0, air);
DecoratorCore.placeSurfaceSingle(
decorator, 0, 0, 0, 0, 0, output, false, false, null);
decorator, 0, 0, 0, 0, 0, output, false, false, null, ModuleLogs.discarding());
assertSame(farmland, output.get(0, 0, 0));
assertSame(wheat, output.get(0, 1, 0));
@@ -10,6 +10,7 @@ import art.arcane.iris.engine.object.material.IrisBlockData;
import art.arcane.iris.engine.object.world.biome.IrisBiome;
import art.arcane.iris.spi.PlatformBlockState;
import com.google.gson.Gson;
import com.volmit.host.ModuleLogs;
import com.volmit.noise.NoiseFactory;
import com.volmit.noise.NoiseSampler;
import org.junit.After;
@@ -55,7 +56,7 @@ public class ResolvedDecoratorTest {
Gson gson = new Gson();
StringBuilder transcript = new StringBuilder();
for (String json : DECORATORS) {
ResolvedDecorator resolved = ResolvedDecorator.of(gson.fromJson(json, Decorator.class), engine, SEED);
ResolvedDecorator resolved = ResolvedDecorator.of(gson.fromJson(json, Decorator.class), engine, SEED, ModuleLogs.discarding());
for (int x = -40; x < 40; x += 3) {
for (int z = -40; z < 40; z += 5) {
transcript.append(resolved.passesChanceGate(x, z)).append(resolved.stackHeight(x, z)).append(key(resolved.pickBlock(x, z)))
@@ -82,7 +83,7 @@ public class ResolvedDecoratorTest {
};
Decorator decorator = new Gson().fromJson("{\"style\": {\"style\": \"SIMPLEX\"}, \"variance\": {\"style\": \"PERLIN\"}, \"heightVariance\": {\"style\": \"CLOVER\"},"
+ "\"stackMin\": 2, \"stackMax\": 7}", Decorator.class);
ResolvedDecorator resolved = new ResolvedDecorator(decorator, SEED, recording, state("a", "b", "b"), List.of(), null, List.of(), List.of());
ResolvedDecorator resolved = new ResolvedDecorator(decorator, SEED, recording, state("a", "b", "b"), List.of(), null, List.of(), List.of(), ModuleLogs.discarding());
resolved.warm();
@@ -94,7 +95,7 @@ public class ResolvedDecoratorTest {
NoiseFactory refusing = (style, seed) -> {
throw new IllegalStateException("no noise");
};
ResolvedDecorator single = new ResolvedDecorator(new Decorator(), SEED, refusing, state("a"), List.of(), null, List.of(), List.of());
ResolvedDecorator single = new ResolvedDecorator(new Decorator(), SEED, refusing, state("a"), List.of(), null, List.of(), List.of(), ModuleLogs.discarding());
assertEquals("a one block palette never needs its variance noise", "minecraft:a", single.pickBlock(1, 2).key());
assertEquals("equal limits never need the height noise", 1, single.stackHeight(1, 2));
@@ -104,8 +105,8 @@ public class ResolvedDecoratorTest {
@Test
public void stackHeightFollowsTheHeightNoiseBetweenTheLimits() {
Decorator decorator = new Gson().fromJson("{\"stackMin\": 1, \"stackMax\": 2}", Decorator.class);
ResolvedDecorator top = new ResolvedDecorator(decorator, SEED, (style, seed) -> constant(1.0), state("a"), List.of(), null, List.of(), List.of());
ResolvedDecorator bottom = new ResolvedDecorator(decorator, SEED, (style, seed) -> constant(0.0), state("a"), List.of(), null, List.of(), List.of());
ResolvedDecorator top = new ResolvedDecorator(decorator, SEED, (style, seed) -> constant(1.0), state("a"), List.of(), null, List.of(), List.of(), ModuleLogs.discarding());
ResolvedDecorator bottom = new ResolvedDecorator(decorator, SEED, (style, seed) -> constant(0.0), state("a"), List.of(), null, List.of(), List.of(), ModuleLogs.discarding());
assertEquals(2, top.stackHeight(0, 0));
assertEquals(1, bottom.stackHeight(0, 0));
@@ -117,8 +118,8 @@ public class ResolvedDecoratorTest {
PlatformBlockState stone = state("stone").get(0);
Decorator listed = new Gson().fromJson("{\"whitelist\": [{\"block\": \"sand\"}], \"blacklist\": [{\"block\": \"stone\"}]}", Decorator.class);
ResolvedDecorator resolved = new ResolvedDecorator(listed, SEED, (style, seed) -> constant(0), state("a"), List.of(),
null, List.of(sand), List.of(stone));
ResolvedDecorator unlisted = new ResolvedDecorator(new Decorator(), SEED, (style, seed) -> constant(0), state("a"), List.of(), null, List.of(), List.of());
null, List.of(sand), List.of(stone), ModuleLogs.discarding());
ResolvedDecorator unlisted = new ResolvedDecorator(new Decorator(), SEED, (style, seed) -> constant(0), state("a"), List.of(), null, List.of(), List.of(), ModuleLogs.discarding());
assertFalse(resolved.rejectsSurface(sand));
assertTrue(resolved.rejectsSurface(stone));
@@ -130,9 +131,9 @@ public class ResolvedDecoratorTest {
public void onlyASlopeOutsideTheLimitsBlocksAndOnlyWhenTheDecoratorLimitsIt() {
Decorator limited = new Gson().fromJson("{\"slopeCondition\": {\"maximumSlope\": 4}}", Decorator.class);
Decorator forced = new Gson().fromJson("{\"forcePlace\": true, \"slopeCondition\": {\"maximumSlope\": 4}}", Decorator.class);
ResolvedDecorator resolvedLimited = new ResolvedDecorator(limited, SEED, (style, seed) -> constant(0), state("a"), List.of(), null, List.of(), List.of());
ResolvedDecorator resolvedForced = new ResolvedDecorator(forced, SEED, (style, seed) -> constant(0), state("a"), List.of(), null, List.of(), List.of());
ResolvedDecorator resolvedDefault = new ResolvedDecorator(new Decorator(), SEED, (style, seed) -> constant(0), state("a"), List.of(), null, List.of(), List.of());
ResolvedDecorator resolvedLimited = new ResolvedDecorator(limited, SEED, (style, seed) -> constant(0), state("a"), List.of(), null, List.of(), List.of(), ModuleLogs.discarding());
ResolvedDecorator resolvedForced = new ResolvedDecorator(forced, SEED, (style, seed) -> constant(0), state("a"), List.of(), null, List.of(), List.of(), ModuleLogs.discarding());
ResolvedDecorator resolvedDefault = new ResolvedDecorator(new Decorator(), SEED, (style, seed) -> constant(0), state("a"), List.of(), null, List.of(), List.of(), ModuleLogs.discarding());
assertTrue(resolvedLimited.slopeBlocks(() -> 5));
assertFalse(resolvedLimited.slopeBlocks(() -> 3));
@@ -43,6 +43,7 @@ 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 com.volmit.host.ModuleLogs;
import org.junit.Test;
import java.util.Set;
@@ -279,7 +280,7 @@ public class IrisStructureLocatorContractTest {
ModuleResourceFixture.of(data).resource(StructureResources.PIECES, "test:target-piece", targetPiece);
when(data.load(IrisObject.class, "test:start-object", false)).thenReturn(startObject);
when(data.load(IrisObject.class, "test:target-object", false)).thenReturn(targetObject);
assertFalse(StructureGraphCatalog.compile(data, structure).isAssemblyViable());
assertFalse(StructureGraphCatalog.compile(data, structure, ModuleLogs.discarding()).isAssemblyViable());
IrisStructurePlacement placement = new IrisStructurePlacement()
.setNativeSuppression(NativeStructureSuppression.REPLACE_SOURCE);
@@ -41,6 +41,7 @@ import art.arcane.iris.spi.IrisPlatforms;
import art.arcane.iris.spi.PlatformBlockState;
import art.arcane.iris.spi.PlatformRegistries;
import art.arcane.volmlib.util.math.RNG;
import com.volmit.host.ModuleLogs;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -1213,7 +1214,7 @@ public class StructureAssemblerTest {
}
private StructureAssembler assembler(IrisStructure structure, int x, int y, int z) {
return StructureAssembler.forData(data, structure, new IrisPosition(x, y, z));
return StructureAssembler.forData(data, structure, new IrisPosition(x, y, z), ModuleLogs.discarding());
}
}
}
@@ -1,5 +1,6 @@
package art.arcane.iris.engine.framework.structure.fit;
import com.volmit.host.ModuleLogs;
import com.volmit.vanilla.StructureStep;
import com.volmit.vanilla.TerrainAdaptation;
import org.junit.Test;
@@ -229,7 +230,7 @@ public class SurfaceFittingTest {
FitStart start = FitFixture.start(VACUUM, TerrainAdaptation.NONE, StructureStep.SURFACE_STRUCTURES,
FitFixture.Piece.rigid(new Box(0, 66, 0, 0, 70, 0), 1).cell(0, 66, 0, COBBLESTONE));
SurfaceFitting.prepareSurfaceStructures(world.fitBlocks(), area, List.of(start), (x, z) -> 60, 1);
SurfaceFitting.prepareSurfaceStructures(world.fitBlocks(), area, List.of(start), (x, z) -> 60, 1, ModuleLogs.discarding());
assertEquals(before, world.snapshot());
}
@@ -242,7 +243,7 @@ public class SurfaceFittingTest {
FitFixture.Piece.rigid(new Box(0, 65, 0, 0, 72, 0), 1).cell(0, 65, 0, COBBLESTONE));
SurfaceFitting.VacuumFoundationPlan plan = SurfaceFitting.prepareSurfaceStructures(
world.fitBlocks(), area, List.of(start), (x, z) -> 60, SurfaceFitting.MAX_SURFACE_TEMPLATE_CELLS);
world.fitBlocks(), area, List.of(start), (x, z) -> 60, SurfaceFitting.MAX_SURFACE_TEMPLATE_CELLS, ModuleLogs.discarding());
assertEquals(GRASS, world.at(0, 64, 0));
for (int y = 61; y <= 64; y++) {
world.put(0, y, 0, state("cave_air"));
@@ -27,6 +27,7 @@ import art.arcane.iris.engine.object.loot.IObjectLoot;
import art.arcane.iris.spi.PlatformBlockState;
import art.arcane.volmlib.util.collection.KList;
import art.arcane.volmlib.util.math.RNG;
import com.volmit.host.ModuleLogs;
import com.volmit.service.Loot;
import org.junit.AfterClass;
import org.junit.Before;
@@ -69,7 +70,7 @@ public class PlacementLootTest {
for (String key : List.of("everywhere", "chests", "this-chest", "other")) {
fixture.resource(LootResources.TABLES, key, TestSettings.of(LootTable.class, "{\"name\": \"" + key + "\"}"));
}
placement = new PlacementLoot(data, () -> Set.of("minecraft:chests/simple_dungeon"), LOOT_SEED);
placement = new PlacementLoot(data, () -> Set.of("minecraft:chests/simple_dungeon"), LOOT_SEED, ModuleLogs.discarding());
}
@Test
@@ -36,6 +36,7 @@ import art.arcane.iris.spi.IrisPlatforms;
import art.arcane.iris.spi.PlatformBlockState;
import art.arcane.iris.spi.PlatformRegistries;
import art.arcane.volmlib.util.collection.KList;
import com.volmit.host.ModuleLogs;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
@@ -114,6 +115,6 @@ public class FloatingObjectPlacingBoundaryRadiusTest {
when(engine.getData()).thenReturn(data);
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
assertEquals(33, new FloatingObjectPlacing(engine).reach());
assertEquals(33, new FloatingObjectPlacing(engine, ModuleLogs.discarding()).reach());
}
}
@@ -32,6 +32,7 @@ import art.arcane.volmlib.util.mantle.flag.ReservedFlag;
import art.arcane.volmlib.util.mantle.runtime.Mantle;
import art.arcane.volmlib.util.mantle.runtime.MantleChunk;
import art.arcane.volmlib.util.matter.Matter;
import com.volmit.host.ModuleLogs;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
@@ -128,7 +129,7 @@ public class ObjectPlacingBoundaryRadiusTest {
when(engine.getDimension()).thenReturn(dimension);
when(engine.getData()).thenReturn(data);
assertEquals(53, new ObjectPlacing(engine).reach());
assertEquals(53, new ObjectPlacing(engine, ModuleLogs.discarding()).reach());
}
@Test
@@ -159,7 +160,7 @@ public class ObjectPlacingBoundaryRadiusTest {
when(engine.getDimension()).thenReturn(dimension);
when(engine.getData()).thenReturn(data);
int reach = new ObjectPlacing(engine).reach();
int reach = new ObjectPlacing(engine, ModuleLogs.discarding()).reach();
assertEquals(33, reach);
int chunkRadius = Math.ceilDiv(reach, 16);
assertEquals(3, chunkRadius);
@@ -32,6 +32,7 @@ import com.volmit.FeatureAttachment.Target;
import com.volmit.IrisFeature;
import com.volmit.IrisModule;
import com.volmit.ModuleInfo;
import com.volmit.ModuleLog;
import com.volmit.block.BlockFace;
import com.volmit.block.BlockRegistry;
import com.volmit.block.BlockSpec;
@@ -45,6 +46,7 @@ import com.volmit.generation.GenerationContext;
import com.volmit.host.ArrayHunk;
import com.volmit.host.ChunkRunner;
import com.volmit.host.DiscoveredModule;
import com.volmit.host.ModuleLogs;
import com.volmit.host.ResolvedGraph;
import com.volmit.host.StageGraphBuilder;
import com.volmit.hunk.Hunk;
@@ -409,6 +411,16 @@ public final class ApiChunk implements GenerationContext {
return type.cast(known);
}
@Override
public ModuleLog log() {
return ModuleLogs.discarding();
}
@Override
public PackWorld withLog(ModuleLog log) {
return this;
}
@Override
public long seed(IrisSeed seed) {
return SEED + seed.ordinal();
@@ -13,6 +13,7 @@ import art.arcane.volmlib.util.mantle.runtime.MantleChunk;
import art.arcane.volmlib.util.matter.Matter;
import art.arcane.volmlib.util.matter.MatterCavern;
import art.arcane.volmlib.util.matter.MatterSlice;
import com.volmit.host.ModuleLogs;
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
import org.junit.After;
import org.junit.Before;
@@ -56,7 +57,7 @@ public class CaveApplyingBoundarySupportTest {
doReturn(mock(SeedManager.class)).when(engine).getSeedManager();
DecoratorTestEngines.withGeneration(engine);
CaveApplying modifier = new CaveApplying(engine);
CaveApplying modifier = new CaveApplying(engine, ModuleLogs.discarding());
MantleChunk<Matter> mantleChunk = mock(MantleChunk.class);
Matter floorMatter = mock(Matter.class);
@@ -20,6 +20,7 @@ import art.arcane.iris.util.project.hunk.Hunk;
import art.arcane.iris.util.project.stream.ProceduralStream;
import art.arcane.volmlib.util.matter.MatterCavern;
import com.google.gson.Gson;
import com.volmit.host.ModuleLogs;
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
import org.junit.AfterClass;
import org.junit.BeforeClass;
@@ -68,7 +69,7 @@ public class CaveApplyingInferenceIsolationTest {
doReturn(IrisWorld.builder().minHeight(-256).maxHeight(512).build()).when(engine).getWorld();
doReturn(mock(SeedManager.class)).when(engine).getSeedManager();
DecoratorTestEngines.withGeneration(engine);
CaveApplying modifier = new CaveApplying(engine);
CaveApplying modifier = new CaveApplying(engine, ModuleLogs.discarding());
Map<String, IrisBiome> customBiomes = new HashMap<>();
customBiomes.put("shared", biome);
@@ -10,6 +10,7 @@ import art.arcane.iris.engine.object.world.biome.IrisBiome;
import art.arcane.iris.spi.PlatformBlockState;
import art.arcane.iris.util.project.context.ChunkContext;
import art.arcane.iris.util.project.hunk.Hunk;
import com.volmit.host.ModuleLogs;
import org.junit.Test;
import static org.mockito.ArgumentMatchers.any;
@@ -27,7 +28,7 @@ public class FloatingIslandsTest {
@Test
@SuppressWarnings("unchecked")
public void columnsWithoutFloatingChildBiomesAreLeftAlone() {
FloatingIslands islands = new FloatingIslands(engine());
FloatingIslands islands = new FloatingIslands(engine(), ModuleLogs.discarding());
IrisBiome biome = mock(IrisBiome.class);
when(biome.getModuleSettings()).thenReturn(ModuleSettings.NONE);
FloatingIslandBoundarySampler sampler = mock(FloatingIslandBoundarySampler.class);
@@ -33,6 +33,7 @@ import art.arcane.iris.engine.framework.Engine;
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.host.ModuleLogs;
import org.junit.Test;
import java.util.concurrent.ExecutorService;
@@ -583,9 +584,9 @@ public class FloatingIslandBoundarySamplerTest {
int[] expectedBottom = {159, 158, 156, 153, 150, 147, 144, 142, 141, 140};
int[] expectedTop = {161, 162, 164, 166, 169, 172, 174, 176, 177, 178};
assertNull(FloatingIslandSample.sample(parent, entries, 0, 0, 320, 31L, data, engine, sampler));
assertNull(FloatingIslandSample.sample(parent, entries, 0, 0, 320, 31L, data, engine, sampler, ModuleLogs.discarding()));
for (int i = 0; i < expectedBottom.length; i++) {
FloatingIslandSample sample = FloatingIslandSample.sample(parent, entries, i + 1, 0, 320, 31L, data, engine, sampler);
FloatingIslandSample sample = FloatingIslandSample.sample(parent, entries, i + 1, 0, 320, 31L, data, engine, sampler, ModuleLogs.discarding());
assertNotNull("distance " + (i + 2) + " rejected with code " + FloatingIslandSample.getLastReject(), sample);
assertEquals(expectedBottom[i], sample.bottomY());
assertEquals(expectedTop[i], sample.topY());
@@ -652,8 +653,8 @@ public class FloatingIslandBoundarySamplerTest {
when(engine.getWorld()).thenReturn(world);
FloatingIslandBoundarySampler sampler = new FloatingIslandBoundarySampler((x, z) -> parent);
assertNull(FloatingIslandSample.sample(parent, entries, 0, 0, 320, 35L, data, engine, sampler));
FloatingIslandSample sample = FloatingIslandSample.sample(parent, entries, 1, 0, 320, 35L, data, engine, sampler);
assertNull(FloatingIslandSample.sample(parent, entries, 0, 0, 320, 35L, data, engine, sampler, ModuleLogs.discarding()));
FloatingIslandSample sample = FloatingIslandSample.sample(parent, entries, 1, 0, 320, 35L, data, engine, sampler, ModuleLogs.discarding());
assertNotNull(sample);
assertTrue(sample.hasMergedEntries());
@@ -11,6 +11,7 @@ import art.arcane.iris.spi.PlatformBlockState;
import art.arcane.volmlib.util.collection.KList;
import art.arcane.volmlib.util.math.RNG;
import com.google.gson.Gson;
import com.volmit.host.ModuleLogs;
import org.junit.Test;
import java.io.File;
@@ -73,6 +74,6 @@ public class BiomeLayersCeilingGuardTest {
}
private static BiomeLayers layersOf(IrisData data) {
return new BiomeLayers(TestLayerBlocks.of(data.getPackResources()));
return new BiomeLayers(TestLayerBlocks.of(data.getPackResources()), ModuleLogs.discarding());
}
}
@@ -19,7 +19,9 @@
package art.arcane.iris.engine.terrain;
import art.arcane.iris.builtin.terrain.LayerBlocks;
import com.volmit.ModuleLog;
import com.volmit.config.PackSettings;
import com.volmit.host.ModuleLogs;
import com.volmit.resource.PackResources;
import com.volmit.world.PackWorld;
@@ -57,5 +59,15 @@ public final class TestLayerBlocks {
public <T> T state(Class<T> type, Function<? super PackWorld, ? extends T> create) {
return type.cast(states.computeIfAbsent(type, ignored -> create.apply(this)));
}
@Override
public ModuleLog log() {
return ModuleLogs.discarding();
}
@Override
public PackWorld withLog(ModuleLog log) {
return this;
}
}
}