mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-12-04 04:02:11 +00:00
Compare commits
17
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5c0176531a | ||
|
|
512ea0b0d7 | ||
|
|
9425e802dc | ||
|
|
95395cbc87 | ||
|
|
c71feb62e0 | ||
|
|
77969617d8 | ||
|
|
ac5788ef02 | ||
|
|
d7c5526eab | ||
|
|
4c90095361 | ||
|
|
25c612b3c3 | ||
|
|
3dea6e30e9 | ||
|
|
bccfbae35c | ||
|
|
f501e4b941 | ||
|
|
57e479a25e | ||
|
|
8961e5ec07 | ||
|
|
3742815b7e | ||
|
|
e0aeabd520 |
No files matched your search
+2
@@ -1,5 +1,6 @@
|
||||
package art.arcane.iris.nativegen;
|
||||
|
||||
import art.arcane.iris.world.history.VersionedGenerationSource;
|
||||
import art.arcane.iris.structure.nativegen.GenerationWritePolicy;
|
||||
|
||||
import art.arcane.volmlib.nativelib.minecraft26_2.terrain.NativeGenerationWriteGuard;
|
||||
@@ -86,6 +87,7 @@ public final class NativeGenerationWriteGuardTest {
|
||||
GenerationHistory history = mock(GenerationHistory.class);
|
||||
GenerationActivation active = mock(GenerationActivation.class);
|
||||
when(engine.getGenerationHistoryRuntimeRouter()).thenReturn(Optional.of(router));
|
||||
when(engine.getGenerationSource()).thenReturn(new VersionedGenerationSource(router));
|
||||
when(router.history()).thenReturn(history);
|
||||
when(history.activeActivation()).thenReturn(active);
|
||||
when(active.activationId()).thenReturn(4L);
|
||||
|
||||
+3
-1
@@ -1,5 +1,6 @@
|
||||
package art.arcane.iris.platform.bukkit.nms.v26_2_R1;
|
||||
|
||||
import art.arcane.iris.world.history.VersionedGenerationSource;
|
||||
import art.arcane.iris.platform.bukkit.nms.BukkitGeneratorContext;
|
||||
import org.bukkit.World;
|
||||
import art.arcane.volmlib.nativelib.v26_2_R1.terrain.NativeChunkGenerator;
|
||||
@@ -118,13 +119,14 @@ public class IrisChunkGeneratorSpawnAdmissionTest {
|
||||
NativeBiomeSourceImpl source = mock(NativeBiomeSourceImpl.class);
|
||||
when(engine.getGenerationSessions()).thenReturn(sessions);
|
||||
when(engine.getGenerationHistoryRuntimeRouter()).thenReturn(Optional.of(router));
|
||||
when(engine.getGenerationSource()).thenReturn(new VersionedGenerationSource(router));
|
||||
when(router.biomes()).thenReturn(saved);
|
||||
when(saved.nativeSpawnSelection(0, 64, 0, "")).thenAnswer(invocation -> {
|
||||
assertAdmitted();
|
||||
savedReads.incrementAndGet();
|
||||
return new NativeBiomeSpawnSelection(NativeBiomeSpawnSelection.Mode.RETAINED, "minecraft:plains");
|
||||
});
|
||||
when(engine.openGenerationHistoryCoordinateScope(0, 0)).thenAnswer(invocation -> {
|
||||
when(engine.openGenerationScope(0, 0)).thenAnswer(invocation -> {
|
||||
assertAdmitted();
|
||||
routes.incrementAndGet();
|
||||
return null;
|
||||
|
||||
+5
-1
@@ -1,5 +1,7 @@
|
||||
package art.arcane.iris.structure.nativegen;
|
||||
|
||||
import art.arcane.iris.generation.runtime.GenerationSource;
|
||||
import art.arcane.iris.world.history.VersionedGenerationSource;
|
||||
import art.arcane.iris.structure.nativegen.IrisStructureVolumePolicy;
|
||||
|
||||
import art.arcane.volmlib.nativelib.minecraft26_2.terrain.NativeStructureVolumeSource;
|
||||
@@ -165,6 +167,7 @@ public class NativeStructureVolumeIndexTest {
|
||||
public void absentOrMismatchedRuntimeOwnershipKeepsCoordinateRouting() throws Exception {
|
||||
ScopedEngine detached = scopedEngine(true, 1);
|
||||
when(detached.engine().getGenerationHistoryRuntimeRouter()).thenReturn(Optional.empty());
|
||||
when(detached.engine().getGenerationSource()).thenReturn(GenerationSource.singlePack());
|
||||
for (ScopedEngine scoped : List.of(scopedEngine(false, 1), scopedEngine(true, 0),
|
||||
scopedEngine(true, 2), detached)) {
|
||||
NativeStructureVolumeIndex index = NativeStructureVolumeIndex.forTesting(new CountingResolver(0, 0));
|
||||
@@ -472,6 +475,7 @@ public class NativeStructureVolumeIndexTest {
|
||||
GenerationHistoryRuntimeRouter router = mock(GenerationHistoryRuntimeRouter.class);
|
||||
when(engine.hasGenerationRuntimeScope()).thenReturn(scoped);
|
||||
when(engine.getGenerationHistoryRuntimeRouter()).thenReturn(Optional.of(router));
|
||||
when(engine.getGenerationSource()).thenReturn(new VersionedGenerationSource(router));
|
||||
when(engine.getCacheID()).thenReturn(1);
|
||||
if (ownerRuntimeId != 0) {
|
||||
IrisEngine.GenerationRuntimeBinding binding = mock(IrisEngine.GenerationRuntimeBinding.class);
|
||||
@@ -480,7 +484,7 @@ public class NativeStructureVolumeIndexTest {
|
||||
new GenerationHistoryRuntimeRouter.RuntimeOwnership(1L, binding)));
|
||||
}
|
||||
AtomicInteger scopes = new AtomicInteger();
|
||||
when(engine.openGenerationHistoryCoordinateScope(anyInt(), anyInt())).thenAnswer(invocation -> {
|
||||
when(engine.openGenerationScope(anyInt(), anyInt())).thenAnswer(invocation -> {
|
||||
scopes.incrementAndGet();
|
||||
return null;
|
||||
});
|
||||
|
||||
+2
@@ -1,5 +1,6 @@
|
||||
package art.arcane.iris.nativegen.v26_3_R1;
|
||||
|
||||
import art.arcane.iris.world.history.VersionedGenerationSource;
|
||||
import art.arcane.iris.structure.nativegen.GenerationWritePolicy;
|
||||
|
||||
import art.arcane.volmlib.nativelib.v26_3_R1.terrain.NativeGenerationWriteGuard;
|
||||
@@ -86,6 +87,7 @@ public final class NativeGenerationWriteGuardTest {
|
||||
GenerationHistory history = mock(GenerationHistory.class);
|
||||
GenerationActivation active = mock(GenerationActivation.class);
|
||||
when(engine.getGenerationHistoryRuntimeRouter()).thenReturn(Optional.of(router));
|
||||
when(engine.getGenerationSource()).thenReturn(new VersionedGenerationSource(router));
|
||||
when(router.history()).thenReturn(history);
|
||||
when(history.activeActivation()).thenReturn(active);
|
||||
when(active.activationId()).thenReturn(4L);
|
||||
|
||||
+3
-1
@@ -1,5 +1,6 @@
|
||||
package art.arcane.iris.platform.bukkit.nms.v26_3_R1;
|
||||
|
||||
import art.arcane.iris.world.history.VersionedGenerationSource;
|
||||
import art.arcane.iris.platform.bukkit.nms.BukkitGeneratorContext;
|
||||
import org.bukkit.World;
|
||||
import art.arcane.volmlib.nativelib.v26_3_R1.terrain.NativeChunkGenerator;
|
||||
@@ -122,13 +123,14 @@ public class IrisChunkGeneratorSpawnAdmissionTest {
|
||||
setField(generator, "runtimeLevel", level);
|
||||
when(engine.getGenerationSessions()).thenReturn(sessions);
|
||||
when(engine.getGenerationHistoryRuntimeRouter()).thenReturn(Optional.of(router));
|
||||
when(engine.getGenerationSource()).thenReturn(new VersionedGenerationSource(router));
|
||||
when(router.biomes()).thenReturn(saved);
|
||||
when(saved.nativeSpawnSelection(0, 64, 0, "")).thenAnswer(invocation -> {
|
||||
assertAdmitted();
|
||||
savedReads.incrementAndGet();
|
||||
return new NativeBiomeSpawnSelection(NativeBiomeSpawnSelection.Mode.RETAINED, "minecraft:plains");
|
||||
});
|
||||
when(engine.openGenerationHistoryCoordinateScope(0, 0)).thenAnswer(invocation -> {
|
||||
when(engine.openGenerationScope(0, 0)).thenAnswer(invocation -> {
|
||||
assertAdmitted();
|
||||
routes.incrementAndGet();
|
||||
return null;
|
||||
|
||||
+5
-1
@@ -1,5 +1,7 @@
|
||||
package art.arcane.iris.structure.nativegen;
|
||||
|
||||
import art.arcane.iris.generation.runtime.GenerationSource;
|
||||
import art.arcane.iris.world.history.VersionedGenerationSource;
|
||||
import art.arcane.iris.structure.nativegen.IrisStructureVolumePolicy;
|
||||
|
||||
import art.arcane.volmlib.nativelib.v26_3_R1.terrain.NativeStructureVolumeSource;
|
||||
@@ -165,6 +167,7 @@ public class NativeStructureVolumeIndexTest {
|
||||
public void absentOrMismatchedRuntimeOwnershipKeepsCoordinateRouting() throws Exception {
|
||||
ScopedEngine detached = scopedEngine(true, 1);
|
||||
when(detached.engine().getGenerationHistoryRuntimeRouter()).thenReturn(Optional.empty());
|
||||
when(detached.engine().getGenerationSource()).thenReturn(GenerationSource.singlePack());
|
||||
for (ScopedEngine scoped : List.of(scopedEngine(false, 1), scopedEngine(true, 0),
|
||||
scopedEngine(true, 2), detached)) {
|
||||
NativeStructureVolumeIndex index = NativeStructureVolumeIndex.forTesting(new CountingResolver(0, 0));
|
||||
@@ -472,6 +475,7 @@ public class NativeStructureVolumeIndexTest {
|
||||
GenerationHistoryRuntimeRouter router = mock(GenerationHistoryRuntimeRouter.class);
|
||||
when(engine.hasGenerationRuntimeScope()).thenReturn(scoped);
|
||||
when(engine.getGenerationHistoryRuntimeRouter()).thenReturn(Optional.of(router));
|
||||
when(engine.getGenerationSource()).thenReturn(new VersionedGenerationSource(router));
|
||||
when(engine.getCacheID()).thenReturn(1);
|
||||
if (ownerRuntimeId != 0) {
|
||||
IrisEngine.GenerationRuntimeBinding binding = mock(IrisEngine.GenerationRuntimeBinding.class);
|
||||
@@ -480,7 +484,7 @@ public class NativeStructureVolumeIndexTest {
|
||||
new GenerationHistoryRuntimeRouter.RuntimeOwnership(1L, binding)));
|
||||
}
|
||||
AtomicInteger scopes = new AtomicInteger();
|
||||
when(engine.openGenerationHistoryCoordinateScope(anyInt(), anyInt())).thenAnswer(invocation -> {
|
||||
when(engine.openGenerationScope(anyInt(), anyInt())).thenAnswer(invocation -> {
|
||||
scopes.incrementAndGet();
|
||||
return null;
|
||||
});
|
||||
|
||||
@@ -24,7 +24,6 @@ import art.arcane.iris.pack.datapack.ServerConfigurator;
|
||||
import art.arcane.iris.pack.datapack.DataVersion;
|
||||
import art.arcane.iris.world.runtime.ChunkClearer;
|
||||
import art.arcane.iris.generation.validation.GoldenHashScanner;
|
||||
import art.arcane.iris.world.runtime.InPlaceChunkRegenerator;
|
||||
import art.arcane.iris.generation.runtime.IrisEngineSVC;
|
||||
import art.arcane.iris.pack.IrisPackBenchmarking;
|
||||
import art.arcane.iris.world.IrisToolbelt;
|
||||
@@ -305,51 +304,6 @@ public class CommandDeveloper implements DirectorExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
// --- Regen ---
|
||||
|
||||
@Director(name = "regen", aliases = {"rg"}, description = "Delete and regenerate nearby chunks in place using Iris generation", descriptionKey = "iris.director.commanddeveloper.director.delete_regenerate_nearby_chunks_place_using_iris_generation", origin = DirectorOrigin.PLAYER)
|
||||
public void regen(
|
||||
@Param(name = "radius", description = "The radius of nearby chunks", descriptionKey = "iris.director.commanddeveloper.param.radius_nearby_chunks", defaultValue = "5")
|
||||
int radius
|
||||
) {
|
||||
if (radius < 0) {
|
||||
sender().sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_DEVELOPER_RADIUS_MUST_BE_0_GREATER_2));
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = player();
|
||||
VolmitSender commandSender = sender();
|
||||
World world = player.getWorld();
|
||||
if (!IrisToolbelt.isIrisWorld(world)) {
|
||||
commandSender.sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_DEVELOPER_YOU_MUST_BE_IRIS_WORLD_USE_REGEN));
|
||||
return;
|
||||
}
|
||||
|
||||
Engine engine = IrisToolbelt.access(world).getEngine();
|
||||
if (engine == null) {
|
||||
commandSender.sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_DEVELOPER_ENGINE_ACCESS_THIS_WORLD_IS_NULL_GENERATE_NEARBY_CHUNKS_FIRST));
|
||||
return;
|
||||
}
|
||||
|
||||
int chunks = (radius * 2 + 1) * (radius * 2 + 1);
|
||||
|
||||
// The player position must be read on the thread owning the player; the regenerator hops per chunk itself.
|
||||
if (!J.runEntity(player, () -> {
|
||||
int centerX = player.getLocation().getBlockX() >> 4;
|
||||
int centerZ = player.getLocation().getBlockZ() >> 4;
|
||||
|
||||
commandSender.sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_DEVELOPER_REGEN_STARTED_CHUNK_S_AROUND_DELETING_REGENERATING_PLACE, MessageArgument.untrusted("chunks", chunks), MessageArgument.untrusted("centerX", centerX), MessageArgument.untrusted("centerZ", centerZ)));
|
||||
Iris.info("Regen run start: world=" + world.getName()
|
||||
+ " center=" + centerX + "," + centerZ
|
||||
+ " radius=" + radius
|
||||
+ " chunks=" + chunks);
|
||||
|
||||
new InPlaceChunkRegenerator(world, engine, commandSender, centerX, centerZ, radius).start();
|
||||
})) {
|
||||
Iris.warn("Could not schedule regen on the thread owning " + player.getName() + ".");
|
||||
}
|
||||
}
|
||||
|
||||
@Director(name = "goldenhash", aliases = {"gold"}, description = "Generate chunks into buffers (no world writes) and hash blocks+biomes; captures a golden file or verifies against an existing one. Deletes the world's entire mantle - use on disposable test worlds.", descriptionKey = "iris.director.commanddeveloper.director.generate_chunks_into_buffers_no_world_writes_hash_blocks_biomes_captures_golden", origin = DirectorOrigin.BOTH)
|
||||
public void goldenhash(
|
||||
@Param(description = "The world to scan", descriptionKey = "iris.director.commanddeveloper.param.world_scan", contextual = true, contextualOverride = true)
|
||||
|
||||
@@ -34,6 +34,7 @@ import art.arcane.iris.structure.BulkStructureImporter;
|
||||
import art.arcane.iris.structure.FeatureImporter;
|
||||
import art.arcane.iris.structure.StructureImporter;
|
||||
import art.arcane.iris.world.IrisToolbelt;
|
||||
import art.arcane.iris.world.runtime.InPlaceChunkRegenerator;
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.iris.world.loot.InventorySlotType;
|
||||
import art.arcane.iris.generation.biome.IrisBiome;
|
||||
@@ -220,6 +221,49 @@ public class CommandStudio implements DirectorExecutor {
|
||||
LanguageAudience.run(audience, () -> sendHotloadResult(commandSender, failure)));
|
||||
}
|
||||
|
||||
@Director(name = "regen", aliases = {"rg"}, description = "Delete and regenerate nearby chunks in place using Iris generation", descriptionKey = "iris.director.commanddeveloper.director.delete_regenerate_nearby_chunks_place_using_iris_generation", origin = DirectorOrigin.PLAYER)
|
||||
public void regen(
|
||||
@Param(name = "radius", description = "The radius of nearby chunks", descriptionKey = "iris.director.commanddeveloper.param.radius_nearby_chunks", defaultValue = "5")
|
||||
int radius
|
||||
) {
|
||||
if (radius < 0) {
|
||||
sender().sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_DEVELOPER_RADIUS_MUST_BE_0_GREATER_2));
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = player();
|
||||
VolmitSender commandSender = sender();
|
||||
World world = player.getWorld();
|
||||
if (!IrisToolbelt.isIrisWorld(world)) {
|
||||
commandSender.sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_DEVELOPER_YOU_MUST_BE_IRIS_WORLD_USE_REGEN));
|
||||
return;
|
||||
}
|
||||
|
||||
Engine engine = IrisToolbelt.access(world).getEngine();
|
||||
if (engine == null) {
|
||||
commandSender.sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_DEVELOPER_ENGINE_ACCESS_THIS_WORLD_IS_NULL_GENERATE_NEARBY_CHUNKS_FIRST));
|
||||
return;
|
||||
}
|
||||
|
||||
int chunks = (radius * 2 + 1) * (radius * 2 + 1);
|
||||
|
||||
// The player position must be read on the thread owning the player; the regenerator hops per chunk itself.
|
||||
if (!J.runEntity(player, () -> {
|
||||
int centerX = player.getLocation().getBlockX() >> 4;
|
||||
int centerZ = player.getLocation().getBlockZ() >> 4;
|
||||
|
||||
commandSender.sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_DEVELOPER_REGEN_STARTED_CHUNK_S_AROUND_DELETING_REGENERATING_PLACE, MessageArgument.untrusted("chunks", chunks), MessageArgument.untrusted("centerX", centerX), MessageArgument.untrusted("centerZ", centerZ)));
|
||||
Iris.info("Regen run start: world=" + world.getName()
|
||||
+ " center=" + centerX + "," + centerZ
|
||||
+ " radius=" + radius
|
||||
+ " chunks=" + chunks);
|
||||
|
||||
new InPlaceChunkRegenerator(world, engine, commandSender, centerX, centerZ, radius).start();
|
||||
})) {
|
||||
Iris.warn("Could not schedule regen on the thread owning " + player.getName() + ".");
|
||||
}
|
||||
}
|
||||
|
||||
@Director(description = "Toggle your Studio debug scoreboard", descriptionKey = "iris.director.commandstudio.director.toggle_your_studio_debug_scoreboard", aliases = {"board", "sidebar", "sb"}, origin = DirectorOrigin.PLAYER)
|
||||
public void scoreboard() {
|
||||
Player target = player();
|
||||
|
||||
@@ -27,7 +27,7 @@ export default {
|
||||
await context.step('regeneration removes target furniture and preserves neighbor ownership', async () => {
|
||||
const ready = await context.command('/iriscenative neighbor', /CE_NEIGHBOR_READY|CE_FAILED/, 30000)
|
||||
context.expect(ready.includes('CE_NEIGHBOR_READY chunk=2,0 furniture=3 target=1'), ready)
|
||||
const regenerated = await context.command('/iris developer regen radius=0', /Regen complete:|Regen failed:/, 90000)
|
||||
const regenerated = await context.command('/iris studio regen radius=0', /Regen complete:|Regen failed:/, 90000)
|
||||
context.expect(regenerated.includes('Regen complete:'), regenerated)
|
||||
const response = await context.command('/iriscenative loaded', /CE_LOADED|CE_FAILED/, 30000)
|
||||
context.expect(response.includes('CE_LOADED removed=1 untouched=1 replacement=1 wall=1 target=1'), response)
|
||||
|
||||
+4
@@ -1,5 +1,7 @@
|
||||
package art.arcane.iris.world;
|
||||
|
||||
import art.arcane.iris.generation.runtime.GenerationSource;
|
||||
import art.arcane.iris.world.history.VersionedGenerationSource;
|
||||
import art.arcane.iris.Iris;
|
||||
import art.arcane.iris.generation.runtime.IrisEngine;
|
||||
import art.arcane.iris.generation.terrain.IrisDimension;
|
||||
@@ -47,6 +49,7 @@ public class BukkitWorldReconcilerRuntimeTest {
|
||||
fixture.backend().validateLoadedRuntime(fixture.world(), fixture.key(), "overworld", 1337L));
|
||||
when(fixture.generator().getStartupReady()).thenReturn(CompletableFuture.completedFuture(null));
|
||||
when(fixture.engine().getGenerationHistoryRuntimeRouter()).thenReturn(Optional.empty());
|
||||
when(fixture.engine().getGenerationSource()).thenReturn(GenerationSource.singlePack());
|
||||
assertEquals(BukkitWorldReconciler.LoadedRuntimeStatus.UNAVAILABLE,
|
||||
fixture.backend().validateLoadedRuntime(fixture.world(), fixture.key(), "overworld", 1337L));
|
||||
}
|
||||
@@ -152,6 +155,7 @@ public class BukkitWorldReconcilerRuntimeTest {
|
||||
when(generator.getGenerationHistory()).thenReturn(history);
|
||||
when(generator.getDimensionKey()).thenReturn("overworld");
|
||||
when(engine.getGenerationHistoryRuntimeRouter()).thenReturn(Optional.of(router));
|
||||
when(engine.getGenerationSource()).thenReturn(new VersionedGenerationSource(router));
|
||||
when(router.history()).thenReturn(history);
|
||||
when(history.paths()).thenReturn(GenerationHistoryPaths.forDimension(root));
|
||||
when(history.activeEpoch()).thenReturn(epoch);
|
||||
|
||||
+23
-15
@@ -82,6 +82,9 @@ import art.arcane.iris.structure.nativegen.NativeFeatureGenerationPolicy;
|
||||
import art.arcane.iris.structure.nativegen.NativeStructureStartPlan;
|
||||
import art.arcane.iris.world.history.GenerationEpoch;
|
||||
import art.arcane.iris.world.history.GenerationHistoryRuntimeRouter;
|
||||
import art.arcane.iris.generation.runtime.GenerationRoute;
|
||||
import art.arcane.iris.generation.runtime.GenerationScope;
|
||||
import art.arcane.iris.generation.runtime.GenerationSource;
|
||||
import art.arcane.iris.world.history.GenerationRegistryContract;
|
||||
import art.arcane.iris.world.history.GenerationRegistryContractFactory;
|
||||
import art.arcane.iris.generation.terrain.IrisDimension;
|
||||
@@ -902,7 +905,7 @@ public final class IrisModdedChunkGenerator implements NativeGeneratorOwner, Nat
|
||||
importedFeatures.evictRuntime(runtimeIdentity);
|
||||
}
|
||||
|
||||
private GenerationHistoryRuntimeRouter.RuntimeRoute openHistoryRoute(
|
||||
private GenerationRoute openHistoryRoute(
|
||||
Engine current,
|
||||
int chunkX,
|
||||
int chunkZ,
|
||||
@@ -911,16 +914,16 @@ public final class IrisModdedChunkGenerator implements NativeGeneratorOwner, Nat
|
||||
if (allowsGenerationHistoryBypass(current)) {
|
||||
return null;
|
||||
}
|
||||
GenerationHistoryRuntimeRouter router = requireHistoryRouter(current, operation);
|
||||
GenerationSource source = requireVersionedSource(current, operation);
|
||||
try {
|
||||
return router.openRoute(chunkX, chunkZ);
|
||||
return source.openRoute(chunkX, chunkZ);
|
||||
} catch (IOException failure) {
|
||||
throw new IllegalStateException("Iris " + operation + " could not route chunk "
|
||||
+ chunkX + "," + chunkZ + " through generation history.", failure);
|
||||
}
|
||||
}
|
||||
|
||||
private GenerationHistoryRuntimeRouter.CoordinateScope openHistoryCoordinateScope(
|
||||
private GenerationScope openHistoryCoordinateScope(
|
||||
Engine current,
|
||||
int blockX,
|
||||
int blockZ,
|
||||
@@ -929,15 +932,27 @@ public final class IrisModdedChunkGenerator implements NativeGeneratorOwner, Nat
|
||||
if (allowsGenerationHistoryBypass(current)) {
|
||||
return null;
|
||||
}
|
||||
GenerationHistoryRuntimeRouter router = requireHistoryRouter(current, operation);
|
||||
GenerationSource source = requireVersionedSource(current, operation);
|
||||
try {
|
||||
return router.openCoordinateScope(blockX, blockZ);
|
||||
return source.openGenerationScope(blockX, blockZ);
|
||||
} catch (IOException failure) {
|
||||
throw new IllegalStateException("Iris " + operation + " could not route block "
|
||||
+ blockX + "," + blockZ + " through generation history.", failure);
|
||||
}
|
||||
}
|
||||
|
||||
private GenerationSource requireVersionedSource(Engine current, String operation) {
|
||||
if (!(current instanceof IrisEngine irisEngine)) {
|
||||
throw new IllegalStateException("Iris " + operation + " requires an IrisEngine runtime.");
|
||||
}
|
||||
GenerationSource source = irisEngine.getGenerationSource();
|
||||
if (!source.keepsPackVersions()) {
|
||||
throw new IllegalStateException("Iris " + operation
|
||||
+ " requires an attached generation-history runtime router.");
|
||||
}
|
||||
return source;
|
||||
}
|
||||
|
||||
private GenerationHistoryRuntimeRouter requireHistoryRouter(Engine current, String operation) {
|
||||
if (!(current instanceof IrisEngine irisEngine)) {
|
||||
throw new IllegalStateException("Iris " + operation + " requires an IrisEngine runtime.");
|
||||
@@ -966,12 +981,6 @@ public final class IrisModdedChunkGenerator implements NativeGeneratorOwner, Nat
|
||||
+ "generation-history routing.");
|
||||
}
|
||||
|
||||
private static GenerationHistoryRuntimeRouter.RuntimeRoute.RuntimeScope openHistoryRuntimeScope(
|
||||
GenerationHistoryRuntimeRouter.RuntimeRoute route
|
||||
) {
|
||||
return route == null ? null : route.openRuntimeScope();
|
||||
}
|
||||
|
||||
GenerationSessionLease requireGenerationLease(Engine current, String operation) {
|
||||
try {
|
||||
return current.acquireGenerationLease(operation);
|
||||
@@ -1150,13 +1159,12 @@ public final class IrisModdedChunkGenerator implements NativeGeneratorOwner, Nat
|
||||
|
||||
@Override
|
||||
public byte[] terrainReceipt(NativeGenerationRoute nativeRoute) throws IOException {
|
||||
GenerationHistoryRuntimeRouter.RuntimeRoute route = (GenerationHistoryRuntimeRouter.RuntimeRoute) nativeRoute;
|
||||
return ModdedNativeTerrainReceipts.encode(route);
|
||||
return nativeRoute == null ? null : ((GenerationRoute) nativeRoute).naturalTerrainReceipt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long structureActivation(NativeGenerationRoute route) {
|
||||
return ((GenerationHistoryRuntimeRouter.RuntimeRoute) route).activation().activationId();
|
||||
return ((GenerationRoute) route).activationId();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+16
-13
@@ -37,7 +37,8 @@ import art.arcane.iris.generation.runtime.IrisEngine;
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.iris.generation.runtime.GenerationSessionException;
|
||||
import art.arcane.iris.generation.runtime.GenerationSessionLease;
|
||||
import art.arcane.iris.world.history.GenerationHistoryRuntimeRouter;
|
||||
import art.arcane.iris.generation.runtime.GenerationScope;
|
||||
import art.arcane.iris.generation.runtime.GenerationSource;
|
||||
import art.arcane.iris.generation.biome.IrisBiome;
|
||||
import art.arcane.iris.generation.biome.IrisBiomeCustom;
|
||||
import art.arcane.iris.generation.terrain.IrisDimension;
|
||||
@@ -271,7 +272,7 @@ final class ModdedBiomePolicy<H, S> implements NativeModdedBiomePolicy<H, S> {
|
||||
if (engine == null) {
|
||||
return access.serializedNoise(quartX, quartY, quartZ, sampler);
|
||||
}
|
||||
GenerationHistoryRuntimeRouter.CoordinateScope historyScope = openHistoryCoordinateScope(
|
||||
GenerationScope historyScope = openHistoryCoordinateScope(
|
||||
engine, quartX << 2, quartZ << 2, "modded_structure_biome");
|
||||
try (historyScope) {
|
||||
GenerationSessionLease lease = tryAcquireGenerationLease(engine, "modded_structure_biome");
|
||||
@@ -334,7 +335,7 @@ final class ModdedBiomePolicy<H, S> implements NativeModdedBiomePolicy<H, S> {
|
||||
}
|
||||
|
||||
private H locateVisibleBiome(Engine engine, int quartX, int quartY, int quartZ, S sampler) {
|
||||
try (GenerationHistoryRuntimeRouter.CoordinateScope ignored = openHistoryCoordinateScope(
|
||||
try (GenerationScope ignored = openHistoryCoordinateScope(
|
||||
engine, quartX << 2, quartZ << 2, "modded_locate_visible_biome")) {
|
||||
return resolveVisibleBiome(engine, quartX, quartY, quartZ, sampler, null);
|
||||
}
|
||||
@@ -426,7 +427,7 @@ final class ModdedBiomePolicy<H, S> implements NativeModdedBiomePolicy<H, S> {
|
||||
if (engine == null) {
|
||||
return access.serializedNoise(quartX, quartY, quartZ, sampler);
|
||||
}
|
||||
GenerationHistoryRuntimeRouter.CoordinateScope historyScope = openHistoryCoordinateScope(
|
||||
GenerationScope historyScope = openHistoryCoordinateScope(
|
||||
engine, quartX << 2, quartZ << 2, "modded_visible_biome");
|
||||
try (historyScope) {
|
||||
GenerationSessionLease lease = tryAcquireGenerationLease(engine, "modded_visible_biome");
|
||||
@@ -482,7 +483,7 @@ final class ModdedBiomePolicy<H, S> implements NativeModdedBiomePolicy<H, S> {
|
||||
if (engine == null) {
|
||||
return null;
|
||||
}
|
||||
GenerationHistoryRuntimeRouter.CoordinateScope historyScope = openHistoryCoordinateScope(
|
||||
GenerationScope historyScope = openHistoryCoordinateScope(
|
||||
engine, blockX, blockZ, "modded_surface_spawn_biome");
|
||||
try (historyScope) {
|
||||
GenerationSessionLease lease = tryAcquireGenerationLease(engine, "modded_surface_spawn_biome");
|
||||
@@ -571,7 +572,7 @@ final class ModdedBiomePolicy<H, S> implements NativeModdedBiomePolicy<H, S> {
|
||||
}
|
||||
boolean surfaceQuery;
|
||||
try (lease) {
|
||||
try (GenerationHistoryRuntimeRouter.CoordinateScope historyScope = openHistoryCoordinateScope(
|
||||
try (GenerationScope historyScope = openHistoryCoordinateScope(
|
||||
engine, x, z, "modded_biomes_within");
|
||||
IrisContext.Scope ignored = IrisContext.open(engine, lease.sessionId(), null)) {
|
||||
if (!isReady(engine)) {
|
||||
@@ -592,7 +593,7 @@ final class ModdedBiomePolicy<H, S> implements NativeModdedBiomePolicy<H, S> {
|
||||
Set<H> biomes = new HashSet<>(columns);
|
||||
for (int quartZ = minQuartZ; quartZ <= maxQuartZ; quartZ++) {
|
||||
for (int quartX = minQuartX; quartX <= maxQuartX; quartX++) {
|
||||
try (GenerationHistoryRuntimeRouter.CoordinateScope historyScope = openHistoryCoordinateScope(
|
||||
try (GenerationScope historyScope = openHistoryCoordinateScope(
|
||||
engine, quartX << 2, quartZ << 2, "modded_biomes_within");
|
||||
IrisContext.Scope ignored = IrisContext.open(engine, lease.sessionId(), null)) {
|
||||
biomes.add(getSurfaceStructureBiome(engine, quartX, quartZ, sampler));
|
||||
@@ -855,7 +856,7 @@ final class ModdedBiomePolicy<H, S> implements NativeModdedBiomePolicy<H, S> {
|
||||
throw new IllegalStateException("Iris structure biome source is not bound to its generator");
|
||||
}
|
||||
Engine engine = current.awaitEngine().get();
|
||||
GenerationHistoryRuntimeRouter.CoordinateScope historyScope = openHistoryCoordinateScope(
|
||||
GenerationScope historyScope = openHistoryCoordinateScope(
|
||||
engine, quartX << 2, quartZ << 2, "modded_structure_state_biome");
|
||||
try (historyScope) {
|
||||
GenerationSessionLease lease = tryAcquireGenerationLease(engine, "modded_structure_state_biome");
|
||||
@@ -957,7 +958,7 @@ final class ModdedBiomePolicy<H, S> implements NativeModdedBiomePolicy<H, S> {
|
||||
return current == null ? null : current.currentEngine().get();
|
||||
}
|
||||
|
||||
private GenerationHistoryRuntimeRouter.CoordinateScope openHistoryCoordinateScope(
|
||||
private GenerationScope openHistoryCoordinateScope(
|
||||
Engine engine,
|
||||
int blockX,
|
||||
int blockZ,
|
||||
@@ -970,11 +971,13 @@ final class ModdedBiomePolicy<H, S> implements NativeModdedBiomePolicy<H, S> {
|
||||
if (!(engine instanceof IrisEngine irisEngine)) {
|
||||
throw new IllegalStateException("Iris " + operation + " requires an IrisEngine runtime.");
|
||||
}
|
||||
GenerationHistoryRuntimeRouter router = irisEngine.getGenerationHistoryRuntimeRouter().orElseThrow(() ->
|
||||
new IllegalStateException("Iris " + operation
|
||||
+ " requires an attached generation-history runtime router."));
|
||||
GenerationSource source = irisEngine.getGenerationSource();
|
||||
if (!source.keepsPackVersions()) {
|
||||
throw new IllegalStateException("Iris " + operation
|
||||
+ " requires an attached generation-history runtime router.");
|
||||
}
|
||||
try {
|
||||
return router.openCoordinateScope(blockX, blockZ);
|
||||
return source.openGenerationScope(blockX, blockZ);
|
||||
} catch (IOException failure) {
|
||||
throw new IllegalStateException("Iris " + operation + " could not route block "
|
||||
+ blockX + "," + blockZ + " through generation history.", failure);
|
||||
|
||||
@@ -30,6 +30,7 @@ import art.arcane.iris.world.loot.IrisLootTable;
|
||||
import art.arcane.iris.structure.object.IrisObjectLoot;
|
||||
import art.arcane.iris.structure.object.IrisObjectPlacement;
|
||||
import art.arcane.iris.structure.object.IrisObjectVanillaLoot;
|
||||
import art.arcane.iris.pack.loading.IrisData;
|
||||
import art.arcane.iris.spi.IrisLogging;
|
||||
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
|
||||
import art.arcane.volmlib.util.mantle.runtime.MantleChunk;
|
||||
@@ -40,6 +41,9 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public final class ModdedLootApplier {
|
||||
private static final String LOOT_TABLE_KEY_KIND = "missing-loot-table";
|
||||
private static final String VANILLA_LOOT_TABLE_KEY_KIND = "missing-vanilla-loot-table";
|
||||
|
||||
private ModdedLootApplier() {
|
||||
}
|
||||
|
||||
@@ -117,7 +121,8 @@ public final class ModdedLootApplier {
|
||||
}
|
||||
IrisLootTable table = engine.getData().getLootLoader().load(loot.getName());
|
||||
if (table == null) {
|
||||
IrisLogging.warn("Couldn't find loot table " + loot.getName());
|
||||
IrisLogging.warnOnce(IrisData.onceKey(engine.getData(), LOOT_TABLE_KEY_KIND, loot.getName()),
|
||||
"Couldn't find loot table " + loot.getName());
|
||||
continue;
|
||||
}
|
||||
bucket(engine, loot, new Candidate(new IrisLootSource(table), loot.getWeight()), access, exact, basic, global);
|
||||
@@ -129,7 +134,8 @@ public final class ModdedLootApplier {
|
||||
}
|
||||
NativeContainerLoot.Table table = access.table(loot.getName());
|
||||
if (table == null) {
|
||||
IrisLogging.warn("Couldn't find vanilla loot table " + loot.getName());
|
||||
IrisLogging.warnOnce(IrisData.onceKey(engine.getData(), VANILLA_LOOT_TABLE_KEY_KIND, loot.getName()),
|
||||
"Couldn't find vanilla loot table " + loot.getName());
|
||||
continue;
|
||||
}
|
||||
bucket(engine, loot, new Candidate(new NativeLootSource(table), loot.getWeight()), access, exact, basic, global);
|
||||
|
||||
-17
@@ -1,17 +0,0 @@
|
||||
package art.arcane.iris.modded;
|
||||
|
||||
import art.arcane.iris.world.history.GenerationHistoryRuntimeRouter;
|
||||
import art.arcane.iris.world.history.NativeTerrainReceipt;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public final class ModdedNativeTerrainReceipts {
|
||||
private ModdedNativeTerrainReceipts() {
|
||||
}
|
||||
|
||||
public static byte[] encode(GenerationHistoryRuntimeRouter.RuntimeRoute route) throws IOException {
|
||||
return route == null || route.naturalTerrain().isEmpty() ? null
|
||||
: NativeTerrainReceipt.encode(route.naturalTerrain().orElseThrow(),
|
||||
route.activation().activationId(), route.epoch().epochId());
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -73,7 +73,6 @@ final class ModdedCommandHelp {
|
||||
Entry.command("catalog", "[namespace|refresh]", ModdedCatalogMessages.HELP_CATALOG),
|
||||
Entry.group("ingest", ModdedCatalogMessages.HELP_INGEST),
|
||||
Entry.command("metrics", "", ModdedHelpMessages.COMMAND_METRICS_PRINT_GENERATION_METRICS_FOR_YOUR_CURRENT_IRIS_DIMENSION, "measure"),
|
||||
Entry.command("regen", "[radius]", ModdedHelpMessages.COMMAND_REGEN_DELETE_AND_REGENERATE_NEARBY_CHUNKS_IN_PLACE, "rg"),
|
||||
Entry.group("pregen", ModdedHelpMessages.GROUP_PREGEN_PREGENERATE_AN_IRIS_DIMENSION, "pregenerate"),
|
||||
Entry.command("wand", "", ModdedHelpMessages.COMMAND_WAND_GET_AN_IRIS_OBJECT_WAND),
|
||||
Entry.command("dust", "", ModdedHelpMessages.COMMAND_DUST_GET_DUST_THAT_REVEALS_OBJECT_PLACEMENTS, "d"),
|
||||
@@ -151,6 +150,7 @@ final class ModdedCommandHelp {
|
||||
Entry.command("tpstudio", "", ModdedHelpMessages.COMMAND_TPSTUDIO_TELEPORT_INTO_THE_OPEN_STUDIO_DIMENSION, "stp"),
|
||||
Entry.command("status", "", ModdedHelpMessages.COMMAND_STATUS_SHOW_THE_OPEN_STUDIO_DIMENSION_AND_ITS_PACK),
|
||||
Entry.command("hotload", "", ModdedHelpMessages.COMMAND_HOTLOAD_REFRESH_THE_OPEN_STUDIO, "refresh"),
|
||||
Entry.command("regen", "[radius]", ModdedHelpMessages.COMMAND_REGEN_DELETE_AND_REGENERATE_NEARBY_CHUNKS_IN_PLACE, "rg"),
|
||||
Entry.command("noise", "[generator] [seed]", ModdedHelpMessages.COMMAND_NOISE_OPEN_THE_NOISE_EXPLORER_GUI_ON_THE_SERVER_DISPLAY, "nmap"),
|
||||
Entry.command("map", "", ModdedHelpMessages.COMMAND_MAP_OPEN_THE_VISION_MAP_GUI_ON_THE_SERVER_DISPLAY, "render"),
|
||||
Entry.command("vscode", "[pack]", ModdedHelpMessages.COMMAND_VSCODE_REGENERATE_THE_CODE_WORKSPACE_FOR_A_PACK_AND_OPEN_IT_IN_YOUR, "vsc"),
|
||||
|
||||
-10
@@ -120,9 +120,6 @@ final class ModdedCommandTree {
|
||||
root.then(metricsTree("metrics"));
|
||||
root.then(metricsTree("measure"));
|
||||
|
||||
root.then(regenTree("regen"));
|
||||
root.then(regenTree("rg"));
|
||||
|
||||
root.then(pregenTree("pregen"));
|
||||
root.then(pregenTree("pregenerate"));
|
||||
|
||||
@@ -222,13 +219,6 @@ final class ModdedCommandTree {
|
||||
.executes(ModdedCommandTree.localized((CommandContext<NativeCommandSource> context) -> IrisModdedCommands.metrics(context.getSource())));
|
||||
}
|
||||
|
||||
private static LiteralArgumentBuilder<NativeCommandSource> regenTree(String name) {
|
||||
return NativeCommandRegistration.literal(name).requires(GATE)
|
||||
.executes(ModdedCommandTree.localized((CommandContext<NativeCommandSource> context) -> IrisModdedCommands.regen(context.getSource(), 0)))
|
||||
.then(NativeCommandRegistration.argument("radius", IntegerArgumentType.integer(0, 64))
|
||||
.executes(ModdedCommandTree.localized((CommandContext<NativeCommandSource> context) -> IrisModdedCommands.regen(context.getSource(), IntegerArgumentType.getInteger(context, "radius")))));
|
||||
}
|
||||
|
||||
private static LiteralArgumentBuilder<NativeCommandSource> gotoTree(String name) {
|
||||
return NativeCommandRegistration.literal(name).requires(GATE)
|
||||
.executes(ModdedCommandTree.localized((CommandContext<NativeCommandSource> context) -> ModdedCommandHelp.send(context.getSource(), name)))
|
||||
|
||||
+9
@@ -159,6 +159,8 @@ public final class ModdedStudioCommands {
|
||||
.executes(ModdedCommandTree.localized((CommandContext<NativeCommandSource> context) -> hotload(context.getSource()))));
|
||||
root.then(NativeCommandRegistration.literal("refresh")
|
||||
.executes(ModdedCommandTree.localized((CommandContext<NativeCommandSource> context) -> hotload(context.getSource()))));
|
||||
root.then(regenTree("regen"));
|
||||
root.then(regenTree("rg"));
|
||||
root.then(workspaceTree("vscode", true));
|
||||
root.then(workspaceTree("vsc", true));
|
||||
root.then(workspaceTree("update", false));
|
||||
@@ -210,6 +212,13 @@ public final class ModdedStudioCommands {
|
||||
STUDIOS.clear();
|
||||
}
|
||||
|
||||
private static LiteralArgumentBuilder<NativeCommandSource> regenTree(String name) {
|
||||
return NativeCommandRegistration.literal(name)
|
||||
.executes(ModdedCommandTree.localized((CommandContext<NativeCommandSource> context) -> IrisModdedCommands.regen(context.getSource(), 0)))
|
||||
.then(NativeCommandRegistration.argument("radius", IntegerArgumentType.integer(0, 64))
|
||||
.executes(ModdedCommandTree.localized((CommandContext<NativeCommandSource> context) -> IrisModdedCommands.regen(context.getSource(), IntegerArgumentType.getInteger(context, "radius")))));
|
||||
}
|
||||
|
||||
private static LiteralArgumentBuilder<NativeCommandSource> openTree(String name) {
|
||||
return NativeCommandRegistration.literal(name)
|
||||
.executes(ModdedCommandTree.localized((CommandContext<NativeCommandSource> context) -> openHelp(context.getSource())))
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package art.arcane.iris.modded;
|
||||
|
||||
import art.arcane.iris.world.history.VersionedGenerationSource;
|
||||
import art.arcane.iris.generation.biome.IrisBiome;
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.iris.generation.runtime.DimensionStackLayout;
|
||||
@@ -206,6 +207,7 @@ public class ModdedBiomePolicyTest {
|
||||
when(router.openCoordinateScope(anyInt(), anyInt())).thenReturn(scope);
|
||||
IrisEngine engine = mock(IrisEngine.class);
|
||||
when(engine.getGenerationHistoryRuntimeRouter()).thenReturn(Optional.of(router));
|
||||
when(engine.getGenerationSource()).thenReturn(new VersionedGenerationSource(router));
|
||||
when(engine.getDimension()).thenReturn(dimension);
|
||||
when(engine.getData()).thenReturn(data);
|
||||
when(engine.getComplex()).thenReturn(complex);
|
||||
|
||||
+17
@@ -206,6 +206,23 @@ public class IrisModdedCommandParityTest {
|
||||
assertNotNull("pack cp", child(child(iris, "pk"), "cp").getCommand());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void regenLivesUnderStudio() {
|
||||
SharedConstants.tryDetectVersion();
|
||||
Bootstrap.bootStrap();
|
||||
CommandDispatcher<CommandSourceStack> dispatcher = new CommandDispatcher<>();
|
||||
|
||||
IrisModdedCommands.register(new NativeCommandRegistration(dispatcher));
|
||||
|
||||
CommandNode<CommandSourceStack> iris = child(dispatcher.getRoot(), "iris");
|
||||
assertNotNull("std regen", child(child(iris, "std"), "regen").getCommand());
|
||||
assertNotNull("studio rg radius", child(child(child(iris, "studio"), "rg"), "radius").getCommand());
|
||||
assertNull("top-level regen", iris.getChild("regen"));
|
||||
assertNull("top-level rg", iris.getChild("rg"));
|
||||
assertTrue(ModdedCommandHelp.consoleLines("studio").stream().anyMatch((String line) ->
|
||||
line.startsWith("/iris studio regen [radius] (rg) - ")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void consoleHelpListsEveryEntryWithInlineUsageAndDescription() {
|
||||
List<String> root = ModdedCommandHelp.consoleLines("");
|
||||
|
||||
+2
-1
@@ -1,5 +1,6 @@
|
||||
package art.arcane.iris.nativegen;
|
||||
|
||||
import art.arcane.iris.generation.runtime.GenerationScope;
|
||||
import art.arcane.iris.structure.nativegen.IrisStructurePolicy;
|
||||
|
||||
import art.arcane.volmlib.nativelib.minecraft26_2.terrain.NativeStructureReferenceRepair;
|
||||
@@ -439,7 +440,7 @@ public class NativeStructureReferenceRepairTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public GenerationHistoryRuntimeRouter.CoordinateScope openGenerationHistoryCoordinateScope(
|
||||
public GenerationScope openGenerationScope(
|
||||
int blockX,
|
||||
int blockZ
|
||||
) {
|
||||
|
||||
+1
-1
@@ -482,7 +482,7 @@ List<String> dependencyBuildMetadata = [
|
||||
'META-INF/versions/*/OSGI-INF/**'
|
||||
]
|
||||
|
||||
String languageTomlSupportClassPattern = 'art/arcane/volmlib/util/config/(?:TomlCodec|ConfigJson|ConfigExposePolicy|ConfigDoc|ConfigDescription|ConfigDocumentation)(?:\\$[^/]+)?\\.class'
|
||||
String languageTomlSupportClassPattern = 'art/arcane/volmlib/util/config/(?:TomlCodec|TomlSegments|ConfigComments|ConfigJson|ConfigExposePolicy|ConfigDoc|ConfigDescription|ConfigDocumentation)(?:\\$[^/]+)?\\.class'
|
||||
|
||||
tasks.named('shadowJar', ShadowJar).configure {
|
||||
inputs.property('languageTomlSupportClassPattern', languageTomlSupportClassPattern)
|
||||
|
||||
@@ -400,7 +400,7 @@ public class IrisSettings {
|
||||
@Data
|
||||
public static class IrisSettingsStudio {
|
||||
public boolean openVSCode = true;
|
||||
public boolean blendChanges = true;
|
||||
public boolean keepPackVersions = false;
|
||||
public boolean disableTimeAndWeather = true;
|
||||
public boolean entitySpawning = true;
|
||||
public boolean autoStartDefaultStudio = false;
|
||||
|
||||
@@ -478,7 +478,8 @@ public class IrisBiome extends IrisRegistrant implements Rarity {
|
||||
}
|
||||
|
||||
public CNG getChildrenGenerator(PackRuntime runtime, long seed, double scale) {
|
||||
return runtime.biome(this).childrenGenerator(seed, scale);
|
||||
double childScale = getChildStyle().isSeeded() ? 1 : scale;
|
||||
return runtime.biome(this).childrenGenerator(seed, childScale);
|
||||
}
|
||||
|
||||
CNG createChildrenGenerator(long seed, double scale, PackRuntime runtime) {
|
||||
|
||||
@@ -231,10 +231,10 @@ final class IrisBiomeLayerGenerator {
|
||||
int layerIndex = findLayer(boundaries, position);
|
||||
IrisBiomePaletteLayer layer = layers.get(layerIndex);
|
||||
int offset = position - boundaries[layerIndex];
|
||||
double zoom = layer.getZoom();
|
||||
double blocksPerSample = layer.blocksPerSample();
|
||||
try {
|
||||
data.add(layer.get(random, layerIndex + offset,
|
||||
(wx + offset) / zoom, offset, (wz - offset) / zoom, biomeRuntime.surfaceLayer(layerIndex)));
|
||||
(wx + offset) / blocksPerSample, offset, (wz - offset) / blocksPerSample, biomeRuntime.surfaceLayer(layerIndex)));
|
||||
} catch (Throwable error) {
|
||||
GenerationFailures.skipPlacement(error, "surface layer", "block", (int) wx, height - depth, (int) wz, biome.getLoadKey());
|
||||
}
|
||||
@@ -337,11 +337,11 @@ final class IrisBiomeLayerGenerator {
|
||||
private static void appendLayer(KList<NativeBlockState> blocks, IrisBiomePaletteLayer layer,
|
||||
PaletteLayerRuntime layerRuntime, int layerIndex, int thickness, double x, double z,
|
||||
RNG random, int maxDepth) {
|
||||
double zoom = layer.getZoom();
|
||||
double blocksPerSample = layer.blocksPerSample();
|
||||
for (int offset = 0; offset < thickness && blocks.size() < maxDepth; offset++) {
|
||||
try {
|
||||
blocks.add(layer.get(random, layerIndex + offset,
|
||||
(x + offset) / zoom, offset, (z - offset) / zoom, layerRuntime));
|
||||
(x + offset) / blocksPerSample, offset, (z - offset) / blocksPerSample, layerRuntime));
|
||||
} catch (Throwable error) {
|
||||
GenerationFailures.skipPlacement(error, "surface layer", "block", (int) x, -1, (int) z, "none");
|
||||
}
|
||||
|
||||
@@ -112,11 +112,19 @@ public class IrisBiomePaletteLayer {
|
||||
|
||||
private NativeBlockState fit(KList<NativeBlockState> localBlockData, PaletteLayerRuntime layerRuntime,
|
||||
RNG parent, int signature, double x, double y, double z) {
|
||||
double localZoom = zoom;
|
||||
CNG generator = layerRuntime.layerGenerator(layerGeneratorSeed(parent, signature, localBlockData.size()));
|
||||
if (style.isSeeded()) {
|
||||
return generator.fit(localBlockData, x, z);
|
||||
}
|
||||
double localZoom = zoom;
|
||||
return generator.fit(localBlockData, x / localZoom, y / localZoom, z / localZoom);
|
||||
}
|
||||
|
||||
/** How many blocks one step of the layer's block noise spans: its zoom, or 1 for a seeded style, which is read flat. */
|
||||
public double blocksPerSample() {
|
||||
return style.isSeeded() ? 1 : zoom;
|
||||
}
|
||||
|
||||
public CNG getLayerGenerator(RNG rng, PackRuntime runtime) {
|
||||
return getLayerGenerator(rng, 0, runtime);
|
||||
}
|
||||
|
||||
@@ -169,11 +169,17 @@ public class IrisDecorator {
|
||||
if (getBlockData(decoratorRuntime.packRuntime().data()).isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
double xx = x / style.getZoom();
|
||||
double zz = z / style.getZoom();
|
||||
double blocksPerSample = chanceBlocksPerSample();
|
||||
double xx = x / blocksPerSample;
|
||||
double zz = z / blocksPerSample;
|
||||
return decoratorRuntime.layerGenerator(rng.getSeed()).fitDouble(0D, 1D, xx, zz) <= chance;
|
||||
}
|
||||
|
||||
/** A style without a seed divides by its zoom here on top of its own scale; a seeded one is read in plain blocks. */
|
||||
private double chanceBlocksPerSample() {
|
||||
return style.isSeeded() ? 1 : style.getZoom();
|
||||
}
|
||||
|
||||
public NativeBlockState getBlockData(IrisBiome b, RNG rng, double x, double z, PackRuntime runtime) {
|
||||
if (!passesChanceGate(rng, x, z, runtime)) {
|
||||
return null;
|
||||
@@ -204,8 +210,9 @@ public class IrisDecorator {
|
||||
return getBlockData100(b, rng, x, y, z, runtime);
|
||||
}
|
||||
|
||||
double xx = x / style.getZoom();
|
||||
double zz = z / style.getZoom();
|
||||
double blocksPerSample = chanceBlocksPerSample();
|
||||
double xx = x / blocksPerSample;
|
||||
double zz = z / blocksPerSample;
|
||||
|
||||
if (getGenerator(rng, runtime).fitDouble(0D, 1D, xx, zz) <= chance) { //Exclude y from here
|
||||
if (topPalette.size() == 1) {
|
||||
|
||||
@@ -4,9 +4,8 @@ import art.arcane.iris.generation.biome.IrisBiome;
|
||||
import art.arcane.iris.generation.context.ChunkContext;
|
||||
import art.arcane.iris.generation.context.IrisContext;
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.iris.generation.runtime.IrisEngine;
|
||||
import art.arcane.iris.generation.runtime.BiomeEnvironment;
|
||||
import art.arcane.iris.world.history.GenerationHistoryRuntimeRouter;
|
||||
import art.arcane.iris.generation.runtime.GenerationSource;
|
||||
import art.arcane.iris.world.history.SavedBiomeRuntime;
|
||||
import art.arcane.iris.generation.runtime.GenerationSessionException;
|
||||
import art.arcane.iris.generation.runtime.GenerationSessionLease;
|
||||
@@ -20,7 +19,6 @@ import art.arcane.iris.generation.terrain.IrisRegion;
|
||||
import art.arcane.iris.world.history.GenerationSemanticIndex;
|
||||
import art.arcane.iris.world.history.GenerationSemanticQueries;
|
||||
import art.arcane.iris.world.history.GenerationFindCatalog;
|
||||
import art.arcane.iris.world.history.GenerationHistory;
|
||||
import art.arcane.iris.world.history.ChunkGenerationSemantics;
|
||||
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
|
||||
import art.arcane.volmlib.nativelib.terrain.NativeWorld;
|
||||
@@ -168,8 +166,8 @@ public final class BiomeLocator implements Locator<IrisBiome> {
|
||||
|
||||
@Override
|
||||
public SearchCandidate nearestRecordedCandidate(Engine engine, Position2 origin, int maximumRadius) {
|
||||
GenerationHistory history = GenerationLocatorPolicy.history(engine).orElse(null);
|
||||
if (history == null) {
|
||||
GenerationSource source = GenerationLocatorPolicy.source(engine);
|
||||
if (!source.keepsPackVersions()) {
|
||||
return null;
|
||||
}
|
||||
Set<Position2> rejected = new HashSet<>();
|
||||
@@ -178,7 +176,7 @@ public final class BiomeLocator implements Locator<IrisBiome> {
|
||||
new ChunkGenerationSemantics.BlockPosition((origin.getX() << 4) + 8, originWorldY,
|
||||
(origin.getZ() << 4) + 8), maximumRadius);
|
||||
while (!engine.isClosing() && !Thread.currentThread().isInterrupted() && System.nanoTime() < searchDeadline) {
|
||||
GenerationSemanticIndex.Match match = history.findRecorded(query,
|
||||
GenerationSemanticIndex.Match match = source.recordedChunks().findNearest(query,
|
||||
record -> !rejected.contains(new Position2(record.chunkX(), record.chunkZ()))).orElse(null);
|
||||
if (match == null) {
|
||||
return null;
|
||||
@@ -236,7 +234,7 @@ public final class BiomeLocator implements Locator<IrisBiome> {
|
||||
|
||||
public SubterrainPosition position(Engine engine, Position2 chunk) {
|
||||
if (authoredTarget != null || cavernTargets.containsKey(chunk) || surfaceTargets.contains(chunk) || authored
|
||||
|| activePredictionWithoutHistory(engine, chunk)) {
|
||||
|| GenerationLocatorPolicy.generatesWithActivePack(engine, chunk)) {
|
||||
return position(engine, chunk, Optional.empty());
|
||||
}
|
||||
try {
|
||||
@@ -326,26 +324,8 @@ public final class BiomeLocator implements Locator<IrisBiome> {
|
||||
return GenerationSemanticQueries.drySubterrainLanding(engine, candidate, running).orElse(null);
|
||||
}
|
||||
|
||||
private static boolean activePredictionWithoutHistory(Engine engine, Position2 chunk) {
|
||||
if (!(engine instanceof IrisEngine irisEngine)) {
|
||||
return true;
|
||||
}
|
||||
GenerationHistoryRuntimeRouter router = irisEngine.getGenerationHistoryRuntimeRouter().orElse(null);
|
||||
if (router == null) {
|
||||
return true;
|
||||
}
|
||||
GenerationHistory history = router.history();
|
||||
return history.isActiveUnowned(chunk.getX(), chunk.getZ()) && history.semantics(chunk.getX(), chunk.getZ()).isEmpty();
|
||||
}
|
||||
|
||||
public CompletableFuture<Optional<SavedBiomeRuntime.ReadSession>> prepareRead(Engine engine, Position2 chunk) {
|
||||
if (engine instanceof IrisEngine irisEngine) {
|
||||
GenerationHistoryRuntimeRouter router = irisEngine.getGenerationHistoryRuntimeRouter().orElse(null);
|
||||
if (router != null) {
|
||||
return router.biomes().readChunkAsync(chunk.getX(), chunk.getZ()).thenApply(Optional::of);
|
||||
}
|
||||
}
|
||||
return CompletableFuture.completedFuture(Optional.empty());
|
||||
return GenerationLocatorPolicy.source(engine).savedBiomes().readChunk(chunk.getX(), chunk.getZ());
|
||||
}
|
||||
|
||||
public SubterrainPosition landing(Engine engine, NativeWorld world, SubterrainPosition target,
|
||||
|
||||
@@ -5,8 +5,8 @@ import art.arcane.iris.structure.placement.IrisStructureLocator;
|
||||
|
||||
import art.arcane.iris.generation.runtime.IrisEngine;
|
||||
import art.arcane.iris.world.history.ChunkGenerationSemantics;
|
||||
import art.arcane.iris.world.history.GenerationHistory;
|
||||
import art.arcane.iris.world.history.GenerationHistoryRuntimeRouter;
|
||||
import art.arcane.iris.generation.runtime.GenerationScope;
|
||||
import art.arcane.iris.generation.runtime.GenerationSource;
|
||||
import art.arcane.iris.world.history.GenerationSemanticIndex;
|
||||
import art.arcane.volmlib.util.math.Position2;
|
||||
|
||||
@@ -66,11 +66,7 @@ final class HistoryAwareLocator<T> implements Locator<T> {
|
||||
|
||||
@Override
|
||||
public SearchCandidate nearestRecordedCandidate(Engine engine, Position2 origin, int maxChunkRadius) {
|
||||
GenerationHistory history = GenerationLocatorPolicy.history(engine).orElse(null);
|
||||
if (history == null) {
|
||||
return null;
|
||||
}
|
||||
GenerationSemanticIndex.Match match = history.findRecorded(
|
||||
GenerationSemanticIndex.Match match = GenerationLocatorPolicy.source(engine).recordedChunks().findNearest(
|
||||
GenerationSemanticIndex.Query.acrossActivations(
|
||||
kind,
|
||||
key,
|
||||
@@ -80,7 +76,8 @@ final class HistoryAwareLocator<T> implements Locator<T> {
|
||||
blockCenter(origin.getZ())
|
||||
),
|
||||
maxChunkRadius
|
||||
)
|
||||
),
|
||||
recorded -> true
|
||||
).orElse(null);
|
||||
if (match == null) {
|
||||
return null;
|
||||
@@ -136,40 +133,27 @@ final class GenerationLocatorPolicy {
|
||||
private GenerationLocatorPolicy() {
|
||||
}
|
||||
|
||||
static Optional<GenerationHistory> history(Engine engine) {
|
||||
if (!(engine instanceof IrisEngine irisEngine)) {
|
||||
return Optional.empty();
|
||||
}
|
||||
return irisEngine.getGenerationHistoryRuntimeRouter()
|
||||
.map(GenerationHistoryRuntimeRouter::history);
|
||||
static GenerationSource source(Engine engine) {
|
||||
return engine instanceof IrisEngine irisEngine ? irisEngine.getGenerationSource() : GenerationSource.singlePack();
|
||||
}
|
||||
|
||||
static Optional<ChunkGenerationSemantics> recorded(Engine engine, Position2 chunk) {
|
||||
GenerationHistory history = history(engine).orElse(null);
|
||||
if (history == null) {
|
||||
return Optional.empty();
|
||||
}
|
||||
return history.semantics(chunk.getX(), chunk.getZ())
|
||||
.filter(ChunkGenerationSemantics::sealed);
|
||||
return source(engine).recordedChunks().semantics(chunk.getX(), chunk.getZ());
|
||||
}
|
||||
|
||||
static boolean allowsActivePrediction(Engine engine, Position2 chunk) {
|
||||
if (!engine.getComplex().allowsNewGenerationChunk(chunk.getX(), chunk.getZ())) {
|
||||
return false;
|
||||
}
|
||||
GenerationHistory history = history(engine).orElse(null);
|
||||
if (history == null) {
|
||||
return true;
|
||||
}
|
||||
return history.isActiveUnowned(chunk.getX(), chunk.getZ())
|
||||
&& recorded(engine, chunk).isEmpty();
|
||||
return generatesWithActivePack(engine, chunk);
|
||||
}
|
||||
|
||||
static boolean generatesWithActivePack(Engine engine, Position2 chunk) {
|
||||
return !source(engine).recordedChunks().ownedByEarlierPack(chunk.getX(), chunk.getZ()) && recorded(engine, chunk).isEmpty();
|
||||
}
|
||||
|
||||
static boolean allowsHistoricalFallback(Engine engine, Position2 chunk) {
|
||||
GenerationHistory history = history(engine).orElse(null);
|
||||
return history != null
|
||||
&& history.isHistoricallyOwned(chunk.getX(), chunk.getZ())
|
||||
&& recorded(engine, chunk).isEmpty();
|
||||
return source(engine).recordedChunks().ownedByEarlierPack(chunk.getX(), chunk.getZ()) && recorded(engine, chunk).isEmpty();
|
||||
}
|
||||
|
||||
static boolean allowsProceduralPrediction(Engine engine, Position2 chunk) {
|
||||
@@ -184,8 +168,7 @@ final class GenerationLocatorPolicy {
|
||||
if (radius < 0) {
|
||||
throw new IllegalArgumentException("Historical fallback radius cannot be negative.");
|
||||
}
|
||||
GenerationHistory history = history(engine).orElse(null);
|
||||
return history != null && history.hasHistoricalFallbackInSquare(center.getX(), center.getZ(), radius);
|
||||
return source(engine).recordedChunks().hasUnrecordedEarlierPackChunkInSquare(center.getX(), center.getZ(), radius);
|
||||
}
|
||||
|
||||
static boolean evaluateScoped(
|
||||
@@ -199,8 +182,7 @@ final class GenerationLocatorPolicy {
|
||||
}
|
||||
int blockX = Math.multiplyExact(chunk.getX(), 16);
|
||||
int blockZ = Math.multiplyExact(chunk.getZ(), 16);
|
||||
try (GenerationHistoryRuntimeRouter.CoordinateScope ignored =
|
||||
irisEngine.openGenerationHistoryCoordinateScope(blockX, blockZ)) {
|
||||
try (GenerationScope ignored = irisEngine.openGenerationScope(blockX, blockZ)) {
|
||||
return requiredQuery.getAsBoolean();
|
||||
} catch (IOException exception) {
|
||||
throw new IllegalStateException("Unable to scope an Iris locator query at chunk "
|
||||
@@ -219,8 +201,7 @@ final class GenerationLocatorPolicy {
|
||||
}
|
||||
int blockX = Math.multiplyExact(chunk.getX(), 16);
|
||||
int blockZ = Math.multiplyExact(chunk.getZ(), 16);
|
||||
try (GenerationHistoryRuntimeRouter.CoordinateScope ignored =
|
||||
irisEngine.openGenerationHistoryCoordinateScope(blockX, blockZ)) {
|
||||
try (GenerationScope ignored = irisEngine.openGenerationScope(blockX, blockZ)) {
|
||||
return requiredQuery.get();
|
||||
} catch (IOException exception) {
|
||||
throw new IllegalStateException("Unable to scope an Iris locator query at chunk "
|
||||
|
||||
@@ -35,6 +35,7 @@ import art.arcane.iris.structure.object.IrisAxisRotationClamp;
|
||||
import art.arcane.iris.generation.biome.IrisBiome;
|
||||
import art.arcane.iris.generation.cave.IrisCaveAnchorMode;
|
||||
import art.arcane.iris.generation.cave.IrisCaveProfile;
|
||||
import art.arcane.iris.pack.loading.IrisData;
|
||||
import art.arcane.iris.generation.terrain.IrisDimension;
|
||||
import art.arcane.iris.structure.object.IrisObject;
|
||||
import art.arcane.iris.structure.object.IrisObjectPlacement;
|
||||
@@ -87,7 +88,7 @@ public class MantleObjectComponent extends IrisMantleComponent {
|
||||
private static final int BEDROCK_CLEARANCE = 6;
|
||||
static final byte LIQUID_FORCED_AIR = 3;
|
||||
private static final Map<String, CaveRejectLogState> CAVE_REJECT_LOG_STATE = new ConcurrentHashMap<>();
|
||||
private static final Set<String> MISSING_LOAD_KEY_WARNED = ConcurrentHashMap.newKeySet();
|
||||
private static final String MISSING_LOAD_KEY_KIND = "marker-missing-load-key";
|
||||
private static final long SOURCE_PLAN_STATS_INTERVAL_MS = 30_000L;
|
||||
private static final int MAXIMUM_TREE_MATERIALS = 8192;
|
||||
private static final Map<NativeBlockState, TreeBlockMaterial> TREE_MATERIALS = new ConcurrentHashMap<>();
|
||||
@@ -105,21 +106,29 @@ public class MantleObjectComponent extends IrisMantleComponent {
|
||||
this.collisionRuleState = -1;
|
||||
}
|
||||
|
||||
private static String placementMarker(IrisObject object, int id, String context) {
|
||||
static String placementMarker(IrisObject object, int id, String context) {
|
||||
String key = object == null ? null : object.getLoadKey();
|
||||
if (key == null || key.isEmpty() || key.equals("null")) {
|
||||
String fingerprint = context + "|" + (object == null ? "<null>" : object.getClass().getSimpleName());
|
||||
if (MISSING_LOAD_KEY_WARNED.add(fingerprint)) {
|
||||
java.io.File file = object == null ? null : object.getLoadFile();
|
||||
IrisLogging.warn("Skipping placement marker write: IrisObject has no loadKey (context=" + context
|
||||
+ ", file=" + (file == null ? "<unknown>" : file.getPath()) + "). "
|
||||
+ "This would previously produce 'Couldn't find Object: null' warnings on chunk reload.");
|
||||
}
|
||||
warnMissingLoadKeyOnce(object, context);
|
||||
return null;
|
||||
}
|
||||
return key + "@" + id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Keyed by call-site context and object class only: the file path and coordinates stay in the message,
|
||||
* never in the key, so the key space is bounded.
|
||||
*/
|
||||
private static void warnMissingLoadKeyOnce(IrisObject object, String context) {
|
||||
String fingerprint = context + "|" + (object == null ? "<null>" : object.getClass().getSimpleName());
|
||||
IrisData pack = object == null ? null : object.getLoader();
|
||||
java.io.File file = object == null ? null : object.getLoadFile();
|
||||
IrisLogging.warnOnce(IrisData.onceKey(pack, MISSING_LOAD_KEY_KIND, fingerprint),
|
||||
"Skipping placement marker write: IrisObject has no loadKey (context=" + context
|
||||
+ ", file=" + (file == null ? "<unknown>" : file.getPath()) + "). "
|
||||
+ "This would previously produce 'Couldn't find Object: null' warnings on chunk reload.");
|
||||
}
|
||||
|
||||
private static boolean isTreePlacement(IrisObject object, IrisObjectPlacement placement) {
|
||||
String key = object == null ? null : object.getLoadKey();
|
||||
return (key != null && key.startsWith("trees/"))
|
||||
|
||||
@@ -8,11 +8,14 @@ import art.arcane.volmlib.util.io.CountingDataInputStream;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.UncheckedIOException;
|
||||
import art.arcane.iris.spi.IrisLogging;
|
||||
import art.arcane.iris.world.storage.matter.IrisMatterSupport;
|
||||
import art.arcane.iris.world.storage.matter.RetiredMatterSlices;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@@ -147,6 +150,7 @@ public record ObjectContinuationBundle(List<Fragment> fragments) {
|
||||
Matter matter = new IrisMatter(width, height, depth);
|
||||
int sliceCount = input.readUnsignedByte();
|
||||
matter.getHeader().read(input);
|
||||
HashSet<String> skippedRetired = new HashSet<>();
|
||||
for (int index = 0; index < sliceCount; index++) {
|
||||
int size = input.readInt();
|
||||
long end = input.count() + size;
|
||||
@@ -154,9 +158,24 @@ public record ObjectContinuationBundle(List<Fragment> fragments) {
|
||||
throw new IOException("Invalid object continuation slice size");
|
||||
}
|
||||
String identifier = input.readUTF();
|
||||
if (input.count() > end) {
|
||||
throw new IOException("Object continuation slice size mismatch: " + identifier);
|
||||
}
|
||||
Class<?> type = IrisMatter.getSliceType(identifier);
|
||||
if (type == null || matter.hasSlice(type)) {
|
||||
throw new IOException("Unavailable or duplicate object continuation slice: " + identifier);
|
||||
if (type == null) {
|
||||
if (!RetiredMatterSlices.isRetired(identifier)) {
|
||||
throw new IOException("Unknown object continuation slice type: " + identifier);
|
||||
}
|
||||
if (!skippedRetired.add(identifier)) {
|
||||
throw new IOException("Duplicate object continuation slice type: " + identifier);
|
||||
}
|
||||
input.skipTo(end);
|
||||
IrisLogging.warnOnce("object-continuation:retired-slice:" + identifier,
|
||||
"Skipping retired object continuation slice %s written by an older Iris version", identifier);
|
||||
continue;
|
||||
}
|
||||
if (matter.hasSlice(type)) {
|
||||
throw new IOException("Duplicate object continuation slice type: " + identifier);
|
||||
}
|
||||
MatterSlice<?> slice = matter.createSlice(type, matter);
|
||||
if (slice == null) {
|
||||
|
||||
@@ -15,6 +15,7 @@ public final class GeneratorProgram {
|
||||
private final NoiseLayerProgram cliffs;
|
||||
private final boolean multiplicitive;
|
||||
private final double opacity;
|
||||
private final double exponent;
|
||||
private final double offsetX;
|
||||
private final double offsetZ;
|
||||
private final double zoom;
|
||||
@@ -36,6 +37,7 @@ public final class GeneratorProgram {
|
||||
this.cliffs = cliffs;
|
||||
this.multiplicitive = generator.isMultiplicitive();
|
||||
this.opacity = generator.getOpacity();
|
||||
this.exponent = generator.getExponent();
|
||||
this.offsetX = generator.getOffsetX();
|
||||
this.offsetZ = generator.getOffsetZ();
|
||||
this.zoom = generator.getZoom();
|
||||
@@ -122,7 +124,8 @@ public final class GeneratorProgram {
|
||||
double noise = layer.sample(scratch, sampleX, sampleZ);
|
||||
value = multiplicitive ? value * noise : value + noise;
|
||||
}
|
||||
value = multiplicitive ? value * opacity : (value / totalOpacity) * opacity;
|
||||
double combined = multiplicitive ? value : value / totalOpacity;
|
||||
value = IrisGenerator.applyExponent(combined, exponent) * opacity;
|
||||
if (Double.isNaN(value)) {
|
||||
value = 0D;
|
||||
}
|
||||
@@ -302,7 +305,8 @@ public final class GeneratorProgram {
|
||||
}
|
||||
}
|
||||
for (int index = 0; index < count; index++) {
|
||||
double value = multiplicitive ? out[index] * opacity : (out[index] / totalOpacity) * opacity;
|
||||
double combined = multiplicitive ? out[index] : out[index] / totalOpacity;
|
||||
double value = IrisGenerator.applyExponent(combined, exponent) * opacity;
|
||||
out[index] = Double.isNaN(value) ? 0D : value;
|
||||
}
|
||||
if (cliffs != null) {
|
||||
|
||||
@@ -62,6 +62,9 @@ public class IrisGenerator extends IrisRegistrant {
|
||||
@Description("Multiply the compsites instead of adding them")
|
||||
private boolean multiplicitive = false;
|
||||
@MinNumber(0.001)
|
||||
@Description("Curves the combined composite value (0-1) as value^exponent before opacity. Above 1 flattens lows and sharpens peaks, below 1 does the opposite. Unlike the exponent on a single noise generator, this acts on the combined result of all composites.")
|
||||
private double exponent = 1;
|
||||
@MinNumber(0.001)
|
||||
@Description("The size of the cell fractures")
|
||||
private double cellFractureZoom = 1D;
|
||||
@MinNumber(0)
|
||||
@@ -178,6 +181,7 @@ public class IrisGenerator extends IrisRegistrant {
|
||||
if (!Double.isFinite(surfaceDetail) || surfaceDetail < 0D || surfaceDetail > 1D) {
|
||||
throw new IllegalArgumentException("Generator surfaceDetail must be finite and between 0 and 1");
|
||||
}
|
||||
requireValidExponent();
|
||||
if (composite.isEmpty()) {
|
||||
return 0D;
|
||||
}
|
||||
@@ -204,6 +208,7 @@ public class IrisGenerator extends IrisRegistrant {
|
||||
if (!Double.isFinite(surfaceDetail) || surfaceDetail < 0D || surfaceDetail > 1D) {
|
||||
throw new IllegalArgumentException("Generator surfaceDetail must be finite and between 0 and 1");
|
||||
}
|
||||
requireValidExponent();
|
||||
if (!supportsBatch()) {
|
||||
throw new IllegalStateException("Generator " + getLoadKey() + " cannot be compiled into a batch program");
|
||||
}
|
||||
@@ -298,7 +303,8 @@ public class IrisGenerator extends IrisRegistrant {
|
||||
}
|
||||
}
|
||||
|
||||
double v = multiplicitive ? h * opacity : (h / tp) * opacity;
|
||||
double combined = multiplicitive ? h : h / tp;
|
||||
double v = applyExponent(combined, exponent) * opacity;
|
||||
|
||||
if (Double.isNaN(v)) {
|
||||
v = 0;
|
||||
@@ -310,6 +316,20 @@ public class IrisGenerator extends IrisRegistrant {
|
||||
return v;
|
||||
}
|
||||
|
||||
static double applyExponent(double value, double exponent) {
|
||||
if (exponent == 1) {
|
||||
return value;
|
||||
}
|
||||
|
||||
return value < 0 ? -Math.pow(-value, exponent) : Math.pow(value, exponent);
|
||||
}
|
||||
|
||||
private void requireValidExponent() {
|
||||
if (!Double.isFinite(exponent) || exponent <= 0D) {
|
||||
throw new IllegalArgumentException("Generator exponent must be finite and above 0");
|
||||
}
|
||||
}
|
||||
|
||||
private double cachedSurfaceHeight(double x, double z, long superSeed, SurfaceCacheStripe[] stripes, PackRuntime runtime) {
|
||||
if (x != (int) x || z != (int) z) {
|
||||
return sampleHeight(x, z, superSeed, runtime);
|
||||
|
||||
@@ -83,6 +83,8 @@ public class IrisGeneratorStyle {
|
||||
@MaxNumber(8192)
|
||||
@Description("If the cache size is set above 0, this generator will be cached")
|
||||
private int cacheSize = 0;
|
||||
@Description("Rolls this noise from the world seed and this number, so every style with the same seed shares one noise. Child biomes, palettes and decorator placement read a seeded style flat in blocks: zoom is its only scale, so a layer's zoom, childShrinkFactor and the decorator's extra zoom don't apply.")
|
||||
private Long seed = null;
|
||||
|
||||
public IrisGeneratorStyle(NoiseStyle s) {
|
||||
this.style = s;
|
||||
@@ -119,7 +121,34 @@ public class IrisGeneratorStyle {
|
||||
}
|
||||
|
||||
private int hash() {
|
||||
return Objects.hash(expression, imageMapHash(), multiplier, fracture != null ? fracture.hash() : 0, exponent, cacheSize, zoom, cellularZoom, cellularFrequency, style == null ? null : style.name());
|
||||
int unseededHash = Objects.hash(expression, imageMapHash(), multiplier, fracture != null ? fracture.hash() : 0, exponent, cacheSize, zoom, cellularZoom, cellularFrequency, style == null ? null : style.name());
|
||||
return isSeeded() ? Objects.hash(unseededHash, seed) : unseededHash;
|
||||
}
|
||||
|
||||
public boolean isSeeded() {
|
||||
return seed != null;
|
||||
}
|
||||
|
||||
/** The random a style is built from: the caller's, or for a seeded style one rolled from its seed and the world seed. */
|
||||
public RNG rollFor(RNG callerRandom, Engine engine) {
|
||||
if (!isSeeded()) {
|
||||
return callerRandom;
|
||||
}
|
||||
|
||||
return new RNG(rolledSeed(engine));
|
||||
}
|
||||
|
||||
private long rolledSeed(Engine engine) {
|
||||
long worldSeed = engine == null ? 0L : engine.getSeedManager().getSeed();
|
||||
return splitMix(worldSeed ^ splitMix(seed));
|
||||
}
|
||||
|
||||
// Spreads nearby seed numbers far apart; Iris's own seed forking only adds.
|
||||
private static long splitMix(long value) {
|
||||
long mixed = value + 0x9E3779B97F4A7C15L;
|
||||
mixed = (mixed ^ (mixed >>> 30)) * 0xBF58476D1CE4E5B9L;
|
||||
mixed = (mixed ^ (mixed >>> 27)) * 0x94D049BB133111EBL;
|
||||
return mixed ^ (mixed >>> 31);
|
||||
}
|
||||
|
||||
public int prebakeSignature() {
|
||||
@@ -163,10 +192,11 @@ public class IrisGeneratorStyle {
|
||||
}
|
||||
}
|
||||
|
||||
private CNG createNoCache(RNG rng, PackRuntime runtime, int octaveMultiplier, int fallbackCacheSize,
|
||||
private CNG createNoCache(RNG callerRandom, PackRuntime runtime, int octaveMultiplier, int fallbackCacheSize,
|
||||
boolean quietCacheLog) {
|
||||
IrisData data = runtime.data();
|
||||
Engine engine = runtime.engine();
|
||||
RNG rng = rollFor(callerRandom, engine);
|
||||
requirePositiveFinite("zoom", zoom);
|
||||
requirePositiveFinite("exponent", exponent);
|
||||
if (!Double.isFinite(cellularFrequency) || cellularFrequency < 0D) {
|
||||
@@ -231,8 +261,8 @@ public class IrisGeneratorStyle {
|
||||
return create(rng.getSeed(), runtime);
|
||||
}
|
||||
|
||||
public CNG create(long seed, PackRuntime runtime) {
|
||||
return runtime.styleGenerator(this, seed);
|
||||
public CNG create(long callerSeed, PackRuntime runtime) {
|
||||
return runtime.styleGenerator(this, isSeeded() ? rolledSeed(runtime.engine()) : callerSeed);
|
||||
}
|
||||
|
||||
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
|
||||
|
||||
@@ -269,9 +269,13 @@ public final class DimensionTerrainContext implements DataProvider {
|
||||
Interpolated.of(value -> 0D, value -> focusBiome.getInferredType())
|
||||
);
|
||||
|
||||
boolean sealessRegions = IrisComplex.lacks(preparedBiomeStreams, InferredType.SEA);
|
||||
ProceduralStream<IrisBiome> proceduralBaseBiomeStream = focusBiome == null
|
||||
? bridgeStream
|
||||
.convertAware2D((type, x, z) -> {
|
||||
.convertAware2D((continent, x, z) -> {
|
||||
InferredType type = sealessRegions
|
||||
? IrisComplex.baseType(preparedBiomeStreams, regionStream.get(x, z), continent)
|
||||
: continent;
|
||||
ProceduralStream<IrisBiome> stream = inferredStreams.get(type);
|
||||
return stream != null
|
||||
? stream.get(x, z)
|
||||
@@ -536,13 +540,17 @@ public final class DimensionTerrainContext implements DataProvider {
|
||||
IrisRegion region,
|
||||
InferredType type
|
||||
) {
|
||||
if ((type == InferredType.SEA || type == InferredType.SHORE) && loadInferredBiomes(runtime.data(), biomeKeys(region, type), type).isEmpty()) {
|
||||
return IrisComplex.NO_BIOMES;
|
||||
}
|
||||
return switch (type) {
|
||||
case LAND -> dimension.getLandBiomeStyle()
|
||||
.create(rng.nextParallelRNG(InferredType.LAND.ordinal()), runtime).stream()
|
||||
.zoom(dimension.getBiomeZoom())
|
||||
.zoom(dimension.getLandZoom())
|
||||
.zoom(region.getLandBiomeZoom())
|
||||
.selectRarity(loadInferredBiomes(runtime.data(), region.getLandBiomes(), InferredType.LAND));
|
||||
.selectRarity(IrisComplex.requireLandBiomes(region,
|
||||
loadInferredBiomes(runtime.data(), region.getLandBiomes(), InferredType.LAND)));
|
||||
case SEA -> dimension.getSeaBiomeStyle()
|
||||
.create(rng.nextParallelRNG(InferredType.SEA.ordinal()), runtime).stream()
|
||||
.zoom(dimension.getBiomeZoom())
|
||||
@@ -558,6 +566,10 @@ public final class DimensionTerrainContext implements DataProvider {
|
||||
};
|
||||
}
|
||||
|
||||
private static KList<String> biomeKeys(IrisRegion region, InferredType type) {
|
||||
return type == InferredType.SEA ? region.getSeaBiomes() : region.getShoreBiomes();
|
||||
}
|
||||
|
||||
private static KList<IrisBiome> loadInferredBiomes(
|
||||
IrisData data,
|
||||
KList<String> keys,
|
||||
|
||||
@@ -258,11 +258,9 @@ final class EngineHotloader {
|
||||
throw new IllegalStateException("Studio engine changed while its generation cutover was draining.");
|
||||
}
|
||||
engine.prepareRuntimeHotload();
|
||||
IrisSettings settings = IrisSettings.get();
|
||||
int transitionWidth = settings.getStudio().isBlendChanges()
|
||||
? settings.getGenerator().getGenerationTransitionWidthBlocks() : 0;
|
||||
history.stageUpdate(update.source(), update.fingerprint(), update.dimensionContract(),
|
||||
update.registryContract(), transitionWidth);
|
||||
int transitionWidth = IrisSettings.get().getGenerator().getGenerationTransitionWidthBlocks();
|
||||
history.stageUpdateReplacingStalePending(update.source(), update.fingerprint(),
|
||||
update.dimensionContract(), update.registryContract(), transitionWidth);
|
||||
}
|
||||
long stagedAt = System.nanoTime();
|
||||
cutover.promotePending();
|
||||
|
||||
@@ -27,7 +27,6 @@ import art.arcane.iris.generation.mantle.ObjectContinuationPersistence;
|
||||
import art.arcane.iris.generation.stage.IrisDimensionStackActuator;
|
||||
import art.arcane.iris.generation.stage.IrisTransitionGeometryActuator;
|
||||
import art.arcane.iris.world.history.FloatingBiomeOverlay;
|
||||
import art.arcane.iris.world.history.GenerationHistoryRuntimeRouter;
|
||||
import art.arcane.iris.world.history.SavedTerrainChunk;
|
||||
import art.arcane.volmlib.nativelib.terrain.NativeBiome;
|
||||
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
|
||||
@@ -235,17 +234,9 @@ public interface EngineMode extends Staged {
|
||||
if (!(getEngine() instanceof IrisEngine irisEngine)) {
|
||||
return List.of();
|
||||
}
|
||||
GenerationHistoryRuntimeRouter router = irisEngine.getGenerationHistoryRuntimeRouter().orElse(null);
|
||||
if (router == null) {
|
||||
return List.of();
|
||||
}
|
||||
List<GenerationHistoryRuntimeRouter.ObjectContinuation> fragments = router.objectContinuations(
|
||||
getComplex().getTransitionGenerationPlan(), x >> 4, z >> 4);
|
||||
if (fragments.isEmpty()) {
|
||||
return List.of();
|
||||
}
|
||||
try {
|
||||
List<Matter> continuations = router.decodeObjectContinuations(fragments);
|
||||
List<Matter> continuations = irisEngine.getGenerationSource().transitions().objectContinuations(
|
||||
getComplex().getTransitionGenerationPlan(), x >> 4, z >> 4);
|
||||
for (Matter continuation : continuations) {
|
||||
if (continuation.getHeight() != getEngine().getHeight()) {
|
||||
throw new IOException("Object continuation height does not match the world");
|
||||
@@ -264,8 +255,8 @@ public interface EngineMode extends Staged {
|
||||
if (!(getEngine() instanceof IrisEngine irisEngine)) {
|
||||
return;
|
||||
}
|
||||
GenerationHistoryRuntimeRouter router = irisEngine.getGenerationHistoryRuntimeRouter().orElse(null);
|
||||
if (router == null) {
|
||||
GenerationSource source = irisEngine.getGenerationSource();
|
||||
if (!source.keepsPackVersions()) {
|
||||
return;
|
||||
}
|
||||
FloatingBiomeOverlay floating = context.getFloatingBiomes();
|
||||
@@ -283,8 +274,7 @@ public interface EngineMode extends Staged {
|
||||
try {
|
||||
SavedTerrainChunk terrain = IrisTransitionGeometryActuator.capture(
|
||||
x, z, blocks, biomes, getEngine().getMinHeight(), context, true);
|
||||
router.recordNaturalTerrain(terrain);
|
||||
router.recordFloatingBiomes(x >> 4, z >> 4, floating);
|
||||
source.transitions().recordNaturalTerrain(terrain, floating);
|
||||
} catch (IOException failure) {
|
||||
throw new IllegalStateException("Unable to capture natural terrain at " + (x >> 4) + "," + (z >> 4), failure);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package art.arcane.iris.generation.runtime;
|
||||
|
||||
import art.arcane.volmlib.nativelib.terrain.NativeGenerationRoute;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* A native chunk generation pass routed to the activation that owns the chunk.
|
||||
*/
|
||||
public interface GenerationRoute extends NativeGenerationRoute {
|
||||
long activationId();
|
||||
|
||||
/**
|
||||
* @return the receipt for the natural terrain this pass captured, or null when it captured none
|
||||
*/
|
||||
byte[] naturalTerrainReceipt() throws IOException;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package art.arcane.iris.generation.runtime;
|
||||
|
||||
import art.arcane.volmlib.nativelib.terrain.NativeGenerationScope;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Binds the calling thread to the pack that owns one column until closed.
|
||||
*/
|
||||
public interface GenerationScope extends NativeGenerationScope {
|
||||
/**
|
||||
* Records what the scoped chunk generated, when its pack keeps a record.
|
||||
*
|
||||
* @return true when this call recorded the chunk
|
||||
*/
|
||||
boolean claimGeneratedSemantics() throws IOException;
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package art.arcane.iris.generation.runtime;
|
||||
|
||||
import art.arcane.iris.world.history.GenerationBoundary;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Answers which pack generated, or will generate, a chunk. A single-pack world always answers the current pack. A
|
||||
* versioned world keeps every earlier pack version and routes each chunk to the one that owns it.
|
||||
*/
|
||||
public interface GenerationSource {
|
||||
static GenerationSource singlePack() {
|
||||
return SinglePackGenerationSource.INSTANCE;
|
||||
}
|
||||
|
||||
/** True when chunks may belong to an earlier pack version than the one loaded now. */
|
||||
boolean keepsPackVersions();
|
||||
|
||||
GenerationScope openGenerationScope(int blockX, int blockZ) throws IOException;
|
||||
|
||||
/** Like {@link #openGenerationScope(int, int)}, but may borrow the runtime the thread is already bound to. */
|
||||
GenerationScope openReadScope(int blockX, int blockZ) throws IOException;
|
||||
|
||||
/** @return null when every chunk generates with the current pack and needs no route */
|
||||
GenerationRoute openRoute(int chunkX, int chunkZ) throws IOException;
|
||||
|
||||
/** The activation and runtime the calling thread generates for, while it holds a route. */
|
||||
Optional<RouteOwnership> currentRouteOwnership();
|
||||
|
||||
boolean predatesActivePack(long activationId);
|
||||
|
||||
/** Lets the current pack regenerate these chunks, whichever pack generated them before. */
|
||||
void releaseForRegeneration(List<GenerationBoundary.ChunkCoordinate> chunks) throws IOException;
|
||||
|
||||
void sync() throws IOException;
|
||||
|
||||
SavedBiomes savedBiomes();
|
||||
|
||||
RecordedChunks recordedChunks();
|
||||
|
||||
PackTransitions transitions();
|
||||
|
||||
record RouteOwnership(long activationId, IrisEngine.GenerationRuntimeBinding binding) {
|
||||
}
|
||||
}
|
||||
@@ -57,8 +57,6 @@ import art.arcane.iris.generation.hydrology.raster.WaterRole;
|
||||
import art.arcane.iris.generation.hydrology.water.HydrologyTier;
|
||||
import art.arcane.iris.generation.image.IrisImageMapApplication;
|
||||
import art.arcane.iris.generation.image.IrisImageMapRuntime;
|
||||
import art.arcane.iris.generation.mantle.ObjectContinuationBundle;
|
||||
import art.arcane.iris.world.history.GenerationHistoryRuntimeRouter;
|
||||
import art.arcane.iris.generation.terrain.InferredType;
|
||||
import art.arcane.iris.generation.biome.IrisBiome;
|
||||
import art.arcane.iris.generation.biome.IrisBiomeGeneratorLink;
|
||||
@@ -154,6 +152,12 @@ public class IrisComplex implements DataProvider {
|
||||
InferredType.SEA,
|
||||
InferredType.SHORE
|
||||
};
|
||||
/**
|
||||
* The biome stream of a sea or shore list a region leaves empty. It answers null everywhere, which tells the
|
||||
* surface resolution to keep the column's own biome instead of converting it.
|
||||
*/
|
||||
static final ProceduralStream<IrisBiome> NO_BIOMES = ProceduralStream.of((x, z) -> null,
|
||||
Interpolated.of(value -> 0D, value -> null));
|
||||
@Getter(AccessLevel.NONE)
|
||||
private final transient ThreadSlots<GridBoundsCache> gridBoundsCache = new ThreadSlots<>(GridBoundsCache::new);
|
||||
@Getter(AccessLevel.NONE)
|
||||
@@ -206,6 +210,8 @@ public class IrisComplex implements DataProvider {
|
||||
private ProceduralStream<Double> regionStyleStream;
|
||||
private ProceduralStream<Double> regionIdentityStream;
|
||||
private ProceduralStream<InferredType> bridgeStream;
|
||||
@Getter(AccessLevel.NONE)
|
||||
private ProceduralStream<InferredType> baseTypeStream;
|
||||
private ProceduralStream<IrisBiome> landBiomeStream;
|
||||
private ProceduralStream<IrisBiome> caveBiomeStream;
|
||||
private ProceduralStream<IrisBiome> seaBiomeStream;
|
||||
@@ -455,9 +461,15 @@ public class IrisComplex implements DataProvider {
|
||||
bridgeStream = focusedBiomes != null ? focusedBiomes.convert(IrisBiome::getInferredType) :
|
||||
ContinentGenerator.create(engine.getDimension(), rng, packRuntime).stream()
|
||||
.convert((v) -> v >= engine.getDimension().getLandChance() ? InferredType.SEA : InferredType.LAND);
|
||||
// A region without sea biomes picks its continental sea from its land biomes.
|
||||
baseTypeStream = focusedBiomes != null || !lacks(inferredBiomeStreams, InferredType.SEA) ? bridgeStream
|
||||
: ProceduralStream.of(
|
||||
(x, z) -> baseType(inferredBiomeStreams, contextRegionStream.get(x, z), bridgeStream.get(x, z)),
|
||||
(x, y, z) -> baseType(inferredBiomeStreams, contextRegionStream.get(x, z), bridgeStream.get(x, y, z)),
|
||||
Interpolated.of(value -> 0D, value -> null));
|
||||
ProceduralStream<IrisBiome> proceduralBaseBiomeStream = focusedBiomes != null ? focusedBiomes
|
||||
: ProceduralStream.of(this::proceduralBaseBiome,
|
||||
(x, y, z) -> implode(inferredByType.get(bridgeStream.get(x, y, z)).get(x, z), x, z),
|
||||
(x, y, z) -> implode(inferredByType.get(baseTypeStream.get(x, y, z)).get(x, z), x, z),
|
||||
Interpolated.of(value -> 0D, value -> null));
|
||||
baseBiomeSource = focusedBiomes != null || !imageMapRuntime.has(IrisImageMapApplication.BIOME)
|
||||
? proceduralBaseBiomeStream : ProceduralStream.of((x, z) -> {
|
||||
@@ -1067,7 +1079,7 @@ public class IrisComplex implements DataProvider {
|
||||
}
|
||||
|
||||
private IrisBiome proceduralBaseBiome(double x, double z) {
|
||||
return implode(inferredByType.get(bridgeStream.get(x, z)).get(x, z), x, z);
|
||||
return implode(inferredByType.get(baseTypeStream.get(x, z)).get(x, z), x, z);
|
||||
}
|
||||
|
||||
private final class BakeSource implements PlaneSource {
|
||||
@@ -1168,9 +1180,53 @@ public class IrisComplex implements DataProvider {
|
||||
InferredType inferredType,
|
||||
IrisBiome emptyBiome
|
||||
) {
|
||||
ProceduralStream<IrisBiome> picked = new RarityStream<>(biomePickNoiseStream(engine.getDimension(), region, inferredType),
|
||||
loadInferredBiomes(biomeKeys(region, inferredType), inferredType));
|
||||
return inferredType == InferredType.CAVE ? picked.onNull(emptyBiome) : picked;
|
||||
ProceduralStream<Double> noise = biomePickNoiseStream(engine.getDimension(), region, inferredType);
|
||||
KList<IrisBiome> biomes = loadInferredBiomes(biomeKeys(region, inferredType), inferredType);
|
||||
return switch (inferredType) {
|
||||
case CAVE -> new RarityStream<>(noise, biomes).onNull(emptyBiome);
|
||||
case LAND -> new RarityStream<>(noise, requireLandBiomes(region, biomes));
|
||||
case SEA, SHORE -> biomes.isEmpty() ? NO_BIOMES : new RarityStream<>(noise, biomes);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Every region needs a land biome: the surface falls back to land wherever it leaves sea or shore, and a region
|
||||
* without sea biomes picks its continental sea from land too.
|
||||
*/
|
||||
static KList<IrisBiome> requireLandBiomes(IrisRegion region, KList<IrisBiome> landBiomes) {
|
||||
if (!landBiomes.isEmpty()) {
|
||||
return landBiomes;
|
||||
}
|
||||
String regionKey = region.getLoadKey() == null || region.getLoadKey().isBlank() ? "<unkeyed>" : region.getLoadKey();
|
||||
throw new IllegalStateException(region.getLandBiomes().isEmpty()
|
||||
? "Region '" + regionKey + "' has no landBiomes; every region needs at least one land biome."
|
||||
: "Region '" + regionKey + "' has no landBiomes this Minecraft version can generate; every listed land biome is excluded.");
|
||||
}
|
||||
|
||||
/** Whether any prepared region left the given biome list empty. */
|
||||
static boolean lacks(Map<IrisRegion, Map<InferredType, ProceduralStream<IrisBiome>>> streams, InferredType inferredType) {
|
||||
for (Map<InferredType, ProceduralStream<IrisBiome>> regionStreams : streams.values()) {
|
||||
if (regionStreams.get(inferredType) == NO_BIOMES) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** The biome list a spot's base biome comes from: the continent's choice, or land where the region has no sea. */
|
||||
static InferredType baseType(
|
||||
Map<IrisRegion, Map<InferredType, ProceduralStream<IrisBiome>>> streams,
|
||||
IrisRegion region,
|
||||
InferredType continent
|
||||
) {
|
||||
return continent == InferredType.SEA && preparedInferredBiomeStream(streams, region, InferredType.SEA) == NO_BIOMES
|
||||
? InferredType.LAND
|
||||
: continent;
|
||||
}
|
||||
|
||||
/** The biome list the given region picks this spot's base biome from. */
|
||||
public InferredType baseTypeIn(IrisRegion region, double x, double z) {
|
||||
return baseTypeStream == bridgeStream ? bridgeStream.get(x, z) : baseType(inferredBiomeStreams, region, bridgeStream.get(x, z));
|
||||
}
|
||||
|
||||
private ProceduralStream<Double> biomePickNoiseStream(IrisDimension dimension, IrisRegion region, InferredType inferredType) {
|
||||
@@ -1252,7 +1308,7 @@ public class IrisComplex implements DataProvider {
|
||||
if (focusBiome != null) {
|
||||
return new BiomePick(focusBiome, focusBiome.getInferredType());
|
||||
}
|
||||
InferredType type = bridgeStream.get(x, z);
|
||||
InferredType type = baseTypeIn(region, x, z);
|
||||
return new BiomePick(implode(createInferredBiomeStream(region, type).get(x, z), x, z), type);
|
||||
}
|
||||
|
||||
@@ -1666,7 +1722,7 @@ public class IrisComplex implements DataProvider {
|
||||
|
||||
public boolean isHistoricalChunk(int chunkX, int chunkZ) {
|
||||
return transitionGenerationPlan != null
|
||||
&& transitionGenerationPlan.boundary().isHistoricalChunk(chunkX, chunkZ);
|
||||
&& transitionGenerationPlan.isHistoricalChunk(chunkX, chunkZ);
|
||||
}
|
||||
|
||||
public boolean allowsMantleWrite(int blockX, int blockZ) {
|
||||
@@ -1676,7 +1732,7 @@ public class IrisComplex implements DataProvider {
|
||||
|
||||
public boolean allowsMantleChunkWrite(int chunkX, int chunkZ) {
|
||||
return transitionGenerationPlan == null
|
||||
|| !transitionGenerationPlan.boundary().isHistoricalChunk(chunkX, chunkZ);
|
||||
|| !transitionGenerationPlan.isHistoricalChunk(chunkX, chunkZ);
|
||||
}
|
||||
|
||||
public boolean allowsNewDiscreteContentAt(int blockX, int blockZ) {
|
||||
@@ -1709,10 +1765,8 @@ public class IrisComplex implements DataProvider {
|
||||
if (!transitionGenerationPlan.allowsNewFootprint(minimumX, minimumZ, maximumX, maximumZ)) {
|
||||
return false;
|
||||
}
|
||||
GenerationHistoryRuntimeRouter router = terrainEngine instanceof IrisEngine irisEngine
|
||||
? irisEngine.getGenerationHistoryRuntimeRouter().orElse(null) : null;
|
||||
return router == null || router.allowsObjectFootprint(transitionGenerationPlan,
|
||||
new ObjectContinuationBundle.Bounds(minimumX, minimumZ, maximumX, maximumZ));
|
||||
return !(terrainEngine instanceof IrisEngine irisEngine) || irisEngine.getGenerationSource()
|
||||
.transitions().allowsObjectFootprint(transitionGenerationPlan, minimumX, minimumZ, maximumX, maximumZ);
|
||||
}
|
||||
|
||||
public Optional<String> historicalPhysicalBiomeKeyAt(int blockX, int blockY, int blockZ) {
|
||||
@@ -1924,7 +1978,7 @@ public class IrisComplex implements DataProvider {
|
||||
|
||||
if (height >= fluidHeight - 1 && !biome.isShore()) {
|
||||
if (!aboveShoreBand(height, region, x, z, fluidHeight, shoreSlopes)) {
|
||||
return shoreBiomes.get(x, z);
|
||||
return convertedOrKept(shoreBiomes.get(x, z), biome);
|
||||
}
|
||||
if (!biome.isLand()) {
|
||||
return landBiomes.get(x, z);
|
||||
@@ -1934,16 +1988,21 @@ public class IrisComplex implements DataProvider {
|
||||
}
|
||||
|
||||
if (height < fluidHeight && !biome.isAquatic()) {
|
||||
return seaBiomes.get(x, z);
|
||||
return convertedOrKept(seaBiomes.get(x, z), biome);
|
||||
}
|
||||
|
||||
if (height == fluidHeight && !biome.isShore()) {
|
||||
return shoreBiomes.get(x, z);
|
||||
return convertedOrKept(shoreBiomes.get(x, z), biome);
|
||||
}
|
||||
|
||||
return biome;
|
||||
}
|
||||
|
||||
// A null conversion comes from NO_BIOMES: the region lists no biomes of that type, so the column keeps its own.
|
||||
private static IrisBiome convertedOrKept(IrisBiome converted, IrisBiome biome) {
|
||||
return converted == null ? biome : converted;
|
||||
}
|
||||
|
||||
private double interpolateGenerators(Engine engine, IrisInterpolator interpolator, int interpolatorIndex, IrisGenerator[] generators, double x, double z, long seed) {
|
||||
if (generators.length == 0) {
|
||||
return 0;
|
||||
@@ -2536,7 +2595,7 @@ public class IrisComplex implements DataProvider {
|
||||
|
||||
private List<IrisBiome> childLineage(IrisBiome biome, int x, int z) {
|
||||
IrisBiome[] rootFirst = new IrisBiome[IrisBiome.CHILD_HOPS + 1];
|
||||
IrisBiome current = inferredByType.get(bridgeStream.get(x, z)).get(x, z);
|
||||
IrisBiome current = inferredByType.get(baseTypeStream.get(x, z)).get(x, z);
|
||||
rootFirst[0] = current;
|
||||
int size = 1;
|
||||
for (int hop = 0; hop < IrisBiome.CHILD_HOPS && !current.getChildren().isEmpty(); hop++) {
|
||||
@@ -2885,7 +2944,7 @@ public class IrisComplex implements DataProvider {
|
||||
if (constant != null) {
|
||||
return constant;
|
||||
}
|
||||
InferredType type = pick != null ? pick.type() : complex.bridgeStream.get(x, z);
|
||||
InferredType type = pick != null ? pick.type() : complex.baseTypeIn(region, x, z);
|
||||
constant = constants == null ? null : constants.typed(type, group);
|
||||
if (constant != null) {
|
||||
return constant;
|
||||
|
||||
@@ -30,6 +30,7 @@ import art.arcane.iris.structure.nativegen.NativeStructureOwnershipStore;
|
||||
import art.arcane.iris.world.history.GenerationBoundarySignatureSampler;
|
||||
import art.arcane.iris.world.history.GenerationHistory;
|
||||
import art.arcane.iris.world.history.GenerationHistoryRuntimeRouter;
|
||||
import art.arcane.iris.world.history.VersionedGenerationSource;
|
||||
import art.arcane.iris.world.history.ChunkGenerationSemantics;
|
||||
import art.arcane.iris.world.history.GenerationKernelRegistry;
|
||||
import art.arcane.iris.world.history.TransitionGenerationPlan;
|
||||
@@ -176,9 +177,8 @@ public class IrisEngine implements Engine {
|
||||
@Getter(AccessLevel.NONE)
|
||||
@Setter(AccessLevel.NONE)
|
||||
volatile GenerationHistoryRuntimeRouter generationHistoryRuntimeRouter;
|
||||
@Getter(AccessLevel.NONE)
|
||||
@Setter(AccessLevel.NONE)
|
||||
private volatile boolean generationHistoryRoutingRequired;
|
||||
private volatile GenerationSource generationSource = GenerationSource.singlePack();
|
||||
@Getter(AccessLevel.NONE)
|
||||
@Setter(AccessLevel.NONE)
|
||||
private volatile SubterrainGate subterrainGate;
|
||||
@@ -499,8 +499,7 @@ public class IrisEngine implements Engine {
|
||||
@Override
|
||||
public void generateMatter(int x, int z, boolean multicore, ChunkContext context) {
|
||||
awaitGenerationCacheWarm();
|
||||
try (GenerationHistoryRuntimeRouter.CoordinateScope historyScope =
|
||||
openGenerationHistoryCoordinateScope(x << 4, z << 4);
|
||||
try (GenerationScope historyScope = openGenerationScope(x << 4, z << 4);
|
||||
GenerationSessionLease lease = acquireGenerationLease("matter_generate");
|
||||
IrisContext.Scope ignored = IrisContext.open(this, lease.sessionId(), context)) {
|
||||
IrisComplex activeComplex = getComplex();
|
||||
@@ -525,12 +524,12 @@ public class IrisEngine implements Engine {
|
||||
if (!usesSavedBiomeEnvironment()) {
|
||||
return Engine.super.draw(x, z);
|
||||
}
|
||||
return generationHistoryRuntimeRouter.biomes().readSurfaceBiome(x, z, saved -> {
|
||||
return getGenerationSource().savedBiomes().readSurface(x, z, saved -> {
|
||||
if (saved.isPresent()) {
|
||||
return drawBiomeEnvironment(x, z, saved.get());
|
||||
}
|
||||
try (GenerationHistoryRuntimeRouter.CoordinateScope ignored =
|
||||
openGenerationHistoryReadScope(x, z, "draw a pregeneration preview")) {
|
||||
try (GenerationScope ignored =
|
||||
openReadScope(x, z, "draw a pregeneration preview")) {
|
||||
return Engine.super.draw(x, z);
|
||||
}
|
||||
});
|
||||
@@ -554,8 +553,8 @@ public class IrisEngine implements Engine {
|
||||
return CompletableFuture.completedFuture(getBiomeEnvironment(x, y, z));
|
||||
}
|
||||
int worldY = y + getWorld().minHeight();
|
||||
return generationHistoryRuntimeRouter.biomes().readChunkAsync(Math.floorDiv(x, 16), Math.floorDiv(z, 16))
|
||||
.thenApply(session -> session.resolve(x, worldY, z, false)
|
||||
return getGenerationSource().savedBiomes().readChunk(Math.floorDiv(x, 16), Math.floorDiv(z, 16))
|
||||
.thenApply(read -> read.flatMap(session -> session.resolve(x, worldY, z, false))
|
||||
.orElseGet(() -> resolveUnsavedBiomeEnvironment(x, y, z)));
|
||||
} catch (RuntimeException | Error failure) {
|
||||
return CompletableFuture.failedFuture(failure);
|
||||
@@ -568,8 +567,8 @@ public class IrisEngine implements Engine {
|
||||
if (saved.isPresent()) {
|
||||
return saved.get();
|
||||
}
|
||||
try (GenerationHistoryRuntimeRouter.CoordinateScope ignored =
|
||||
openGenerationHistoryReadScope(x, z, "resolve a mantle biome environment")) {
|
||||
try (GenerationScope ignored =
|
||||
openReadScope(x, z, "resolve a mantle biome environment")) {
|
||||
return Engine.super.getBiomeOrMantleEnvironment(x, y, z);
|
||||
}
|
||||
}
|
||||
@@ -580,8 +579,8 @@ public class IrisEngine implements Engine {
|
||||
if (saved.isPresent()) {
|
||||
return saved.get();
|
||||
}
|
||||
try (GenerationHistoryRuntimeRouter.CoordinateScope ignored =
|
||||
openGenerationHistoryReadScope(x, z, "resolve a surface biome environment")) {
|
||||
try (GenerationScope ignored =
|
||||
openReadScope(x, z, "resolve a surface biome environment")) {
|
||||
return Engine.super.getSurfaceBiomeEnvironment(x, z);
|
||||
}
|
||||
}
|
||||
@@ -595,8 +594,8 @@ public class IrisEngine implements Engine {
|
||||
}
|
||||
|
||||
private BiomeEnvironment resolveUnsavedBiomeEnvironment(int x, int y, int z) {
|
||||
try (GenerationHistoryRuntimeRouter.CoordinateScope ignored =
|
||||
openGenerationHistoryReadScope(x, z, "resolve a biome environment")) {
|
||||
try (GenerationScope ignored =
|
||||
openReadScope(x, z, "resolve a biome environment")) {
|
||||
return Engine.super.getBiomeEnvironment(x, y, z);
|
||||
}
|
||||
}
|
||||
@@ -605,11 +604,11 @@ public class IrisEngine implements Engine {
|
||||
if (!usesSavedBiomeEnvironment()) {
|
||||
return Optional.empty();
|
||||
}
|
||||
return generationHistoryRuntimeRouter.biomes().resolve(x, y + getWorld().minHeight(), z, surface);
|
||||
return getGenerationSource().savedBiomes().at(x, y + getWorld().minHeight(), z, surface);
|
||||
}
|
||||
|
||||
private boolean usesSavedBiomeEnvironment() {
|
||||
if (hasGenerationRuntimeScope() || generationHistoryRuntimeRouter == null) {
|
||||
if (hasGenerationRuntimeScope() || !getGenerationSource().keepsPackVersions()) {
|
||||
return false;
|
||||
}
|
||||
IrisContext context = IrisContext.get();
|
||||
@@ -620,10 +619,9 @@ public class IrisEngine implements Engine {
|
||||
@Override
|
||||
public SubterrainCell getSubterrainCell(int x, int y, int z) {
|
||||
EngineThreadState.Frame frame = threadState.current();
|
||||
GenerationHistoryRuntimeRouter router = generationHistoryRuntimeRouter;
|
||||
if ((frame == null || frame.binding == null) && router != null) {
|
||||
Optional<SubterrainCell> saved = router.biomes()
|
||||
.subterrainCell(x, y + targetIn(frame).getWorld().minHeight(), z);
|
||||
if ((frame == null || frame.binding == null) && getGenerationSource().keepsPackVersions()) {
|
||||
Optional<SubterrainCell> saved = generationSource
|
||||
.savedBiomes().subterrainCellAt(x, y + targetIn(frame).getWorld().minHeight(), z);
|
||||
if (saved.isPresent()) {
|
||||
return saved.get();
|
||||
}
|
||||
@@ -645,7 +643,7 @@ public class IrisEngine implements Engine {
|
||||
@ChunkCoordinates
|
||||
public SubterrainChunkCells subterrainChunkCells(int chunkX, int chunkZ) {
|
||||
EngineThreadState.Frame frame = threadState.current();
|
||||
if ((frame == null || frame.binding == null) && generationHistoryRuntimeRouter != null) {
|
||||
if ((frame == null || frame.binding == null) && getGenerationSource().keepsPackVersions()) {
|
||||
return SubterrainChunkCells.delegated(this);
|
||||
}
|
||||
SubterrainPlanner planner = subterrainPlannerIn(frame);
|
||||
@@ -673,7 +671,7 @@ public class IrisEngine implements Engine {
|
||||
@ChunkCoordinates
|
||||
@Override
|
||||
public boolean subterrainAbsentInChunk(int chunkX, int chunkZ) {
|
||||
if (!hasGenerationRuntimeScope() && generationHistoryRuntimeRouter != null) {
|
||||
if (!hasGenerationRuntimeScope() && getGenerationSource().keepsPackVersions()) {
|
||||
return false;
|
||||
}
|
||||
return Engine.super.subterrainAbsentInChunk(chunkX, chunkZ);
|
||||
@@ -698,8 +696,8 @@ public class IrisEngine implements Engine {
|
||||
if (saved.isPresent()) {
|
||||
return saved.get().biome();
|
||||
}
|
||||
try (GenerationHistoryRuntimeRouter.CoordinateScope ignored =
|
||||
openGenerationHistoryReadScope(x, z, "resolve a biome")) {
|
||||
try (GenerationScope ignored =
|
||||
openReadScope(x, z, "resolve a biome")) {
|
||||
return Engine.super.getBiome(x, y, z);
|
||||
}
|
||||
}
|
||||
@@ -711,8 +709,8 @@ public class IrisEngine implements Engine {
|
||||
if (saved.isPresent()) {
|
||||
return saved.get().biome();
|
||||
}
|
||||
try (GenerationHistoryRuntimeRouter.CoordinateScope ignored =
|
||||
openGenerationHistoryReadScope(x, z, "resolve a biome or mantle biome")) {
|
||||
try (GenerationScope ignored =
|
||||
openReadScope(x, z, "resolve a biome or mantle biome")) {
|
||||
return Engine.super.getBiomeOrMantle(x, y, z);
|
||||
}
|
||||
}
|
||||
@@ -727,8 +725,8 @@ public class IrisEngine implements Engine {
|
||||
}
|
||||
return;
|
||||
}
|
||||
try (GenerationHistoryRuntimeRouter.CoordinateScope ignored =
|
||||
openGenerationHistoryReadScope(x, z, "resolve a biome or mantle biome column")) {
|
||||
try (GenerationScope ignored =
|
||||
openReadScope(x, z, "resolve a biome or mantle biome column")) {
|
||||
Engine.super.getBiomeOrMantleColumn(x, z, step, biomes, regions);
|
||||
}
|
||||
}
|
||||
@@ -740,8 +738,8 @@ public class IrisEngine implements Engine {
|
||||
if (saved.isPresent()) {
|
||||
return saved.get().region();
|
||||
}
|
||||
try (GenerationHistoryRuntimeRouter.CoordinateScope ignored =
|
||||
openGenerationHistoryReadScope(x, z, "resolve a region")) {
|
||||
try (GenerationScope ignored =
|
||||
openReadScope(x, z, "resolve a region")) {
|
||||
return Engine.super.getRegion(x, z);
|
||||
}
|
||||
}
|
||||
@@ -753,8 +751,8 @@ public class IrisEngine implements Engine {
|
||||
if (saved.isPresent()) {
|
||||
return saved.get().region();
|
||||
}
|
||||
try (GenerationHistoryRuntimeRouter.CoordinateScope ignored =
|
||||
openGenerationHistoryReadScope(x, z, "resolve a vertical region")) {
|
||||
try (GenerationScope ignored =
|
||||
openReadScope(x, z, "resolve a vertical region")) {
|
||||
return Engine.super.getRegion(x, y, z);
|
||||
}
|
||||
}
|
||||
@@ -766,8 +764,8 @@ public class IrisEngine implements Engine {
|
||||
if (saved.isPresent()) {
|
||||
return saved.get().biome();
|
||||
}
|
||||
try (GenerationHistoryRuntimeRouter.CoordinateScope ignored =
|
||||
openGenerationHistoryReadScope(x, z, "resolve a cave or mantle biome")) {
|
||||
try (GenerationScope ignored =
|
||||
openReadScope(x, z, "resolve a cave or mantle biome")) {
|
||||
return Engine.super.getCaveOrMantleBiome(x, y, z);
|
||||
}
|
||||
}
|
||||
@@ -776,7 +774,7 @@ public class IrisEngine implements Engine {
|
||||
@Override
|
||||
public IrisBiome getCaveBiome(int x, int z) {
|
||||
if (usesSavedBiomeEnvironment()) {
|
||||
Optional<BiomeEnvironment> saved = generationHistoryRuntimeRouter.biomes().resolveCaveBase(x, z);
|
||||
Optional<BiomeEnvironment> saved = getGenerationSource().savedBiomes().caveBaseAt(x, z);
|
||||
if (saved.isPresent()) {
|
||||
return saved.get().biome();
|
||||
}
|
||||
@@ -784,8 +782,8 @@ public class IrisEngine implements Engine {
|
||||
if (usesScopedNaturalTerrain()) {
|
||||
return Engine.super.getCaveBiome(x, z);
|
||||
}
|
||||
try (GenerationHistoryRuntimeRouter.CoordinateScope ignored =
|
||||
openGenerationHistoryReadScope(x, z, "resolve a cave biome")) {
|
||||
try (GenerationScope ignored =
|
||||
openReadScope(x, z, "resolve a cave biome")) {
|
||||
return Engine.super.getCaveBiome(x, z);
|
||||
}
|
||||
}
|
||||
@@ -811,8 +809,8 @@ public class IrisEngine implements Engine {
|
||||
if (usesScopedNaturalTerrain()) {
|
||||
return Engine.super.getCaveBiome(x, y, z, state);
|
||||
}
|
||||
try (GenerationHistoryRuntimeRouter.CoordinateScope ignored =
|
||||
openGenerationHistoryReadScope(x, z, "resolve a vertical cave biome")) {
|
||||
try (GenerationScope ignored =
|
||||
openReadScope(x, z, "resolve a vertical cave biome")) {
|
||||
return Engine.super.getCaveBiome(x, y, z, state);
|
||||
}
|
||||
}
|
||||
@@ -827,8 +825,8 @@ public class IrisEngine implements Engine {
|
||||
if (usesScopedNaturalTerrain()) {
|
||||
return Engine.super.getSurfaceBiome(x, z);
|
||||
}
|
||||
try (GenerationHistoryRuntimeRouter.CoordinateScope ignored =
|
||||
openGenerationHistoryReadScope(x, z, "resolve a surface biome")) {
|
||||
try (GenerationScope ignored =
|
||||
openReadScope(x, z, "resolve a surface biome")) {
|
||||
return Engine.super.getSurfaceBiome(x, z);
|
||||
}
|
||||
}
|
||||
@@ -836,8 +834,8 @@ public class IrisEngine implements Engine {
|
||||
@BlockCoordinates
|
||||
@Override
|
||||
public double getSlope(int x, int z) {
|
||||
try (GenerationHistoryRuntimeRouter.CoordinateScope ignored =
|
||||
openGenerationHistoryReadScope(x, z, "resolve terrain slope")) {
|
||||
try (GenerationScope ignored =
|
||||
openReadScope(x, z, "resolve terrain slope")) {
|
||||
return Engine.super.getSlope(x, z);
|
||||
}
|
||||
}
|
||||
@@ -851,8 +849,8 @@ public class IrisEngine implements Engine {
|
||||
@BlockCoordinates
|
||||
@Override
|
||||
public int getHeight(int x, int z, boolean ignoreFluid) {
|
||||
try (GenerationHistoryRuntimeRouter.CoordinateScope ignored =
|
||||
openGenerationHistoryReadScope(x, z, "resolve terrain height")) {
|
||||
try (GenerationScope ignored =
|
||||
openReadScope(x, z, "resolve terrain height")) {
|
||||
return Engine.super.getHeight(x, z, ignoreFluid);
|
||||
}
|
||||
}
|
||||
@@ -860,12 +858,12 @@ public class IrisEngine implements Engine {
|
||||
@ChunkCoordinates
|
||||
@Override
|
||||
public Set<String> getObjectsAt(int x, int z) {
|
||||
Optional<ChunkGenerationSemantics> recorded = recordedChunkSemantics(x, z);
|
||||
Optional<ChunkGenerationSemantics> recorded = getGenerationSource().recordedChunks().semantics(x, z);
|
||||
if (recorded.isPresent()) {
|
||||
return recorded.get().objectKeys();
|
||||
}
|
||||
try (GenerationHistoryRuntimeRouter.CoordinateScope ignored =
|
||||
openGenerationHistoryReadScope(x << 4, z << 4, "resolve chunk objects")) {
|
||||
try (GenerationScope ignored =
|
||||
openReadScope(x << 4, z << 4, "resolve chunk objects")) {
|
||||
return getMantle().getObjectComponent().guess(x, z);
|
||||
}
|
||||
}
|
||||
@@ -873,12 +871,12 @@ public class IrisEngine implements Engine {
|
||||
@ChunkCoordinates
|
||||
@Override
|
||||
public Set<ChunkGenerationSemantics.PointOfInterest> getPOIsAt(int chunkX, int chunkZ) {
|
||||
Optional<ChunkGenerationSemantics> recorded = recordedChunkSemantics(chunkX, chunkZ);
|
||||
Optional<ChunkGenerationSemantics> recorded = getGenerationSource().recordedChunks().semantics(chunkX, chunkZ);
|
||||
if (recorded.isPresent()) {
|
||||
return new HashSet<>(recorded.get().pointsOfInterest());
|
||||
}
|
||||
try (GenerationHistoryRuntimeRouter.CoordinateScope ignored =
|
||||
openGenerationHistoryReadScope(
|
||||
try (GenerationScope ignored =
|
||||
openReadScope(
|
||||
chunkX << 4, chunkZ << 4, "resolve chunk points of interest")) {
|
||||
Set<ChunkGenerationSemantics.PointOfInterest> pois = new HashSet<>();
|
||||
getMantle().getMantle().iterateChunk(
|
||||
@@ -892,12 +890,6 @@ public class IrisEngine implements Engine {
|
||||
}
|
||||
}
|
||||
|
||||
private Optional<ChunkGenerationSemantics> recordedChunkSemantics(int chunkX, int chunkZ) {
|
||||
GenerationHistoryRuntimeRouter router = getGenerationHistoryRuntimeRouter().orElse(null);
|
||||
return router == null ? Optional.empty()
|
||||
: router.history().semantics(chunkX, chunkZ).filter(ChunkGenerationSemantics::sealed);
|
||||
}
|
||||
|
||||
private void warmupChunk(int x, int z) {
|
||||
for (int i = 0; i < 16; i++) {
|
||||
for (int j = 0; j < 16; j++) {
|
||||
@@ -973,8 +965,8 @@ public class IrisEngine implements Engine {
|
||||
int queryMaximumX = Math.min(maximumX, chunkMinimumX + 15);
|
||||
int queryMinimumZ = Math.max(minimumZ, chunkMinimumZ);
|
||||
int queryMaximumZ = Math.min(maximumZ, chunkMinimumZ + 15);
|
||||
try (GenerationHistoryRuntimeRouter.CoordinateScope ignored =
|
||||
openGenerationHistoryReadScope(
|
||||
try (GenerationScope ignored =
|
||||
openReadScope(
|
||||
chunkMinimumX,
|
||||
chunkMinimumZ,
|
||||
"resolve native structure volumes")) {
|
||||
@@ -1070,46 +1062,25 @@ public class IrisEngine implements Engine {
|
||||
return Optional.ofNullable(generationHistoryRuntimeRouter);
|
||||
}
|
||||
|
||||
public GenerationHistoryRuntimeRouter.CoordinateScope openGenerationHistoryCoordinateScope(
|
||||
int blockX,
|
||||
int blockZ
|
||||
) throws IOException {
|
||||
GenerationHistoryRuntimeRouter router = generationHistoryRuntimeRouter;
|
||||
if (router != null) {
|
||||
return router.openCoordinateScope(blockX, blockZ);
|
||||
}
|
||||
if (!generationHistoryRoutingRequired) {
|
||||
return null;
|
||||
}
|
||||
router = generationHistoryRuntimeRouter;
|
||||
if (router == null) {
|
||||
throw new IllegalStateException("Iris generation-history runtime router is detached.");
|
||||
}
|
||||
return router.openCoordinateScope(blockX, blockZ);
|
||||
}
|
||||
|
||||
public boolean hasGenerationRuntimeScope() {
|
||||
return threadState.binding() != null;
|
||||
}
|
||||
|
||||
public boolean hasGenerationHistoryRouting() {
|
||||
return generationHistoryRuntimeRouter != null || generationHistoryRoutingRequired;
|
||||
}
|
||||
|
||||
private boolean usesScopedNaturalTerrain() {
|
||||
return hasGenerationRuntimeScope() && getComplex().isNaturalTerrainContext();
|
||||
}
|
||||
|
||||
private GenerationHistoryRuntimeRouter.CoordinateScope openGenerationHistoryReadScope(
|
||||
public GenerationScope openGenerationScope(int blockX, int blockZ) throws IOException {
|
||||
return getGenerationSource().openGenerationScope(blockX, blockZ);
|
||||
}
|
||||
|
||||
private GenerationScope openReadScope(
|
||||
int blockX,
|
||||
int blockZ,
|
||||
String operation
|
||||
) {
|
||||
try {
|
||||
GenerationHistoryRuntimeRouter router = generationHistoryRuntimeRouter;
|
||||
return router == null
|
||||
? openGenerationHistoryCoordinateScope(blockX, blockZ)
|
||||
: router.openReadScope(blockX, blockZ);
|
||||
return getGenerationSource().openReadScope(blockX, blockZ);
|
||||
} catch (IOException failure) {
|
||||
throw new IllegalStateException("Unable to " + operation + " through Iris generation history at "
|
||||
+ blockX + "," + blockZ + ".", failure);
|
||||
@@ -1129,7 +1100,7 @@ public class IrisEngine implements Engine {
|
||||
}
|
||||
shutdownSequence.retainGenerationHistory(required.history());
|
||||
generationHistoryRuntimeRouter = required;
|
||||
generationHistoryRoutingRequired = true;
|
||||
generationSource = new VersionedGenerationSource(required);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1137,11 +1108,18 @@ public class IrisEngine implements Engine {
|
||||
public void detachGenerationHistoryRuntimeRouter(GenerationHistoryRuntimeRouter router) {
|
||||
synchronized (generationHistoryRuntimeRouterLock) {
|
||||
if (generationHistoryRuntimeRouter == router) {
|
||||
generationHistoryRuntimeRouter = null;
|
||||
releaseGenerationHistoryRuntimeRouterLocked();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void releaseGenerationHistoryRuntimeRouterLocked() {
|
||||
generationHistoryRuntimeRouter = null;
|
||||
if (generationSource instanceof VersionedGenerationSource versioned) {
|
||||
versioned.detach();
|
||||
}
|
||||
}
|
||||
|
||||
void closeAttachedGenerationHistoryRuntimeRouter() {
|
||||
GenerationHistoryRuntimeRouter attached;
|
||||
synchronized (generationHistoryRuntimeRouterLock) {
|
||||
@@ -1153,7 +1131,7 @@ public class IrisEngine implements Engine {
|
||||
attached.close();
|
||||
synchronized (generationHistoryRuntimeRouterLock) {
|
||||
if (generationHistoryRuntimeRouter == attached) {
|
||||
generationHistoryRuntimeRouter = null;
|
||||
releaseGenerationHistoryRuntimeRouterLocked();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1639,8 +1617,7 @@ public class IrisEngine implements Engine {
|
||||
if (platformHooks.shouldRefuseGeneration(this)) {
|
||||
refuseMaintenanceGeneration(x >> 4, z >> 4);
|
||||
}
|
||||
try (GenerationHistoryRuntimeRouter.CoordinateScope historyScope =
|
||||
openGenerationHistoryCoordinateScope(x, z);
|
||||
try (GenerationScope historyScope = openGenerationScope(x, z);
|
||||
GenerationSessionLease lease = acquireGenerationLease("chunk_generate");
|
||||
IrisContext.Scope generationScope = IrisContext.open(this, lease.sessionId(), null)) {
|
||||
getEngineData().getStatistics().generatedChunk();
|
||||
@@ -1729,12 +1706,8 @@ public class IrisEngine implements Engine {
|
||||
|
||||
@Override
|
||||
public void syncGenerationHistory() {
|
||||
GenerationHistoryRuntimeRouter router = getGenerationHistoryRuntimeRouter().orElse(null);
|
||||
if (router == null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
router.history().sync();
|
||||
getGenerationSource().sync();
|
||||
} catch (IOException failure) {
|
||||
throw new IllegalStateException("Unable to force Iris generation history to stable storage for "
|
||||
+ getWorld().name() + ".", failure);
|
||||
|
||||
@@ -113,7 +113,7 @@ final class MarkerSpawnScanner {
|
||||
|
||||
private Map<IrisPosition, MarkerSpawnData> collectMarkerSpawnData(int chunkX, int chunkZ) {
|
||||
if (manager.getEngine() instanceof IrisEngine engine) {
|
||||
engine.getGenerationHistoryRuntimeRouter().ifPresent(router -> router.biomes().prepareChunk(chunkX, chunkZ));
|
||||
engine.getGenerationSource().savedBiomes().prepareChunk(chunkX, chunkZ);
|
||||
}
|
||||
Map<IrisPosition, MarkerSpawnData> markerData = new KMap<>();
|
||||
manager.getMantle().iterateChunk(chunkX, chunkZ, MatterMarker.class, (x, y, z, t) -> {
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package art.arcane.iris.generation.runtime;
|
||||
|
||||
import art.arcane.iris.world.history.FloatingBiomeOverlay;
|
||||
import art.arcane.iris.world.history.SavedTerrainChunk;
|
||||
import art.arcane.iris.world.history.TransitionGenerationPlan;
|
||||
import art.arcane.volmlib.util.matter.Matter;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Answers what generation reads and writes at the border between pack versions.
|
||||
*/
|
||||
public interface PackTransitions {
|
||||
/** Object fragments that earlier packs placed across the transition band into this chunk. */
|
||||
List<Matter> objectContinuations(TransitionGenerationPlan plan, int chunkX, int chunkZ) throws IOException;
|
||||
|
||||
boolean allowsObjectFootprint(TransitionGenerationPlan plan, int minimumX, int minimumZ, int maximumX, int maximumZ);
|
||||
|
||||
void recordNaturalTerrain(SavedTerrainChunk terrain, FloatingBiomeOverlay floatingBiomes);
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package art.arcane.iris.generation.runtime;
|
||||
|
||||
import art.arcane.iris.world.history.ChunkGenerationSemantics;
|
||||
import art.arcane.iris.world.history.GenerationSemanticIndex;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
/**
|
||||
* Answers what earlier generation recorded about each chunk, for locate and recorded lookups.
|
||||
*/
|
||||
public interface RecordedChunks {
|
||||
boolean ownedByEarlierPack(int chunkX, int chunkZ);
|
||||
|
||||
boolean hasUnrecordedEarlierPackChunkInSquare(int centerChunkX, int centerChunkZ, int radius);
|
||||
|
||||
Optional<ChunkGenerationSemantics> semantics(int chunkX, int chunkZ);
|
||||
|
||||
Optional<GenerationSemanticIndex.Match> findNearest(
|
||||
GenerationSemanticIndex.Query query,
|
||||
Predicate<ChunkGenerationSemantics> eligibility
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package art.arcane.iris.generation.runtime;
|
||||
|
||||
import art.arcane.iris.generation.subterrain.SubterrainCell;
|
||||
import art.arcane.iris.world.history.SavedBiomeRuntime;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* Answers which biomes an earlier pack version saved for the chunks it generated.
|
||||
*/
|
||||
public interface SavedBiomes {
|
||||
Optional<BiomeEnvironment> at(int blockX, int worldY, int blockZ, boolean surface);
|
||||
|
||||
Optional<BiomeEnvironment> caveBaseAt(int blockX, int blockZ);
|
||||
|
||||
Optional<SubterrainCell> subterrainCellAt(int blockX, int worldY, int blockZ);
|
||||
|
||||
<T> T readSurface(int blockX, int blockZ, Function<Optional<BiomeEnvironment>, T> reader)
|
||||
throws InterruptedException;
|
||||
|
||||
CompletableFuture<Optional<SavedBiomeRuntime.ReadSession>> readChunk(int chunkX, int chunkZ);
|
||||
|
||||
void prepareChunk(int chunkX, int chunkZ);
|
||||
|
||||
boolean mayHaveBlockDropRules(String material);
|
||||
}
|
||||
+174
@@ -0,0 +1,174 @@
|
||||
package art.arcane.iris.generation.runtime;
|
||||
|
||||
import art.arcane.iris.generation.subterrain.SubterrainCell;
|
||||
import art.arcane.iris.world.history.ChunkGenerationSemantics;
|
||||
import art.arcane.iris.world.history.FloatingBiomeOverlay;
|
||||
import art.arcane.iris.world.history.GenerationBoundary;
|
||||
import art.arcane.iris.world.history.GenerationSemanticIndex;
|
||||
import art.arcane.iris.world.history.SavedBiomeRuntime;
|
||||
import art.arcane.iris.world.history.SavedTerrainChunk;
|
||||
import art.arcane.iris.world.history.TransitionGenerationPlan;
|
||||
import art.arcane.volmlib.util.matter.Matter;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
/**
|
||||
* Every chunk belongs to the pack loaded now, so nothing is routed, recorded or stored.
|
||||
*/
|
||||
final class SinglePackGenerationSource implements GenerationSource {
|
||||
static final SinglePackGenerationSource INSTANCE = new SinglePackGenerationSource();
|
||||
private static final GenerationScope UNROUTED = new UnroutedScope();
|
||||
private static final SavedBiomes NO_SAVED_BIOMES = new NoSavedBiomes();
|
||||
private static final RecordedChunks NO_RECORDED_CHUNKS = new NoRecordedChunks();
|
||||
private static final PackTransitions NO_TRANSITIONS = new NoTransitions();
|
||||
|
||||
private SinglePackGenerationSource() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keepsPackVersions() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GenerationScope openGenerationScope(int blockX, int blockZ) {
|
||||
return UNROUTED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GenerationScope openReadScope(int blockX, int blockZ) {
|
||||
return UNROUTED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GenerationRoute openRoute(int chunkX, int chunkZ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<RouteOwnership> currentRouteOwnership() {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean predatesActivePack(long activationId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void releaseForRegeneration(List<GenerationBoundary.ChunkCoordinate> chunks) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sync() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public SavedBiomes savedBiomes() {
|
||||
return NO_SAVED_BIOMES;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecordedChunks recordedChunks() {
|
||||
return NO_RECORDED_CHUNKS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackTransitions transitions() {
|
||||
return NO_TRANSITIONS;
|
||||
}
|
||||
|
||||
private static final class UnroutedScope implements GenerationScope {
|
||||
@Override
|
||||
public boolean claimGeneratedSemantics() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
}
|
||||
}
|
||||
|
||||
private static final class NoSavedBiomes implements SavedBiomes {
|
||||
@Override
|
||||
public Optional<BiomeEnvironment> at(int blockX, int worldY, int blockZ, boolean surface) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<BiomeEnvironment> caveBaseAt(int blockX, int blockZ) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<SubterrainCell> subterrainCellAt(int blockX, int worldY, int blockZ) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T readSurface(int blockX, int blockZ, Function<Optional<BiomeEnvironment>, T> reader) {
|
||||
return reader.apply(Optional.empty());
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Optional<SavedBiomeRuntime.ReadSession>> readChunk(int chunkX, int chunkZ) {
|
||||
return CompletableFuture.completedFuture(Optional.empty());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void prepareChunk(int chunkX, int chunkZ) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mayHaveBlockDropRules(String material) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static final class NoRecordedChunks implements RecordedChunks {
|
||||
@Override
|
||||
public boolean ownedByEarlierPack(int chunkX, int chunkZ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasUnrecordedEarlierPackChunkInSquare(int centerChunkX, int centerChunkZ, int radius) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<ChunkGenerationSemantics> semantics(int chunkX, int chunkZ) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<GenerationSemanticIndex.Match> findNearest(
|
||||
GenerationSemanticIndex.Query query,
|
||||
Predicate<ChunkGenerationSemantics> eligibility
|
||||
) {
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
private static final class NoTransitions implements PackTransitions {
|
||||
@Override
|
||||
public List<Matter> objectContinuations(TransitionGenerationPlan plan, int chunkX, int chunkZ) {
|
||||
return List.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allowsObjectFootprint(
|
||||
TransitionGenerationPlan plan, int minimumX, int minimumZ, int maximumX, int maximumZ
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recordNaturalTerrain(SavedTerrainChunk terrain, FloatingBiomeOverlay floatingBiomes) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -308,7 +308,7 @@ final class WorldBlockDropRouter {
|
||||
return true;
|
||||
}
|
||||
if (manager.getEngine() instanceof IrisEngine engine) {
|
||||
return engine.getGenerationHistoryRuntimeRouter().map(router -> router.biomes().mayHaveBlockDropRules(material)).orElse(false);
|
||||
return engine.getGenerationSource().savedBiomes().mayHaveBlockDropRules(material);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1421,7 +1421,7 @@ public class IrisCarveModifier extends EngineAssignedModifier<NativeBlockState>
|
||||
&& context != null && context.getChunkContext() != null
|
||||
&& context.getChunkContext().getComplex() == complex;
|
||||
boolean natural = generating && context.getChunkContext().isNaturalTerrain();
|
||||
boolean unrouted = !bound && worker && !irisEngine.hasGenerationHistoryRouting();
|
||||
boolean unrouted = !bound && worker && !irisEngine.getGenerationSource().keepsPackVersions();
|
||||
boolean scoped = natural || generating && contentChunk || unrouted;
|
||||
this.subterrainFirst = unrouted;
|
||||
this.chunkLimited = !natural && !unrouted;
|
||||
|
||||
+1
-1
@@ -102,7 +102,7 @@ public class IrisFloatingChildBiomeModifier extends EngineAssignedModifier<Nativ
|
||||
}
|
||||
|
||||
try {
|
||||
generated.add(layer.get(random.nextParallelRNG(i + j), (wx + j) / layer.getZoom(), j, (wz - j) / layer.getZoom(), runtime));
|
||||
generated.add(layer.get(random.nextParallelRNG(i + j), (wx + j) / layer.blocksPerSample(), j, (wz - j) / layer.blocksPerSample(), runtime));
|
||||
} catch (Throwable e) {
|
||||
GenerationFailures.skipPlacement(e, "surface layer", "block", (int) wx, -1, (int) wz, "floating");
|
||||
}
|
||||
|
||||
+6
-2
@@ -85,7 +85,7 @@ public class IrisDimensionCarvingEntry {
|
||||
}
|
||||
|
||||
public CNG createChildrenGenerator(long childrenGeneratorSeed, PackRuntime runtime) {
|
||||
return getChildStyle().createScaledGenerator(deriveChildStyleSeed(childrenGeneratorSeed), runtime, childShrinkFactor());
|
||||
return getChildStyle().createScaledGenerator(deriveChildStyleSeed(childrenGeneratorSeed), runtime, childScale());
|
||||
}
|
||||
|
||||
long deriveChildrenGeneratorSeed(long worldSeed) {
|
||||
@@ -96,7 +96,11 @@ public class IrisDimensionCarvingEntry {
|
||||
return new RNG(childrenGeneratorSeed).nextParallelRNG(CHILDREN_SEED_SALT);
|
||||
}
|
||||
|
||||
private double childShrinkFactor() {
|
||||
private double childScale() {
|
||||
if (getChildStyle().isSeeded()) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return Math.max(MINIMUM_CHILD_SHRINK_FACTOR, getChildShrinkFactor());
|
||||
}
|
||||
|
||||
|
||||
@@ -85,10 +85,15 @@ public class IrisMaterialPalette implements StructurePalette {
|
||||
return localBlockData.get(0);
|
||||
}
|
||||
|
||||
CNG generator = getLayerGenerator(rng, runtime);
|
||||
if (style.isSeeded()) {
|
||||
return generator.fit(localBlockData, x, z);
|
||||
}
|
||||
|
||||
double scaledX = x / zoom;
|
||||
double scaledY = y / zoom;
|
||||
double scaledZ = z / zoom;
|
||||
return getLayerGenerator(rng, runtime).fit(localBlockData, scaledX, scaledY, scaledZ);
|
||||
return generator.fit(localBlockData, scaledX, scaledY, scaledZ);
|
||||
}
|
||||
|
||||
public Optional<TileData> getTile(RNG rng, double x, double y, double z, IrisData rdata) {
|
||||
|
||||
@@ -39,6 +39,8 @@ final class PackDimensionValidator {
|
||||
private static final String STYLE_SNIPPET_TYPE = "style";
|
||||
private static final String RANGE_SNIPPET_TYPE = "range";
|
||||
private static final Pattern RESOURCE_KEY = Pattern.compile("[a-z0-9_.-]+:[a-z0-9/._-]+");
|
||||
private static final int VANILLA_OVERWORLD_MIN_Y = -64;
|
||||
private static final int VANILLA_OVERWORLD_MAX_Y = 320;
|
||||
|
||||
private PackDimensionValidator() {
|
||||
}
|
||||
@@ -63,6 +65,7 @@ final class PackDimensionValidator {
|
||||
}
|
||||
|
||||
validateImportedStructurePolicy(dimensionKey, dimJson, blockingErrors, warnings);
|
||||
validateImportedFeatureHeight(packFolder, dimensionKey, dimJson, warnings);
|
||||
validateDimensionHeights(packFolder, dimensionKey, dimJson, blockingErrors);
|
||||
validateBorrowedDimensionType(dimensionKey, dimJson, borrowedDimensionTypesSupported(), blockingErrors);
|
||||
validateSamplingStep(dimensionKey, dimJson, "terrainSamplingStep", 1, blockingErrors);
|
||||
@@ -101,12 +104,13 @@ final class PackDimensionValidator {
|
||||
continue;
|
||||
}
|
||||
|
||||
int anyBiome = countBiomeRefs(regionJson, "landBiomes", biomesFolder, regionKey, warnings)
|
||||
+ countBiomeRefs(regionJson, "seaBiomes", biomesFolder, regionKey, warnings)
|
||||
+ countBiomeRefs(regionJson, "shoreBiomes", biomesFolder, regionKey, warnings)
|
||||
+ countBiomeRefs(regionJson, "caveBiomes", biomesFolder, regionKey, warnings);
|
||||
if (anyBiome == 0) {
|
||||
blockingErrors.add("Region '" + regionKey + "' has no resolvable biomes.");
|
||||
// Sea, shore and cave lists may be empty; land is what every other list falls back to.
|
||||
int landBiomes = countBiomeRefs(regionJson, "landBiomes", biomesFolder, regionKey, warnings);
|
||||
countBiomeRefs(regionJson, "seaBiomes", biomesFolder, regionKey, warnings);
|
||||
countBiomeRefs(regionJson, "shoreBiomes", biomesFolder, regionKey, warnings);
|
||||
countBiomeRefs(regionJson, "caveBiomes", biomesFolder, regionKey, warnings);
|
||||
if (landBiomes == 0) {
|
||||
blockingErrors.add("Region '" + regionKey + "' has no landBiomes; every region needs at least one land biome.");
|
||||
}
|
||||
resolvedRegions++;
|
||||
}
|
||||
@@ -278,6 +282,24 @@ final class PackDimensionValidator {
|
||||
}
|
||||
}
|
||||
|
||||
static void validateImportedFeatureHeight(File packFolder, String dimensionKey, JSONObject dimension,
|
||||
List<String> warnings) {
|
||||
JSONObject importedFeatures = dimension.optJSONObject("importedFeatures");
|
||||
if (importedFeatures == null || !importedFeatures.optBoolean("enabled", false)) {
|
||||
return;
|
||||
}
|
||||
JSONObject height = resolveDimensionHeight(packFolder, dimension);
|
||||
int minY = height == null ? VANILLA_OVERWORLD_MIN_Y : (int) height.optDouble("min", 16D);
|
||||
int maxY = height == null ? VANILLA_OVERWORLD_MAX_Y : (int) height.optDouble("max", 32D);
|
||||
// Vanilla anchors ore bands to the world bottom and top, so any height other than -64..320 moves them.
|
||||
if (minY == VANILLA_OVERWORLD_MIN_Y && maxY == VANILLA_OVERWORLD_MAX_Y) {
|
||||
return;
|
||||
}
|
||||
warnings.add("Dimension '" + dimensionKey + "' runs importedFeatures in a " + minY + ".." + maxY
|
||||
+ " world. Vanilla ores shift with the height; remove them with importedFeatures.disabled"
|
||||
+ " (minecraft:ore) or disabledSteps (UNDERGROUND_ORES).");
|
||||
}
|
||||
|
||||
static void validateStaticObjects(File packFolder, String dimensionKey, JSONObject dimension,
|
||||
List<String> blockingErrors) {
|
||||
if (!dimension.has("staticObjects")) {
|
||||
|
||||
@@ -211,6 +211,7 @@ public final class PackValidator {
|
||||
applyCompatFindings(minecraftVersion, dimensions.anyExcluded(), findings, blockingErrors, warnings);
|
||||
applyRequireAllContent(packFolder.getName(), dimensions.reachedByRequiringDimension(),
|
||||
minecraftVersion, findings, blockingErrors);
|
||||
addDistinct(blockingErrors, excludedLandErrors(data, dimensions.regionKeys(), minecraftVersion));
|
||||
return findings;
|
||||
} catch (Throwable e) {
|
||||
IrisLogging.reportError("Version-content gating failed for pack '" + packFolder.getName() + "'", e);
|
||||
@@ -239,6 +240,7 @@ public final class PackValidator {
|
||||
private static GatedDimensions loadEverything(File packFolder, IrisData data, File[] dimensionFiles) {
|
||||
boolean dimensionExcluded = false;
|
||||
Map<String, Set<String>> reachedByRequiringDimension = new LinkedHashMap<>();
|
||||
Set<String> regionKeys = new LinkedHashSet<>();
|
||||
List<String> folders = data.getLoaders().values().stream().map(ResourceLoader::getFolderName).toList();
|
||||
File dimensionsFolder = new File(packFolder, DIMENSIONS_FOLDER);
|
||||
for (File dimensionFile : dimensionFiles) {
|
||||
@@ -249,6 +251,8 @@ public final class PackValidator {
|
||||
}
|
||||
if (dimension.isCompatExcluded()) {
|
||||
dimensionExcluded = true;
|
||||
} else {
|
||||
regionKeys.addAll(dimension.getRegions());
|
||||
}
|
||||
if (dimension.isRequireAllContent()) {
|
||||
reachedByRequiringDimension.put(dimension.getLoadKey(), PackContentReach.referencedFrom(
|
||||
@@ -271,10 +275,31 @@ public final class PackValidator {
|
||||
for (IrisObjectPlacement placement : placements) {
|
||||
placement.evaluateCompat(data);
|
||||
}
|
||||
return new GatedDimensions(dimensionExcluded, reachedByRequiringDimension);
|
||||
return new GatedDimensions(dimensionExcluded, reachedByRequiringDimension, regionKeys);
|
||||
}
|
||||
|
||||
private record GatedDimensions(boolean anyExcluded, Map<String, Set<String>> reachedByRequiringDimension) {
|
||||
private record GatedDimensions(boolean anyExcluded, Map<String, Set<String>> reachedByRequiringDimension,
|
||||
Set<String> regionKeys) {
|
||||
}
|
||||
|
||||
/**
|
||||
* A region whose land biomes the version-content gate excluded cannot generate. Regions that list no land biome
|
||||
* at all are already reported by {@link PackDimensionValidator}.
|
||||
*/
|
||||
private static List<String> excludedLandErrors(IrisData data, Collection<String> regionKeys, String minecraftVersion) {
|
||||
List<String> errors = new ArrayList<>();
|
||||
for (String regionKey : regionKeys) {
|
||||
IrisRegion region = data.getRegionLoader().load(regionKey, false);
|
||||
if (region == null || region.isCompatExcluded()) {
|
||||
continue;
|
||||
}
|
||||
List<IrisBiome> land = data.getBiomeLoader().loadAll(region.getLandBiomes());
|
||||
if (!land.isEmpty() && land.stream().allMatch(IrisBiome::isCompatExcluded)) {
|
||||
errors.add("Region '" + regionKey + "' has no landBiomes Minecraft " + versionOrUnknown(minecraftVersion)
|
||||
+ " can generate; every listed land biome is excluded.");
|
||||
}
|
||||
}
|
||||
return errors;
|
||||
}
|
||||
|
||||
private static void collectPlacements(IrisRegistrant registrant, Set<IrisObjectPlacement> out) {
|
||||
|
||||
+19
-3
@@ -8,6 +8,7 @@ import art.arcane.iris.generation.noise.IrisStyledRange;
|
||||
import art.arcane.iris.pack.datapack.DataVersion;
|
||||
import art.arcane.iris.pack.datapack.export.ir.CostClass;
|
||||
import art.arcane.iris.pack.datapack.export.ir.ExportDiagnostic;
|
||||
import art.arcane.iris.pack.datapack.export.ir.ExportLimit;
|
||||
import art.arcane.iris.pack.datapack.export.ir.Field;
|
||||
import art.arcane.iris.pack.datapack.export.ir.NoiseDef;
|
||||
import art.arcane.iris.pack.datapack.export.lower.ExportCapabilities;
|
||||
@@ -23,6 +24,7 @@ import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.Function;
|
||||
|
||||
@@ -37,6 +39,8 @@ public final class NoiseStyleCompiler implements StyleCompiler {
|
||||
|
||||
private final CellularStyleLowering cellular;
|
||||
private final StyleCompiler selectors;
|
||||
private final List<ExportDiagnostic> diagnostics;
|
||||
private final Set<String> reportedSeeds = ConcurrentHashMap.newKeySet();
|
||||
private final Map<LeafKey, LeafNoiseFit.FittedLeaf> leaves = new ConcurrentHashMap<>();
|
||||
private final Map<LevelKey, WarpFit.LevelFit> levels = new ConcurrentHashMap<>();
|
||||
private final PackRuntime runtime = PackRuntime.standalone(null);
|
||||
@@ -44,17 +48,20 @@ public final class NoiseStyleCompiler implements StyleCompiler {
|
||||
public NoiseStyleCompiler(CellularStyleLowering cellular) {
|
||||
this.cellular = Objects.requireNonNull(cellular, "cellular");
|
||||
this.selectors = this;
|
||||
this.diagnostics = null;
|
||||
}
|
||||
|
||||
private NoiseStyleCompiler(Function<StyleCompiler, CellularStyleLowering> cellular, StyleCompiler selectors) {
|
||||
private NoiseStyleCompiler(Function<StyleCompiler, CellularStyleLowering> cellular, StyleCompiler selectors,
|
||||
List<ExportDiagnostic> diagnostics) {
|
||||
this.cellular = Objects.requireNonNull(cellular.apply(this), "cellular");
|
||||
this.selectors = selectors == null ? this : selectors;
|
||||
this.diagnostics = diagnostics;
|
||||
}
|
||||
|
||||
public static NoiseStyleCompiler create(List<ExportDiagnostic> diagnostics) {
|
||||
Objects.requireNonNull(diagnostics, "diagnostics");
|
||||
NoiseStyleCompiler selectors = new NoiseStyleCompiler(nested -> new DefaultCellularStyleLowering(diagnostics, nested::compile, CellularMode.QUADRANT_2X2), null);
|
||||
return new NoiseStyleCompiler(nested -> new DefaultCellularStyleLowering(diagnostics, nested::compile, CellularMode.GRID_3X3), selectors);
|
||||
NoiseStyleCompiler selectors = new NoiseStyleCompiler(nested -> new DefaultCellularStyleLowering(diagnostics, nested::compile, CellularMode.QUADRANT_2X2), null, diagnostics);
|
||||
return new NoiseStyleCompiler(nested -> new DefaultCellularStyleLowering(diagnostics, nested::compile, CellularMode.GRID_3X3), selectors, diagnostics);
|
||||
}
|
||||
|
||||
public static CNG generator(IrisGeneratorStyle style) {
|
||||
@@ -67,6 +74,14 @@ public final class NoiseStyleCompiler implements StyleCompiler {
|
||||
return style(Objects.requireNonNull(style, "style"), 1, Domain.IDENTITY, emit, "s");
|
||||
}
|
||||
|
||||
private void reportSeed(IrisGeneratorStyle style) {
|
||||
if (diagnostics == null || style == null || !style.isSeeded() || !reportedSeeds.add(String.valueOf(style.getSeed()))) {
|
||||
return;
|
||||
}
|
||||
diagnostics.add(new ExportDiagnostic(ExportDiagnostic.Severity.WARNING, ExportLimit.NOISE_STYLE, "",
|
||||
"Noise style seed " + style.getSeed() + " is not exported; the style uses its exported salt instead"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public StyleCompiler selectors() {
|
||||
return selectors;
|
||||
@@ -182,6 +197,7 @@ public final class NoiseStyleCompiler implements StyleCompiler {
|
||||
}
|
||||
|
||||
private Field style(IrisGeneratorStyle style, int octaveMultiplier, Domain domain, Emit emit, String path) {
|
||||
reportSeed(style);
|
||||
IrisGeneratorStyle prepared = prepared(Objects.requireNonNull(style, "noise style"), domain.zoom());
|
||||
String stylePath = path + "/" + styleName(style);
|
||||
CNG root = build(prepared, octaveMultiplier, runtime);
|
||||
|
||||
+6
@@ -101,6 +101,9 @@ public final class GeneratorCompiler {
|
||||
}
|
||||
|
||||
public Field style(IrisGeneratorStyle style, double zoom, String path) {
|
||||
if (style != null && style.isSeeded()) {
|
||||
report(path, "Noise style seed " + style.getSeed() + " is not exported; the style uses its exported salt instead");
|
||||
}
|
||||
return styles.compile(zoomed(style, zoom), salt(path), registry, capabilities);
|
||||
}
|
||||
|
||||
@@ -119,6 +122,9 @@ public final class GeneratorCompiler {
|
||||
if (generator.hasCliffs()) {
|
||||
value = new Field.Round(Field.RoundMode.ROUND, value, cliffStep(generator, root, path, resource, name));
|
||||
}
|
||||
if (generator.getExponent() != 1.0) {
|
||||
report(resource, "Generator exponent " + generator.getExponent() + " is not exported; the uncurved height is used");
|
||||
}
|
||||
if (generator.getCellFractureHeight() != 0.0) {
|
||||
report(resource, "Generator cell fracture is not exported; the unfractured height is used");
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ public class DataFixerV1217 extends DataFixerV1213 {
|
||||
attributes.put("minecraft:gameplay/bed_rule", new JSONObject()
|
||||
.put("can_set_spawn", "never")
|
||||
.put("can_sleep", "never")
|
||||
.put("explodes", true));
|
||||
.put("destroy_on_use", true));
|
||||
}
|
||||
|
||||
attributes.put("minecraft:gameplay/respawn_anchor_works", json.remove("respawn_anchor_works"));
|
||||
|
||||
@@ -63,14 +63,14 @@ public class ImageResourceLoader extends ResourceLoader<IrisImage> {
|
||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
try (ImageInputStream input = ImageIO.createImageInputStream(j)) {
|
||||
if (input == null) {
|
||||
IrisLogging.warn("Couldn't read " + resourceTypeName + " file: " + j.getPath()
|
||||
+ " (unsupported or corrupt image)");
|
||||
warnReadFailureOnce(j, "Couldn't read " + resourceTypeName + " file: " + j.getPath()
|
||||
+ " (unsupported or corrupt image)", null);
|
||||
return null;
|
||||
}
|
||||
Iterator<ImageReader> readers = ImageIO.getImageReaders(input);
|
||||
if (!readers.hasNext()) {
|
||||
IrisLogging.warn("Couldn't read " + resourceTypeName + " file: " + j.getPath()
|
||||
+ " (unsupported or corrupt image)");
|
||||
warnReadFailureOnce(j, "Couldn't read " + resourceTypeName + " file: " + j.getPath()
|
||||
+ " (unsupported or corrupt image)", null);
|
||||
return null;
|
||||
}
|
||||
ImageReader reader = readers.next();
|
||||
@@ -78,21 +78,21 @@ public class ImageResourceLoader extends ResourceLoader<IrisImage> {
|
||||
reader.setInput(input, true, true);
|
||||
String format = reader.getFormatName().toLowerCase(Locale.ROOT);
|
||||
if (!"png".equals(format)) {
|
||||
IrisLogging.warn("Couldn't read " + resourceTypeName + " file: " + j.getPath()
|
||||
+ " (expected PNG, got " + format + ")");
|
||||
warnReadFailureOnce(j, "Couldn't read " + resourceTypeName + " file: " + j.getPath()
|
||||
+ " (expected PNG, got " + format + ")", null);
|
||||
return null;
|
||||
}
|
||||
int width = reader.getWidth(0);
|
||||
int height = reader.getHeight(0);
|
||||
if (!supportedDimensions(width, height)) {
|
||||
IrisLogging.warn("Couldn't read " + resourceTypeName + " file: " + j.getPath()
|
||||
+ " (dimensions " + width + "x" + height + " exceed the supported image-map limits)");
|
||||
warnReadFailureOnce(j, "Couldn't read " + resourceTypeName + " file: " + j.getPath()
|
||||
+ " (dimensions " + width + "x" + height + " exceed the supported image-map limits)", null);
|
||||
return null;
|
||||
}
|
||||
BufferedImage image = reader.read(0);
|
||||
if (image == null) {
|
||||
IrisLogging.warn("Couldn't read " + resourceTypeName + " file: " + j.getPath()
|
||||
+ " (unsupported or corrupt image)");
|
||||
warnReadFailureOnce(j, "Couldn't read " + resourceTypeName + " file: " + j.getPath()
|
||||
+ " (unsupported or corrupt image)", null);
|
||||
return null;
|
||||
}
|
||||
IrisImage loaded = new IrisImage(image, format);
|
||||
@@ -107,8 +107,7 @@ public class ImageResourceLoader extends ResourceLoader<IrisImage> {
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
IrisLogging.reportError(e);
|
||||
IrisLogging.warn("Couldn't read " + resourceTypeName + " file: " + j.getPath() + ": " + e.getMessage());
|
||||
warnReadFailureOnce(j, "Couldn't read " + resourceTypeName + " file: " + j.getPath() + ": " + e.getMessage(), e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -180,7 +179,7 @@ public class ImageResourceLoader extends ResourceLoader<IrisImage> {
|
||||
return null;
|
||||
}
|
||||
if (name.equals("null")) {
|
||||
IrisLogging.warn("Refusing " + resourceTypeName + " lookup for literal string \"null\" (called by " + callerHint() + ")");
|
||||
warnLiteralNullOnce("lookup");
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -190,7 +189,7 @@ public class ImageResourceLoader extends ResourceLoader<IrisImage> {
|
||||
return file;
|
||||
}
|
||||
|
||||
IrisLogging.warn("Couldn't find " + resourceTypeName + ": " + name + " (called by " + callerHint() + ")");
|
||||
warnMissingOnce(name);
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -206,7 +205,7 @@ public class ImageResourceLoader extends ResourceLoader<IrisImage> {
|
||||
return loadFile(file, name);
|
||||
}
|
||||
|
||||
IrisLogging.warn("Couldn't find " + resourceTypeName + ": " + name + " (called by " + callerHint() + ")");
|
||||
warnMissingOnce(name);
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -216,7 +215,7 @@ public class ImageResourceLoader extends ResourceLoader<IrisImage> {
|
||||
return null;
|
||||
}
|
||||
if (name.equals("null") && warn) {
|
||||
IrisLogging.warn("Refusing " + resourceTypeName + " load for literal string \"null\" (called by " + callerHint() + ")");
|
||||
warnLiteralNullOnce("load");
|
||||
return null;
|
||||
}
|
||||
return loadCache.get(name);
|
||||
|
||||
@@ -121,6 +121,8 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
@Data
|
||||
public class IrisData implements ExclusionStrategy, TypeAdapterFactory {
|
||||
private static final int CUSTOM_BIOME_KEY_CACHE_LIMIT = 4096;
|
||||
private static final String PACK_ONCE_KEY_PREFIX = "pack|";
|
||||
private static final String PACK_ONCE_KEY_SEPARATOR = "|";
|
||||
private static final Map<File, IrisData> dataLoaders = new ConcurrentHashMap<>();
|
||||
// Loaders (cached or detached) that currently have registered engines; see hasActiveEngines.
|
||||
// Identity-keyed on purpose: Lombok's @Data hashCode over this class's mutable loader state
|
||||
@@ -741,6 +743,8 @@ public class IrisData implements ExclusionStrategy, TypeAdapterFactory {
|
||||
}
|
||||
|
||||
public synchronized void hotloaded() {
|
||||
// Studio hotload reopens or rebuilds the pack through here without ever calling clearLists().
|
||||
IrisLogging.forgetOnceKeys(onceKeyPrefix());
|
||||
blockDropMaterials = null;
|
||||
StructureGraphCatalog.invalidate(this);
|
||||
IrisObjectScale.invalidate(this);
|
||||
@@ -863,7 +867,28 @@ public class IrisData implements ExclusionStrategy, TypeAdapterFactory {
|
||||
throw failure;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prefix shared by every warn-once key that belongs to this pack, so {@link #clearLists()} can forget
|
||||
* them together. The trailing separator keeps {@code /packs/a} from matching {@code /packs/ab}.
|
||||
*/
|
||||
public String onceKeyPrefix() {
|
||||
return PACK_ONCE_KEY_PREFIX + dataFolder.getAbsolutePath() + PACK_ONCE_KEY_SEPARATOR;
|
||||
}
|
||||
|
||||
public String onceKey(String kind, String detail) {
|
||||
return onceKeyPrefix() + kind + PACK_ONCE_KEY_SEPARATOR + detail;
|
||||
}
|
||||
|
||||
/**
|
||||
* Key for a warning whose site may not know its pack: scoped to the pack when there is one so a
|
||||
* hotload forgets it, otherwise a plain stable key.
|
||||
*/
|
||||
public static String onceKey(IrisData data, String kind, String detail) {
|
||||
return data == null ? kind + PACK_ONCE_KEY_SEPARATOR + detail : data.onceKey(kind, detail);
|
||||
}
|
||||
|
||||
public void clearLists() {
|
||||
IrisLogging.forgetOnceKeys(onceKeyPrefix());
|
||||
blockDropMaterials = null;
|
||||
for (ResourceLoader<?> i : loaders.values()) {
|
||||
i.clearList();
|
||||
|
||||
@@ -58,8 +58,7 @@ public class MatterObjectResourceLoader extends ResourceLoader<IrisMatterObject>
|
||||
tlt.addAndGet(p.getMilliseconds());
|
||||
return t;
|
||||
} catch (Throwable e) {
|
||||
IrisLogging.reportError(e);
|
||||
IrisLogging.warn("Couldn't read " + resourceTypeName + " file: " + j.getPath() + ": " + e.getMessage());
|
||||
warnReadFailureOnce(j, "Couldn't read " + resourceTypeName + " file: " + j.getPath() + ": " + e.getMessage(), e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -120,7 +119,7 @@ public class MatterObjectResourceLoader extends ResourceLoader<IrisMatterObject>
|
||||
return null;
|
||||
}
|
||||
if (name.equals("null")) {
|
||||
IrisLogging.warn("Refusing " + resourceTypeName + " lookup for literal string \"null\" (called by " + callerHint() + ")");
|
||||
warnLiteralNullOnce("lookup");
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -130,7 +129,7 @@ public class MatterObjectResourceLoader extends ResourceLoader<IrisMatterObject>
|
||||
return file;
|
||||
}
|
||||
|
||||
IrisLogging.warn("Couldn't find " + resourceTypeName + ": " + name + " (called by " + callerHint() + ")");
|
||||
warnMissingOnce(name);
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -146,7 +145,7 @@ public class MatterObjectResourceLoader extends ResourceLoader<IrisMatterObject>
|
||||
return loadFile(file, name);
|
||||
}
|
||||
|
||||
IrisLogging.warn("Couldn't find " + resourceTypeName + ": " + name + " (called by " + callerHint() + ")");
|
||||
warnMissingOnce(name);
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -156,7 +155,7 @@ public class MatterObjectResourceLoader extends ResourceLoader<IrisMatterObject>
|
||||
return null;
|
||||
}
|
||||
if (name.equals("null") && warn) {
|
||||
IrisLogging.warn("Refusing " + resourceTypeName + " load for literal string \"null\" (called by " + callerHint() + ")");
|
||||
warnLiteralNullOnce("load");
|
||||
return null;
|
||||
}
|
||||
return loadCache.get(name);
|
||||
|
||||
@@ -60,13 +60,12 @@ public class ObjectResourceLoader extends ResourceLoader<IrisObject> {
|
||||
tlt.addAndGet(p.getMilliseconds());
|
||||
return t;
|
||||
} catch (Throwable e) {
|
||||
IrisLogging.reportError(e);
|
||||
String message = e.getMessage();
|
||||
String reason = e.getClass().getSimpleName();
|
||||
if (message != null && !message.isBlank()) {
|
||||
reason = reason + ": " + message;
|
||||
}
|
||||
IrisLogging.warn("Couldn't read " + resourceTypeName + " file: " + j.getPath() + " (" + reason + ")");
|
||||
warnReadFailureOnce(j, "Couldn't read " + resourceTypeName + " file: " + j.getPath() + " (" + reason + ")", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -127,7 +126,7 @@ public class ObjectResourceLoader extends ResourceLoader<IrisObject> {
|
||||
return null;
|
||||
}
|
||||
if (name.equals("null")) {
|
||||
IrisLogging.warn("Refusing " + resourceTypeName + " lookup for literal string \"null\" (called by " + callerHint() + ")");
|
||||
warnLiteralNullOnce("lookup");
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -137,7 +136,7 @@ public class ObjectResourceLoader extends ResourceLoader<IrisObject> {
|
||||
return file;
|
||||
}
|
||||
|
||||
IrisLogging.warn("Couldn't find " + resourceTypeName + ": " + name + " (called by " + callerHint() + ")");
|
||||
warnMissingOnce(name);
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -156,12 +155,12 @@ public class ObjectResourceLoader extends ResourceLoader<IrisObject> {
|
||||
return null;
|
||||
}
|
||||
if (name.equals("null") && warn) {
|
||||
IrisLogging.warn("Refusing " + resourceTypeName + " load for literal string \"null\" (called by " + callerHint() + ")");
|
||||
warnLiteralNullOnce("load");
|
||||
return null;
|
||||
}
|
||||
IrisObject result = loadCache.get(name);
|
||||
if (result == null && warn) {
|
||||
IrisLogging.warn("Couldn't find " + resourceTypeName + ": " + name + " (called by " + callerHint() + ")");
|
||||
warnMissingOnce(name);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -91,6 +91,9 @@ public class ResourceLoader<T extends IrisRegistrant> implements MeteredCache {
|
||||
private static final int PREFETCH_ENTRY_LIMIT = 1_024;
|
||||
private static final int PREFETCH_KEY_LENGTH_LIMIT = 1_024;
|
||||
private static final long PREFETCH_FILE_SIZE_LIMIT = 4L * 1_024L * 1_024L;
|
||||
private static final String MISSING_KEY_KIND = "missing:";
|
||||
private static final String LITERAL_NULL_KEY_KIND = "literal-null:";
|
||||
private static final String READ_KEY_KIND = "read:";
|
||||
private static volatile ExecutorService schemaBuildExecutor;
|
||||
private static final Set<String> schemaBuildQueue = ConcurrentHashMap.newKeySet();
|
||||
protected final AtomicCache<KList<File>> folderCache;
|
||||
@@ -217,7 +220,7 @@ public class ResourceLoader<T extends IrisRegistrant> implements MeteredCache {
|
||||
return null;
|
||||
}
|
||||
if (name.equals("null")) {
|
||||
IrisLogging.warn("Refusing " + resourceTypeName + " lookup for literal string \"null\" (called by " + callerHint() + ")");
|
||||
warnLiteralNullOnce("lookup");
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -227,7 +230,7 @@ public class ResourceLoader<T extends IrisRegistrant> implements MeteredCache {
|
||||
return file;
|
||||
}
|
||||
|
||||
IrisLogging.warn("Couldn't find " + resourceTypeName + ": " + name + " (called by " + callerHint() + ")");
|
||||
warnMissingOnce(name);
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -306,6 +309,27 @@ public class ResourceLoader<T extends IrisRegistrant> implements MeteredCache {
|
||||
.orElse("<unknown>"));
|
||||
}
|
||||
|
||||
protected void warnMissingOnce(String name) {
|
||||
IrisLogging.warnOnce(manager.onceKey(MISSING_KEY_KIND + resourceTypeName, name),
|
||||
() -> "Couldn't find " + resourceTypeName + ": " + name + " (called by " + callerHint() + ")");
|
||||
}
|
||||
|
||||
protected void warnLiteralNullOnce(String action) {
|
||||
IrisLogging.warnOnce(manager.onceKey(LITERAL_NULL_KEY_KIND + resourceTypeName, action),
|
||||
() -> "Refusing " + resourceTypeName + " " + action + " for literal string \"null\" (called by " + callerHint() + ")");
|
||||
}
|
||||
|
||||
/**
|
||||
* Warns once per file; only that first warning carries the stack trace, so a file that fails on every
|
||||
* lookup does not repeat it.
|
||||
*/
|
||||
protected void warnReadFailureOnce(File file, String message, Throwable failure) {
|
||||
String key = manager.onceKey(READ_KEY_KIND + resourceTypeName, file.getPath());
|
||||
if (IrisLogging.warnOnce(key, message) && failure != null) {
|
||||
IrisLogging.reportError(failure);
|
||||
}
|
||||
}
|
||||
|
||||
public void logLoad(File path, T t) {
|
||||
loads.getAndIncrement();
|
||||
|
||||
@@ -529,7 +553,7 @@ public class ResourceLoader<T extends IrisRegistrant> implements MeteredCache {
|
||||
return null;
|
||||
}
|
||||
if (name.equals("null") && warn) {
|
||||
IrisLogging.warn("Refusing " + resourceTypeName + " load for literal string \"null\" (called by " + callerHint() + ")");
|
||||
warnLiteralNullOnce("load");
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.iris.generation.stream.ProvisionalSampling;
|
||||
import art.arcane.iris.generation.runtime.GenerationSessionException;
|
||||
import art.arcane.iris.generation.runtime.GenerationSessionLease;
|
||||
import art.arcane.iris.world.history.GenerationHistoryRuntimeRouter;
|
||||
import art.arcane.iris.generation.runtime.GenerationScope;
|
||||
import art.arcane.iris.generation.biome.IrisBiome;
|
||||
import art.arcane.iris.generation.biome.IrisBiomeCustom;
|
||||
import art.arcane.iris.generation.terrain.IrisDimension;
|
||||
@@ -310,7 +310,7 @@ public final class BukkitBiomePolicy<H, V> implements NativeBiomeSourcePolicy<H>
|
||||
public H getNoiseBiome(int x, int y, int z) {
|
||||
int blockX = x << 2;
|
||||
int blockZ = z << 2;
|
||||
try (GenerationHistoryRuntimeRouter.CoordinateScope historyScope =
|
||||
try (GenerationScope historyScope =
|
||||
openHistoryCoordinateScope(blockX, blockZ, "bukkit_structure_biome");
|
||||
GenerationSessionLease lease = requireGenerationLease(
|
||||
"bukkit_structure_biome",
|
||||
@@ -436,7 +436,7 @@ public final class BukkitBiomePolicy<H, V> implements NativeBiomeSourcePolicy<H>
|
||||
}
|
||||
|
||||
private H locateVisibleBiomeHolder(int quartX, int quartY, int quartZ) {
|
||||
try (GenerationHistoryRuntimeRouter.CoordinateScope ignored = openHistoryCoordinateScope(
|
||||
try (GenerationScope ignored = openHistoryCoordinateScope(
|
||||
quartX << 2, quartZ << 2, "bukkit_locate_visible_biome")) {
|
||||
return resolveVisibleBiomeHolder(quartX, quartY, quartZ, null);
|
||||
}
|
||||
@@ -501,7 +501,7 @@ public final class BukkitBiomePolicy<H, V> implements NativeBiomeSourcePolicy<H>
|
||||
private H getSurfaceStructureBiomeHolder(int x, int z) {
|
||||
int blockX = x << 2;
|
||||
int blockZ = z << 2;
|
||||
try (GenerationHistoryRuntimeRouter.CoordinateScope historyScope =
|
||||
try (GenerationScope historyScope =
|
||||
openHistoryCoordinateScope(blockX, blockZ, "bukkit_surface_structure_biome")) {
|
||||
RuntimeColumnKey columnKey = new RuntimeColumnKey(
|
||||
engine.getCacheID(), packColumnKey(x, z));
|
||||
@@ -563,7 +563,7 @@ public final class BukkitBiomePolicy<H, V> implements NativeBiomeSourcePolicy<H>
|
||||
private H getNaturalSurfaceStructureBiomeHolder(int x, int z) {
|
||||
int blockX = x << 2;
|
||||
int blockZ = z << 2;
|
||||
try (GenerationHistoryRuntimeRouter.CoordinateScope historyScope =
|
||||
try (GenerationScope historyScope =
|
||||
openHistoryCoordinateScope(blockX, blockZ, "bukkit_natural_structure_biome")) {
|
||||
RuntimeColumnKey columnKey = new RuntimeColumnKey(
|
||||
engine.getCacheID(), packColumnKey(x, z));
|
||||
@@ -633,7 +633,7 @@ public final class BukkitBiomePolicy<H, V> implements NativeBiomeSourcePolicy<H>
|
||||
}
|
||||
|
||||
public H getVisibleNoiseBiome(int x, int y, int z) {
|
||||
try (GenerationHistoryRuntimeRouter.CoordinateScope historyScope = openHistoryCoordinateScope(
|
||||
try (GenerationScope historyScope = openHistoryCoordinateScope(
|
||||
x << 2, z << 2, "bukkit_visible_biome");
|
||||
GenerationSessionLease lease = requireGenerationLease(
|
||||
"bukkit_visible_biome",
|
||||
@@ -749,7 +749,7 @@ public final class BukkitBiomePolicy<H, V> implements NativeBiomeSourcePolicy<H>
|
||||
return !engine.isClosed() && engine.getComplex() != null;
|
||||
}
|
||||
|
||||
private GenerationHistoryRuntimeRouter.CoordinateScope openHistoryCoordinateScope(
|
||||
private GenerationScope openHistoryCoordinateScope(
|
||||
int blockX,
|
||||
int blockZ,
|
||||
String operation
|
||||
@@ -758,7 +758,7 @@ public final class BukkitBiomePolicy<H, V> implements NativeBiomeSourcePolicy<H>
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return irisEngine.openGenerationHistoryCoordinateScope(blockX, blockZ);
|
||||
return irisEngine.openGenerationScope(blockX, blockZ);
|
||||
} catch (IOException failure) {
|
||||
throw new IllegalStateException("Iris " + operation
|
||||
+ " could not route generation history at "
|
||||
|
||||
+10
-18
@@ -4,11 +4,10 @@ import art.arcane.iris.generation.context.IrisContext;
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.iris.generation.runtime.GenerationSessionException;
|
||||
import art.arcane.iris.generation.runtime.GenerationSessionLease;
|
||||
import art.arcane.iris.generation.runtime.GenerationRoute;
|
||||
import art.arcane.iris.generation.runtime.GenerationSource;
|
||||
import art.arcane.iris.generation.runtime.IrisEngine;
|
||||
import art.arcane.iris.platform.generation.BukkitChunkGenerator;
|
||||
import art.arcane.iris.world.history.GenerationHistoryRuntimeRouter;
|
||||
import art.arcane.iris.world.history.NativeTerrainReceipt;
|
||||
import art.arcane.iris.world.history.SavedTerrainChunk;
|
||||
import art.arcane.volmlib.nativelib.terrain.NativeGenerationLease;
|
||||
import art.arcane.volmlib.nativelib.terrain.NativeTerrainPipelinePolicy;
|
||||
import org.bukkit.NamespacedKey;
|
||||
@@ -16,7 +15,7 @@ import org.bukkit.NamespacedKey;
|
||||
import java.io.IOException;
|
||||
|
||||
public class BukkitGenerationPolicy
|
||||
implements NativeTerrainPipelinePolicy<GenerationHistoryRuntimeRouter.RuntimeRoute> {
|
||||
implements NativeTerrainPipelinePolicy<GenerationRoute> {
|
||||
private static final NamespacedKey NATURAL_TERRAIN = new NamespacedKey("iris", "natural_terrain");
|
||||
|
||||
private final Engine engine;
|
||||
@@ -44,19 +43,16 @@ public class BukkitGenerationPolicy
|
||||
}
|
||||
|
||||
@Override
|
||||
public GenerationHistoryRuntimeRouter.RuntimeRoute openRoute(int chunkX, int chunkZ, String operation) {
|
||||
public GenerationRoute openRoute(int chunkX, int chunkZ, String operation) {
|
||||
if (!(engine instanceof IrisEngine irisEngine)) {
|
||||
return null;
|
||||
}
|
||||
GenerationHistoryRuntimeRouter router = irisEngine.getGenerationHistoryRuntimeRouter().orElse(null);
|
||||
if (router == null) {
|
||||
if (generator != null && generator.getGenerationHistory() != null) {
|
||||
throw new IllegalStateException("Iris " + operation + " has no generation-history runtime router.");
|
||||
}
|
||||
return null;
|
||||
GenerationSource source = irisEngine.getGenerationSource();
|
||||
if (!source.keepsPackVersions() && generator != null && generator.getGenerationHistory() != null) {
|
||||
throw new IllegalStateException("Iris " + operation + " has no generation-history runtime router.");
|
||||
}
|
||||
try {
|
||||
return router.openRoute(chunkX, chunkZ);
|
||||
return source.openRoute(chunkX, chunkZ);
|
||||
} catch (IOException failure) {
|
||||
throw new IllegalStateException("Iris " + operation
|
||||
+ " could not route generation history for chunk " + chunkX + "," + chunkZ + ".", failure);
|
||||
@@ -94,11 +90,7 @@ public class BukkitGenerationPolicy
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] naturalTerrainReceipt(GenerationHistoryRuntimeRouter.RuntimeRoute route) throws IOException {
|
||||
if (route.naturalTerrain().isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
SavedTerrainChunk terrain = route.naturalTerrain().orElseThrow();
|
||||
return NativeTerrainReceipt.encode(terrain, route.activation().activationId(), route.epoch().epochId());
|
||||
public byte[] naturalTerrainReceipt(GenerationRoute route) throws IOException {
|
||||
return route.naturalTerrainReceipt();
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@ import art.arcane.iris.structure.nativegen.IrisStructureVolumePolicy;
|
||||
import art.arcane.iris.structure.nativegen.NativeStructureOwnershipRecord;
|
||||
import art.arcane.iris.structure.nativegen.NativeStructureStartPlan;
|
||||
import art.arcane.iris.structure.nativegen.NativeStructureVolumeIndex;
|
||||
import art.arcane.iris.world.history.GenerationHistoryRuntimeRouter;
|
||||
import art.arcane.iris.generation.runtime.GenerationRoute;
|
||||
import art.arcane.iris.world.history.NativeBiomeSpawnSelection;
|
||||
import art.arcane.iris.spi.IrisLogging;
|
||||
import art.arcane.volmlib.nativelib.terrain.NativeBukkitGeneratorContext;
|
||||
@@ -31,7 +31,7 @@ import java.util.function.IntConsumer;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public final class BukkitGeneratorContext extends BukkitGenerationPolicy implements NativeBukkitGeneratorContext<
|
||||
Engine, IrisDimension, NativeStructureStartPlan, NativeStructureOwnershipRecord, GenerationHistoryRuntimeRouter.RuntimeRoute> {
|
||||
Engine, IrisDimension, NativeStructureStartPlan, NativeStructureOwnershipRecord, GenerationRoute> {
|
||||
private static final NamespacedKey STRUCTURE_ACTIVATION = new NamespacedKey("iris", "structure_activation");
|
||||
private final Options options;
|
||||
private final BukkitChunkGenerator generator;
|
||||
@@ -118,7 +118,7 @@ public final class BukkitGeneratorContext extends BukkitGenerationPolicy impleme
|
||||
public NativeGenerationScope openCoordinateScope(int blockX, int blockZ, String operation) {
|
||||
if (!(current() instanceof IrisEngine irisEngine)) { return null; }
|
||||
try {
|
||||
return irisEngine.openGenerationHistoryCoordinateScope(blockX, blockZ);
|
||||
return irisEngine.openGenerationScope(blockX, blockZ);
|
||||
} catch (IOException failure) {
|
||||
throw new IllegalStateException("Iris " + operation + " could not route generation history at "
|
||||
+ blockX + "," + blockZ + ".", failure);
|
||||
@@ -139,7 +139,7 @@ public final class BukkitGeneratorContext extends BukkitGenerationPolicy impleme
|
||||
public NamespacedKey structureActivationKey() { return STRUCTURE_ACTIVATION; }
|
||||
|
||||
@Override
|
||||
public long activationId(GenerationHistoryRuntimeRouter.RuntimeRoute route) { return route.activation().activationId(); }
|
||||
public long activationId(GenerationRoute route) { return route.activationId(); }
|
||||
|
||||
@Override
|
||||
public void failed(String operation, Throwable failure) { IrisLogging.reportError(operation, failure); }
|
||||
|
||||
+4
-4
@@ -7,7 +7,7 @@ import art.arcane.iris.generation.runtime.GenerationSessionLease;
|
||||
import art.arcane.iris.generation.runtime.IrisEngine;
|
||||
import art.arcane.iris.platform.generation.BukkitChunkGenerator;
|
||||
import art.arcane.iris.studio.generation.JigsawStudioGenerator;
|
||||
import art.arcane.iris.world.history.GenerationHistoryRuntimeRouter;
|
||||
import art.arcane.iris.generation.runtime.GenerationScope;
|
||||
import art.arcane.iris.world.history.TerrainNativeBlockKeys;
|
||||
import art.arcane.volmlib.nativelib.terrain.NativeBlockColumn;
|
||||
import art.arcane.volmlib.nativelib.terrain.NativeTerrainColumnPolicy;
|
||||
@@ -51,12 +51,12 @@ public final class BukkitTerrainColumnPolicy implements NativeTerrainColumnPolic
|
||||
return TerrainNativeBlockKeys.placementKey(stateKey);
|
||||
}
|
||||
|
||||
private GenerationHistoryRuntimeRouter.CoordinateScope openHistory(Query query) {
|
||||
private GenerationScope openHistory(Query query) {
|
||||
if (!(engine instanceof IrisEngine irisEngine)) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return irisEngine.openGenerationHistoryCoordinateScope(query.blockX(), query.blockZ());
|
||||
return irisEngine.openGenerationScope(query.blockX(), query.blockZ());
|
||||
} catch (IOException failure) {
|
||||
throw new IllegalStateException("Iris " + query.operation() + " could not route generation history at "
|
||||
+ query.blockX() + "," + query.blockZ() + ".", failure);
|
||||
@@ -65,7 +65,7 @@ public final class BukkitTerrainColumnPolicy implements NativeTerrainColumnPolic
|
||||
|
||||
private final class Session implements ColumnSession {
|
||||
private final Query query;
|
||||
private final GenerationHistoryRuntimeRouter.CoordinateScope history;
|
||||
private final GenerationScope history;
|
||||
private final GenerationSessionLease lease;
|
||||
private final IrisContext.Scope context;
|
||||
|
||||
|
||||
@@ -41,6 +41,8 @@ import art.arcane.iris.studio.jigsaw.JigsawStudioSession;
|
||||
import art.arcane.iris.studio.StudioSVC;
|
||||
import art.arcane.iris.world.IrisToolbelt;
|
||||
import art.arcane.iris.generation.runtime.IrisComplex;
|
||||
import art.arcane.iris.generation.runtime.GenerationScope;
|
||||
import art.arcane.iris.generation.runtime.GenerationSource;
|
||||
import art.arcane.iris.generation.runtime.IrisEngine;
|
||||
import art.arcane.iris.generation.runtime.IrisWorldManager;
|
||||
import art.arcane.volmlib.util.cache.AtomicCache;
|
||||
@@ -1094,11 +1096,23 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun
|
||||
|
||||
withExclusiveControl(() -> {
|
||||
if (!studioUpdatesPaused && !closing) {
|
||||
getEngine().hotload();
|
||||
hotloadEngine();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void hotloadEngine() {
|
||||
Engine activeEngine = getEngine();
|
||||
long started = M.ms();
|
||||
activeEngine.hotload();
|
||||
IrisLogging.info("Hotloaded " + packKeyOf(activeEngine) + " in " + (M.ms() - started) + "ms");
|
||||
}
|
||||
|
||||
private static String packKeyOf(Engine activeEngine) {
|
||||
IrisDimension dimension = activeEngine.getDimension();
|
||||
return dimension == null ? "unknown pack" : dimension.getLoadKey();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Void> hotloadAsync() {
|
||||
if (!canHotloadStudio()) {
|
||||
@@ -1108,7 +1122,7 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun
|
||||
if (!canHotloadStudio()) {
|
||||
throw new IllegalStateException("Studio is not ready for hotload.");
|
||||
}
|
||||
getEngine().hotload();
|
||||
hotloadEngine();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1133,7 +1147,7 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun
|
||||
if (!initialEntryPending && !studioUpdatesPaused && shouldRunStudioHotload(isStudio(), closing, jigsawStudioActive)) {
|
||||
IrisLogging.debug("Studio update admission: world=%s wait=%dms",
|
||||
getTarget().getWorld().name(), TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - queuedAt));
|
||||
getEngine().hotload();
|
||||
hotloadEngine();
|
||||
}
|
||||
}, pending));
|
||||
}
|
||||
@@ -1357,16 +1371,13 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun
|
||||
} else {
|
||||
SectionBuffer blocks = new SectionBuffer(d.getMaxHeight() - d.getMinHeight());
|
||||
Hunk<NativeBiome> biomes = new ColumnBiomeHunk(d.getMaxHeight() - d.getMinHeight(), () -> BukkitBiome.of(Biome.PLAINS));
|
||||
try (GenerationHistoryRuntimeRouter.CoordinateScope historyScope =
|
||||
openGenerationHistoryCoordinateScope(engine, x << 4, z << 4);
|
||||
try (GenerationScope historyScope = openGenerationScope(engine, x << 4, z << 4);
|
||||
GenerationSessionLease lease = engine.acquireGenerationLease("bukkit_terrain_stage");
|
||||
IrisContext.Scope ignored = IrisContext.open(engine, lease.sessionId(), null)) {
|
||||
engine.generate(x << 4, z << 4, blocks, biomes,
|
||||
initialEntryPending || studioEntryBootstrapActive.get() || engine.shouldGenerateMulticore());
|
||||
ChunkDataOutput.apply(d, blocks);
|
||||
if (historyScope != null) {
|
||||
historyScope.claimGeneratedSemantics();
|
||||
}
|
||||
historyScope.claimGeneratedSemantics();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1390,21 +1401,22 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun
|
||||
}
|
||||
}
|
||||
|
||||
private @Nullable GenerationHistoryRuntimeRouter.CoordinateScope openGenerationHistoryCoordinateScope(
|
||||
Engine currentEngine,
|
||||
int blockX,
|
||||
int blockZ
|
||||
) throws IOException {
|
||||
if (generationHistory == null) {
|
||||
return null;
|
||||
}
|
||||
private GenerationScope openGenerationScope(Engine currentEngine, int blockX, int blockZ) throws IOException {
|
||||
return requireGenerationSource(currentEngine).openGenerationScope(blockX, blockZ);
|
||||
}
|
||||
|
||||
private GenerationSource requireGenerationSource(Engine currentEngine) {
|
||||
if (!(currentEngine instanceof IrisEngine irisEngine)) {
|
||||
throw new IllegalStateException("Persistent Iris generation requires an IrisEngine runtime.");
|
||||
if (generationHistory != null) {
|
||||
throw new IllegalStateException("Persistent Iris generation requires an IrisEngine runtime.");
|
||||
}
|
||||
return GenerationSource.singlePack();
|
||||
}
|
||||
GenerationHistoryRuntimeRouter router = irisEngine.getGenerationHistoryRuntimeRouter()
|
||||
.orElseThrow(() -> new IllegalStateException(
|
||||
"Persistent Iris generation has no generation-history runtime router."));
|
||||
return router.openCoordinateScope(blockX, blockZ);
|
||||
GenerationSource source = irisEngine.getGenerationSource();
|
||||
if (generationHistory != null && !source.keepsPackVersions()) {
|
||||
throw new IllegalStateException("Persistent Iris generation has no generation-history runtime router.");
|
||||
}
|
||||
return source;
|
||||
}
|
||||
|
||||
private boolean isExpectedTeardown(Engine currentEngine, Throwable throwable) {
|
||||
@@ -1454,8 +1466,7 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun
|
||||
default -> false;
|
||||
};
|
||||
|
||||
try (GenerationHistoryRuntimeRouter.CoordinateScope historyScope =
|
||||
openGenerationHistoryCoordinateScope(currentEngine, x, z);
|
||||
try (GenerationScope historyScope = openGenerationScope(currentEngine, x, z);
|
||||
GenerationSessionLease lease = currentEngine.acquireGenerationLease("bukkit_base_height");
|
||||
IrisContext.Scope ignored = IrisContext.open(currentEngine, lease.sessionId(), null)) {
|
||||
return currentEngine.getMinHeight() + currentEngine.getHeight(x, z, ignoreFluid) + 1;
|
||||
|
||||
@@ -5,7 +5,6 @@ import art.arcane.iris.generation.runtime.DimensionStackLayout;
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.iris.generation.runtime.IrisEngine;
|
||||
import art.arcane.iris.generation.terrain.IrisDimension;
|
||||
import art.arcane.iris.world.history.GenerationHistoryRuntimeRouter;
|
||||
import art.arcane.iris.structure.object.IrisStaticObjectLayer;
|
||||
import art.arcane.volmlib.nativelib.terrain.NativeBlockPositionPredicate;
|
||||
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
|
||||
@@ -22,8 +21,7 @@ public final class GenerationWritePolicy {
|
||||
if (activation <= 0 || !(engine instanceof IrisEngine irisEngine)) {
|
||||
return false;
|
||||
}
|
||||
GenerationHistoryRuntimeRouter router = irisEngine.getGenerationHistoryRuntimeRouter().orElse(null);
|
||||
return router != null && activation < router.history().activeActivation().activationId();
|
||||
return irisEngine.getGenerationSource().predatesActivePack(activation);
|
||||
}
|
||||
|
||||
public static StructureSeaSurface seaSurface(Engine engine) {
|
||||
|
||||
@@ -6,7 +6,7 @@ import art.arcane.volmlib.nativelib.terrain.structure.StructureFingerprint;
|
||||
import art.arcane.volmlib.nativelib.terrain.structure.StructureInjectionPolicy;
|
||||
import art.arcane.volmlib.nativelib.terrain.structure.StructureReferencePolicy;
|
||||
import art.arcane.iris.generation.runtime.IrisEngine;
|
||||
import art.arcane.iris.world.history.GenerationHistoryRuntimeRouter;
|
||||
import art.arcane.iris.generation.runtime.GenerationScope;
|
||||
import java.io.IOException;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@@ -75,12 +75,12 @@ public record IrisStructurePolicy(Engine engine)
|
||||
}
|
||||
|
||||
@Override
|
||||
public GenerationHistoryRuntimeRouter.CoordinateScope openOriginScope(int chunkX, int chunkZ) {
|
||||
public GenerationScope openOriginScope(int chunkX, int chunkZ) {
|
||||
if (!(engine instanceof IrisEngine irisEngine)) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return irisEngine.openGenerationHistoryCoordinateScope(chunkX << 4, chunkZ << 4);
|
||||
return irisEngine.openGenerationScope(chunkX << 4, chunkZ << 4);
|
||||
} catch (IOException failure) {
|
||||
throw new IllegalStateException("Unable to resolve native structure references for origin "
|
||||
+ chunkX + "," + chunkZ + " through generation history.", failure);
|
||||
|
||||
+4
-6
@@ -4,7 +4,7 @@ import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.iris.generation.runtime.GenerationClosedException;
|
||||
|
||||
import art.arcane.iris.generation.runtime.IrisEngine;
|
||||
import art.arcane.iris.world.history.GenerationHistoryRuntimeRouter;
|
||||
import art.arcane.iris.generation.runtime.GenerationSource;
|
||||
import art.arcane.iris.generation.mantle.EngineMantle;
|
||||
import art.arcane.volmlib.util.mantle.runtime.Mantle;
|
||||
import art.arcane.volmlib.util.mantle.runtime.MantleChunk;
|
||||
@@ -19,7 +19,6 @@ import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@@ -419,12 +418,11 @@ public final class NativeStructureOwnershipStore {
|
||||
if (!(active instanceof IrisEngine irisEngine)) {
|
||||
return new RuntimeMantleOwner(0L, runtimeId, null, mantle);
|
||||
}
|
||||
Optional<GenerationHistoryRuntimeRouter> attached = irisEngine.getGenerationHistoryRuntimeRouter();
|
||||
if (attached.isEmpty()) {
|
||||
GenerationSource source = irisEngine.getGenerationSource();
|
||||
if (!source.keepsPackVersions()) {
|
||||
return new RuntimeMantleOwner(0L, runtimeId, null, mantle);
|
||||
}
|
||||
GenerationHistoryRuntimeRouter.RuntimeOwnership routed = attached.get()
|
||||
.currentRuntimeOwnership()
|
||||
GenerationSource.RouteOwnership routed = source.currentRouteOwnership()
|
||||
.orElseThrow(() -> new IllegalStateException(
|
||||
"Native structure ownership requires an active generation-history runtime route."));
|
||||
if (routed.binding().runtimeId() != runtimeId) {
|
||||
|
||||
+6
-14
@@ -7,7 +7,8 @@ import art.arcane.volmlib.nativelib.terrain.structure.NativeStructureVolume;
|
||||
|
||||
import art.arcane.iris.generation.runtime.IrisEngine;
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.iris.world.history.GenerationHistoryRuntimeRouter;
|
||||
import art.arcane.iris.generation.runtime.GenerationScope;
|
||||
import art.arcane.iris.generation.runtime.GenerationSource;
|
||||
import art.arcane.volmlib.util.cache.CacheKey;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
|
||||
@@ -168,11 +169,7 @@ public final class NativeStructureVolumeIndex {
|
||||
if (!(engine instanceof IrisEngine irisEngine) || !irisEngine.hasGenerationRuntimeScope()) {
|
||||
return null;
|
||||
}
|
||||
GenerationHistoryRuntimeRouter router = irisEngine.getGenerationHistoryRuntimeRouter().orElse(null);
|
||||
if (router == null) {
|
||||
return null;
|
||||
}
|
||||
GenerationHistoryRuntimeRouter.RuntimeOwnership ownership = router.currentRuntimeOwnership().orElse(null);
|
||||
GenerationSource.RouteOwnership ownership = irisEngine.getGenerationSource().currentRouteOwnership().orElse(null);
|
||||
int runtimeId = runtimeId(engine);
|
||||
return ownership != null && ownership.binding().runtimeId() == runtimeId ? runtimeId : null;
|
||||
}
|
||||
@@ -191,8 +188,7 @@ public final class NativeStructureVolumeIndex {
|
||||
}
|
||||
|
||||
KList<NativeStructureVolume> originVolumes(Engine engine, int chunkX, int chunkZ) {
|
||||
try (GenerationHistoryRuntimeRouter.CoordinateScope ignored =
|
||||
openHistoryCoordinateScope(engine, chunkX, chunkZ)) {
|
||||
try (GenerationScope ignored = openGenerationScope(engine, chunkX, chunkZ)) {
|
||||
int runtimeId = runtimeId(engine);
|
||||
return cached(
|
||||
originCache,
|
||||
@@ -258,16 +254,12 @@ public final class NativeStructureVolumeIndex {
|
||||
return ((long) chunkX << 32) ^ (chunkZ & 0xffffffffL);
|
||||
}
|
||||
|
||||
private static GenerationHistoryRuntimeRouter.CoordinateScope openHistoryCoordinateScope(
|
||||
Engine engine,
|
||||
int chunkX,
|
||||
int chunkZ
|
||||
) {
|
||||
private static GenerationScope openGenerationScope(Engine engine, int chunkX, int chunkZ) {
|
||||
if (!(engine instanceof IrisEngine irisEngine)) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return irisEngine.openGenerationHistoryCoordinateScope(chunkX << 4, chunkZ << 4);
|
||||
return irisEngine.openGenerationScope(chunkX << 4, chunkZ << 4);
|
||||
} catch (IOException failure) {
|
||||
throw new IllegalStateException("Unable to route native structure origin "
|
||||
+ chunkX + "," + chunkZ + " through generation history.", failure);
|
||||
|
||||
@@ -87,6 +87,7 @@ import java.util.function.Function;
|
||||
@Description("Represents an iris object placer. It places objects.")
|
||||
@Data
|
||||
public class IrisObjectPlacement {
|
||||
private static final String LOOT_TABLE_KEY_KIND = "missing-loot-table";
|
||||
@RegistryListResource(IrisObject.class)
|
||||
@Required
|
||||
@ArrayType(min = 1, type = String.class)
|
||||
@@ -417,7 +418,7 @@ public class IrisObjectPlacement {
|
||||
return (int) Math.round(densityStyle.get(rng, x, z, runtime));
|
||||
}
|
||||
|
||||
private TableCache getCache(IrisData manager) {
|
||||
TableCache getCache(IrisData manager) {
|
||||
return cache.aquire(() -> {
|
||||
TableCache cache = new TableCache();
|
||||
|
||||
@@ -436,7 +437,8 @@ public class IrisObjectPlacement {
|
||||
continue;
|
||||
IrisLootTable table = loader.apply(loot.getName());
|
||||
if (table == null) {
|
||||
IrisLogging.warn("Couldn't find loot table " + loot.getName());
|
||||
IrisLogging.warnOnce(IrisData.onceKey(manager, LOOT_TABLE_KEY_KIND, loot.getName()),
|
||||
"Couldn't find loot table " + loot.getName());
|
||||
continue;
|
||||
}
|
||||
if (table.isCompatExcluded()) {
|
||||
|
||||
@@ -12,7 +12,7 @@ import art.arcane.iris.pack.loading.IrisData;
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.iris.generation.runtime.IrisComplex;
|
||||
import art.arcane.iris.generation.runtime.IrisEngine;
|
||||
import art.arcane.iris.world.history.GenerationHistoryRuntimeRouter;
|
||||
import art.arcane.iris.generation.runtime.GenerationSource;
|
||||
import art.arcane.iris.generation.decoration.tree.TreeBlockMaterial;
|
||||
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
|
||||
import art.arcane.volmlib.util.hunk.Hunk;
|
||||
@@ -108,11 +108,10 @@ public final class IrisStaticObjectLayer {
|
||||
if (complex.getTransitionGenerationPlan() == null) {
|
||||
return this;
|
||||
}
|
||||
GenerationHistoryRuntimeRouter router = engine instanceof IrisEngine irisEngine
|
||||
? irisEngine.getGenerationHistoryRuntimeRouter().orElse(null) : null;
|
||||
boolean cacheable = !(engine instanceof IrisEngine) || router != null;
|
||||
GenerationSource source = engine instanceof IrisEngine irisEngine ? irisEngine.getGenerationSource() : null;
|
||||
boolean cacheable = source == null || source.keepsPackVersions();
|
||||
TransitionLayer cached = transitionLayer;
|
||||
if (cacheable && cached != null && cached.complex() == complex && cached.router() == router) {
|
||||
if (cacheable && cached != null && cached.complex() == complex && cached.source() == source) {
|
||||
return cached.layer();
|
||||
}
|
||||
List<Placement> accepted = new ArrayList<>(placements.size());
|
||||
@@ -125,7 +124,7 @@ public final class IrisStaticObjectLayer {
|
||||
}
|
||||
IrisStaticObjectLayer filtered = accepted.size() == placements.size() ? this : merge(accepted);
|
||||
if (cacheable) {
|
||||
transitionLayer = new TransitionLayer(complex, router, filtered);
|
||||
transitionLayer = new TransitionLayer(complex, source, filtered);
|
||||
}
|
||||
return filtered;
|
||||
}
|
||||
@@ -249,7 +248,7 @@ public final class IrisStaticObjectLayer {
|
||||
private record Placement(ObjectContinuationBundle.PlacementKey key, Map<Long, Chunk> chunks, Footprint footprint) {
|
||||
}
|
||||
|
||||
private record TransitionLayer(IrisComplex complex, GenerationHistoryRuntimeRouter router, IrisStaticObjectLayer layer) {
|
||||
private record TransitionLayer(IrisComplex complex, GenerationSource source, IrisStaticObjectLayer layer) {
|
||||
}
|
||||
|
||||
private static final class Compilation implements IObjectPlacer {
|
||||
|
||||
@@ -141,7 +141,7 @@ final class BiomeExplorer {
|
||||
|
||||
private void add(double x, double z) {
|
||||
count++;
|
||||
InferredType type = complex.getBridgeStream().get(x, z);
|
||||
InferredType type = complex.baseTypeIn(region, x, z);
|
||||
for (TypedSpread typed : spreads) {
|
||||
if (typed.type() == type) {
|
||||
typed.spread().add(noiseByType.computeIfAbsent(type, shown -> complex.biomePickNoiseStream(region, shown)).get(x, z));
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
package art.arcane.iris.studio.map;
|
||||
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.iris.generation.biome.IrisBiome;
|
||||
import art.arcane.iris.generation.runtime.IrisComplex;
|
||||
import art.arcane.iris.generation.terrain.IrisRegion;
|
||||
import art.arcane.iris.studio.map.components.MapLayer;
|
||||
@@ -43,7 +44,7 @@ final class PackFileOpener {
|
||||
File file = switch (layer.type()) {
|
||||
case BIOME, HEIGHT, RIVER, OBJECT_LOAD, DECORATOR_LOAD, LAYER_LOAD -> complex.getTrueBiomeStream().get(worldX, worldZ).openInVSCode();
|
||||
case BIOME_LAND -> complex.getLandBiomeStream().get(worldX, worldZ).openInVSCode();
|
||||
case BIOME_SEA -> complex.getSeaBiomeStream().get(worldX, worldZ).openInVSCode();
|
||||
case BIOME_SEA -> openBiome(complex.getSeaBiomeStream().get(worldX, worldZ));
|
||||
case REGION -> complex.getRegionStream().get(worldX, worldZ).openInVSCode();
|
||||
case REGION_PREVIEW -> openPreviewedBiome(engine, layer.previewRegionKey(), worldX, worldZ);
|
||||
case CAVE_LAND -> complex.getCaveBiomeStream().get(worldX, worldZ).openInVSCode();
|
||||
@@ -51,6 +52,11 @@ final class PackFileOpener {
|
||||
return Optional.ofNullable(file).map(File::getName);
|
||||
}
|
||||
|
||||
/** A region without sea biomes has none to open. */
|
||||
private static File openBiome(IrisBiome biome) {
|
||||
return biome == null ? null : biome.openInVSCode();
|
||||
}
|
||||
|
||||
private static File openPreviewedBiome(Engine engine, String regionKey, double worldX, double worldZ) {
|
||||
IrisRegion region = engine.getData().getRegionLoader().load(regionKey);
|
||||
return region == null ? null : engine.getComplex().surfaceBiomeAsIfIn(region, worldX, worldZ).openInVSCode();
|
||||
|
||||
@@ -236,12 +236,11 @@ public final class MapTileRenderer {
|
||||
// The biome view shows each spot's base biome, which its own region picks from the biome list of the spot's type.
|
||||
private static NoiseField baseBiomePickNoise(IrisComplex complex) {
|
||||
ProceduralStream<IrisRegion> regions = complex.getRegionStream();
|
||||
ProceduralStream<InferredType> types = complex.getBridgeStream();
|
||||
Map<IrisRegion, Map<InferredType, ProceduralStream<Double>>> noiseByRegion = new IdentityHashMap<>();
|
||||
return (gridIndex, x, z) -> {
|
||||
IrisRegion region = regions.get(x, z);
|
||||
return noiseByRegion.computeIfAbsent(region, subject -> new EnumMap<>(InferredType.class))
|
||||
.computeIfAbsent(types.get(x, z), type -> complex.biomePickNoiseStream(region, type))
|
||||
.computeIfAbsent(complex.baseTypeIn(region, x, z), type -> complex.biomePickNoiseStream(region, type))
|
||||
.get(x, z);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -176,6 +176,8 @@ public final class IrisRenderer {
|
||||
return Math.max(1, Math.min(resolution, (int) Math.floor(16D / absoluteStep)));
|
||||
}
|
||||
|
||||
private static final int NO_BIOME_COLOR = 0xFF000000;
|
||||
|
||||
private PixelShader shader(RenderType currentType) {
|
||||
IrisComplex complex = renderer.getComplex();
|
||||
return switch (currentType) {
|
||||
@@ -193,6 +195,9 @@ public final class IrisRenderer {
|
||||
IdentityHashMap<IrisBiome, Integer> colors = new IdentityHashMap<>();
|
||||
return (double x, double z) -> {
|
||||
IrisBiome biome = stream.get(x, z);
|
||||
if (biome == null) {
|
||||
return NO_BIOME_COLOR;
|
||||
}
|
||||
Integer color = colors.get(biome);
|
||||
if (color == null) {
|
||||
color = biome.getColor(renderer, currentType).getRGB();
|
||||
|
||||
@@ -139,6 +139,10 @@ public class IrisCreator {
|
||||
);
|
||||
}
|
||||
|
||||
private boolean usesSinglePackStudio() {
|
||||
return studio && !IrisSettings.get().getStudio().isKeepPackVersions();
|
||||
}
|
||||
|
||||
public static int removeTransientStudioWorldsFromBukkitYml() throws IOException {
|
||||
return BukkitWorldConfiguration.removeMatching(
|
||||
BUKKIT_YML,
|
||||
@@ -267,7 +271,9 @@ public class IrisCreator {
|
||||
long packPreparationStart = System.nanoTime();
|
||||
GenerationHistory publishedHistory = null;
|
||||
IrisDimension installedDimension;
|
||||
if (benchmark && !studio) {
|
||||
if (usesSinglePackStudio()) {
|
||||
installedDimension = resolvedDimension;
|
||||
} else if (benchmark && !studio) {
|
||||
installedDimension = studioService.installIntoTransientWorld(sender, resolvedDimension, dimensionRoot);
|
||||
} else {
|
||||
StudioSVC.GenerationPublication publication = studioService.installIntoWorld(
|
||||
|
||||
@@ -138,6 +138,9 @@ public class IrisWorldCreator {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
if (studio && generationHistory == null) {
|
||||
return null;
|
||||
}
|
||||
Path root = Objects.requireNonNull(dimensionRoot, "Dimension root").toPath().toAbsolutePath().normalize();
|
||||
try {
|
||||
if (generationHistory == null) {
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package art.arcane.iris.world.history;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
final class AttachedRouter {
|
||||
private volatile GenerationHistoryRuntimeRouter router;
|
||||
|
||||
AttachedRouter(GenerationHistoryRuntimeRouter router) {
|
||||
this.router = Objects.requireNonNull(router, "generation-history runtime router");
|
||||
}
|
||||
|
||||
void detach() {
|
||||
router = null;
|
||||
}
|
||||
|
||||
GenerationHistoryRuntimeRouter attachedOrNull() {
|
||||
return router;
|
||||
}
|
||||
|
||||
GenerationHistoryRuntimeRouter require() {
|
||||
GenerationHistoryRuntimeRouter attached = router;
|
||||
if (attached == null) {
|
||||
throw new IllegalStateException("Iris generation-history runtime router is detached.");
|
||||
}
|
||||
return attached;
|
||||
}
|
||||
}
|
||||
@@ -144,6 +144,17 @@ public final class ChunkGenerationOwnership {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean reclaim(int chunkX, int chunkZ, long activation) throws IOException {
|
||||
requireActivation(activation);
|
||||
lock.writeLock().lock();
|
||||
try {
|
||||
RegionGenerationOwnership region = regionForAssignment(chunkX, chunkZ);
|
||||
return region.reclaim(chunkX, chunkZ, activation);
|
||||
} finally {
|
||||
lock.writeLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public int assignAll(WorldChunkInventory inventory, long activation) throws IOException {
|
||||
requireActivation(activation);
|
||||
lock.writeLock().lock();
|
||||
|
||||
@@ -82,6 +82,17 @@ public final class GenerationBoundary {
|
||||
int minimumZ,
|
||||
int maximumX,
|
||||
int maximumZ
|
||||
) {
|
||||
return intersectsHistoricalBlocks(minimumX, minimumZ, maximumX, maximumZ, (chunkX, chunkZ) -> true);
|
||||
}
|
||||
|
||||
/** Like {@link #intersectsHistoricalBlocks(int, int, int, int)}, counting only historical chunks the filter keeps. */
|
||||
public boolean intersectsHistoricalBlocks(
|
||||
int minimumX,
|
||||
int minimumZ,
|
||||
int maximumX,
|
||||
int maximumZ,
|
||||
ChunkFilter counted
|
||||
) {
|
||||
if (minimumX > maximumX || minimumZ > maximumZ) {
|
||||
throw new IllegalArgumentException("Generation footprint bounds are inverted");
|
||||
@@ -99,7 +110,7 @@ public final class GenerationBoundary {
|
||||
if (candidateCount <= historicalChunkCount) {
|
||||
for (long chunkX = minimumChunkX; chunkX <= maximumChunkX; chunkX++) {
|
||||
for (long chunkZ = minimumChunkZ; chunkZ <= maximumChunkZ; chunkZ++) {
|
||||
if (isHistoricalChunk((int) chunkX, (int) chunkZ)) {
|
||||
if (isHistoricalChunk((int) chunkX, (int) chunkZ) && counted.test((int) chunkX, (int) chunkZ)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -111,7 +122,8 @@ public final class GenerationBoundary {
|
||||
historicalChunks.forEach((chunkX, chunkZ) -> {
|
||||
if (!found[0]
|
||||
&& chunkX >= minimumChunkX && chunkX <= maximumChunkX
|
||||
&& chunkZ >= minimumChunkZ && chunkZ <= maximumChunkZ) {
|
||||
&& chunkZ >= minimumChunkZ && chunkZ <= maximumChunkZ
|
||||
&& counted.test(chunkX, chunkZ)) {
|
||||
found[0] = true;
|
||||
}
|
||||
});
|
||||
@@ -398,6 +410,11 @@ public final class GenerationBoundary {
|
||||
void accept(int chunkX, int chunkZ) throws IOException;
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
public interface ChunkFilter {
|
||||
boolean test(int chunkX, int chunkZ);
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
public interface BlockColumnConsumer {
|
||||
void accept(int blockX, int blockZ) throws IOException;
|
||||
|
||||
@@ -122,6 +122,22 @@ public final class GenerationBoundaryStore {
|
||||
return publishCatalog(activationId, builder);
|
||||
}
|
||||
|
||||
synchronized void discardSnapshot(long activationId) throws IOException {
|
||||
Path target = snapshotPath(activationId);
|
||||
if (!Files.exists(directory, LinkOption.NOFOLLOW_LINKS)) {
|
||||
return;
|
||||
}
|
||||
validateStorageAncestors();
|
||||
try (GenerationPublicationLock ignored = GenerationPublicationLock.acquire(
|
||||
directory,
|
||||
".activation-" + activationId + SNAPSHOT_FILE_SUFFIX + ".lock"
|
||||
)) {
|
||||
if (Files.deleteIfExists(target)) {
|
||||
forceDirectory(directory);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public GenerationBoundary load(long activationId) throws IOException {
|
||||
requireActivation(activationId);
|
||||
validateStorageAncestors();
|
||||
|
||||
@@ -51,6 +51,7 @@ public final class GenerationHistory {
|
||||
private final Map<Long, GenerationBoundary> boundaryCache;
|
||||
private final Map<Long, TerrainBoundarySignatureStore.Snapshot> terrainSignatureCache;
|
||||
private final Map<Long, TransitionGenerationPlan> transitionPlanCache;
|
||||
private final Long2ObjectOpenHashMap<ReclaimedChunks> reclaimedChunksByActivation = new Long2ObjectOpenHashMap<>();
|
||||
private final ArrayBlockingQueue<PendingSemanticClaim> pendingSemanticClaims =
|
||||
new ArrayBlockingQueue<>(MAXIMUM_PENDING_SEMANTIC_CLAIMS);
|
||||
private final AtomicBoolean semanticWriter = new AtomicBoolean();
|
||||
@@ -343,6 +344,31 @@ public final class GenerationHistory {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stages an update like {@link #stageUpdate(Path, String, GenerationEpoch.DimensionContract,
|
||||
* GenerationRegistryContract, int)}, but first discards a pending activation for a different pack that never
|
||||
* published its transition. A failed Studio hotload leaves such an activation behind, and the newer pack supersedes
|
||||
* it.
|
||||
*/
|
||||
public synchronized GenerationActivation stageUpdateReplacingStalePending(
|
||||
Path packSource,
|
||||
String packFingerprint,
|
||||
GenerationEpoch.DimensionContract dimensionContract,
|
||||
GenerationRegistryContract registryContract,
|
||||
int transitionWidthBlocks
|
||||
) throws IOException {
|
||||
return stageUpdate(
|
||||
packSource,
|
||||
packFingerprint,
|
||||
GenerationPackFingerprint.CURRENT_VERSION,
|
||||
dimensionContract,
|
||||
registryContract,
|
||||
transitionWidthBlocks,
|
||||
kernels.current(),
|
||||
StalePendingUpdate.REPLACE
|
||||
);
|
||||
}
|
||||
|
||||
synchronized GenerationActivation stageUpdate(
|
||||
Path packSource,
|
||||
String packFingerprint,
|
||||
@@ -358,7 +384,8 @@ public final class GenerationHistory {
|
||||
dimensionContract,
|
||||
registryContract,
|
||||
transitionWidthBlocks,
|
||||
version
|
||||
version,
|
||||
StalePendingUpdate.REJECT
|
||||
);
|
||||
}
|
||||
|
||||
@@ -369,7 +396,8 @@ public final class GenerationHistory {
|
||||
GenerationEpoch.DimensionContract dimensionContract,
|
||||
GenerationRegistryContract registryContract,
|
||||
int transitionWidthBlocks,
|
||||
GenerationKernelRegistry.Version version
|
||||
GenerationKernelRegistry.Version version,
|
||||
StalePendingUpdate stalePending
|
||||
) throws IOException {
|
||||
GenerationEpoch candidate = epoch(
|
||||
packFingerprint,
|
||||
@@ -393,17 +421,20 @@ public final class GenerationHistory {
|
||||
}
|
||||
|
||||
Optional<GenerationActivation> pending = store.pendingActivation();
|
||||
if (pending.isPresent()) {
|
||||
GenerationActivation activation = pending.get();
|
||||
if (!activation.epochId().equals(candidate.epochId())) {
|
||||
if (pending.isPresent() && !pending.get().epochId().equals(candidate.epochId())) {
|
||||
if (stalePending == StalePendingUpdate.REJECT) {
|
||||
throw new IllegalStateException("A different generation activation is already pending.");
|
||||
}
|
||||
discardStalePending(pending.get());
|
||||
pending = Optional.empty();
|
||||
}
|
||||
if (pending.isPresent()) {
|
||||
packs.requireExactPack(
|
||||
candidate.epochId(),
|
||||
candidate.packFingerprint(),
|
||||
candidate.packFingerprintVersion()
|
||||
);
|
||||
return activation;
|
||||
return pending.get();
|
||||
}
|
||||
|
||||
if (store.activeEpoch().equals(candidate)) {
|
||||
@@ -435,6 +466,29 @@ public final class GenerationHistory {
|
||||
return store.preparePendingActivation(candidate, transitionWidthBlocks);
|
||||
}
|
||||
|
||||
/**
|
||||
* Snapshots go before the manifest entry: a snapshot left without its activation would block the next activation
|
||||
* that reuses the ID, while an activation left without snapshots simply publishes them again.
|
||||
*/
|
||||
private void discardStalePending(GenerationActivation stale) throws IOException {
|
||||
if (stale.transition().isComplete()) {
|
||||
throw new IllegalStateException("A different generation activation is already pending.");
|
||||
}
|
||||
long activationId = stale.activationId();
|
||||
boundaries.discardSnapshot(activationId);
|
||||
terrainSignatures.discardSnapshot(activationId);
|
||||
boundaryCache.remove(activationId);
|
||||
terrainSignatureCache.remove(activationId);
|
||||
transitionPlanCache.remove(activationId);
|
||||
reclaimedChunksByActivation.remove(activationId);
|
||||
store.discardPendingActivation(activationId);
|
||||
}
|
||||
|
||||
private enum StalePendingUpdate {
|
||||
REJECT,
|
||||
REPLACE
|
||||
}
|
||||
|
||||
GenerationActivation promotePending(
|
||||
Collection<TerrainBoundarySignature> signatures
|
||||
) throws IOException {
|
||||
@@ -604,7 +658,8 @@ public final class GenerationHistory {
|
||||
active.dimensionContract(),
|
||||
active.registryContract(),
|
||||
transitionWidthBlocks,
|
||||
kernels.current()
|
||||
kernels.current(),
|
||||
StalePendingUpdate.REJECT
|
||||
);
|
||||
}
|
||||
|
||||
@@ -697,7 +752,8 @@ public final class GenerationHistory {
|
||||
&& !selected.contains(ownership.resolve(chunkX, chunkZ, outgoing));
|
||||
WorldChunkInventory inventory;
|
||||
if (startupRecovery) {
|
||||
inventory = SavedTerrainRecoveryScan.scan(paths.dimensionRoot(), allocated, retained);
|
||||
inventory = SavedTerrainRecoveryScan.scan(paths.dimensionRoot(), allocated, retained,
|
||||
paths.irisRoot().resolve(SavedTerrainStatusCache.FILE_NAME));
|
||||
} else {
|
||||
try (SavedTerrainChunkReader.StatusReader reader = new SavedTerrainChunkReader.StatusReader(paths.dimensionRoot())) {
|
||||
inventory = allocated.filter((chunkX, chunkZ) -> retained.test(chunkX, chunkZ)
|
||||
@@ -992,12 +1048,83 @@ public final class GenerationHistory {
|
||||
transition.terrainSignatureIdentity()
|
||||
),
|
||||
boundary,
|
||||
terrainSnapshot
|
||||
terrainSnapshot,
|
||||
reclaimedChunks(activationId, boundary)
|
||||
);
|
||||
transitionPlanCache.put(activationId, plan);
|
||||
return plan;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hands the given chunks to the active activation so they regenerate like new chunks. Ownership, the boundary's
|
||||
* reclaimed set, recorded semantics and saved biomes change together, so a later promotion still finds every
|
||||
* record owned by the activation that claimed it. Records go first: a crash in between leaves chunks with an owner
|
||||
* and no record, which generation recovers from, instead of records that contradict their owner.
|
||||
*
|
||||
* @return how many chunks changed owner
|
||||
*/
|
||||
public synchronized int releaseForRegeneration(List<GenerationBoundary.ChunkCoordinate> chunks) throws IOException {
|
||||
GenerationActivation active = store.activeActivation();
|
||||
if (active.isInitial()) {
|
||||
return 0;
|
||||
}
|
||||
long activationId = active.activationId();
|
||||
GenerationBoundary boundary = boundary(activationId);
|
||||
List<GenerationBoundary.ChunkCoordinate> released = chunksTheActivePackMayOwn(chunks, boundary, activationId);
|
||||
semantics.forgetEarlierClaims(released, activationId);
|
||||
savedBiomes.forgetEarlierClaims(released, activationId);
|
||||
return reclaimBoundaryChunks(released, boundary, activationId);
|
||||
}
|
||||
|
||||
private List<GenerationBoundary.ChunkCoordinate> chunksTheActivePackMayOwn(
|
||||
List<GenerationBoundary.ChunkCoordinate> chunks, GenerationBoundary boundary, long activationId
|
||||
) {
|
||||
List<GenerationBoundary.ChunkCoordinate> released = new ArrayList<>(chunks.size());
|
||||
for (GenerationBoundary.ChunkCoordinate chunk : chunks) {
|
||||
if (boundary.isHistoricalChunk(chunk.chunkX(), chunk.chunkZ())
|
||||
|| resolveActivation(chunk.chunkX(), chunk.chunkZ()).activationId() == activationId) {
|
||||
released.add(chunk);
|
||||
}
|
||||
}
|
||||
return released;
|
||||
}
|
||||
|
||||
private int reclaimBoundaryChunks(
|
||||
List<GenerationBoundary.ChunkCoordinate> chunks, GenerationBoundary boundary, long activationId
|
||||
) throws IOException {
|
||||
ReclaimedChunks reclaimed = reclaimedChunks(activationId, boundary);
|
||||
int moved = 0;
|
||||
for (GenerationBoundary.ChunkCoordinate chunk : chunks) {
|
||||
if (!boundary.isHistoricalChunk(chunk.chunkX(), chunk.chunkZ())
|
||||
|| reclaimed.contains(chunk.chunkX(), chunk.chunkZ())) {
|
||||
continue;
|
||||
}
|
||||
ownership.reclaim(chunk.chunkX(), chunk.chunkZ(), activationId);
|
||||
reclaimed.add(chunk.chunkX(), chunk.chunkZ());
|
||||
moved++;
|
||||
}
|
||||
if (moved > 0) {
|
||||
ownership.persist();
|
||||
}
|
||||
return moved;
|
||||
}
|
||||
|
||||
/** Every plan of one activation shares this set, so a plan rebuilt after cache eviction still sees later reclaims. */
|
||||
private ReclaimedChunks reclaimedChunks(long activationId, GenerationBoundary boundary) throws IOException {
|
||||
ReclaimedChunks existing = reclaimedChunksByActivation.get(activationId);
|
||||
if (existing != null) {
|
||||
return existing;
|
||||
}
|
||||
ReclaimedChunks loaded = new ReclaimedChunks();
|
||||
ownership.forEachAssignment((chunkX, chunkZ, owner) -> {
|
||||
if (owner == activationId && boundary.isHistoricalChunk(chunkX, chunkZ)) {
|
||||
loaded.add(chunkX, chunkZ);
|
||||
}
|
||||
});
|
||||
reclaimedChunksByActivation.put(activationId, loaded);
|
||||
return loaded;
|
||||
}
|
||||
|
||||
public synchronized int explicitChunkCount() {
|
||||
return ownership.explicitChunkCount();
|
||||
}
|
||||
|
||||
+29
-2
@@ -11,6 +11,8 @@ import art.arcane.iris.generation.runtime.IrisEngine;
|
||||
import art.arcane.iris.generation.runtime.IrisEngineMantle;
|
||||
import art.arcane.iris.generation.runtime.EngineTarget;
|
||||
import art.arcane.iris.generation.runtime.GenerationClosedException;
|
||||
import art.arcane.iris.generation.runtime.GenerationRoute;
|
||||
import art.arcane.iris.generation.runtime.GenerationScope;
|
||||
import art.arcane.iris.generation.runtime.GenerationTransitionGate;
|
||||
import art.arcane.iris.generation.mantle.ObjectContinuationBundle;
|
||||
import art.arcane.iris.world.storage.matter.IrisMatterContext;
|
||||
@@ -138,6 +140,19 @@ public final class GenerationHistoryRuntimeRouter implements AutoCloseable {
|
||||
public record ObjectContinuation(long activationId, ObjectContinuationBundle.Fragment fragment) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Hands chunks to the active pack, so they generate like new chunks. Regen uses it to rebuild chunks from before the
|
||||
* last hotload with the current pack, objects and caves included.
|
||||
*/
|
||||
public int releaseForRegeneration(List<GenerationBoundary.ChunkCoordinate> chunks) throws IOException {
|
||||
try (GenerationTransitionGate.Participation ignored = engine.getGenerationSessions().transitionGate().enter()) {
|
||||
int released = history.releaseForRegeneration(chunks);
|
||||
biomes.invalidateQueries(chunks);
|
||||
objectContinuations.clear();
|
||||
return released;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean allowsObjectFootprint(TransitionGenerationPlan plan, ObjectContinuationBundle.Bounds bounds) {
|
||||
return objectContinuations.allowsFootprint(plan, bounds.minimumX(), bounds.minimumZ(), bounds.maximumX(), bounds.maximumZ());
|
||||
}
|
||||
@@ -1452,7 +1467,7 @@ public final class GenerationHistoryRuntimeRouter implements AutoCloseable {
|
||||
}
|
||||
}
|
||||
|
||||
public static final class RuntimeRoute implements NativeGenerationRoute {
|
||||
public static final class RuntimeRoute implements GenerationRoute {
|
||||
private final GenerationHistoryRuntimeRouter router;
|
||||
private final GenerationHistory.GenerationStage stage;
|
||||
private final RuntimeLease lease;
|
||||
@@ -1498,6 +1513,18 @@ public final class GenerationHistoryRuntimeRouter implements AutoCloseable {
|
||||
return stage.activation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long activationId() {
|
||||
return stage.activation().activationId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] naturalTerrainReceipt() throws IOException {
|
||||
SavedTerrainChunk terrain = naturalTerrain;
|
||||
return terrain == null ? null
|
||||
: NativeTerrainReceipt.encode(terrain, activationId(), stage.epoch().epochId());
|
||||
}
|
||||
|
||||
public GenerationEpoch epoch() {
|
||||
return stage.epoch();
|
||||
}
|
||||
@@ -1763,7 +1790,7 @@ public final class GenerationHistoryRuntimeRouter implements AutoCloseable {
|
||||
}
|
||||
}
|
||||
|
||||
public static final class CoordinateScope implements NativeGenerationScope {
|
||||
public static final class CoordinateScope implements GenerationScope {
|
||||
private final int blockX;
|
||||
private final int blockZ;
|
||||
private final RuntimeRoute route;
|
||||
|
||||
@@ -183,6 +183,13 @@ public final class GenerationHistoryStore {
|
||||
return updated.pendingActivation().orElseThrow();
|
||||
}
|
||||
|
||||
public synchronized void discardPendingActivation(long expectedActivationId) throws IOException {
|
||||
requireUsable();
|
||||
GenerationManifest updated = manifest.discardPending(expectedActivationId);
|
||||
writeUpdatedManifest(updated);
|
||||
manifest = updated;
|
||||
}
|
||||
|
||||
public synchronized GenerationActivation completePendingTransition(
|
||||
long expectedActivationId,
|
||||
String boundaryIdentity,
|
||||
|
||||
@@ -155,6 +155,32 @@ public final class GenerationManifest {
|
||||
));
|
||||
}
|
||||
|
||||
GenerationManifest discardPending(long expectedActivationId) {
|
||||
GenerationActivation pending = pendingActivation()
|
||||
.orElseThrow(() -> new IllegalStateException("No generation activation is pending."));
|
||||
if (pending.activationId() != expectedActivationId) {
|
||||
throw new IllegalStateException("Pending activation changed before it was discarded.");
|
||||
}
|
||||
if (pending.transition().isComplete()) {
|
||||
throw new IllegalStateException("A pending activation that published its transition cannot be discarded.");
|
||||
}
|
||||
TreeMap<Long, GenerationActivation> nextActivations = new TreeMap<>(activations);
|
||||
nextActivations.remove(pending.activationId());
|
||||
TreeMap<String, GenerationEpoch> nextEpochs = new TreeMap<>(epochs);
|
||||
boolean epochStillReferenced = nextActivations.values().stream()
|
||||
.anyMatch(activation -> activation.epochId().equals(pending.epochId()));
|
||||
if (!epochStillReferenced) {
|
||||
nextEpochs.remove(pending.epochId());
|
||||
}
|
||||
return new GenerationManifest(new State(
|
||||
schemaVersion,
|
||||
nextEpochs,
|
||||
nextActivations,
|
||||
activeActivationId,
|
||||
null
|
||||
));
|
||||
}
|
||||
|
||||
GenerationManifest completePendingTransition(
|
||||
long expectedActivationId,
|
||||
String boundaryIdentity,
|
||||
|
||||
@@ -31,6 +31,7 @@ import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.EnumMap;
|
||||
import java.util.EnumSet;
|
||||
@@ -341,19 +342,7 @@ public final class GenerationSemanticIndex {
|
||||
int regionZ = regionZ(regionKey);
|
||||
RegionShard previous = loadRegionLocked(regionKey, regionX, regionZ);
|
||||
RegionShard replacement = previous.retainingStoredClaims(stored, selected);
|
||||
int count = previous.recordCount() - replacement.recordCount();
|
||||
if (count == 0) {
|
||||
continue;
|
||||
}
|
||||
byte[] encoded = replacement.encode();
|
||||
String hash = sha256(encoded);
|
||||
publisher.publish(directory, regionX, regionZ, encoded);
|
||||
pointerPublisher.publish(directory, regionX, regionZ, hash);
|
||||
String previousHash = shardHashes.put(regionKey, hash);
|
||||
regionRecordCounts.put(regionKey, replacement.recordCount());
|
||||
cacheRegion(regionKey, replacement);
|
||||
removed += count;
|
||||
deleteUnreferencedShard(regionX, regionZ, previousHash, hash);
|
||||
removed += replaceRegionLocked(regionKey, previous, replacement);
|
||||
}
|
||||
return removed;
|
||||
} finally {
|
||||
@@ -362,6 +351,61 @@ public final class GenerationSemanticIndex {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Drops the records of the given chunks that an activation other than the one now owning them claimed, so those
|
||||
* chunks can be generated and recorded again by their owner.
|
||||
*
|
||||
* @return how many records were dropped
|
||||
*/
|
||||
public int forgetEarlierClaims(Collection<GenerationBoundary.ChunkCoordinate> chunks, long owningActivationId)
|
||||
throws IOException {
|
||||
Map<Long, LongOpenHashSet> chunksByRegion = new LinkedHashMap<>();
|
||||
for (GenerationBoundary.ChunkCoordinate chunk : chunks) {
|
||||
chunksByRegion.computeIfAbsent(packRegion(chunk.chunkX() >> 5, chunk.chunkZ() >> 5),
|
||||
ignored -> new LongOpenHashSet()).add(ChunkGenerationOwnership.packChunk(chunk.chunkX(), chunk.chunkZ()));
|
||||
}
|
||||
if (chunksByRegion.isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
lock.writeLock().lock();
|
||||
publicationLock.lock();
|
||||
try {
|
||||
compactJournals();
|
||||
int removed = 0;
|
||||
for (Map.Entry<Long, LongOpenHashSet> region : chunksByRegion.entrySet()) {
|
||||
long regionKey = region.getKey();
|
||||
RegionShard previous = loadRegionLocked(regionKey, regionX(regionKey), regionZ(regionKey));
|
||||
RegionShard replacement = previous.withoutEarlierClaims(region.getValue(), owningActivationId);
|
||||
removed += replaceRegionLocked(regionKey, previous, replacement);
|
||||
}
|
||||
if (removed > 0) {
|
||||
riverRevision.incrementAndGet();
|
||||
}
|
||||
return removed;
|
||||
} finally {
|
||||
publicationLock.unlock();
|
||||
lock.writeLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
private int replaceRegionLocked(long regionKey, RegionShard previous, RegionShard replacement) throws IOException {
|
||||
int count = previous.recordCount() - replacement.recordCount();
|
||||
if (count == 0) {
|
||||
return 0;
|
||||
}
|
||||
int regionX = regionX(regionKey);
|
||||
int regionZ = regionZ(regionKey);
|
||||
byte[] encoded = replacement.encode();
|
||||
String hash = sha256(encoded);
|
||||
publisher.publish(directory, regionX, regionZ, encoded);
|
||||
pointerPublisher.publish(directory, regionX, regionZ, hash);
|
||||
String previousHash = shardHashes.put(regionKey, hash);
|
||||
regionRecordCounts.put(regionKey, replacement.recordCount());
|
||||
cacheRegion(regionKey, replacement);
|
||||
deleteUnreferencedShard(regionX, regionZ, previousHash, hash);
|
||||
return count;
|
||||
}
|
||||
|
||||
public void compactJournals() throws IOException {
|
||||
lock.writeLock().lock();
|
||||
publicationLock.lock();
|
||||
@@ -2596,6 +2640,23 @@ public final class GenerationSemanticIndex {
|
||||
return replacement;
|
||||
}
|
||||
|
||||
private RegionShard withoutEarlierClaims(LongOpenHashSet chunks, long owningActivationId) {
|
||||
RegionShard replacement = new RegionShard(regionX, regionZ);
|
||||
for (int index = 0; index < records.length; index++) {
|
||||
ChunkGenerationSemantics record = records[index];
|
||||
if (record == null) {
|
||||
continue;
|
||||
}
|
||||
boolean forgotten = record.activationId() != owningActivationId
|
||||
&& chunks.contains(ChunkGenerationOwnership.packChunk(record.chunkX(), record.chunkZ()));
|
||||
if (!forgotten) {
|
||||
replacement.records[index] = record;
|
||||
replacement.recordCount++;
|
||||
}
|
||||
}
|
||||
return replacement;
|
||||
}
|
||||
|
||||
private RegionShard withRecord(ChunkGenerationSemantics semantics) {
|
||||
if ((semantics.chunkX() >> 5) != regionX || (semantics.chunkZ() >> 5) != regionZ) {
|
||||
throw new IllegalArgumentException("Chunk does not belong to generation semantic shard");
|
||||
|
||||
@@ -35,7 +35,7 @@ final class HistoricalObjectContinuations {
|
||||
}
|
||||
|
||||
List<ObjectContinuation> at(TransitionGenerationPlan plan, int chunkX, int chunkZ) {
|
||||
if (plan == null || plan.boundary().isHistoricalChunk(chunkX, chunkZ)) {
|
||||
if (plan == null || plan.isHistoricalChunk(chunkX, chunkZ)) {
|
||||
return List.of();
|
||||
}
|
||||
RegionKey key = new RegionKey(plan.activationId(), chunkX >> 5, chunkZ >> 5);
|
||||
@@ -74,7 +74,7 @@ final class HistoricalObjectContinuations {
|
||||
for (Map.Entry<Long, ObjectContinuationBundle> entry : stored.entrySet()) {
|
||||
int chunkX = ChunkGenerationOwnership.chunkX(entry.getKey());
|
||||
int chunkZ = ChunkGenerationOwnership.chunkZ(entry.getKey());
|
||||
if (plan.boundary().isHistoricalChunk(chunkX, chunkZ)) {
|
||||
if (plan.isHistoricalChunk(chunkX, chunkZ)) {
|
||||
continue;
|
||||
}
|
||||
for (ObjectContinuationBundle.Fragment fragment : entry.getValue().fragments()) {
|
||||
@@ -99,7 +99,7 @@ final class HistoricalObjectContinuations {
|
||||
private boolean intersectsSavedPlacement(TransitionGenerationPlan plan, long activationId,
|
||||
ObjectContinuationBundle.Fragment fragment) {
|
||||
for (ObjectContinuationBundle.ChunkPosition chunk : fragment.touchedChunks()) {
|
||||
if (plan.boundary().isHistoricalChunk(chunk.x(), chunk.z())
|
||||
if (plan.isHistoricalChunk(chunk.x(), chunk.z())
|
||||
&& history.resolveActivation(chunk.x(), chunk.z()).activationId() == activationId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package art.arcane.iris.world.history;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* Historical chunks that regen rebuilt with their activation's own pack. They generate like chunks the transition never
|
||||
* froze. Ownership records each one, so the set is rebuilt after a restart.
|
||||
*/
|
||||
final class ReclaimedChunks {
|
||||
private final Set<Long> chunks = ConcurrentHashMap.newKeySet();
|
||||
|
||||
boolean contains(int chunkX, int chunkZ) {
|
||||
return !chunks.isEmpty() && chunks.contains(ChunkGenerationOwnership.packChunk(chunkX, chunkZ));
|
||||
}
|
||||
|
||||
boolean add(int chunkX, int chunkZ) {
|
||||
return chunks.add(ChunkGenerationOwnership.packChunk(chunkX, chunkZ));
|
||||
}
|
||||
}
|
||||
@@ -203,6 +203,20 @@ final class RegionGenerationOwnership {
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Moves an owned chunk to a newer activation; regen uses it when it rebuilds the chunk with that activation's pack. */
|
||||
synchronized boolean reclaim(int chunkX, int chunkZ, long activation) {
|
||||
requireActivation(activation);
|
||||
int index = chunkIndex(chunkX, chunkZ);
|
||||
long existing = activations[index];
|
||||
if (existing == 0L || existing >= activation) {
|
||||
throw new IllegalStateException("Chunk " + chunkX + "," + chunkZ + " belongs to activation " + existing
|
||||
+ " and cannot be reclaimed by activation " + activation);
|
||||
}
|
||||
activations[index] = activation;
|
||||
dirty = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
synchronized int discardUnstoredClaims(WorldChunkInventory stored, Set<Long> activationIds) {
|
||||
int removed = 0;
|
||||
for (int localZ = 0; localZ < CHUNKS_PER_SIDE; localZ++) {
|
||||
|
||||
@@ -22,6 +22,7 @@ import java.io.UncheckedIOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.LinkOption;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
@@ -255,8 +256,18 @@ public final class SavedBiomeRuntime implements AutoCloseable {
|
||||
public void capture(SavedBiomeChunk chunk) throws IOException {
|
||||
requireOpen();
|
||||
store.claimAndPersist(chunk);
|
||||
invalidateQuery(chunk.chunkX(), chunk.chunkZ());
|
||||
}
|
||||
|
||||
void invalidateQueries(Collection<GenerationBoundary.ChunkCoordinate> chunks) {
|
||||
for (GenerationBoundary.ChunkCoordinate chunk : chunks) {
|
||||
invalidateQuery(chunk.chunkX(), chunk.chunkZ());
|
||||
}
|
||||
}
|
||||
|
||||
private void invalidateQuery(int chunkX, int chunkZ) {
|
||||
synchronized (queries) {
|
||||
long key = key(chunk.chunkX(), chunk.chunkZ());
|
||||
long key = key(chunkX, chunkZ);
|
||||
PreparedQuery removed = queries.remove(key);
|
||||
if (removed != null) {
|
||||
queryBytes -= removed.estimatedBytes();
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.nio.file.Path;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.nio.file.StandardOpenOption;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
@@ -351,6 +352,48 @@ public final class SavedBiomeStore {
|
||||
return removed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Drops the saved biomes of the given chunks that an activation other than the one now owning them captured, so
|
||||
* their owner can capture them again.
|
||||
*
|
||||
* @return how many chunks were dropped
|
||||
*/
|
||||
public int forgetEarlierClaims(Collection<GenerationBoundary.ChunkCoordinate> chunks, long owningActivationId)
|
||||
throws IOException {
|
||||
requireSafeAncestors();
|
||||
if (chunks.isEmpty() || !Files.exists(directory, LinkOption.NOFOLLOW_LINKS)) {
|
||||
return 0;
|
||||
}
|
||||
Map<Long, List<GenerationBoundary.ChunkCoordinate>> chunksByRegion = new LinkedHashMap<>();
|
||||
for (GenerationBoundary.ChunkCoordinate chunk : chunks) {
|
||||
chunksByRegion.computeIfAbsent(key(chunk.chunkX() >> 5, chunk.chunkZ() >> 5),
|
||||
ignored -> new ArrayList<>()).add(chunk);
|
||||
}
|
||||
int removed = 0;
|
||||
for (List<GenerationBoundary.ChunkCoordinate> regionChunks : chunksByRegion.values()) {
|
||||
GenerationBoundary.ChunkCoordinate anchor = regionChunks.getFirst();
|
||||
synchronized (regionLock(anchor.chunkX(), anchor.chunkZ())) {
|
||||
requireWritable();
|
||||
RegionIndex region = region(anchor.chunkX(), anchor.chunkZ());
|
||||
boolean[] discarded = new boolean[1024];
|
||||
int count = 0;
|
||||
for (GenerationBoundary.ChunkCoordinate chunk : regionChunks) {
|
||||
int slot = slot(chunk.chunkX(), chunk.chunkZ());
|
||||
if (!discarded[slot] && region.offsets[slot] != 0L
|
||||
&& readRecord(region, slot).activationId() != owningActivationId) {
|
||||
discarded[slot] = true;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
if (count != 0) {
|
||||
rewriteRegion(region, discarded);
|
||||
removed = Math.addExact(removed, count);
|
||||
}
|
||||
}
|
||||
}
|
||||
return removed;
|
||||
}
|
||||
|
||||
int cachedRegionCount() {
|
||||
synchronized (regions) {
|
||||
return regions.size();
|
||||
|
||||
@@ -3,6 +3,7 @@ package art.arcane.iris.world.history;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.BitSet;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
@@ -20,10 +21,16 @@ final class SavedTerrainRecoveryScan implements AutoCloseable {
|
||||
private final int regionByteLimit;
|
||||
private final SavedTerrainChunkReader.StatusReader[] readers;
|
||||
private final ExecutorService executor;
|
||||
private final SavedTerrainStatusCache cache;
|
||||
private byte[] regionBuffer = new byte[0];
|
||||
|
||||
SavedTerrainRecoveryScan(Path world, Limits limits) {
|
||||
this(world, limits, null);
|
||||
}
|
||||
|
||||
SavedTerrainRecoveryScan(Path world, Limits limits, SavedTerrainStatusCache cache) {
|
||||
this.world = world;
|
||||
this.cache = cache;
|
||||
regionByteLimit = limits.regionBytes();
|
||||
readers = new SavedTerrainChunkReader.StatusReader[limits.workers()];
|
||||
for (int index = 0; index < readers.length; index++) {
|
||||
@@ -35,11 +42,26 @@ final class SavedTerrainRecoveryScan implements AutoCloseable {
|
||||
|
||||
static WorldChunkInventory scan(Path world, WorldChunkInventory inventory,
|
||||
WorldChunkInventory.ChunkPredicate retained) throws IOException {
|
||||
return scan(world, inventory, retained, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scans with the status cache at {@code cacheFile}, or without a cache when it is null. The cache is
|
||||
* written once, after the whole scan succeeded.
|
||||
*/
|
||||
static WorldChunkInventory scan(Path world, WorldChunkInventory inventory,
|
||||
WorldChunkInventory.ChunkPredicate retained, Path cacheFile) throws IOException {
|
||||
Runtime runtime = Runtime.getRuntime();
|
||||
SavedTerrainStatusCache cache = cacheFile == null ? null : SavedTerrainStatusCache.load(cacheFile, world);
|
||||
WorldChunkInventory result;
|
||||
try (SavedTerrainRecoveryScan scan = new SavedTerrainRecoveryScan(world,
|
||||
Limits.forRuntime(runtime.availableProcessors(), runtime.maxMemory()))) {
|
||||
return scan.filter(inventory, retained);
|
||||
Limits.forRuntime(runtime.availableProcessors(), runtime.maxMemory()), cache)) {
|
||||
result = scan.filter(inventory, retained);
|
||||
}
|
||||
if (cache != null) {
|
||||
cache.save();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
WorldChunkInventory filter(WorldChunkInventory inventory, WorldChunkInventory.ChunkPredicate retained)
|
||||
@@ -81,18 +103,39 @@ final class SavedTerrainRecoveryScan implements AutoCloseable {
|
||||
}
|
||||
}
|
||||
if (pending.isEmpty()) {
|
||||
if (cache != null) {
|
||||
cache.carry(region.x(), region.z());
|
||||
}
|
||||
return accepted;
|
||||
}
|
||||
Path file = world.resolve("region/r." + region.x() + "." + region.z() + ".mca");
|
||||
SavedTerrainStatusCache.Header header = cache == null ? null : readHeader(file);
|
||||
SavedTerrainStatusCache.Update update = null;
|
||||
if (header != null) {
|
||||
update = cache.begin(region.x(), region.z(), header, pending, accepted);
|
||||
if (pending.isEmpty()) {
|
||||
update.commit();
|
||||
return accepted;
|
||||
}
|
||||
}
|
||||
int snapshotLimit = Math.min(regionByteLimit, pending.cardinality() * 64 * 1024);
|
||||
Optional<SavedTerrainRegionSnapshot> captured = SavedTerrainRegionSnapshot.read(file, snapshotLimit, regionBuffer);
|
||||
if (captured.isEmpty()) {
|
||||
BitSet terrain = new BitSet(1024);
|
||||
for (int slot = pending.nextSetBit(0); slot >= 0; slot = pending.nextSetBit(slot + 1)) {
|
||||
requireNotInterrupted();
|
||||
if (SavedTerrainChunk.hasTerrain(readers[0].readStatus(region.chunkX(slot), region.chunkZ(slot)))) {
|
||||
accepted.set(slot);
|
||||
terrain.set(slot);
|
||||
}
|
||||
}
|
||||
accepted.or(terrain);
|
||||
if (update != null) {
|
||||
SavedTerrainStatusCache.Header after = readHeader(file);
|
||||
if (after != null && header.sameHeader(after)) {
|
||||
record(update, region, header, pending, terrain);
|
||||
}
|
||||
update.commit();
|
||||
}
|
||||
return accepted;
|
||||
}
|
||||
SavedTerrainRegionSnapshot snapshot = captured.get();
|
||||
@@ -106,8 +149,9 @@ final class SavedTerrainRecoveryScan implements AutoCloseable {
|
||||
pending.clear(slot);
|
||||
}
|
||||
}
|
||||
BitSet terrain;
|
||||
if (executor == null || pending.cardinality() < MIN_PARALLEL_CHUNKS) {
|
||||
accepted.or(decode(new DecodeRegion(region, pending, snapshot), 0, 1));
|
||||
terrain = decode(new DecodeRegion(region, pending, snapshot), 0, 1);
|
||||
} else {
|
||||
List<Future<BitSet>> tasks = new ArrayList<>(readers.length);
|
||||
DecodeRegion input = new DecodeRegion(region, pending, snapshot);
|
||||
@@ -115,12 +159,36 @@ final class SavedTerrainRecoveryScan implements AutoCloseable {
|
||||
int worker = index;
|
||||
tasks.add(executor.submit(() -> decode(input, worker, readers.length)));
|
||||
}
|
||||
accepted.or(await(tasks));
|
||||
terrain = await(tasks);
|
||||
}
|
||||
accepted.or(terrain);
|
||||
snapshot.validateUnchanged();
|
||||
if (update != null) {
|
||||
record(update, region, new SavedTerrainStatusCache.Header(header.fileKey(), header.size(),
|
||||
Arrays.copyOf(snapshot.bytes(), SavedTerrainStatusCache.Header.BYTES)), pending, terrain);
|
||||
update.commit();
|
||||
}
|
||||
return accepted;
|
||||
}
|
||||
|
||||
private void record(SavedTerrainStatusCache.Update update, Region region, SavedTerrainStatusCache.Header header,
|
||||
BitSet decoded, BitSet terrain) {
|
||||
for (int slot = decoded.nextSetBit(0); slot >= 0; slot = decoded.nextSetBit(slot + 1)) {
|
||||
if (!cache.isExternal(region.chunkX(slot), region.chunkZ(slot))) {
|
||||
update.record(slot, header.location(slot), header.timestamp(slot), terrain.get(slot));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static SavedTerrainStatusCache.Header readHeader(Path file) {
|
||||
try {
|
||||
return SavedTerrainStatusCache.Header.read(file);
|
||||
} catch (IOException ignored) {
|
||||
// The uncached read reports the real problem with this region.
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private BitSet decode(DecodeRegion input, int worker, int stride) throws IOException {
|
||||
BitSet accepted = new BitSet(1024);
|
||||
int ordinal = 0;
|
||||
|
||||
@@ -0,0 +1,379 @@
|
||||
package art.arcane.iris.world.history;
|
||||
|
||||
import art.arcane.iris.spi.IrisLogging;
|
||||
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.nio.file.DirectoryStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.LinkOption;
|
||||
import java.nio.file.NoSuchFileException;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.nio.file.StandardOpenOption;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
import java.util.Arrays;
|
||||
import java.util.BitSet;
|
||||
import java.util.Objects;
|
||||
import java.util.zip.CRC32;
|
||||
|
||||
/**
|
||||
* Remembers the decoded "has terrain" bit of each saved chunk between startups. A bit is reused only while the
|
||||
* slot's location word and timestamp in the region header are unchanged, the timestamp is at least two seconds
|
||||
* older than the scan that decoded it, and the chunk is not stored in an external .mcc file. Ownership filtering
|
||||
* is never cached; callers apply it on every scan.
|
||||
*/
|
||||
final class SavedTerrainStatusCache {
|
||||
static final String FILE_NAME = "terrain-status.cache";
|
||||
|
||||
private static final int MAGIC = 0x49545343;
|
||||
private static final int VERSION = 1;
|
||||
private static final int SLOTS = 1024;
|
||||
private static final int HEADER_BYTES = 2 * 4096;
|
||||
private static final long MAX_CACHE_BYTES = 1L << 30;
|
||||
|
||||
private final Path file;
|
||||
private final Path regionDirectory;
|
||||
private final long scanSeconds;
|
||||
private final long previousScanSeconds;
|
||||
private final Long2ObjectOpenHashMap<Region> previous;
|
||||
private final Long2ObjectOpenHashMap<Region> next = new Long2ObjectOpenHashMap<>();
|
||||
private LongOpenHashSet externalChunks;
|
||||
private boolean externalChunksUnknown;
|
||||
|
||||
private SavedTerrainStatusCache(Path file, Path world, long scanSeconds, Contents contents) {
|
||||
this.file = file;
|
||||
regionDirectory = world.toAbsolutePath().normalize().resolve(GenerationHistoryPaths.REGION_DIRECTORY_NAME);
|
||||
this.scanSeconds = scanSeconds;
|
||||
previousScanSeconds = contents.scanSeconds();
|
||||
previous = contents.regions();
|
||||
}
|
||||
|
||||
static SavedTerrainStatusCache load(Path file, Path world) {
|
||||
Objects.requireNonNull(file, "file");
|
||||
Objects.requireNonNull(world, "world");
|
||||
long now = System.currentTimeMillis() / 1000L;
|
||||
return new SavedTerrainStatusCache(file, world, now, readContents(file));
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts the cache update for one region and moves every pending slot whose cached bit is still valid out of
|
||||
* {@code pending}, setting it in {@code accepted} when the chunk has terrain.
|
||||
*/
|
||||
Update begin(int regionX, int regionZ, Header header, BitSet pending, BitSet accepted) {
|
||||
Update update = new Update(regionX, regionZ, header);
|
||||
Region cached = previous.get(ChunkGenerationOwnership.packChunk(regionX, regionZ));
|
||||
if (cached == null || !cached.matches(header)) {
|
||||
return update;
|
||||
}
|
||||
for (int entry = 0; entry < cached.slots().length; entry++) {
|
||||
int slot = cached.slots()[entry];
|
||||
if (header.location(slot) != cached.locations()[entry]
|
||||
|| header.timestamp(slot) != cached.timestamps()[entry]
|
||||
|| !reusable(cached.locations()[entry], cached.timestamps()[entry], previousScanSeconds)
|
||||
|| isExternal(regionX * 32 + (slot & 31), regionZ * 32 + (slot >> 5))) {
|
||||
continue;
|
||||
}
|
||||
boolean terrain = cached.terrain().get(entry);
|
||||
update.keep(slot, cached.locations()[entry], cached.timestamps()[entry], terrain);
|
||||
if (pending.get(slot)) {
|
||||
pending.clear(slot);
|
||||
if (terrain) {
|
||||
accepted.set(slot);
|
||||
}
|
||||
}
|
||||
}
|
||||
return update;
|
||||
}
|
||||
|
||||
/**
|
||||
* Keeps a region's cached entries as they are, for a region the scan did not need to read.
|
||||
*/
|
||||
void carry(int regionX, int regionZ) {
|
||||
long key = ChunkGenerationOwnership.packChunk(regionX, regionZ);
|
||||
Region cached = previous.get(key);
|
||||
if (cached != null) {
|
||||
next.put(key, cached);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* True when the chunk has an external .mcc payload, or when the region directory could not be listed.
|
||||
*/
|
||||
boolean isExternal(int chunkX, int chunkZ) {
|
||||
if (externalChunks == null && !externalChunksUnknown) {
|
||||
try {
|
||||
externalChunks = listExternalChunks(regionDirectory);
|
||||
} catch (IOException | RuntimeException failure) {
|
||||
externalChunksUnknown = true;
|
||||
IrisLogging.warnOnce("saved-terrain-cache-external", () -> "Not using the saved terrain status cache"
|
||||
+ " because " + regionDirectory + " could not be listed: " + failure);
|
||||
}
|
||||
}
|
||||
return externalChunksUnknown
|
||||
|| externalChunks.contains(ChunkGenerationOwnership.packChunk(chunkX, chunkZ));
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the cache with the regions visited by this scan. Regions that were not visited are dropped. Failures
|
||||
* are logged and never reach the caller.
|
||||
*/
|
||||
void save() {
|
||||
try {
|
||||
byte[] encoded = encode(scanSeconds, next);
|
||||
Path directory = file.toAbsolutePath().getParent();
|
||||
Files.createDirectories(directory);
|
||||
Path temporary = Files.createTempFile(directory, "." + file.getFileName() + "-", ".tmp");
|
||||
try {
|
||||
Files.write(temporary, encoded);
|
||||
Files.move(temporary, file, StandardCopyOption.ATOMIC_MOVE, StandardCopyOption.REPLACE_EXISTING);
|
||||
} finally {
|
||||
Files.deleteIfExists(temporary);
|
||||
}
|
||||
} catch (IOException | RuntimeException failure) {
|
||||
IrisLogging.warnOnce("saved-terrain-cache-write", () -> "Could not write the saved terrain status cache "
|
||||
+ file + ": " + failure);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean reusable(int location, int timestamp, long decodedAt) {
|
||||
return location != 0 && Integer.toUnsignedLong(timestamp) < decodedAt - 1L;
|
||||
}
|
||||
|
||||
private static LongOpenHashSet listExternalChunks(Path regionDirectory) throws IOException {
|
||||
LongOpenHashSet chunks = new LongOpenHashSet();
|
||||
try (DirectoryStream<Path> entries = Files.newDirectoryStream(regionDirectory, "c.*.*.mcc")) {
|
||||
for (Path entry : entries) {
|
||||
String[] parts = entry.getFileName().toString().split("\\.");
|
||||
if (parts.length != 4) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
chunks.add(ChunkGenerationOwnership.packChunk(Integer.parseInt(parts[1]),
|
||||
Integer.parseInt(parts[2])));
|
||||
} catch (NumberFormatException ignored) {
|
||||
// Not a chunk payload name; the region reader ignores it too.
|
||||
}
|
||||
}
|
||||
} catch (NoSuchFileException ignored) {
|
||||
return chunks;
|
||||
}
|
||||
return chunks;
|
||||
}
|
||||
|
||||
private static Contents readContents(Path file) {
|
||||
try {
|
||||
if (!Files.isRegularFile(file, LinkOption.NOFOLLOW_LINKS)) {
|
||||
return Contents.EMPTY;
|
||||
}
|
||||
if (Files.size(file) > MAX_CACHE_BYTES) {
|
||||
throw new IOException("cache file is too large");
|
||||
}
|
||||
return decode(Files.readAllBytes(file));
|
||||
} catch (IOException | RuntimeException failure) {
|
||||
IrisLogging.warnOnce("saved-terrain-cache-read", () -> "Ignoring the saved terrain status cache "
|
||||
+ file + ": " + failure.getMessage());
|
||||
return Contents.EMPTY;
|
||||
}
|
||||
}
|
||||
|
||||
private static byte[] encode(long scanSeconds, Long2ObjectOpenHashMap<Region> regions) throws IOException {
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
try (DataOutputStream output = new DataOutputStream(buffer)) {
|
||||
output.writeInt(MAGIC);
|
||||
output.writeInt(VERSION);
|
||||
output.writeLong(scanSeconds);
|
||||
output.writeInt(regions.size());
|
||||
for (Region region : regions.values()) {
|
||||
output.writeInt(region.x());
|
||||
output.writeInt(region.z());
|
||||
output.writeLong(region.size());
|
||||
output.writeUTF(region.fileKey());
|
||||
output.writeShort(region.slots().length);
|
||||
for (int entry = 0; entry < region.slots().length; entry++) {
|
||||
output.writeShort(region.slots()[entry]);
|
||||
output.writeInt(region.locations()[entry]);
|
||||
output.writeInt(region.timestamps()[entry]);
|
||||
output.writeBoolean(region.terrain().get(entry));
|
||||
}
|
||||
}
|
||||
CRC32 checksum = new CRC32();
|
||||
checksum.update(buffer.toByteArray());
|
||||
output.writeLong(checksum.getValue());
|
||||
}
|
||||
return buffer.toByteArray();
|
||||
}
|
||||
|
||||
private static Contents decode(byte[] bytes) throws IOException {
|
||||
if (bytes.length < Long.BYTES) {
|
||||
throw new IOException("cache file is truncated");
|
||||
}
|
||||
CRC32 checksum = new CRC32();
|
||||
checksum.update(bytes, 0, bytes.length - Long.BYTES);
|
||||
if (ByteBuffer.wrap(bytes, bytes.length - Long.BYTES, Long.BYTES).getLong() != checksum.getValue()) {
|
||||
throw new IOException("cache checksum does not match");
|
||||
}
|
||||
DataInputStream input = new DataInputStream(new ByteArrayInputStream(bytes, 0, bytes.length - Long.BYTES));
|
||||
if (input.readInt() != MAGIC) {
|
||||
throw new IOException("not a saved terrain status cache");
|
||||
}
|
||||
int version = input.readInt();
|
||||
if (version != VERSION) {
|
||||
throw new IOException("unsupported cache version " + version);
|
||||
}
|
||||
long scanSeconds = input.readLong();
|
||||
int regionCount = input.readInt();
|
||||
if (regionCount < 0) {
|
||||
throw new IOException("invalid region count");
|
||||
}
|
||||
Long2ObjectOpenHashMap<Region> regions = new Long2ObjectOpenHashMap<>(Math.min(regionCount, 65536));
|
||||
for (int index = 0; index < regionCount; index++) {
|
||||
int x = input.readInt();
|
||||
int z = input.readInt();
|
||||
long size = input.readLong();
|
||||
String fileKey = input.readUTF();
|
||||
int count = input.readUnsignedShort();
|
||||
if (size < HEADER_BYTES || count > SLOTS) {
|
||||
throw new IOException("invalid region entry");
|
||||
}
|
||||
int[] slots = new int[count];
|
||||
int[] locations = new int[count];
|
||||
int[] timestamps = new int[count];
|
||||
BitSet terrain = new BitSet(count);
|
||||
int previousSlot = -1;
|
||||
for (int entry = 0; entry < count; entry++) {
|
||||
int slot = input.readUnsignedShort();
|
||||
if (slot >= SLOTS || slot <= previousSlot) {
|
||||
throw new IOException("invalid chunk slot");
|
||||
}
|
||||
previousSlot = slot;
|
||||
slots[entry] = slot;
|
||||
locations[entry] = input.readInt();
|
||||
timestamps[entry] = input.readInt();
|
||||
terrain.set(entry, input.readBoolean());
|
||||
}
|
||||
if (regions.put(ChunkGenerationOwnership.packChunk(x, z),
|
||||
new Region(x, z, size, fileKey, slots, locations, timestamps, terrain)) != null) {
|
||||
throw new IOException("duplicate region entry");
|
||||
}
|
||||
}
|
||||
if (input.available() != 0) {
|
||||
throw new IOException("unexpected trailing data");
|
||||
}
|
||||
return new Contents(scanSeconds, regions);
|
||||
}
|
||||
|
||||
final class Update {
|
||||
private final int regionX;
|
||||
private final int regionZ;
|
||||
private final Header header;
|
||||
private final int[] locations = new int[SLOTS];
|
||||
private final int[] timestamps = new int[SLOTS];
|
||||
private final BitSet known = new BitSet(SLOTS);
|
||||
private final BitSet terrain = new BitSet(SLOTS);
|
||||
|
||||
private Update(int regionX, int regionZ, Header header) {
|
||||
this.regionX = regionX;
|
||||
this.regionZ = regionZ;
|
||||
this.header = header;
|
||||
}
|
||||
|
||||
/**
|
||||
* Records a freshly decoded bit. Call only after the region was confirmed unchanged during decoding.
|
||||
*/
|
||||
void record(int slot, int location, int timestamp, boolean hasTerrain) {
|
||||
if (reusable(location, timestamp, scanSeconds)) {
|
||||
keep(slot, location, timestamp, hasTerrain);
|
||||
} else {
|
||||
known.clear(slot);
|
||||
}
|
||||
}
|
||||
|
||||
void commit() {
|
||||
int count = known.cardinality();
|
||||
int[] slots = new int[count];
|
||||
int[] storedLocations = new int[count];
|
||||
int[] storedTimestamps = new int[count];
|
||||
BitSet storedTerrain = new BitSet(count);
|
||||
int entry = 0;
|
||||
for (int slot = known.nextSetBit(0); slot >= 0; slot = known.nextSetBit(slot + 1)) {
|
||||
slots[entry] = slot;
|
||||
storedLocations[entry] = locations[slot];
|
||||
storedTimestamps[entry] = timestamps[slot];
|
||||
storedTerrain.set(entry, terrain.get(slot));
|
||||
entry++;
|
||||
}
|
||||
next.put(ChunkGenerationOwnership.packChunk(regionX, regionZ), new Region(regionX, regionZ,
|
||||
header.size(), header.fileKey(), slots, storedLocations, storedTimestamps, storedTerrain));
|
||||
}
|
||||
|
||||
private void keep(int slot, int location, int timestamp, boolean hasTerrain) {
|
||||
locations[slot] = location;
|
||||
timestamps[slot] = timestamp;
|
||||
known.set(slot);
|
||||
terrain.set(slot, hasTerrain);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The 8 KiB header of a region file together with the identity of the file it came from.
|
||||
*/
|
||||
record Header(String fileKey, long size, byte[] bytes) {
|
||||
static final int BYTES = HEADER_BYTES;
|
||||
|
||||
static Header read(Path file) throws IOException {
|
||||
Path normalized = file.toAbsolutePath().normalize();
|
||||
BasicFileAttributes attributes = Files.readAttributes(normalized, BasicFileAttributes.class,
|
||||
LinkOption.NOFOLLOW_LINKS);
|
||||
if (!attributes.isRegularFile() || attributes.size() < HEADER_BYTES) {
|
||||
throw new IOException("Saved chunk region header is unavailable: " + normalized);
|
||||
}
|
||||
byte[] bytes = new byte[HEADER_BYTES];
|
||||
try (FileChannel input = FileChannel.open(normalized, StandardOpenOption.READ, LinkOption.NOFOLLOW_LINKS)) {
|
||||
ByteBuffer buffer = ByteBuffer.wrap(bytes);
|
||||
while (buffer.hasRemaining()) {
|
||||
if (input.read(buffer) < 0) {
|
||||
throw new IOException("Truncated saved chunk region: " + normalized);
|
||||
}
|
||||
}
|
||||
}
|
||||
Object key = attributes.fileKey();
|
||||
return new Header(key == null ? "" : key.toString(), attributes.size(), bytes);
|
||||
}
|
||||
|
||||
int location(int slot) {
|
||||
return word(slot * Integer.BYTES);
|
||||
}
|
||||
|
||||
int timestamp(int slot) {
|
||||
return word(4096 + slot * Integer.BYTES);
|
||||
}
|
||||
|
||||
boolean sameHeader(Header other) {
|
||||
return fileKey.equals(other.fileKey) && Arrays.equals(bytes, other.bytes);
|
||||
}
|
||||
|
||||
private int word(int offset) {
|
||||
return (bytes[offset] & 255) << 24 | (bytes[offset + 1] & 255) << 16
|
||||
| (bytes[offset + 2] & 255) << 8 | bytes[offset + 3] & 255;
|
||||
}
|
||||
}
|
||||
|
||||
record Region(int x, int z, long size, String fileKey, int[] slots, int[] locations, int[] timestamps,
|
||||
BitSet terrain) {
|
||||
boolean matches(Header header) {
|
||||
return fileKey.equals(header.fileKey()) && header.size() >= size;
|
||||
}
|
||||
}
|
||||
|
||||
private record Contents(long scanSeconds, Long2ObjectOpenHashMap<Region> regions) {
|
||||
static final Contents EMPTY = new Contents(0L, new Long2ObjectOpenHashMap<>());
|
||||
}
|
||||
}
|
||||
@@ -224,6 +224,22 @@ public final class TerrainBoundarySignatureStore {
|
||||
return load(activationId);
|
||||
}
|
||||
|
||||
synchronized void discardSnapshot(long activationId) throws IOException {
|
||||
Path target = snapshotPath(activationId);
|
||||
if (!Files.exists(directory, LinkOption.NOFOLLOW_LINKS)) {
|
||||
return;
|
||||
}
|
||||
validateStorageAncestors();
|
||||
try (GenerationPublicationLock ignored = GenerationPublicationLock.acquire(
|
||||
directory,
|
||||
".activation-" + activationId + SNAPSHOT_FILE_SUFFIX + ".lock"
|
||||
)) {
|
||||
if (Files.deleteIfExists(target)) {
|
||||
forceDirectory(directory);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Snapshot load(long activationId) throws IOException {
|
||||
requireActivation(activationId);
|
||||
validateStorageAncestors();
|
||||
|
||||
@@ -10,12 +10,23 @@ public final class TransitionGenerationPlan {
|
||||
private final TransitionBoundarySampler terrainSampler;
|
||||
private final TransitionBandIndex terrainBand;
|
||||
private final TerrainSample newTerrain;
|
||||
private final ReclaimedChunks reclaimedChunks;
|
||||
|
||||
public TransitionGenerationPlan(
|
||||
Specification specification,
|
||||
GenerationBoundary boundary,
|
||||
TerrainBoundarySignatureStore.Snapshot terrainSignatures
|
||||
) {
|
||||
this(specification, boundary, terrainSignatures, new ReclaimedChunks());
|
||||
}
|
||||
|
||||
TransitionGenerationPlan(
|
||||
Specification specification,
|
||||
GenerationBoundary boundary,
|
||||
TerrainBoundarySignatureStore.Snapshot terrainSignatures,
|
||||
ReclaimedChunks reclaimedChunks
|
||||
) {
|
||||
this.reclaimedChunks = Objects.requireNonNull(reclaimedChunks, "Reclaimed chunks");
|
||||
this.specification = Objects.requireNonNull(specification, "Transition specification");
|
||||
this.boundary = Objects.requireNonNull(boundary, "Generation boundary");
|
||||
this.terrainSignatures = Objects.requireNonNull(terrainSignatures, "Terrain signatures");
|
||||
@@ -76,8 +87,13 @@ public final class TransitionGenerationPlan {
|
||||
return terrainSignatures;
|
||||
}
|
||||
|
||||
/** A chunk the boundary froze, unless regen has since rebuilt it with this activation's pack. */
|
||||
public boolean isHistoricalChunk(int chunkX, int chunkZ) {
|
||||
return boundary.isHistoricalChunk(chunkX, chunkZ) && !reclaimedChunks.contains(chunkX, chunkZ);
|
||||
}
|
||||
|
||||
public boolean isHistoricalBlock(int blockX, int blockZ) {
|
||||
return boundary.isHistoricalBlock(blockX, blockZ);
|
||||
return isHistoricalChunk(blockX >> 4, blockZ >> 4);
|
||||
}
|
||||
|
||||
public double distanceToHistoricalChunks(int blockX, int blockZ) {
|
||||
@@ -89,7 +105,7 @@ public final class TransitionGenerationPlan {
|
||||
}
|
||||
|
||||
public boolean allowsNewDiscreteContentAt(int blockX, int blockZ) {
|
||||
return !boundary.isHistoricalBlock(blockX, blockZ);
|
||||
return !isHistoricalBlock(blockX, blockZ);
|
||||
}
|
||||
|
||||
public boolean hasTransitionAtChunk(int chunkX, int chunkZ) {
|
||||
@@ -104,7 +120,7 @@ public final class TransitionGenerationPlan {
|
||||
}
|
||||
|
||||
public TerrainSample terrainSampleAt(int blockX, int blockZ) {
|
||||
if (boundary.isHistoricalBlock(blockX, blockZ)) {
|
||||
if (isHistoricalBlock(blockX, blockZ)) {
|
||||
return TerrainSample.historicalTerrain();
|
||||
}
|
||||
return hasTransitionAtChunk(blockX >> 4, blockZ >> 4) ? terrainSampler.sample(blockX, blockZ) : newTerrain;
|
||||
@@ -129,7 +145,8 @@ public final class TransitionGenerationPlan {
|
||||
if (minimumX > maximumX || minimumZ > maximumZ) {
|
||||
throw new IllegalArgumentException("Generation footprint bounds are inverted");
|
||||
}
|
||||
return !boundary.intersectsHistoricalBlocks(minimumX, minimumZ, maximumX, maximumZ);
|
||||
return !boundary.intersectsHistoricalBlocks(minimumX, minimumZ, maximumX, maximumZ,
|
||||
(chunkX, chunkZ) -> !reclaimedChunks.contains(chunkX, chunkZ));
|
||||
}
|
||||
|
||||
long terrainCatalogProbeCount() {
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
package art.arcane.iris.world.history;
|
||||
|
||||
import art.arcane.iris.generation.runtime.GenerationRoute;
|
||||
import art.arcane.iris.generation.runtime.GenerationScope;
|
||||
import art.arcane.iris.generation.runtime.GenerationSource;
|
||||
import art.arcane.iris.generation.runtime.PackTransitions;
|
||||
import art.arcane.iris.generation.runtime.RecordedChunks;
|
||||
import art.arcane.iris.generation.runtime.SavedBiomes;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Routes each chunk to the generation activation that owns it. Once its router detaches the world can no longer
|
||||
* generate, and the source refuses to route instead of falling back to the current pack.
|
||||
*/
|
||||
public final class VersionedGenerationSource implements GenerationSource {
|
||||
private final AttachedRouter router;
|
||||
private final SavedBiomes savedBiomes;
|
||||
private final RecordedChunks recordedChunks;
|
||||
private final PackTransitions transitions;
|
||||
|
||||
public VersionedGenerationSource(GenerationHistoryRuntimeRouter router) {
|
||||
this.router = new AttachedRouter(router);
|
||||
this.savedBiomes = new VersionedSavedBiomes(this.router);
|
||||
this.recordedChunks = new VersionedRecordedChunks(this.router);
|
||||
this.transitions = new VersionedPackTransitions(this.router);
|
||||
}
|
||||
|
||||
public void detach() {
|
||||
router.detach();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keepsPackVersions() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GenerationScope openGenerationScope(int blockX, int blockZ) throws IOException {
|
||||
return router.require().openCoordinateScope(blockX, blockZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GenerationScope openReadScope(int blockX, int blockZ) throws IOException {
|
||||
return router.require().openReadScope(blockX, blockZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GenerationRoute openRoute(int chunkX, int chunkZ) throws IOException {
|
||||
return router.require().openRoute(chunkX, chunkZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<RouteOwnership> currentRouteOwnership() {
|
||||
GenerationHistoryRuntimeRouter attached = router.attachedOrNull();
|
||||
if (attached == null) {
|
||||
return Optional.empty();
|
||||
}
|
||||
return attached.currentRuntimeOwnership()
|
||||
.map(ownership -> new RouteOwnership(ownership.activationId(), ownership.binding()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean predatesActivePack(long activationId) {
|
||||
GenerationHistoryRuntimeRouter attached = router.attachedOrNull();
|
||||
return attached != null && activationId < attached.history().activeActivation().activationId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void releaseForRegeneration(List<GenerationBoundary.ChunkCoordinate> chunks) throws IOException {
|
||||
GenerationHistoryRuntimeRouter attached = router.attachedOrNull();
|
||||
if (attached != null) {
|
||||
attached.releaseForRegeneration(chunks);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sync() throws IOException {
|
||||
GenerationHistoryRuntimeRouter attached = router.attachedOrNull();
|
||||
if (attached != null) {
|
||||
attached.history().sync();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SavedBiomes savedBiomes() {
|
||||
return savedBiomes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecordedChunks recordedChunks() {
|
||||
return recordedChunks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackTransitions transitions() {
|
||||
return transitions;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package art.arcane.iris.world.history;
|
||||
|
||||
import art.arcane.iris.generation.mantle.ObjectContinuationBundle;
|
||||
import art.arcane.iris.generation.runtime.PackTransitions;
|
||||
import art.arcane.volmlib.util.matter.Matter;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
final class VersionedPackTransitions implements PackTransitions {
|
||||
private final AttachedRouter router;
|
||||
|
||||
VersionedPackTransitions(AttachedRouter router) {
|
||||
this.router = router;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Matter> objectContinuations(TransitionGenerationPlan plan, int chunkX, int chunkZ) throws IOException {
|
||||
GenerationHistoryRuntimeRouter attached = router.attachedOrNull();
|
||||
if (attached == null) {
|
||||
return List.of();
|
||||
}
|
||||
List<GenerationHistoryRuntimeRouter.ObjectContinuation> fragments =
|
||||
attached.objectContinuations(plan, chunkX, chunkZ);
|
||||
return fragments.isEmpty() ? List.of() : attached.decodeObjectContinuations(fragments);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allowsObjectFootprint(
|
||||
TransitionGenerationPlan plan, int minimumX, int minimumZ, int maximumX, int maximumZ
|
||||
) {
|
||||
GenerationHistoryRuntimeRouter attached = router.attachedOrNull();
|
||||
return attached == null || attached.allowsObjectFootprint(plan,
|
||||
new ObjectContinuationBundle.Bounds(minimumX, minimumZ, maximumX, maximumZ));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recordNaturalTerrain(SavedTerrainChunk terrain, FloatingBiomeOverlay floatingBiomes) {
|
||||
GenerationHistoryRuntimeRouter attached = router.attachedOrNull();
|
||||
if (attached == null) {
|
||||
return;
|
||||
}
|
||||
attached.recordNaturalTerrain(terrain);
|
||||
attached.recordFloatingBiomes(terrain.chunkX(), terrain.chunkZ(), floatingBiomes);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package art.arcane.iris.world.history;
|
||||
|
||||
import art.arcane.iris.generation.runtime.RecordedChunks;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
final class VersionedRecordedChunks implements RecordedChunks {
|
||||
private final AttachedRouter router;
|
||||
|
||||
VersionedRecordedChunks(AttachedRouter router) {
|
||||
this.router = router;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean ownedByEarlierPack(int chunkX, int chunkZ) {
|
||||
GenerationHistoryRuntimeRouter attached = router.attachedOrNull();
|
||||
return attached != null && attached.history().isHistoricallyOwned(chunkX, chunkZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasUnrecordedEarlierPackChunkInSquare(int centerChunkX, int centerChunkZ, int radius) {
|
||||
GenerationHistoryRuntimeRouter attached = router.attachedOrNull();
|
||||
return attached != null && attached.history().hasHistoricalFallbackInSquare(centerChunkX, centerChunkZ, radius);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<ChunkGenerationSemantics> semantics(int chunkX, int chunkZ) {
|
||||
GenerationHistoryRuntimeRouter attached = router.attachedOrNull();
|
||||
if (attached == null) {
|
||||
return Optional.empty();
|
||||
}
|
||||
return attached.history().semantics(chunkX, chunkZ).filter(ChunkGenerationSemantics::sealed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<GenerationSemanticIndex.Match> findNearest(
|
||||
GenerationSemanticIndex.Query query,
|
||||
Predicate<ChunkGenerationSemantics> eligibility
|
||||
) {
|
||||
GenerationHistoryRuntimeRouter attached = router.attachedOrNull();
|
||||
return attached == null ? Optional.empty() : attached.history().findRecorded(query, eligibility);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package art.arcane.iris.world.history;
|
||||
|
||||
import art.arcane.iris.generation.runtime.BiomeEnvironment;
|
||||
import art.arcane.iris.generation.runtime.SavedBiomes;
|
||||
import art.arcane.iris.generation.subterrain.SubterrainCell;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.function.Function;
|
||||
|
||||
final class VersionedSavedBiomes implements SavedBiomes {
|
||||
private final AttachedRouter router;
|
||||
|
||||
VersionedSavedBiomes(AttachedRouter router) {
|
||||
this.router = router;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<BiomeEnvironment> at(int blockX, int worldY, int blockZ, boolean surface) {
|
||||
GenerationHistoryRuntimeRouter attached = router.attachedOrNull();
|
||||
return attached == null ? Optional.empty() : attached.biomes().resolve(blockX, worldY, blockZ, surface);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<BiomeEnvironment> caveBaseAt(int blockX, int blockZ) {
|
||||
GenerationHistoryRuntimeRouter attached = router.attachedOrNull();
|
||||
return attached == null ? Optional.empty() : attached.biomes().resolveCaveBase(blockX, blockZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<SubterrainCell> subterrainCellAt(int blockX, int worldY, int blockZ) {
|
||||
GenerationHistoryRuntimeRouter attached = router.attachedOrNull();
|
||||
return attached == null ? Optional.empty() : attached.biomes().subterrainCell(blockX, worldY, blockZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T readSurface(int blockX, int blockZ, Function<Optional<BiomeEnvironment>, T> reader)
|
||||
throws InterruptedException {
|
||||
GenerationHistoryRuntimeRouter attached = router.attachedOrNull();
|
||||
return attached == null ? reader.apply(Optional.empty())
|
||||
: attached.biomes().readSurfaceBiome(blockX, blockZ, reader);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Optional<SavedBiomeRuntime.ReadSession>> readChunk(int chunkX, int chunkZ) {
|
||||
GenerationHistoryRuntimeRouter attached = router.attachedOrNull();
|
||||
if (attached == null) {
|
||||
return CompletableFuture.completedFuture(Optional.empty());
|
||||
}
|
||||
return attached.biomes().readChunkAsync(chunkX, chunkZ).thenApply(Optional::of);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void prepareChunk(int chunkX, int chunkZ) {
|
||||
GenerationHistoryRuntimeRouter attached = router.attachedOrNull();
|
||||
if (attached != null) {
|
||||
attached.biomes().prepareChunk(chunkX, chunkZ);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mayHaveBlockDropRules(String material) {
|
||||
GenerationHistoryRuntimeRouter attached = router.attachedOrNull();
|
||||
return attached != null && attached.biomes().mayHaveBlockDropRules(material);
|
||||
}
|
||||
}
|
||||
Loaded 100 of 161 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user