Host side of ModuleLog: Iris's log carries each module's lines labelled and follows the debug setting, worlds, services, hooks and vanilla structure fits are scoped to the module they are handed to; module signatures that gained a log

This commit is contained in:
piexel committed 2026-10-10 14:25:52 +02:00
1 parent 00a313bd69
commit 95283099fe
31 files changed
+469 -111

No files matched your search

@@ -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 {
@@ -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");
@@ -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;
}
}
}