mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-12-01 18:24:06 +00:00
Split GenerationSource into routing and three focused roles
This commit is contained in:
1 parent
bccfbae35c
commit
3dea6e30e9
19 files changed
+567
-288
No files matched your search
@@ -176,7 +176,7 @@ public final class BiomeLocator implements Locator<IrisBiome> {
|
|||||||
new ChunkGenerationSemantics.BlockPosition((origin.getX() << 4) + 8, originWorldY,
|
new ChunkGenerationSemantics.BlockPosition((origin.getX() << 4) + 8, originWorldY,
|
||||||
(origin.getZ() << 4) + 8), maximumRadius);
|
(origin.getZ() << 4) + 8), maximumRadius);
|
||||||
while (!engine.isClosing() && !Thread.currentThread().isInterrupted() && System.nanoTime() < searchDeadline) {
|
while (!engine.isClosing() && !Thread.currentThread().isInterrupted() && System.nanoTime() < searchDeadline) {
|
||||||
GenerationSemanticIndex.Match match = source.findRecorded(query,
|
GenerationSemanticIndex.Match match = source.recordedChunks().findNearest(query,
|
||||||
record -> !rejected.contains(new Position2(record.chunkX(), record.chunkZ()))).orElse(null);
|
record -> !rejected.contains(new Position2(record.chunkX(), record.chunkZ()))).orElse(null);
|
||||||
if (match == null) {
|
if (match == null) {
|
||||||
return null;
|
return null;
|
||||||
@@ -325,7 +325,7 @@ public final class BiomeLocator implements Locator<IrisBiome> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public CompletableFuture<Optional<SavedBiomeRuntime.ReadSession>> prepareRead(Engine engine, Position2 chunk) {
|
public CompletableFuture<Optional<SavedBiomeRuntime.ReadSession>> prepareRead(Engine engine, Position2 chunk) {
|
||||||
return GenerationLocatorPolicy.source(engine).readSavedBiomes(chunk.getX(), chunk.getZ());
|
return GenerationLocatorPolicy.source(engine).savedBiomes().readChunk(chunk.getX(), chunk.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
public SubterrainPosition landing(Engine engine, NativeWorld world, SubterrainPosition target,
|
public SubterrainPosition landing(Engine engine, NativeWorld world, SubterrainPosition target,
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ final class HistoryAwareLocator<T> implements Locator<T> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SearchCandidate nearestRecordedCandidate(Engine engine, Position2 origin, int maxChunkRadius) {
|
public SearchCandidate nearestRecordedCandidate(Engine engine, Position2 origin, int maxChunkRadius) {
|
||||||
GenerationSemanticIndex.Match match = GenerationLocatorPolicy.source(engine).findRecorded(
|
GenerationSemanticIndex.Match match = GenerationLocatorPolicy.source(engine).recordedChunks().findNearest(
|
||||||
GenerationSemanticIndex.Query.acrossActivations(
|
GenerationSemanticIndex.Query.acrossActivations(
|
||||||
kind,
|
kind,
|
||||||
key,
|
key,
|
||||||
@@ -138,7 +138,7 @@ final class GenerationLocatorPolicy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Optional<ChunkGenerationSemantics> recorded(Engine engine, Position2 chunk) {
|
static Optional<ChunkGenerationSemantics> recorded(Engine engine, Position2 chunk) {
|
||||||
return source(engine).recordedSemantics(chunk.getX(), chunk.getZ());
|
return source(engine).recordedChunks().semantics(chunk.getX(), chunk.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean allowsActivePrediction(Engine engine, Position2 chunk) {
|
static boolean allowsActivePrediction(Engine engine, Position2 chunk) {
|
||||||
@@ -149,11 +149,11 @@ final class GenerationLocatorPolicy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static boolean generatesWithActivePack(Engine engine, Position2 chunk) {
|
static boolean generatesWithActivePack(Engine engine, Position2 chunk) {
|
||||||
return !source(engine).ownedByEarlierPack(chunk.getX(), chunk.getZ()) && recorded(engine, chunk).isEmpty();
|
return !source(engine).recordedChunks().ownedByEarlierPack(chunk.getX(), chunk.getZ()) && recorded(engine, chunk).isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean allowsHistoricalFallback(Engine engine, Position2 chunk) {
|
static boolean allowsHistoricalFallback(Engine engine, Position2 chunk) {
|
||||||
return source(engine).ownedByEarlierPack(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) {
|
static boolean allowsProceduralPrediction(Engine engine, Position2 chunk) {
|
||||||
@@ -168,7 +168,7 @@ final class GenerationLocatorPolicy {
|
|||||||
if (radius < 0) {
|
if (radius < 0) {
|
||||||
throw new IllegalArgumentException("Historical fallback radius cannot be negative.");
|
throw new IllegalArgumentException("Historical fallback radius cannot be negative.");
|
||||||
}
|
}
|
||||||
return source(engine).hasUnrecordedEarlierPackChunkInSquare(center.getX(), center.getZ(), radius);
|
return source(engine).recordedChunks().hasUnrecordedEarlierPackChunkInSquare(center.getX(), center.getZ(), radius);
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean evaluateScoped(
|
static boolean evaluateScoped(
|
||||||
|
|||||||
@@ -235,7 +235,7 @@ public interface EngineMode extends Staged {
|
|||||||
return List.of();
|
return List.of();
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
List<Matter> continuations = irisEngine.getGenerationSource().objectContinuations(
|
List<Matter> continuations = irisEngine.getGenerationSource().transitions().objectContinuations(
|
||||||
getComplex().getTransitionGenerationPlan(), x >> 4, z >> 4);
|
getComplex().getTransitionGenerationPlan(), x >> 4, z >> 4);
|
||||||
for (Matter continuation : continuations) {
|
for (Matter continuation : continuations) {
|
||||||
if (continuation.getHeight() != getEngine().getHeight()) {
|
if (continuation.getHeight() != getEngine().getHeight()) {
|
||||||
@@ -274,7 +274,7 @@ public interface EngineMode extends Staged {
|
|||||||
try {
|
try {
|
||||||
SavedTerrainChunk terrain = IrisTransitionGeometryActuator.capture(
|
SavedTerrainChunk terrain = IrisTransitionGeometryActuator.capture(
|
||||||
x, z, blocks, biomes, getEngine().getMinHeight(), context, true);
|
x, z, blocks, biomes, getEngine().getMinHeight(), context, true);
|
||||||
source.recordNaturalTerrain(terrain, floating);
|
source.transitions().recordNaturalTerrain(terrain, floating);
|
||||||
} catch (IOException failure) {
|
} catch (IOException failure) {
|
||||||
throw new IllegalStateException("Unable to capture natural terrain at " + (x >> 4) + "," + (z >> 4), failure);
|
throw new IllegalStateException("Unable to capture natural terrain at " + (x >> 4) + "," + (z >> 4), failure);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,21 +1,10 @@
|
|||||||
package art.arcane.iris.generation.runtime;
|
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.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.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.concurrent.CompletableFuture;
|
|
||||||
import java.util.function.Function;
|
|
||||||
import java.util.function.Predicate;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Answers which pack generated, or will generate, a chunk. A single-pack world always answers the current pack. A
|
* Answers which pack generated, or will generate, a chunk. A single-pack world always answers the current pack. A
|
||||||
@@ -42,44 +31,17 @@ public interface GenerationSource {
|
|||||||
|
|
||||||
boolean predatesActivePack(long activationId);
|
boolean predatesActivePack(long activationId);
|
||||||
|
|
||||||
boolean ownedByEarlierPack(int chunkX, int chunkZ);
|
|
||||||
|
|
||||||
boolean hasUnrecordedEarlierPackChunkInSquare(int centerChunkX, int centerChunkZ, int radius);
|
|
||||||
|
|
||||||
Optional<ChunkGenerationSemantics> recordedSemantics(int chunkX, int chunkZ);
|
|
||||||
|
|
||||||
Optional<GenerationSemanticIndex.Match> findRecorded(
|
|
||||||
GenerationSemanticIndex.Query query,
|
|
||||||
Predicate<ChunkGenerationSemantics> eligibility
|
|
||||||
);
|
|
||||||
|
|
||||||
Optional<BiomeEnvironment> savedBiome(int blockX, int worldY, int blockZ, boolean surface);
|
|
||||||
|
|
||||||
Optional<BiomeEnvironment> savedCaveBase(int blockX, int blockZ);
|
|
||||||
|
|
||||||
Optional<SubterrainCell> savedSubterrainCell(int blockX, int worldY, int blockZ);
|
|
||||||
|
|
||||||
<T> T readSavedSurfaceBiome(int blockX, int blockZ, Function<Optional<BiomeEnvironment>, T> reader)
|
|
||||||
throws InterruptedException;
|
|
||||||
|
|
||||||
CompletableFuture<Optional<SavedBiomeRuntime.ReadSession>> readSavedBiomes(int chunkX, int chunkZ);
|
|
||||||
|
|
||||||
void prepareSavedBiomes(int chunkX, int chunkZ);
|
|
||||||
|
|
||||||
boolean savedBiomesMayHaveBlockDropRules(String material);
|
|
||||||
|
|
||||||
/** 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);
|
|
||||||
|
|
||||||
/** Lets the current pack regenerate these chunks, whichever pack generated them before. */
|
/** Lets the current pack regenerate these chunks, whichever pack generated them before. */
|
||||||
void releaseForRegeneration(List<GenerationBoundary.ChunkCoordinate> chunks) throws IOException;
|
void releaseForRegeneration(List<GenerationBoundary.ChunkCoordinate> chunks) throws IOException;
|
||||||
|
|
||||||
void sync() throws IOException;
|
void sync() throws IOException;
|
||||||
|
|
||||||
|
SavedBiomes savedBiomes();
|
||||||
|
|
||||||
|
RecordedChunks recordedChunks();
|
||||||
|
|
||||||
|
PackTransitions transitions();
|
||||||
|
|
||||||
record RouteOwnership(long activationId, IrisEngine.GenerationRuntimeBinding binding) {
|
record RouteOwnership(long activationId, IrisEngine.GenerationRuntimeBinding binding) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1706,7 +1706,7 @@ public class IrisComplex implements DataProvider {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return !(terrainEngine instanceof IrisEngine irisEngine) || irisEngine.getGenerationSource()
|
return !(terrainEngine instanceof IrisEngine irisEngine) || irisEngine.getGenerationSource()
|
||||||
.allowsObjectFootprint(transitionGenerationPlan, minimumX, minimumZ, maximumX, maximumZ);
|
.transitions().allowsObjectFootprint(transitionGenerationPlan, minimumX, minimumZ, maximumX, maximumZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<String> historicalPhysicalBiomeKeyAt(int blockX, int blockY, int blockZ) {
|
public Optional<String> historicalPhysicalBiomeKeyAt(int blockX, int blockY, int blockZ) {
|
||||||
|
|||||||
@@ -524,7 +524,7 @@ public class IrisEngine implements Engine {
|
|||||||
if (!usesSavedBiomeEnvironment()) {
|
if (!usesSavedBiomeEnvironment()) {
|
||||||
return Engine.super.draw(x, z);
|
return Engine.super.draw(x, z);
|
||||||
}
|
}
|
||||||
return getGenerationSource().readSavedSurfaceBiome(x, z, saved -> {
|
return getGenerationSource().savedBiomes().readSurface(x, z, saved -> {
|
||||||
if (saved.isPresent()) {
|
if (saved.isPresent()) {
|
||||||
return drawBiomeEnvironment(x, z, saved.get());
|
return drawBiomeEnvironment(x, z, saved.get());
|
||||||
}
|
}
|
||||||
@@ -553,7 +553,7 @@ public class IrisEngine implements Engine {
|
|||||||
return CompletableFuture.completedFuture(getBiomeEnvironment(x, y, z));
|
return CompletableFuture.completedFuture(getBiomeEnvironment(x, y, z));
|
||||||
}
|
}
|
||||||
int worldY = y + getWorld().minHeight();
|
int worldY = y + getWorld().minHeight();
|
||||||
return getGenerationSource().readSavedBiomes(Math.floorDiv(x, 16), Math.floorDiv(z, 16))
|
return getGenerationSource().savedBiomes().readChunk(Math.floorDiv(x, 16), Math.floorDiv(z, 16))
|
||||||
.thenApply(read -> read.flatMap(session -> session.resolve(x, worldY, z, false))
|
.thenApply(read -> read.flatMap(session -> session.resolve(x, worldY, z, false))
|
||||||
.orElseGet(() -> resolveUnsavedBiomeEnvironment(x, y, z)));
|
.orElseGet(() -> resolveUnsavedBiomeEnvironment(x, y, z)));
|
||||||
} catch (RuntimeException | Error failure) {
|
} catch (RuntimeException | Error failure) {
|
||||||
@@ -604,7 +604,7 @@ public class IrisEngine implements Engine {
|
|||||||
if (!usesSavedBiomeEnvironment()) {
|
if (!usesSavedBiomeEnvironment()) {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
return getGenerationSource().savedBiome(x, y + getWorld().minHeight(), z, surface);
|
return getGenerationSource().savedBiomes().at(x, y + getWorld().minHeight(), z, surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean usesSavedBiomeEnvironment() {
|
private boolean usesSavedBiomeEnvironment() {
|
||||||
@@ -621,7 +621,7 @@ public class IrisEngine implements Engine {
|
|||||||
EngineThreadState.Frame frame = threadState.current();
|
EngineThreadState.Frame frame = threadState.current();
|
||||||
if ((frame == null || frame.binding == null) && getGenerationSource().keepsPackVersions()) {
|
if ((frame == null || frame.binding == null) && getGenerationSource().keepsPackVersions()) {
|
||||||
Optional<SubterrainCell> saved = generationSource
|
Optional<SubterrainCell> saved = generationSource
|
||||||
.savedSubterrainCell(x, y + targetIn(frame).getWorld().minHeight(), z);
|
.savedBiomes().subterrainCellAt(x, y + targetIn(frame).getWorld().minHeight(), z);
|
||||||
if (saved.isPresent()) {
|
if (saved.isPresent()) {
|
||||||
return saved.get();
|
return saved.get();
|
||||||
}
|
}
|
||||||
@@ -774,7 +774,7 @@ public class IrisEngine implements Engine {
|
|||||||
@Override
|
@Override
|
||||||
public IrisBiome getCaveBiome(int x, int z) {
|
public IrisBiome getCaveBiome(int x, int z) {
|
||||||
if (usesSavedBiomeEnvironment()) {
|
if (usesSavedBiomeEnvironment()) {
|
||||||
Optional<BiomeEnvironment> saved = getGenerationSource().savedCaveBase(x, z);
|
Optional<BiomeEnvironment> saved = getGenerationSource().savedBiomes().caveBaseAt(x, z);
|
||||||
if (saved.isPresent()) {
|
if (saved.isPresent()) {
|
||||||
return saved.get().biome();
|
return saved.get().biome();
|
||||||
}
|
}
|
||||||
@@ -858,7 +858,7 @@ public class IrisEngine implements Engine {
|
|||||||
@ChunkCoordinates
|
@ChunkCoordinates
|
||||||
@Override
|
@Override
|
||||||
public Set<String> getObjectsAt(int x, int z) {
|
public Set<String> getObjectsAt(int x, int z) {
|
||||||
Optional<ChunkGenerationSemantics> recorded = getGenerationSource().recordedSemantics(x, z);
|
Optional<ChunkGenerationSemantics> recorded = getGenerationSource().recordedChunks().semantics(x, z);
|
||||||
if (recorded.isPresent()) {
|
if (recorded.isPresent()) {
|
||||||
return recorded.get().objectKeys();
|
return recorded.get().objectKeys();
|
||||||
}
|
}
|
||||||
@@ -871,7 +871,7 @@ public class IrisEngine implements Engine {
|
|||||||
@ChunkCoordinates
|
@ChunkCoordinates
|
||||||
@Override
|
@Override
|
||||||
public Set<ChunkGenerationSemantics.PointOfInterest> getPOIsAt(int chunkX, int chunkZ) {
|
public Set<ChunkGenerationSemantics.PointOfInterest> getPOIsAt(int chunkX, int chunkZ) {
|
||||||
Optional<ChunkGenerationSemantics> recorded = getGenerationSource().recordedSemantics(chunkX, chunkZ);
|
Optional<ChunkGenerationSemantics> recorded = getGenerationSource().recordedChunks().semantics(chunkX, chunkZ);
|
||||||
if (recorded.isPresent()) {
|
if (recorded.isPresent()) {
|
||||||
return new HashSet<>(recorded.get().pointsOfInterest());
|
return new HashSet<>(recorded.get().pointsOfInterest());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ final class MarkerSpawnScanner {
|
|||||||
|
|
||||||
private Map<IrisPosition, MarkerSpawnData> collectMarkerSpawnData(int chunkX, int chunkZ) {
|
private Map<IrisPosition, MarkerSpawnData> collectMarkerSpawnData(int chunkX, int chunkZ) {
|
||||||
if (manager.getEngine() instanceof IrisEngine engine) {
|
if (manager.getEngine() instanceof IrisEngine engine) {
|
||||||
engine.getGenerationSource().prepareSavedBiomes(chunkX, chunkZ);
|
engine.getGenerationSource().savedBiomes().prepareChunk(chunkX, chunkZ);
|
||||||
}
|
}
|
||||||
Map<IrisPosition, MarkerSpawnData> markerData = new KMap<>();
|
Map<IrisPosition, MarkerSpawnData> markerData = new KMap<>();
|
||||||
manager.getMantle().iterateChunk(chunkX, chunkZ, MatterMarker.class, (x, y, z, t) -> {
|
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);
|
||||||
|
}
|
||||||
+97
-73
@@ -22,6 +22,9 @@ import java.util.function.Predicate;
|
|||||||
final class SinglePackGenerationSource implements GenerationSource {
|
final class SinglePackGenerationSource implements GenerationSource {
|
||||||
static final SinglePackGenerationSource INSTANCE = new SinglePackGenerationSource();
|
static final SinglePackGenerationSource INSTANCE = new SinglePackGenerationSource();
|
||||||
private static final GenerationScope UNROUTED = new UnroutedScope();
|
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() {
|
private SinglePackGenerationSource() {
|
||||||
}
|
}
|
||||||
@@ -56,79 +59,6 @@ final class SinglePackGenerationSource implements GenerationSource {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@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> recordedSemantics(int chunkX, int chunkZ) {
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<GenerationSemanticIndex.Match> findRecorded(
|
|
||||||
GenerationSemanticIndex.Query query,
|
|
||||||
Predicate<ChunkGenerationSemantics> eligibility
|
|
||||||
) {
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<BiomeEnvironment> savedBiome(int blockX, int worldY, int blockZ, boolean surface) {
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<BiomeEnvironment> savedCaveBase(int blockX, int blockZ) {
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<SubterrainCell> savedSubterrainCell(int blockX, int worldY, int blockZ) {
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <T> T readSavedSurfaceBiome(int blockX, int blockZ, Function<Optional<BiomeEnvironment>, T> reader) {
|
|
||||||
return reader.apply(Optional.empty());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CompletableFuture<Optional<SavedBiomeRuntime.ReadSession>> readSavedBiomes(int chunkX, int chunkZ) {
|
|
||||||
return CompletableFuture.completedFuture(Optional.empty());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void prepareSavedBiomes(int chunkX, int chunkZ) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean savedBiomesMayHaveBlockDropRules(String material) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@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) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void releaseForRegeneration(List<GenerationBoundary.ChunkCoordinate> chunks) {
|
public void releaseForRegeneration(List<GenerationBoundary.ChunkCoordinate> chunks) {
|
||||||
}
|
}
|
||||||
@@ -137,6 +67,21 @@ final class SinglePackGenerationSource implements GenerationSource {
|
|||||||
public void sync() {
|
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 {
|
private static final class UnroutedScope implements GenerationScope {
|
||||||
@Override
|
@Override
|
||||||
public boolean claimGeneratedSemantics() {
|
public boolean claimGeneratedSemantics() {
|
||||||
@@ -147,4 +92,83 @@ final class SinglePackGenerationSource implements GenerationSource {
|
|||||||
public void close() {
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
if (manager.getEngine() instanceof IrisEngine engine) {
|
if (manager.getEngine() instanceof IrisEngine engine) {
|
||||||
return engine.getGenerationSource().savedBiomesMayHaveBlockDropRules(material);
|
return engine.getGenerationSource().savedBiomes().mayHaveBlockDropRules(material);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,34 +1,35 @@
|
|||||||
package art.arcane.iris.world.history;
|
package art.arcane.iris.world.history;
|
||||||
|
|
||||||
import art.arcane.iris.generation.mantle.ObjectContinuationBundle;
|
|
||||||
import art.arcane.iris.generation.runtime.BiomeEnvironment;
|
|
||||||
import art.arcane.iris.generation.runtime.GenerationRoute;
|
import art.arcane.iris.generation.runtime.GenerationRoute;
|
||||||
import art.arcane.iris.generation.runtime.GenerationScope;
|
import art.arcane.iris.generation.runtime.GenerationScope;
|
||||||
import art.arcane.iris.generation.runtime.GenerationSource;
|
import art.arcane.iris.generation.runtime.GenerationSource;
|
||||||
import art.arcane.iris.generation.subterrain.SubterrainCell;
|
import art.arcane.iris.generation.runtime.PackTransitions;
|
||||||
import art.arcane.volmlib.util.matter.Matter;
|
import art.arcane.iris.generation.runtime.RecordedChunks;
|
||||||
|
import art.arcane.iris.generation.runtime.SavedBiomes;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.concurrent.CompletableFuture;
|
|
||||||
import java.util.function.Function;
|
|
||||||
import java.util.function.Predicate;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Routes each chunk to the generation activation that owns it. Once its router detaches the world can no longer
|
* 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.
|
* generate, and the source refuses to route instead of falling back to the current pack.
|
||||||
*/
|
*/
|
||||||
public final class VersionedGenerationSource implements GenerationSource {
|
public final class VersionedGenerationSource implements GenerationSource {
|
||||||
private volatile GenerationHistoryRuntimeRouter router;
|
private final AttachedRouter router;
|
||||||
|
private final SavedBiomes savedBiomes;
|
||||||
|
private final RecordedChunks recordedChunks;
|
||||||
|
private final PackTransitions transitions;
|
||||||
|
|
||||||
public VersionedGenerationSource(GenerationHistoryRuntimeRouter router) {
|
public VersionedGenerationSource(GenerationHistoryRuntimeRouter router) {
|
||||||
this.router = Objects.requireNonNull(router, "generation-history runtime 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() {
|
public void detach() {
|
||||||
router = null;
|
router.detach();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -38,22 +39,22 @@ public final class VersionedGenerationSource implements GenerationSource {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GenerationScope openGenerationScope(int blockX, int blockZ) throws IOException {
|
public GenerationScope openGenerationScope(int blockX, int blockZ) throws IOException {
|
||||||
return requireRouter().openCoordinateScope(blockX, blockZ);
|
return router.require().openCoordinateScope(blockX, blockZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GenerationScope openReadScope(int blockX, int blockZ) throws IOException {
|
public GenerationScope openReadScope(int blockX, int blockZ) throws IOException {
|
||||||
return requireRouter().openReadScope(blockX, blockZ);
|
return router.require().openReadScope(blockX, blockZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GenerationRoute openRoute(int chunkX, int chunkZ) throws IOException {
|
public GenerationRoute openRoute(int chunkX, int chunkZ) throws IOException {
|
||||||
return requireRouter().openRoute(chunkX, chunkZ);
|
return router.require().openRoute(chunkX, chunkZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<RouteOwnership> currentRouteOwnership() {
|
public Optional<RouteOwnership> currentRouteOwnership() {
|
||||||
GenerationHistoryRuntimeRouter attached = router;
|
GenerationHistoryRuntimeRouter attached = router.attachedOrNull();
|
||||||
if (attached == null) {
|
if (attached == null) {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
@@ -63,122 +64,13 @@ public final class VersionedGenerationSource implements GenerationSource {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean predatesActivePack(long activationId) {
|
public boolean predatesActivePack(long activationId) {
|
||||||
GenerationHistoryRuntimeRouter attached = router;
|
GenerationHistoryRuntimeRouter attached = router.attachedOrNull();
|
||||||
return attached != null && activationId < attached.history().activeActivation().activationId();
|
return attached != null && activationId < attached.history().activeActivation().activationId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean ownedByEarlierPack(int chunkX, int chunkZ) {
|
|
||||||
GenerationHistoryRuntimeRouter attached = router;
|
|
||||||
return attached != null && attached.history().isHistoricallyOwned(chunkX, chunkZ);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasUnrecordedEarlierPackChunkInSquare(int centerChunkX, int centerChunkZ, int radius) {
|
|
||||||
GenerationHistoryRuntimeRouter attached = router;
|
|
||||||
return attached != null && attached.history().hasHistoricalFallbackInSquare(centerChunkX, centerChunkZ, radius);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<ChunkGenerationSemantics> recordedSemantics(int chunkX, int chunkZ) {
|
|
||||||
GenerationHistoryRuntimeRouter attached = router;
|
|
||||||
if (attached == null) {
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
return attached.history().semantics(chunkX, chunkZ).filter(ChunkGenerationSemantics::sealed);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<GenerationSemanticIndex.Match> findRecorded(
|
|
||||||
GenerationSemanticIndex.Query query,
|
|
||||||
Predicate<ChunkGenerationSemantics> eligibility
|
|
||||||
) {
|
|
||||||
GenerationHistoryRuntimeRouter attached = router;
|
|
||||||
return attached == null ? Optional.empty() : attached.history().findRecorded(query, eligibility);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<BiomeEnvironment> savedBiome(int blockX, int worldY, int blockZ, boolean surface) {
|
|
||||||
GenerationHistoryRuntimeRouter attached = router;
|
|
||||||
return attached == null ? Optional.empty() : attached.biomes().resolve(blockX, worldY, blockZ, surface);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<BiomeEnvironment> savedCaveBase(int blockX, int blockZ) {
|
|
||||||
GenerationHistoryRuntimeRouter attached = router;
|
|
||||||
return attached == null ? Optional.empty() : attached.biomes().resolveCaveBase(blockX, blockZ);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<SubterrainCell> savedSubterrainCell(int blockX, int worldY, int blockZ) {
|
|
||||||
GenerationHistoryRuntimeRouter attached = router;
|
|
||||||
return attached == null ? Optional.empty() : attached.biomes().subterrainCell(blockX, worldY, blockZ);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <T> T readSavedSurfaceBiome(int blockX, int blockZ, Function<Optional<BiomeEnvironment>, T> reader)
|
|
||||||
throws InterruptedException {
|
|
||||||
GenerationHistoryRuntimeRouter attached = router;
|
|
||||||
return attached == null ? reader.apply(Optional.empty())
|
|
||||||
: attached.biomes().readSurfaceBiome(blockX, blockZ, reader);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CompletableFuture<Optional<SavedBiomeRuntime.ReadSession>> readSavedBiomes(int chunkX, int chunkZ) {
|
|
||||||
GenerationHistoryRuntimeRouter attached = router;
|
|
||||||
if (attached == null) {
|
|
||||||
return CompletableFuture.completedFuture(Optional.empty());
|
|
||||||
}
|
|
||||||
return attached.biomes().readChunkAsync(chunkX, chunkZ).thenApply(Optional::of);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void prepareSavedBiomes(int chunkX, int chunkZ) {
|
|
||||||
GenerationHistoryRuntimeRouter attached = router;
|
|
||||||
if (attached != null) {
|
|
||||||
attached.biomes().prepareChunk(chunkX, chunkZ);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean savedBiomesMayHaveBlockDropRules(String material) {
|
|
||||||
GenerationHistoryRuntimeRouter attached = router;
|
|
||||||
return attached != null && attached.biomes().mayHaveBlockDropRules(material);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Matter> objectContinuations(TransitionGenerationPlan plan, int chunkX, int chunkZ) throws IOException {
|
|
||||||
GenerationHistoryRuntimeRouter attached = router;
|
|
||||||
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;
|
|
||||||
return attached == null || attached.allowsObjectFootprint(plan,
|
|
||||||
new ObjectContinuationBundle.Bounds(minimumX, minimumZ, maximumX, maximumZ));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void recordNaturalTerrain(SavedTerrainChunk terrain, FloatingBiomeOverlay floatingBiomes) {
|
|
||||||
GenerationHistoryRuntimeRouter attached = router;
|
|
||||||
if (attached == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
attached.recordNaturalTerrain(terrain);
|
|
||||||
attached.recordFloatingBiomes(terrain.chunkX(), terrain.chunkZ(), floatingBiomes);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void releaseForRegeneration(List<GenerationBoundary.ChunkCoordinate> chunks) throws IOException {
|
public void releaseForRegeneration(List<GenerationBoundary.ChunkCoordinate> chunks) throws IOException {
|
||||||
GenerationHistoryRuntimeRouter attached = router;
|
GenerationHistoryRuntimeRouter attached = router.attachedOrNull();
|
||||||
if (attached != null) {
|
if (attached != null) {
|
||||||
attached.releaseForRegeneration(chunks);
|
attached.releaseForRegeneration(chunks);
|
||||||
}
|
}
|
||||||
@@ -186,17 +78,24 @@ public final class VersionedGenerationSource implements GenerationSource {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sync() throws IOException {
|
public void sync() throws IOException {
|
||||||
GenerationHistoryRuntimeRouter attached = router;
|
GenerationHistoryRuntimeRouter attached = router.attachedOrNull();
|
||||||
if (attached != null) {
|
if (attached != null) {
|
||||||
attached.history().sync();
|
attached.history().sync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private GenerationHistoryRuntimeRouter requireRouter() {
|
@Override
|
||||||
GenerationHistoryRuntimeRouter attached = router;
|
public SavedBiomes savedBiomes() {
|
||||||
if (attached == null) {
|
return savedBiomes;
|
||||||
throw new IllegalStateException("Iris generation-history runtime router is detached.");
|
}
|
||||||
}
|
|
||||||
return attached;
|
@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);
|
||||||
|
}
|
||||||
|
}
|
||||||
+37
-14
@@ -9,6 +9,7 @@ import java.util.Optional;
|
|||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.Assert.assertNull;
|
||||||
|
import static org.junit.Assert.assertSame;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
public class SinglePackGenerationSourceTest {
|
public class SinglePackGenerationSourceTest {
|
||||||
@@ -19,9 +20,7 @@ public class SinglePackGenerationSourceTest {
|
|||||||
assertFalse(source.keepsPackVersions());
|
assertFalse(source.keepsPackVersions());
|
||||||
assertNull(source.openRoute(-72, -15));
|
assertNull(source.openRoute(-72, -15));
|
||||||
assertTrue(source.currentRouteOwnership().isEmpty());
|
assertTrue(source.currentRouteOwnership().isEmpty());
|
||||||
assertFalse(source.ownedByEarlierPack(-72, -15));
|
|
||||||
assertFalse(source.predatesActivePack(1L));
|
assertFalse(source.predatesActivePack(1L));
|
||||||
assertFalse(source.hasUnrecordedEarlierPackChunkInSquare(0, 0, 8));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -35,23 +34,47 @@ public class SinglePackGenerationSourceTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void savedStateIsAlwaysAbsent() throws Exception {
|
public void rolesAreSharedAcrossCalls() {
|
||||||
assertTrue(source.recordedSemantics(0, 0).isEmpty());
|
assertSame(source.savedBiomes(), source.savedBiomes());
|
||||||
assertTrue(source.findRecorded(null, record -> true).isEmpty());
|
assertSame(source.recordedChunks(), source.recordedChunks());
|
||||||
assertTrue(source.savedBiome(0, 64, 0, true).isEmpty());
|
assertSame(source.transitions(), source.transitions());
|
||||||
assertTrue(source.savedCaveBase(0, 0).isEmpty());
|
}
|
||||||
assertTrue(source.savedSubterrainCell(0, 0, 0).isEmpty());
|
|
||||||
assertEquals(Optional.empty(), source.readSavedBiomes(0, 0).join());
|
@Test
|
||||||
assertEquals("absent", source.readSavedSurfaceBiome(0, 0, saved -> saved.isEmpty() ? "absent" : "saved"));
|
public void savedBiomesAreAlwaysAbsent() throws Exception {
|
||||||
assertFalse(source.savedBiomesMayHaveBlockDropRules("minecraft:stone"));
|
SavedBiomes biomes = source.savedBiomes();
|
||||||
assertEquals(List.of(), source.objectContinuations(null, 0, 0));
|
|
||||||
assertTrue(source.allowsObjectFootprint(null, -8, -8, 8, 8));
|
assertTrue(biomes.at(0, 64, 0, true).isEmpty());
|
||||||
|
assertTrue(biomes.caveBaseAt(0, 0).isEmpty());
|
||||||
|
assertTrue(biomes.subterrainCellAt(0, 0, 0).isEmpty());
|
||||||
|
assertEquals(Optional.empty(), biomes.readChunk(0, 0).join());
|
||||||
|
assertEquals("absent", biomes.readSurface(0, 0, saved -> saved.isEmpty() ? "absent" : "saved"));
|
||||||
|
assertFalse(biomes.mayHaveBlockDropRules("minecraft:stone"));
|
||||||
|
biomes.prepareChunk(0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void noChunkWasRecordedByAnEarlierPack() {
|
||||||
|
RecordedChunks recorded = source.recordedChunks();
|
||||||
|
|
||||||
|
assertFalse(recorded.ownedByEarlierPack(-72, -15));
|
||||||
|
assertFalse(recorded.hasUnrecordedEarlierPackChunkInSquare(0, 0, 8));
|
||||||
|
assertTrue(recorded.semantics(0, 0).isEmpty());
|
||||||
|
assertTrue(recorded.findNearest(null, record -> true).isEmpty());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void transitionsCarryNothingAndAllowEveryFootprint() throws Exception {
|
||||||
|
PackTransitions transitions = source.transitions();
|
||||||
|
|
||||||
|
assertEquals(List.of(), transitions.objectContinuations(null, 0, 0));
|
||||||
|
assertTrue(transitions.allowsObjectFootprint(null, -8, -8, 8, 8));
|
||||||
|
transitions.recordNaturalTerrain(null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void regenerationAndSyncHaveNothingToRelease() throws Exception {
|
public void regenerationAndSyncHaveNothingToRelease() throws Exception {
|
||||||
source.releaseForRegeneration(List.of(new GenerationBoundary.ChunkCoordinate(-72, -15)));
|
source.releaseForRegeneration(List.of(new GenerationBoundary.ChunkCoordinate(-72, -15)));
|
||||||
source.recordNaturalTerrain(null, null);
|
|
||||||
source.sync();
|
source.sync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+121
-5
@@ -1,20 +1,31 @@
|
|||||||
package art.arcane.iris.world.history;
|
package art.arcane.iris.world.history;
|
||||||
|
|
||||||
|
import art.arcane.iris.generation.mantle.ObjectContinuationBundle;
|
||||||
|
import art.arcane.iris.generation.runtime.BiomeEnvironment;
|
||||||
import art.arcane.iris.generation.runtime.GenerationScope;
|
import art.arcane.iris.generation.runtime.GenerationScope;
|
||||||
|
import art.arcane.iris.generation.runtime.PackTransitions;
|
||||||
|
import art.arcane.iris.generation.runtime.RecordedChunks;
|
||||||
|
import art.arcane.iris.generation.runtime.SavedBiomes;
|
||||||
|
import art.arcane.iris.generation.subterrain.SubterrainCell;
|
||||||
|
import art.arcane.volmlib.util.matter.Matter;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertSame;
|
import static org.junit.Assert.assertSame;
|
||||||
import static org.junit.Assert.assertThrows;
|
import static org.junit.Assert.assertThrows;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.ArgumentMatchers.anyInt;
|
import static org.mockito.ArgumentMatchers.anyInt;
|
||||||
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.never;
|
import static org.mockito.Mockito.never;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
|
import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
public class VersionedGenerationSourceTest {
|
public class VersionedGenerationSourceTest {
|
||||||
@@ -52,10 +63,86 @@ public class VersionedGenerationSourceTest {
|
|||||||
|
|
||||||
assertTrue(source.predatesActivePack(2L));
|
assertTrue(source.predatesActivePack(2L));
|
||||||
assertFalse(source.predatesActivePack(3L));
|
assertFalse(source.predatesActivePack(3L));
|
||||||
assertTrue(source.ownedByEarlierPack(-72, -15));
|
assertTrue(source.recordedChunks().ownedByEarlierPack(-72, -15));
|
||||||
assertFalse(source.ownedByEarlierPack(0, 0));
|
assertFalse(source.recordedChunks().ownedByEarlierPack(0, 0));
|
||||||
assertSame(sealed, source.recordedSemantics(0, 0).orElseThrow());
|
assertSame(sealed, source.recordedChunks().semantics(0, 0).orElseThrow());
|
||||||
assertTrue(source.recordedSemantics(1, 0).isEmpty());
|
assertTrue(source.recordedChunks().semantics(1, 0).isEmpty());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void rolesAreSharedAcrossCalls() {
|
||||||
|
VersionedGenerationSource source = new VersionedGenerationSource(mock(GenerationHistoryRuntimeRouter.class));
|
||||||
|
|
||||||
|
assertSame(source.savedBiomes(), source.savedBiomes());
|
||||||
|
assertSame(source.recordedChunks(), source.recordedChunks());
|
||||||
|
assertSame(source.transitions(), source.transitions());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void recordedChunksReadTheHistory() {
|
||||||
|
GenerationHistoryRuntimeRouter router = mock(GenerationHistoryRuntimeRouter.class);
|
||||||
|
GenerationHistory history = mock(GenerationHistory.class);
|
||||||
|
GenerationSemanticIndex.Match match = mock(GenerationSemanticIndex.Match.class);
|
||||||
|
when(router.history()).thenReturn(history);
|
||||||
|
when(history.hasHistoricalFallbackInSquare(0, 0, 8)).thenReturn(true);
|
||||||
|
when(history.findRecorded(any(), any())).thenReturn(Optional.of(match));
|
||||||
|
RecordedChunks recorded = new VersionedGenerationSource(router).recordedChunks();
|
||||||
|
|
||||||
|
assertTrue(recorded.hasUnrecordedEarlierPackChunkInSquare(0, 0, 8));
|
||||||
|
assertFalse(recorded.hasUnrecordedEarlierPackChunkInSquare(1, 1, 8));
|
||||||
|
assertSame(match, recorded.findNearest(null, record -> true).orElseThrow());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void savedBiomesReadTheSavedBiomeRuntime() throws Exception {
|
||||||
|
GenerationHistoryRuntimeRouter router = mock(GenerationHistoryRuntimeRouter.class);
|
||||||
|
SavedBiomeRuntime saved = mock(SavedBiomeRuntime.class);
|
||||||
|
BiomeEnvironment surface = mock(BiomeEnvironment.class);
|
||||||
|
BiomeEnvironment caveBase = mock(BiomeEnvironment.class);
|
||||||
|
SubterrainCell cell = mock(SubterrainCell.class);
|
||||||
|
SavedBiomeRuntime.ReadSession session = mock(SavedBiomeRuntime.ReadSession.class);
|
||||||
|
when(router.biomes()).thenReturn(saved);
|
||||||
|
when(saved.resolve(-20, 64, 18, true)).thenReturn(Optional.of(surface));
|
||||||
|
when(saved.resolveCaveBase(-20, 18)).thenReturn(Optional.of(caveBase));
|
||||||
|
when(saved.subterrainCell(-20, 12, 18)).thenReturn(Optional.of(cell));
|
||||||
|
when(saved.readSurfaceBiome(eq(-20), eq(18), any())).thenReturn("saved");
|
||||||
|
when(saved.readChunkAsync(-2, 1)).thenReturn(CompletableFuture.completedFuture(session));
|
||||||
|
when(saved.mayHaveBlockDropRules("minecraft:stone")).thenReturn(true);
|
||||||
|
SavedBiomes biomes = new VersionedGenerationSource(router).savedBiomes();
|
||||||
|
|
||||||
|
assertSame(surface, biomes.at(-20, 64, 18, true).orElseThrow());
|
||||||
|
assertSame(caveBase, biomes.caveBaseAt(-20, 18).orElseThrow());
|
||||||
|
assertSame(cell, biomes.subterrainCellAt(-20, 12, 18).orElseThrow());
|
||||||
|
assertEquals("saved", biomes.readSurface(-20, 18, ignored -> "unsaved"));
|
||||||
|
assertSame(session, biomes.readChunk(-2, 1).join().orElseThrow());
|
||||||
|
assertTrue(biomes.mayHaveBlockDropRules("minecraft:stone"));
|
||||||
|
biomes.prepareChunk(-2, 1);
|
||||||
|
verify(saved).prepareChunk(-2, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void transitionsGoThroughTheRouter() throws Exception {
|
||||||
|
GenerationHistoryRuntimeRouter router = mock(GenerationHistoryRuntimeRouter.class);
|
||||||
|
TransitionGenerationPlan plan = mock(TransitionGenerationPlan.class);
|
||||||
|
List<GenerationHistoryRuntimeRouter.ObjectContinuation> fragments =
|
||||||
|
List.of(new GenerationHistoryRuntimeRouter.ObjectContinuation(1L, null));
|
||||||
|
List<Matter> decoded = List.of(mock(Matter.class));
|
||||||
|
SavedTerrainChunk terrain = mock(SavedTerrainChunk.class);
|
||||||
|
FloatingBiomeOverlay floating = mock(FloatingBiomeOverlay.class);
|
||||||
|
when(router.objectContinuations(plan, -2, 1)).thenReturn(fragments);
|
||||||
|
when(router.objectContinuations(plan, 0, 0)).thenReturn(List.of());
|
||||||
|
when(router.decodeObjectContinuations(fragments)).thenReturn(decoded);
|
||||||
|
when(router.allowsObjectFootprint(plan, new ObjectContinuationBundle.Bounds(-8, -8, 8, 8))).thenReturn(false);
|
||||||
|
when(terrain.chunkX()).thenReturn(-2);
|
||||||
|
when(terrain.chunkZ()).thenReturn(1);
|
||||||
|
PackTransitions transitions = new VersionedGenerationSource(router).transitions();
|
||||||
|
|
||||||
|
assertSame(decoded, transitions.objectContinuations(plan, -2, 1));
|
||||||
|
assertEquals(List.of(), transitions.objectContinuations(plan, 0, 0));
|
||||||
|
assertFalse(transitions.allowsObjectFootprint(plan, -8, -8, 8, 8));
|
||||||
|
transitions.recordNaturalTerrain(terrain, floating);
|
||||||
|
verify(router).recordNaturalTerrain(terrain);
|
||||||
|
verify(router).recordFloatingBiomes(-2, 1, floating);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -79,8 +166,37 @@ public class VersionedGenerationSourceTest {
|
|||||||
assertEquals(DETACHED, scope.getMessage());
|
assertEquals(DETACHED, scope.getMessage());
|
||||||
assertEquals(DETACHED, assertThrows(IllegalStateException.class, () -> source.openRoute(0, 0)).getMessage());
|
assertEquals(DETACHED, assertThrows(IllegalStateException.class, () -> source.openRoute(0, 0)).getMessage());
|
||||||
assertEquals(DETACHED, assertThrows(IllegalStateException.class, () -> source.openReadScope(0, 0)).getMessage());
|
assertEquals(DETACHED, assertThrows(IllegalStateException.class, () -> source.openReadScope(0, 0)).getMessage());
|
||||||
assertTrue(source.recordedSemantics(0, 0).isEmpty());
|
assertTrue(source.recordedChunks().semantics(0, 0).isEmpty());
|
||||||
assertTrue(source.currentRouteOwnership().isEmpty());
|
assertTrue(source.currentRouteOwnership().isEmpty());
|
||||||
verify(router, never()).openCoordinateScope(anyInt(), anyInt());
|
verify(router, never()).openCoordinateScope(anyInt(), anyInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void detachedRolesAnswerAsIfNothingWasSaved() throws Exception {
|
||||||
|
GenerationHistoryRuntimeRouter router = mock(GenerationHistoryRuntimeRouter.class);
|
||||||
|
VersionedGenerationSource source = new VersionedGenerationSource(router);
|
||||||
|
SavedBiomes biomes = source.savedBiomes();
|
||||||
|
RecordedChunks recorded = source.recordedChunks();
|
||||||
|
PackTransitions transitions = source.transitions();
|
||||||
|
source.detach();
|
||||||
|
|
||||||
|
assertFalse(source.predatesActivePack(0L));
|
||||||
|
source.releaseForRegeneration(List.of(new GenerationBoundary.ChunkCoordinate(-72, -15)));
|
||||||
|
source.sync();
|
||||||
|
assertTrue(biomes.at(0, 64, 0, true).isEmpty());
|
||||||
|
assertTrue(biomes.caveBaseAt(0, 0).isEmpty());
|
||||||
|
assertTrue(biomes.subterrainCellAt(0, 0, 0).isEmpty());
|
||||||
|
assertEquals("absent", biomes.readSurface(0, 0, saved -> saved.isEmpty() ? "absent" : "saved"));
|
||||||
|
assertEquals(Optional.empty(), biomes.readChunk(0, 0).join());
|
||||||
|
assertFalse(biomes.mayHaveBlockDropRules("minecraft:stone"));
|
||||||
|
biomes.prepareChunk(0, 0);
|
||||||
|
assertFalse(recorded.ownedByEarlierPack(-72, -15));
|
||||||
|
assertFalse(recorded.hasUnrecordedEarlierPackChunkInSquare(0, 0, 8));
|
||||||
|
assertTrue(recorded.semantics(0, 0).isEmpty());
|
||||||
|
assertTrue(recorded.findNearest(null, record -> true).isEmpty());
|
||||||
|
assertEquals(List.of(), transitions.objectContinuations(null, 0, 0));
|
||||||
|
assertTrue(transitions.allowsObjectFootprint(null, -8, -8, 8, 8));
|
||||||
|
transitions.recordNaturalTerrain(null, null);
|
||||||
|
verifyNoInteractions(router);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user