Merge origin/master into terrain-first hydrology

Brings master's Sentry removal, bound platform classification, Vision
entity toggle, release version and generation context binding onto the
rivers rework while keeping the hydrology system master had removed.
Hydrology files master deleted are restored from the branch, master's
non-hydrology edits are kept, and the modded adapter builds drop the
Sentry dependency with master.

Also removes the ridge_tunnel find selector: no course publishes ridge
bores any more, so it could never return a result.
This commit is contained in:
Brian Neumann-Fopiano committed 2026-09-02 02:52:08 -04:00
commit f6a7ad7472
74 files changed
+869 -726

No files matched your search

-1
View File
@@ -21,7 +21,6 @@ dependencies {
testImplementation('org.mockito:mockito-core:5.23.0')
testImplementation(libs.paper.api)
testImplementation(libs.bstats)
testImplementation(libs.sentry)
testImplementation(project(':core'))
testImplementation(volmLibCoordinate) {
transitive = false
@@ -423,7 +423,6 @@ public class Iris extends VolmitPlugin implements Listener, ReloadAware {
return;
}
Bindings.capture(e);
boolean debug = false;
if (instance != null) {
try {
@@ -455,6 +454,8 @@ public class Iris extends VolmitPlugin implements Listener, ReloadAware {
Iris.debug("Exception Logged: " + e.getClass().getSimpleName() + ": " + C.RESET + "" + C.LIGHT_PURPLE + e.getMessage());
}
e.printStackTrace(System.err);
}
public static void reportError(String context, Throwable e) {
@@ -473,7 +474,6 @@ public class Iris extends VolmitPlugin implements Listener, ReloadAware {
}
reportError(error);
error.printStackTrace(System.err);
}
public static void dump() {
@@ -606,7 +606,6 @@ public class Iris extends VolmitPlugin implements Listener, ReloadAware {
SimdSupport.install();
services = new KMap<>();
BukkitPlatform.hostHud(new HudActionBar(this), new HudBossBarLane());
Bindings.setupSentry();
// Explicit, ordered service list: the previous reflective jar scan gave hash-ordered
// enable/disable and paid a full-jar class sweep at boot. Infrastructure first,
// engine/world services next, commands last.
@@ -34,7 +34,6 @@ import art.arcane.iris.engine.IrisEngineMantle;
import art.arcane.iris.engine.framework.Engine;
import art.arcane.iris.engine.object.IrisDimension;
import art.arcane.iris.engine.platform.PlatformChunkGenerator;
import art.arcane.iris.util.project.context.IrisContext;
import art.arcane.iris.util.project.matter.IrisMatterContext;
import art.arcane.iris.util.common.director.DirectorExecutor;
import art.arcane.volmlib.util.director.DirectorOrigin;
@@ -79,19 +78,6 @@ public class CommandDeveloper implements DirectorExecutor {
.engineStatus(sender());
}
@Director(description = "Send a test exception to sentry", descriptionKey = "iris.director.commanddeveloper.director.send_test_exception_sentry")
public void Sentry() {
Engine engine = engine();
Exception testException = new Exception("This is a test");
if (engine == null) {
Iris.reportError(testException);
return;
}
try (IrisContext.Scope scope = IrisContext.open(engine, engine.getGenerationSessionId(), null)) {
Iris.reportError(testException);
}
}
@Director(description = "Hash generated block output of a fixed area for determinism/identity testing", descriptionKey = "iris.director.commanddeveloper.director.hash_generated_block_output_fixed_area_determinism_identity_testing", origin = DirectorOrigin.BOTH)
public void genhash(
@Param(description = "The world to hash", descriptionKey = "iris.director.commanddeveloper.param.world_hash", contextual = true, contextualOverride = true)
+1 -3
View File
@@ -166,8 +166,7 @@ dependencies {
libs.lru,
libs.caffeine,
libs.dom4j,
libs.jaxen,
libs.sentry
libs.jaxen
]
shared.each { Object notation ->
add('bundle', notation)
@@ -275,7 +274,6 @@ tasks.named('shadowJar', ShadowJar).configure {
exclude('art/arcane/iris/platform/bukkit/**')
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
relocate('org.objectweb.asm', 'art.arcane.iris.shadow.asm')
relocate('io.sentry', 'art.arcane.iris.shadow.sentry')
// Split-package guard. A co-installed mod that ships any of these at their original coordinates
// puts two copies of the same package on one module layer, which the loaders reject at boot
// (Terra ships paralithic; caffeine and dom4j are common in mod dependency trees). First-party
+1 -3
View File
@@ -165,8 +165,7 @@ dependencies {
libs.lru,
libs.caffeine,
libs.dom4j,
libs.jaxen,
libs.sentry
libs.jaxen
]
shared.each { Object notation ->
add('bundle', notation)
@@ -267,7 +266,6 @@ tasks.named('shadowJar', ShadowJar).configure {
exclude('art/arcane/iris/platform/bukkit/**')
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
relocate('org.objectweb.asm', 'art.arcane.iris.shadow.asm')
relocate('io.sentry', 'art.arcane.iris.shadow.sentry')
// Split-package guard. A co-installed mod that ships any of these at their original coordinates
// puts two copies of the same package on one module layer, which the loaders reject at boot
// (Terra ships paralithic; caffeine and dom4j are common in mod dependency trees). First-party
@@ -331,34 +331,113 @@ public final class IrisModdedChunkGenerator extends ChunkGenerator {
if (server == null) {
return null;
}
// Snapshot, never server.getAllLevels(): this runs off the server thread from data queries.
for (ServerLevel level : ModdedServerLevels.levels(server)) {
ServerLevel resolved = resolveBoundLevel(server, ModdedServerLevels.levels(server));
if (resolved != null) {
boundLevel = resolved;
}
return resolved;
}
ServerLevel resolveBoundLevel(MinecraftServer server, List<ServerLevel> snapshot) {
for (ServerLevel level : snapshot) {
if (level.getChunkSource().getGenerator() == this) {
boundLevel = level;
return level;
}
}
return null;
ServerLevel overworld = server.getLevel(Level.OVERWORLD);
return overworld != null && overworld.getChunkSource().getGenerator() == this ? overworld : null;
}
Engine engine() {
requireBindingAllowed();
Engine cached = engine;
requireCompletedShutdown(cached);
if (cached != null && !cached.isClosed()) {
Engine cached = readyEngine();
if (cached != null) {
return cached;
}
ServerLevel level = boundLevel();
if (level == null) {
throw new IllegalStateException("Iris generator '" + dimensionKey + "' has no bound ServerLevel yet");
}
return bindEngine(level);
return bindGenerationLevel(level);
}
private Engine engine(ResourceKey<Level> levelKey) {
Engine cached = readyEngine();
if (cached != null) {
return cached;
}
ServerLevel level = boundLevel;
if (level == null) {
level = requirePublishedLevel(ModdedEngineBootstrap.currentServer(), levelKey);
} else {
requireGeneratorLevel(level, levelKey);
}
return bindGenerationLevel(level);
}
private Engine engine(ServerLevel generationLevel) {
Engine cached = readyEngine();
if (cached != null) {
return cached;
}
ServerLevel level = boundLevel == null ? generationLevel : boundLevel;
requireGeneratorLevel(level, generationLevel.dimension());
return bindGenerationLevel(level);
}
private Engine readyEngine() {
requireBindingAllowed();
Engine cached = engine;
requireCompletedShutdown(cached);
if (cached != null && !cached.isClosed()) {
return cached;
}
return null;
}
private Engine bindGenerationLevel(ServerLevel level) {
bindLevel(level);
Engine bound = readyEngine();
if (bound == null) {
throw new IllegalStateException("Iris generator '" + dimensionKey
+ "' completed generation binding without a ready engine");
}
return bound;
}
ServerLevel requirePublishedLevel(MinecraftServer server, ResourceKey<Level> levelKey) {
if (server == null) {
throw new IllegalStateException("Iris generator '" + dimensionKey
+ "' cannot resolve level '" + levelKey.identifier() + "': server is unavailable");
}
ServerLevel level = server.getLevel(levelKey);
if (level == null) {
throw new IllegalStateException("Iris generator '" + dimensionKey
+ "' has no published ServerLevel for '" + levelKey.identifier() + "'");
}
requireGeneratorLevel(level, levelKey);
return level;
}
private void requireGeneratorLevel(ServerLevel level, ResourceKey<Level> levelKey) {
if (!levelKey.equals(level.dimension())) {
throw new IllegalStateException("Iris generator '" + dimensionKey + "' resolved level '"
+ level.dimension().identifier() + "' while binding '" + levelKey.identifier() + "'");
}
ChunkGenerator publishedGenerator = level.getChunkSource().getGenerator();
if (publishedGenerator != this) {
throw new IllegalStateException("Published ServerLevel '" + levelKey.identifier()
+ "' does not use Iris generator '" + dimensionKey + "'");
}
}
synchronized void bindLevel(ServerLevel level) {
if (level.getChunkSource().getGenerator() != this) {
throw new IllegalArgumentException("ServerLevel does not use Iris generator '" + dimensionKey + "'");
}
Engine current = engineIfBound();
if (boundLevel == level && current != null && current.getComplex() != null) {
return;
}
requireCompletedShutdown(engine);
unloading = false;
Engine bound = bindEngine(level);
@@ -853,7 +932,6 @@ public final class IrisModdedChunkGenerator extends ChunkGenerator {
@Override
public void applyBiomeDecoration(WorldGenLevel level, ChunkAccess chunk, StructureManager structureManager) {
Engine current = engine();
// Self-heal for an engine bound through a data-query path instead of bindLevel; a no-op once prepared.
importedFeatures.prepare(current);
try (GenerationSessionLease lease = requireGenerationLease(current, "modded_biome_decoration");
IrisContext.Scope ignored = IrisContext.open(current, lease.sessionId(), null)) {
@@ -867,7 +945,7 @@ public final class IrisModdedChunkGenerator extends ChunkGenerator {
@Override
public void createStructures(RegistryAccess registryAccess, ChunkGeneratorStructureState structureState, StructureManager structureManager, ChunkAccess chunk, StructureTemplateManager templateManager, ResourceKey<Level> levelKey) {
Engine current = engine();
Engine current = engine(levelKey);
try (GenerationSessionLease lease = requireGenerationLease(current, "modded_create_structures");
IrisContext.Scope ignored = IrisContext.open(current, lease.sessionId(), null)) {
Map<Structure, StructureStart> previousStarts = new HashMap<>(chunk.getAllStarts());
@@ -891,7 +969,7 @@ public final class IrisModdedChunkGenerator extends ChunkGenerator {
@Override
public void createReferences(WorldGenLevel level, StructureManager structureManager, ChunkAccess chunk) {
Engine current = engine();
Engine current = engine(level.getLevel());
try (GenerationSessionLease lease = requireGenerationLease(current, "modded_create_references");
IrisContext.Scope ignored = IrisContext.open(current, lease.sessionId(), null)) {
NativeStructureReferenceRepair.createReferences(
@@ -590,6 +590,7 @@ public final class ModdedDimensionManager {
boolean loadEventStarted = false;
try {
serverAccess.initializeLevelData(server, level);
generator.bindLevel(level);
Handle handle = new Handle(dimensionId, pack, packDimensionKey, seed, level, generator);
ServerLevel previous = serverAccess.putLevelIfAbsent(server, key, level);
@@ -113,7 +113,6 @@ public final class ModdedEngineBootstrap {
bindWorldGenerators(server);
services().enableAll();
ModdedProtocolHandler.start(server);
ModdedSentry.start(loader());
}
private static void bindWorldGenerators(MinecraftServer server) {
@@ -194,7 +193,6 @@ public final class ModdedEngineBootstrap {
MultiBurst.burst.close();
MultiBurst.ioBurst.close();
});
failure = runStopStage(failure, "sentry", ModdedSentry::flush);
failure = runStopStage(failure, "startup state", ModdedStartup::reset);
failure = runStopStage(failure, "server state", () -> {
currentServer = null;
@@ -47,7 +47,6 @@ public final class ModdedPlatform implements IrisPlatform {
private static final ConcurrentHashMap<String, ErrorThrottle> ERROR_THROTTLES = new ConcurrentHashMap<>();
private static volatile Consumer<Throwable> ERROR_SINK = null;
private static volatile Consumer<Throwable> CAPTURE_SINK = null;
private final ModdedLoader loader;
private final ModdedRegistries registries;
@@ -67,10 +66,6 @@ public final class ModdedPlatform implements IrisPlatform {
ERROR_SINK = sink;
}
public static void captureSink(Consumer<Throwable> sink) {
CAPTURE_SINK = sink;
}
public MinecraftServer server() {
return ModdedEngineBootstrap.currentServer();
}
@@ -230,9 +225,8 @@ public final class ModdedPlatform implements IrisPlatform {
}
/**
* Throttled per exception signature. A single broken pack rule can fail on every generated chunk, and this
* feeds Sentry, so each distinct signature reports its first few occurrences and then only a periodic
* suppressed-count summary.
* Throttled per exception signature. A single broken pack rule can fail on every generated chunk, so each
* distinct signature reports its first few occurrences and then only a periodic suppressed-count summary.
*/
@Override
public void reportError(Throwable error) {
@@ -261,14 +255,6 @@ public final class ModdedPlatform implements IrisPlatform {
return;
}
ModdedIrisLog.error(message, error);
Consumer<Throwable> capture = CAPTURE_SINK;
if (capture != null) {
try {
capture.accept(error);
} catch (Throwable captureFailure) {
ModdedIrisLog.error("Iris error-reporting sink failed", captureFailure);
}
}
}
static void resetErrorThrottles() {
@@ -1,81 +0,0 @@
/*
* 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.modded;
import art.arcane.iris.BuildConstants;
import art.arcane.iris.core.IrisSettings;
import art.arcane.iris.spi.IrisLogging;
import art.arcane.volmlib.util.json.JSONException;
import com.google.gson.JsonSyntaxException;
import io.sentry.Sentry;
import java.util.concurrent.atomic.AtomicBoolean;
public final class ModdedSentry {
private static final String DSN = "http://4cdbb9ac953306529947f4ca1e8e6b26@sentry.volmit.com:8080/2";
private static final long FLUSH_TIMEOUT_MS = 2000L;
private static final AtomicBoolean STARTED = new AtomicBoolean(false);
private ModdedSentry() {
}
public static void start(ModdedLoader loader) {
IrisSettings.IrisSettingsSentry settings = IrisSettings.get().getSentry();
if (settings.disableAutoReporting || Sentry.isEnabled() || Boolean.getBoolean("iris.suppressReporting")) {
return;
}
if (!STARTED.compareAndSet(false, true)) {
return;
}
IrisLogging.info("Enabling Sentry for anonymous error reporting. You can disable this in the settings.");
Sentry.init(options -> {
options.setDsn(DSN);
if (settings.debug) {
options.setDebug(true);
}
options.setAttachServerName(false);
options.setEnableUncaughtExceptionHandler(false);
options.setRelease(loader.modVersion());
options.setEnvironment(BuildConstants.ENVIRONMENT);
options.setBeforeSend((event, hint) -> suppress(event.getThrowable()) ? null : event);
});
Sentry.configureScope(scope -> {
scope.setTag("server", loader.platformName());
scope.setTag("server.mc", loader.minecraftVersion());
scope.setTag("iris.loader", loader.platformName());
scope.setTag("iris.commit", BuildConstants.COMMIT);
});
ModdedPlatform.captureSink(Sentry::captureException);
}
public static void flush() {
if (Sentry.isEnabled()) {
Sentry.flush(FLUSH_TIMEOUT_MS);
Sentry.close();
}
ModdedPlatform.captureSink(null);
STARTED.set(false);
}
private static boolean suppress(Throwable error) {
return (error instanceof IllegalStateException state && "zip file closed".equals(state.getMessage()))
|| error instanceof JSONException
|| error instanceof JsonSyntaxException;
}
}
@@ -31,6 +31,8 @@ public interface ModdedServerAccess {
LevelStorageSource.LevelStorageAccess levelStorage(MinecraftServer server);
void initializeLevelData(MinecraftServer server, ServerLevel level);
ServerLevel putLevel(MinecraftServer server, ResourceKey<Level> key, ServerLevel level);
ServerLevel putLevelIfAbsent(MinecraftServer server, ResourceKey<Level> key, ServerLevel level);
@@ -23,7 +23,11 @@ import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.storage.LevelStorageSource;
import net.minecraft.world.level.storage.PrimaryLevelData;
import net.minecraft.world.level.storage.WorldData;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ConcurrentModificationException;
import java.util.LinkedHashMap;
import java.util.List;
@@ -34,6 +38,18 @@ import java.util.function.Consumer;
public final class ModdedServerLevels implements ModdedServerAccess {
private static final int CAPTURE_ATTEMPTS = 16;
private static final ClassValue<HostLevelPublication> HOST_LEVEL_PUBLICATIONS = new ClassValue<>() {
@Override
protected HostLevelPublication computeValue(Class<?> type) {
return HostLevelPublication.detect(type, ServerLevel.class);
}
};
private static final ClassValue<HostLevelDataAttachment> HOST_LEVEL_DATA_ATTACHMENTS = new ClassValue<>() {
@Override
protected HostLevelDataAttachment computeValue(Class<?> type) {
return HostLevelDataAttachment.detect(type, PrimaryLevelData.class, ResourceKey.class);
}
};
private static volatile Snapshot snapshot;
private final Consumer<MinecraftServer> levelCacheInvalidator;
@@ -43,8 +59,8 @@ public final class ModdedServerLevels implements ModdedServerAccess {
}
/**
* Immutable view of the loaded levels. {@code server.levels} is a plain map mutated on the server
* thread, so every off-server-thread reader must iterate this snapshot instead of
* Immutable view of the loaded levels. {@code server.levels} is loader-owned and published on the
* server thread, so every off-server-thread reader must iterate this snapshot instead of
* {@code server.getAllLevels()} to avoid ConcurrentModificationException.
*/
public static List<ServerLevel> levels(MinecraftServer server) {
@@ -137,8 +153,32 @@ public final class ModdedServerLevels implements ModdedServerAccess {
return server.storageSource;
}
@Override
public void initializeLevelData(MinecraftServer server, ServerLevel level) {
Object levelData = level.getLevelData();
HostLevelDataAttachment attachment = HOST_LEVEL_DATA_ATTACHMENTS.get(levelData.getClass());
if (!attachment.supported()) {
return;
}
WorldData worldData = server.getWorldData();
if (!(worldData instanceof PrimaryLevelData rootData)) {
throw new IllegalStateException("Host level data attachment requires PrimaryLevelData, found "
+ worldData.getClass().getName());
}
attachment.attach(levelData, rootData, level.dimension());
}
@Override
public ServerLevel putLevel(MinecraftServer server, ResourceKey<Level> key, ServerLevel level) {
HostLevelPublication hostPublication = HOST_LEVEL_PUBLICATIONS.get(server.getClass());
if (hostPublication.supported()) {
ServerLevel previous = server.levels.get(key);
if (previous != level) {
hostPublication.add(server, level);
capture(server);
}
return previous;
}
ServerLevel previous = server.levels.put(key, level);
if (previous != level) {
capture(server);
@@ -149,6 +189,15 @@ public final class ModdedServerLevels implements ModdedServerAccess {
@Override
public ServerLevel putLevelIfAbsent(MinecraftServer server, ResourceKey<Level> key, ServerLevel level) {
HostLevelPublication hostPublication = HOST_LEVEL_PUBLICATIONS.get(server.getClass());
if (hostPublication.supported()) {
ServerLevel previous = server.levels.get(key);
if (previous == null) {
hostPublication.add(server, level);
capture(server);
}
return previous;
}
ServerLevel previous = server.levels.putIfAbsent(key, level);
if (previous == null) {
capture(server);
@@ -159,6 +208,15 @@ public final class ModdedServerLevels implements ModdedServerAccess {
@Override
public ServerLevel removeLevel(MinecraftServer server, ResourceKey<Level> key) {
HostLevelPublication hostPublication = HOST_LEVEL_PUBLICATIONS.get(server.getClass());
if (hostPublication.supported()) {
ServerLevel removed = server.levels.get(key);
if (removed != null) {
hostPublication.remove(server, removed);
capture(server);
}
return removed;
}
ServerLevel removed = server.levels.remove(key);
if (removed != null) {
capture(server);
@@ -175,4 +233,94 @@ public final class ModdedServerLevels implements ModdedServerAccess {
private record Snapshot(MinecraftServer server, List<ServerLevel> levels,
Map<ResourceKey<Level>, ServerLevel> byKey) {
}
static final class HostLevelPublication {
private final Method addLevel;
private final Method removeLevel;
private HostLevelPublication(Method addLevel, Method removeLevel) {
this.addLevel = addLevel;
this.removeLevel = removeLevel;
}
static HostLevelPublication detect(Class<?> serverType, Class<?> levelType) {
try {
Method addLevel = serverType.getMethod("addLevel", levelType);
Method removeLevel = serverType.getMethod("removeLevel", levelType);
return new HostLevelPublication(addLevel, removeLevel);
} catch (NoSuchMethodException e) {
return new HostLevelPublication(null, null);
}
}
boolean supported() {
return addLevel != null && removeLevel != null;
}
void add(Object server, Object level) {
invoke(addLevel, server, level);
}
void remove(Object server, Object level) {
invoke(removeLevel, server, level);
}
private void invoke(Method method, Object server, Object level) {
try {
method.invoke(server, level);
} catch (IllegalAccessException e) {
throw new IllegalStateException("Iris cannot access host level publication method "
+ method.getName(), e);
} catch (InvocationTargetException e) {
Throwable cause = e.getCause();
if (cause instanceof RuntimeException runtimeException) {
throw runtimeException;
}
if (cause instanceof Error fatalError) {
throw fatalError;
}
throw new IllegalStateException("Host level publication method " + method.getName()
+ " failed", cause);
}
}
}
static final class HostLevelDataAttachment {
private final Method attach;
private HostLevelDataAttachment(Method attach) {
this.attach = attach;
}
static HostLevelDataAttachment detect(Class<?> levelDataType, Class<?> rootDataType,
Class<?> dimensionKeyType) {
try {
return new HostLevelDataAttachment(levelDataType.getMethod(
"attach", rootDataType, dimensionKeyType));
} catch (NoSuchMethodException e) {
return new HostLevelDataAttachment(null);
}
}
boolean supported() {
return attach != null;
}
void attach(Object levelData, Object rootData, Object dimensionKey) {
try {
attach.invoke(levelData, rootData, dimensionKey);
} catch (IllegalAccessException e) {
throw new IllegalStateException("Iris cannot access host level data attachment method", e);
} catch (InvocationTargetException e) {
Throwable cause = e.getCause();
if (cause instanceof RuntimeException runtimeException) {
throw runtimeException;
}
if (cause instanceof Error fatalError) {
throw fatalError;
}
throw new IllegalStateException("Host level data attachment failed", cause);
}
}
}
}
@@ -87,7 +87,7 @@ final class ModdedCommandHelp {
Entry.group("datapack", ModdedHelpMessages.GROUP_DATAPACK_WORLD_DATAPACK_INSTALL_AND_STATUS_HELPERS, "datapacks", "dp"),
Entry.group("structure", ModdedHelpMessages.GROUP_STRUCTURE_IRIS_STRUCTURE_INDEX_INFO_AND_PLACEMENT_TOOLS, "struct", "str"),
Entry.command("goldenhash", "[radius] [threads] [capture|verify]", ModdedHelpMessages.COMMAND_GOLDENHASH_GENERATE_DETERMINISTIC_BLOCK_HASHES_FOR_PARITY_TESTING, "gold"),
Entry.group("developer", ModdedHelpMessages.GROUP_DEVELOPER_DEVELOPER_DIAGNOSTICS_SENTRY_TEST_NETWORK_INTERFACES_REGION_FILE_SCAN, "dev")
Entry.group("developer", ModdedHelpMessages.GROUP_DEVELOPER_DEVELOPER_DIAGNOSTICS_NETWORK_INTERFACES_REGION_FILE_SCAN, "dev")
));
SECTIONS.put("what", List.of(
Entry.command("here", "", ModdedHelpMessages.COMMAND_WHAT_HERE_INSPECT_CURRENT_IRIS_CONTEXT),
@@ -197,7 +197,6 @@ final class ModdedCommandHelp {
SECTIONS.put("struct", SECTIONS.get("structure"));
SECTIONS.put("str", SECTIONS.get("structure"));
SECTIONS.put("developer", List.of(
Entry.command("sentry", "", ModdedHelpMessages.COMMAND_SENTRY_SEND_A_TEST_EXCEPTION_TO_THE_IRIS_ERROR_REPORTER),
Entry.command("network", "", ModdedHelpMessages.COMMAND_NETWORK_LIST_NETWORK_INTERFACES_AND_THEIR_ADDRESSES, "ip")
));
SECTIONS.put("dev", SECTIONS.get("developer"));
@@ -19,7 +19,6 @@
package art.arcane.iris.modded.command;
import art.arcane.iris.modded.ModdedIrisLog;
import art.arcane.iris.spi.IrisPlatforms;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.context.CommandContext;
import net.minecraft.commands.CommandSourceStack;
@@ -44,20 +43,12 @@ final class ModdedDeveloperCommands {
static LiteralArgumentBuilder<CommandSourceStack> tree(String name) {
return Commands.literal(name).requires(GATE)
.executes((CommandContext<CommandSourceStack> context) -> ModdedCommandHelp.send(context.getSource(), "developer"))
.then(Commands.literal("sentry")
.executes((CommandContext<CommandSourceStack> context) -> sentry(context.getSource())))
.then(Commands.literal("network")
.executes((CommandContext<CommandSourceStack> context) -> network(context.getSource())))
.then(Commands.literal("ip")
.executes((CommandContext<CommandSourceStack> context) -> network(context.getSource())));
}
private static int sentry(CommandSourceStack source) {
IrisPlatforms.get().reportError(new Exception("This is an Iris Sentry test exception"));
ModdedCommandFeedback.ok(source, IrisLanguage.plain(ModdedCommandMessages.MODDED_DEVELOPER_COMMANDS_DISPATCHED_TEST_EXCEPTION_IRIS_ERROR_REPORTER_SENTRY_IF_ENABLED));
return 1;
}
private static int network(CommandSourceStack source) {
try {
Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces();
@@ -0,0 +1,150 @@
package art.arcane.iris.modded;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerChunkCache;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.chunk.ChunkGenerator;
import org.junit.Test;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.CALLS_REAL_METHODS;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
public class ModdedGenerationBootstrapBindingTest {
private static final String SOURCE_ROOT_PROPERTY = "iris.moddedCommonSources";
@Test
public void publishedLevelRequiresCurrentGeneratorIdentity() {
IrisModdedChunkGenerator generator = mock(IrisModdedChunkGenerator.class, CALLS_REAL_METHODS);
MinecraftServer server = mock(MinecraftServer.class);
ServerLevel level = mock(ServerLevel.class);
ServerChunkCache chunkSource = mock(ServerChunkCache.class);
when(server.getLevel(Level.OVERWORLD)).thenReturn(level);
when(level.dimension()).thenReturn(Level.OVERWORLD);
when(level.getChunkSource()).thenReturn(chunkSource);
when(chunkSource.getGenerator()).thenReturn(generator);
assertSame(level, generator.requirePublishedLevel(server, Level.OVERWORLD));
ChunkGenerator otherGenerator = mock(ChunkGenerator.class);
when(chunkSource.getGenerator()).thenReturn(otherGenerator);
IllegalStateException mismatch = assertThrows(IllegalStateException.class,
() -> generator.requirePublishedLevel(server, Level.OVERWORLD));
assertTrue(mismatch.getMessage().contains("does not use Iris generator"));
}
@Test
public void publishedLevelRejectsMissingServerAndWorld() {
IrisModdedChunkGenerator generator = mock(IrisModdedChunkGenerator.class, CALLS_REAL_METHODS);
IllegalStateException missingServer = assertThrows(IllegalStateException.class,
() -> generator.requirePublishedLevel(null, Level.OVERWORLD));
assertTrue(missingServer.getMessage().contains("server is unavailable"));
MinecraftServer server = mock(MinecraftServer.class);
IllegalStateException missingWorld = assertThrows(IllegalStateException.class,
() -> generator.requirePublishedLevel(server, Level.OVERWORLD));
assertTrue(missingWorld.getMessage().contains("no published ServerLevel"));
}
@Test
public void staleSnapshotResolvesOnlyCanonicalOverworldOwnedByGenerator() {
IrisModdedChunkGenerator generator = mock(IrisModdedChunkGenerator.class, CALLS_REAL_METHODS);
MinecraftServer server = mock(MinecraftServer.class);
ServerLevel overworld = mock(ServerLevel.class);
ServerChunkCache chunkSource = mock(ServerChunkCache.class);
when(server.getLevel(Level.OVERWORLD)).thenReturn(overworld);
when(overworld.getChunkSource()).thenReturn(chunkSource);
when(chunkSource.getGenerator()).thenReturn(generator);
assertSame(overworld, generator.resolveBoundLevel(server, List.of()));
ChunkGenerator otherGenerator = mock(ChunkGenerator.class);
when(chunkSource.getGenerator()).thenReturn(otherGenerator);
assertNull(generator.resolveBoundLevel(server, List.of()));
verify(server, never()).getLevel(Level.NETHER);
}
@Test
public void dynamicLevelStillResolvesFromSnapshotWithoutCanonicalLookup() {
IrisModdedChunkGenerator generator = mock(IrisModdedChunkGenerator.class, CALLS_REAL_METHODS);
MinecraftServer server = mock(MinecraftServer.class);
ServerLevel dynamicLevel = mock(ServerLevel.class);
ServerChunkCache chunkSource = mock(ServerChunkCache.class);
when(dynamicLevel.getChunkSource()).thenReturn(chunkSource);
when(chunkSource.getGenerator()).thenReturn(generator);
assertSame(dynamicLevel, generator.resolveBoundLevel(server, List.of(dynamicLevel)));
verify(server, never()).getLevel(Level.OVERWORLD);
}
@Test
public void firstGenerationStagesProvideAuthoritativeLevelContext() throws IOException {
String source = source("IrisModdedChunkGenerator.java");
String structures = method(source, "public void createStructures(");
String references = method(source, "public void createReferences(");
assertTrue(structures.contains("Engine current = engine(levelKey);"));
assertTrue(references.contains("Engine current = engine(level.getLevel());"));
String publishedBinding = method(source, "private Engine engine(ResourceKey<Level> levelKey)");
assertTrue(publishedBinding.contains("requirePublishedLevel(ModdedEngineBootstrap.currentServer(), levelKey)"));
assertTrue(publishedBinding.contains("return bindGenerationLevel(level);"));
assertFalse(publishedBinding.contains("ModdedServerLevels.level("));
String fullBinding = method(source, "private Engine bindGenerationLevel(ServerLevel level)");
assertTrue(fullBinding.contains("bindLevel(level);"));
assertTrue(fullBinding.contains("Engine bound = readyEngine();"));
String genericBinding = method(source, "Engine engine()");
assertTrue(genericBinding.contains("return bindGenerationLevel(level);"));
}
@Test
public void constructorMixinIsNotPartOfGenerationBootstrap() throws IOException {
String sourceRoot = System.getProperty(SOURCE_ROOT_PROPERTY);
assertTrue(sourceRoot != null && !sourceRoot.isBlank());
Path root = Path.of(sourceRoot);
assertFalse(Files.exists(root.resolve(Path.of("art", "arcane", "iris", "modded", "mixin",
"ServerLevelBindingMixin.java"))));
String mixinConfig = Files.readString(root.getParent().resolve("resources/irisworldgen.entity.mixins.json"));
assertFalse(mixinConfig.contains("ServerLevelBindingMixin"));
}
private String source(String fileName) throws IOException {
String sourceRoot = System.getProperty(SOURCE_ROOT_PROPERTY);
assertTrue(sourceRoot != null && !sourceRoot.isBlank());
return Files.readString(Path.of(sourceRoot, "art", "arcane", "iris", "modded", fileName));
}
private String method(String source, String signature) {
int start = source.indexOf(signature);
assertTrue(start >= 0);
int body = source.indexOf('{', start);
assertTrue(body >= 0);
int depth = 0;
for (int index = body; index < source.length(); index++) {
char token = source.charAt(index);
if (token == '{') {
depth++;
} else if (token == '}') {
depth--;
if (depth == 0) {
return source.substring(start, index + 1);
}
}
}
throw new IllegalArgumentException("Unclosed source contract method: " + signature);
}
}
@@ -0,0 +1,94 @@
package art.arcane.iris.modded;
import org.junit.Test;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
public class ModdedLevelDataAttachmentTest {
@Test
public void detectsAndInvokesHostLevelDataAttachment() {
ModdedServerLevels.HostLevelDataAttachment attachment =
ModdedServerLevels.HostLevelDataAttachment.detect(
AttachedLevelData.class, RootData.class, DimensionKey.class);
AttachedLevelData levelData = new AttachedLevelData();
RootData rootData = new RootData();
DimensionKey dimensionKey = new DimensionKey();
assertTrue(attachment.supported());
attachment.attach(levelData, rootData, dimensionKey);
assertSame(rootData, levelData.rootData);
assertSame(dimensionKey, levelData.dimensionKey);
}
@Test
public void ignoresLevelDataWithoutAttachmentCapability() {
ModdedServerLevels.HostLevelDataAttachment attachment =
ModdedServerLevels.HostLevelDataAttachment.detect(
StandardLevelData.class, RootData.class, DimensionKey.class);
assertFalse(attachment.supported());
}
@Test
public void propagatesHostAttachmentFailureWithoutReflectionWrapper() {
ModdedServerLevels.HostLevelDataAttachment attachment =
ModdedServerLevels.HostLevelDataAttachment.detect(
FailingLevelData.class, RootData.class, DimensionKey.class);
IllegalStateException failure = assertThrows(IllegalStateException.class,
() -> attachment.attach(new FailingLevelData(), new RootData(), new DimensionKey()));
assertNull(failure.getCause());
}
@Test
public void initializesLevelDataBeforeBindingAndPublication() throws IOException {
String source = Files.readString(sourcePath("ModdedDimensionManager.java"));
int construction = source.indexOf("ServerLevel level = new ServerLevel(");
int initialization = source.indexOf("serverAccess.initializeLevelData(server, level);", construction);
int binding = source.indexOf("generator.bindLevel(level);", initialization);
int publication = source.indexOf("serverAccess.putLevelIfAbsent(server, key, level);", binding);
assertTrue(construction >= 0);
assertTrue(initialization > construction);
assertTrue(binding > initialization);
assertTrue(publication > binding);
}
private static Path sourcePath(String fileName) {
return Path.of(System.getProperty("iris.moddedCommonSources"),
"art/arcane/iris/modded", fileName);
}
public static final class AttachedLevelData {
private RootData rootData;
private DimensionKey dimensionKey;
public void attach(RootData rootData, DimensionKey dimensionKey) {
this.rootData = rootData;
this.dimensionKey = dimensionKey;
}
}
public static final class FailingLevelData {
public void attach(RootData rootData, DimensionKey dimensionKey) {
throw new IllegalStateException("attachment failed");
}
}
public static final class StandardLevelData {
}
public static final class RootData {
}
public static final class DimensionKey {
}
}
@@ -0,0 +1,73 @@
package art.arcane.iris.modded;
import org.junit.Test;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
public class ModdedServerLevelsTest {
@Test
public void detectsAndInvokesHostLevelPublicationPair() {
ModdedServerLevels.HostLevelPublication publication =
ModdedServerLevels.HostLevelPublication.detect(PublishingServer.class, PublishedLevel.class);
PublishingServer server = new PublishingServer();
PublishedLevel level = new PublishedLevel();
assertTrue(publication.supported());
publication.add(server, level);
assertSame(level, server.added);
publication.remove(server, level);
assertSame(level, server.removed);
}
@Test
public void rejectsPartialHostLevelPublicationCapability() {
ModdedServerLevels.HostLevelPublication publication =
ModdedServerLevels.HostLevelPublication.detect(AddOnlyServer.class, PublishedLevel.class);
assertFalse(publication.supported());
}
@Test
public void propagatesHostPublicationFailureWithoutReflectionWrapper() {
ModdedServerLevels.HostLevelPublication publication =
ModdedServerLevels.HostLevelPublication.detect(FailingServer.class, PublishedLevel.class);
IllegalStateException failure = assertThrows(IllegalStateException.class,
() -> publication.add(new FailingServer(), new PublishedLevel()));
assertNull(failure.getCause());
}
public static final class PublishingServer {
private PublishedLevel added;
private PublishedLevel removed;
public void addLevel(PublishedLevel level) {
added = level;
}
public void removeLevel(PublishedLevel level) {
removed = level;
}
}
public static final class AddOnlyServer {
public void addLevel(PublishedLevel level) {
}
}
public static final class FailingServer {
public void addLevel(PublishedLevel level) {
throw new IllegalStateException("publication failed");
}
public void removeLevel(PublishedLevel level) {
}
}
public static final class PublishedLevel {
}
}
+1 -3
View File
@@ -135,8 +135,7 @@ dependencies {
libs.lru,
libs.caffeine,
libs.dom4j,
libs.jaxen,
libs.sentry
libs.jaxen
]
shared.each { Object notation ->
add('bundle', notation)
@@ -243,7 +242,6 @@ tasks.named('shadowJar', ShadowJar).configure {
exclude('art/arcane/iris/platform/bukkit/**')
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
relocate('org.objectweb.asm', 'art.arcane.iris.shadow.asm')
relocate('io.sentry', 'art.arcane.iris.shadow.sentry')
// Split-package guard. A co-installed mod that ships any of these at their original coordinates
// puts two copies of the same package on one module layer, which the loaders reject at boot
// (Terra ships paralithic; caffeine and dom4j are common in mod dependency trees). First-party