mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-27 16:25:36 +00:00
Structures respect rivers
- Add the allowWater structure placement field and recapture the schema digest - Skip surface Iris structures whose piece footprint is more than 10% channel, pond, cascade or waterfall water - Skip surface native placements whose start chunk is more than 10% of that water - Fail closed on a provisional water answer off the server thread - Keep BORE and FORCE_CARVE out of water columns from two blocks below the floor and out of the two-block bank up to the water surface - Run structure pieces and stilts inside a MantleWriter object placement that applies the object water veto unless the placement allows water - Let forced single pieces of allowWater structures enter water like an object's own forcePlace - Apply the object water veto to floating-island object transactions - Share the veto between the destination transaction, MantleWriter and floating transactions - Reset the destination transaction's water flag when an object placement ends
This commit is contained in:
1 parent
cabfca700a
commit
ba0bb1a2c0
20 files changed
+1052
-165
No files matched your search
+22
-3
@@ -35,6 +35,7 @@ import java.util.function.Supplier;
|
||||
import java.util.Objects;
|
||||
import art.arcane.volmlib.util.matter.IrisMatter;
|
||||
import art.arcane.volmlib.util.matter.Matter;
|
||||
import art.arcane.volmlib.util.matter.MatterCavern;
|
||||
import art.arcane.iris.world.storage.matter.IrisMatterSupport;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -43,14 +44,18 @@ final class FloatingObjectPlacementTransaction implements IObjectPlacer {
|
||||
private final ObjectContinuationBundle.PlacementKey placementKey;
|
||||
private final KList<BufferedMutation> mutations;
|
||||
private final Map<PositionKey, NativeBlockState> bufferedBlocks;
|
||||
private final boolean entersWater;
|
||||
private ObjectHydrologyVeto waterVeto;
|
||||
private int blockWrites;
|
||||
private BlockPosition canopyPosition;
|
||||
|
||||
FloatingObjectPlacementTransaction(IObjectPlacer delegate, ObjectContinuationBundle.PlacementKey placementKey) {
|
||||
FloatingObjectPlacementTransaction(IObjectPlacer delegate, ObjectContinuationBundle.PlacementKey placementKey,
|
||||
boolean entersWater) {
|
||||
this.delegate = Objects.requireNonNull(delegate);
|
||||
this.placementKey = Objects.requireNonNull(placementKey);
|
||||
this.mutations = new KList<>();
|
||||
this.bufferedBlocks = new HashMap<>();
|
||||
this.entersWater = entersWater;
|
||||
}
|
||||
|
||||
CommitResult commit() {
|
||||
@@ -156,7 +161,7 @@ final class FloatingObjectPlacementTransaction implements IObjectPlacer {
|
||||
|
||||
@Override
|
||||
public void set(int x, int y, int z, NativeBlockState state) {
|
||||
if (state == null) {
|
||||
if (state == null || waterVeto().keepsBlock(x, y, z, state, entersWater)) {
|
||||
return;
|
||||
}
|
||||
mutations.add(new BlockMutation(x, y, z, state, isCanopy(x, y, z)));
|
||||
@@ -234,7 +239,7 @@ final class FloatingObjectPlacementTransaction implements IObjectPlacer {
|
||||
|
||||
@Override
|
||||
public <T> void setData(int x, int y, int z, T data) {
|
||||
if (data == null) {
|
||||
if (data == null || keepsWater(x, y, z, data)) {
|
||||
return;
|
||||
}
|
||||
mutations.add(new DataMutation(x, y, z, data, isCanopy(x, y, z)));
|
||||
@@ -244,6 +249,20 @@ final class FloatingObjectPlacementTransaction implements IObjectPlacer {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean keepsWater(int x, int y, int z, Object data) {
|
||||
if (data instanceof NativeBlockState state) {
|
||||
return waterVeto().keepsBlock(x, y, z, state, entersWater);
|
||||
}
|
||||
return data instanceof MatterCavern && waterVeto().keeps(x, y, z, false, entersWater);
|
||||
}
|
||||
|
||||
private ObjectHydrologyVeto waterVeto() {
|
||||
if (waterVeto == null) {
|
||||
waterVeto = ObjectHydrologyVeto.of(delegate.getEngine());
|
||||
}
|
||||
return waterVeto;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> @Nullable T getData(int x, int y, int z, Class<T> type) {
|
||||
for (int i = mutations.size() - 1; i >= 0; i--) {
|
||||
|
||||
@@ -147,51 +147,51 @@ public class IrisStructureComponent extends IrisMantleComponent {
|
||||
+ " is not implemented for structure '" + key + "'");
|
||||
}
|
||||
|
||||
ObjectPlaceMode mode = structure.getPlaceMode();
|
||||
int failedPieces = 0;
|
||||
IrisStructureStiltSettings stilt = placement.getStilt();
|
||||
Long2IntOpenHashMap foundationColumns = stilt == null
|
||||
? null : new Long2IntOpenHashMap();
|
||||
boolean supportNonOccluding = stilt != null && stilt.isSupportNonOccluding();
|
||||
if (placement.isAnchoredUnderground()) {
|
||||
ObjectPlaceMode undergroundMode = (mode == ObjectPlaceMode.ORGANIC_STILT || mode == ObjectPlaceMode.CEILING_HANG)
|
||||
? mode : ObjectPlaceMode.STRUCTURE_PIECE;
|
||||
for (PlacedStructurePiece p : pieces) {
|
||||
if (placeObject(writer, structure, p, undergroundMode, false, rng,
|
||||
foundationColumns, supportNonOccluding) == -1) {
|
||||
failedPieces++;
|
||||
}
|
||||
}
|
||||
} else if (mode == ObjectPlaceMode.STRUCTURE_PIECE || mode == ObjectPlaceMode.FLOATING) {
|
||||
for (PlacedStructurePiece p : pieces) {
|
||||
if (placeObject(writer, structure, p, ObjectPlaceMode.STRUCTURE_PIECE, false, rng,
|
||||
foundationColumns, supportNonOccluding) == -1) {
|
||||
failedPieces++;
|
||||
}
|
||||
}
|
||||
} else if (pieces.size() == 1) {
|
||||
if (placeObject(writer, structure, pieces.getFirst(), mode, true, rng,
|
||||
foundationColumns, supportNonOccluding) == -1) {
|
||||
failedPieces++;
|
||||
}
|
||||
} else {
|
||||
for (PlacedStructurePiece p : pieces) {
|
||||
if (placeObject(writer, structure, p, ObjectPlaceMode.STRUCTURE_PIECE, false, rng,
|
||||
foundationColumns, supportNonOccluding) == -1) {
|
||||
failedPieces++;
|
||||
}
|
||||
}
|
||||
}
|
||||
int failedPieces = placePieces(writer, placement, structure, pieces, rng);
|
||||
requireAppliedPieces(resolved, cx, cz, failedPieces);
|
||||
if (failedPieces == 0 && stilt != null) {
|
||||
placeFoundation(writer, foundationColumns, stilt, rng, !placement.isAnchoredUnderground());
|
||||
}
|
||||
if (failedPieces == 0) {
|
||||
capture.commit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int placePieces(MantleWriter writer, IrisStructurePlacement placement, IrisStructure structure,
|
||||
KList<PlacedStructurePiece> pieces, RNG rng) {
|
||||
IrisStructureStiltSettings stilt = placement.getStilt();
|
||||
PieceRun run = new PieceRun(structure, rng, stilt == null ? null : new Long2IntOpenHashMap(),
|
||||
stilt != null && stilt.isSupportNonOccluding(), placement.isAllowWater());
|
||||
ObjectPlaceMode mode = structure.getPlaceMode();
|
||||
int failedPieces = 0;
|
||||
int water = writer.beginObjectPlacement(run.allowWater());
|
||||
try {
|
||||
if (placement.isAnchoredUnderground()) {
|
||||
ObjectPlaceMode undergroundMode = (mode == ObjectPlaceMode.ORGANIC_STILT || mode == ObjectPlaceMode.CEILING_HANG)
|
||||
? mode : ObjectPlaceMode.STRUCTURE_PIECE;
|
||||
for (PlacedStructurePiece p : pieces) {
|
||||
if (placeObject(writer, run, p, undergroundMode, false) == -1) {
|
||||
failedPieces++;
|
||||
}
|
||||
}
|
||||
} else if (pieces.size() == 1 && mode != ObjectPlaceMode.STRUCTURE_PIECE && mode != ObjectPlaceMode.FLOATING) {
|
||||
if (placeObject(writer, run, pieces.getFirst(), mode, true) == -1) {
|
||||
failedPieces++;
|
||||
}
|
||||
} else {
|
||||
for (PlacedStructurePiece p : pieces) {
|
||||
if (placeObject(writer, run, p, ObjectPlaceMode.STRUCTURE_PIECE, false) == -1) {
|
||||
failedPieces++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (failedPieces == 0 && stilt != null) {
|
||||
placeFoundation(writer, run.foundationColumns(), stilt, rng, !placement.isAnchoredUnderground());
|
||||
}
|
||||
} finally {
|
||||
writer.endObjectPlacement(water);
|
||||
}
|
||||
return failedPieces;
|
||||
}
|
||||
|
||||
private void placeFoundation(MantleWriter writer, Long2IntOpenHashMap columns,
|
||||
IrisStructureStiltSettings settings, RNG rng,
|
||||
boolean surfaceStructure) {
|
||||
@@ -270,8 +270,8 @@ public class IrisStructureComponent extends IrisMantleComponent {
|
||||
+ " assembled piece(s)");
|
||||
}
|
||||
|
||||
private void boreStructure(MantleWriter writer, KList<PlacedStructurePiece> pieces,
|
||||
IrisStructureTerrain terrain) {
|
||||
void boreStructure(MantleWriter writer, KList<PlacedStructurePiece> pieces,
|
||||
IrisStructureTerrain terrain) {
|
||||
int[] bounds = computePieceBounds(pieces);
|
||||
if (bounds == null) {
|
||||
return;
|
||||
@@ -291,17 +291,11 @@ public class IrisStructureComponent extends IrisMantleComponent {
|
||||
return;
|
||||
}
|
||||
int mantleOffset = getEngineMantle().getEngine().getMinHeight();
|
||||
for (int bx = minX; bx <= maxX; bx++) {
|
||||
for (int by = minY; by <= maxY; by++) {
|
||||
for (int bz = minZ; bz <= maxZ; bz++) {
|
||||
writer.setForcedCarve(bx, by - mantleOffset, bz, CARVE_CAVERN);
|
||||
}
|
||||
}
|
||||
}
|
||||
carveBox(writer, minX, minY, minZ, maxX, maxY, maxZ, mantleOffset);
|
||||
}
|
||||
|
||||
private void forceCarveStructure(MantleWriter writer, KList<PlacedStructurePiece> pieces,
|
||||
IrisStructureTerrain terrain) {
|
||||
void forceCarveStructure(MantleWriter writer, KList<PlacedStructurePiece> pieces,
|
||||
IrisStructureTerrain terrain) {
|
||||
int[] bounds = computePieceBounds(pieces);
|
||||
if (bounds == null) {
|
||||
return;
|
||||
@@ -344,6 +338,8 @@ public class IrisStructureComponent extends IrisMantleComponent {
|
||||
+ " margin=" + margin + " head=" + head + " floorCut=" + floorCut + " work=" + work);
|
||||
}
|
||||
|
||||
StructureCarveWater water = StructureCarveWater.of(getEngineMantle().getComplex(),
|
||||
footprint.minX(), footprint.minZ(), footprint.maxX(), footprint.maxZ());
|
||||
double sideReachSquared = (double) margin * margin;
|
||||
double downReach = Math.max(1D, floorCut);
|
||||
for (int bz = footprint.minZ(); bz <= footprint.maxZ(); bz++) {
|
||||
@@ -365,6 +361,9 @@ public class IrisStructureComponent extends IrisMantleComponent {
|
||||
int minY = Math.max(worldMin, sourceMinY - floorCut);
|
||||
int maxY = Math.min(worldMax, sourceMaxY + columnUpExtension);
|
||||
for (int by = minY; by <= maxY; by++) {
|
||||
if (water.keeps(bx, by - mantleOffset, bz)) {
|
||||
continue;
|
||||
}
|
||||
double normalizedY = StructureCarveEnvelope.normalizedVerticalDistance(
|
||||
by, sourceMinY, sourceMaxY, upReach, downReach);
|
||||
double distanceSquared = normalizedHorizontalDistanceSquared
|
||||
@@ -393,16 +392,19 @@ public class IrisStructureComponent extends IrisMantleComponent {
|
||||
|
||||
private void carveOverboreBox(MantleWriter writer, int[] bounds, int margin, int head, int floorCut,
|
||||
int mantleOffset, int worldMin, int worldMax) {
|
||||
int minX = bounds[0] - margin;
|
||||
int minY = Math.max(worldMin, bounds[1] - floorCut);
|
||||
int minZ = bounds[2] - margin;
|
||||
int maxX = bounds[3] + margin;
|
||||
int maxY = Math.min(worldMax, bounds[4] + head);
|
||||
int maxZ = bounds[5] + margin;
|
||||
carveBox(writer, bounds[0] - margin, Math.max(worldMin, bounds[1] - floorCut), bounds[2] - margin,
|
||||
bounds[3] + margin, Math.min(worldMax, bounds[4] + head), bounds[5] + margin, mantleOffset);
|
||||
}
|
||||
|
||||
private void carveBox(MantleWriter writer, int minX, int minY, int minZ, int maxX, int maxY, int maxZ, int mantleOffset) {
|
||||
StructureCarveWater water = StructureCarveWater.of(getEngineMantle().getComplex(), minX, minZ, maxX, maxZ);
|
||||
for (int bx = minX; bx <= maxX; bx++) {
|
||||
for (int by = minY; by <= maxY; by++) {
|
||||
for (int bz = minZ; bz <= maxZ; bz++) {
|
||||
writer.setForcedCarve(bx, by - mantleOffset, bz, CARVE_CAVERN);
|
||||
for (int bz = minZ; bz <= maxZ; bz++) {
|
||||
for (int by = minY; by <= maxY; by++) {
|
||||
int mantleY = by - mantleOffset;
|
||||
if (!water.keeps(bx, mantleY, bz)) {
|
||||
writer.setForcedCarve(bx, mantleY, bz, CARVE_CAVERN);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -559,27 +561,27 @@ public class IrisStructureComponent extends IrisMantleComponent {
|
||||
return new int[]{minX, minY, minZ, maxX, maxY, maxZ};
|
||||
}
|
||||
|
||||
private int placeObject(MantleWriter writer, IrisStructure structure, PlacedStructurePiece p,
|
||||
ObjectPlaceMode mode, boolean sampledHeight, RNG rng, Long2IntOpenHashMap foundationColumns,
|
||||
boolean supportNonOccluding) {
|
||||
private int placeObject(MantleWriter writer, PieceRun run, PlacedStructurePiece p, ObjectPlaceMode mode,
|
||||
boolean sampledHeight) {
|
||||
IrisObject object = p.getObject();
|
||||
String objectKey = object.getLoadKey();
|
||||
IrisObjectPlacement config = piecePlacement(structure, p, mode);
|
||||
String marker = structurePlacementMarker(structure, p, objectKey);
|
||||
IrisObjectPlacement config = piecePlacement(run.structure(), p, mode, run.allowWater());
|
||||
String marker = structurePlacementMarker(run.structure(), p, objectKey);
|
||||
BiConsumer<BlockPosition, NativeBlockState> listener = (position, state) -> {
|
||||
StructureFoundationPlanner.recordBaseCell(
|
||||
foundationColumns, position.getX(), position.getY(), position.getZ(), state,
|
||||
supportNonOccluding);
|
||||
run.foundationColumns(), position.getX(), position.getY(), position.getZ(), state,
|
||||
run.supportNonOccluding());
|
||||
if (marker != null && shouldWriteStructureMarker(state)) {
|
||||
writer.setData(position.getX(), position.getY(), position.getZ(), marker);
|
||||
}
|
||||
};
|
||||
return sampledHeight
|
||||
? object.place(p.getX(), p.getZ(), writer, config, rng, listener, null, getData())
|
||||
: object.place(p.getX(), p.getY() - getEngineMantle().getEngine().getMinHeight(), p.getZ(), writer, config, rng, listener, null, getData());
|
||||
? object.place(p.getX(), p.getZ(), writer, config, run.rng(), listener, null, getData())
|
||||
: object.place(p.getX(), p.getY() - getEngineMantle().getEngine().getMinHeight(), p.getZ(), writer, config, run.rng(), listener, null, getData());
|
||||
}
|
||||
|
||||
static IrisObjectPlacement piecePlacement(IrisStructure structure, PlacedStructurePiece piece, ObjectPlaceMode mode) {
|
||||
static IrisObjectPlacement piecePlacement(IrisStructure structure, PlacedStructurePiece piece, ObjectPlaceMode mode,
|
||||
boolean allowWater) {
|
||||
IrisObjectPlacement config = structure.createLootPlacement(piece.getObject().getLoadKey());
|
||||
config.setMode(mode);
|
||||
config.setRotation(piece.getRotation());
|
||||
@@ -588,7 +590,7 @@ public class IrisStructureComponent extends IrisMantleComponent {
|
||||
}
|
||||
if (mode != ObjectPlaceMode.STRUCTURE_PIECE && mode != ObjectPlaceMode.FLOATING) {
|
||||
config.setForcePlace(true);
|
||||
config.setForcedByStructure(true);
|
||||
config.setForcedByStructure(!allowWater);
|
||||
}
|
||||
return config;
|
||||
}
|
||||
@@ -713,4 +715,8 @@ public class IrisStructureComponent extends IrisMantleComponent {
|
||||
|
||||
private record ObjectBlockPosition(int x, int y, int z) {
|
||||
}
|
||||
|
||||
private record PieceRun(IrisStructure structure, RNG rng, Long2IntOpenHashMap foundationColumns,
|
||||
boolean supportNonOccluding, boolean allowWater) {
|
||||
}
|
||||
}
|
||||
+5
-3
@@ -217,7 +217,7 @@ public class MantleFloatingObjectComponent extends IrisMantleComponent {
|
||||
int id = rng.i(0, Integer.MAX_VALUE);
|
||||
|
||||
FloatingObjectPlacementTransaction transaction = new FloatingObjectPlacementTransaction(
|
||||
writer, placements.next(minX >> 4, minZ >> 4));
|
||||
writer, placements.next(minX >> 4, minZ >> 4), placement.entersWater());
|
||||
try {
|
||||
int resultY = obj.place(xx, zz, transaction, floatingPlacement, rng, (b, bd) -> {
|
||||
String marker = placementMarker(obj, id);
|
||||
@@ -311,7 +311,8 @@ public class MantleFloatingObjectComponent extends IrisMantleComponent {
|
||||
int yv = pickTopY + 1 - fp.getLowestSolidKeyY();
|
||||
|
||||
IslandObjectPlacer islandPlacer = IslandObjectPlacer.top(writer, sampleProvider, entry, pickTopY);
|
||||
FloatingObjectPlacementTransaction transaction = new FloatingObjectPlacementTransaction(islandPlacer, placements.next(minX >> 4, minZ >> 4));
|
||||
FloatingObjectPlacementTransaction transaction = new FloatingObjectPlacementTransaction(
|
||||
islandPlacer, placements.next(minX >> 4, minZ >> 4), placement.entersWater());
|
||||
int id = rng.i(0, Integer.MAX_VALUE);
|
||||
|
||||
try {
|
||||
@@ -424,7 +425,8 @@ public class MantleFloatingObjectComponent extends IrisMantleComponent {
|
||||
int yv = invertedBaseY(pickBottomY, fp, invertedRotation);
|
||||
|
||||
IslandObjectPlacer islandPlacer = IslandObjectPlacer.bottom(writer, sampleProvider, entry, pickBottomY);
|
||||
FloatingObjectPlacementTransaction transaction = new FloatingObjectPlacementTransaction(islandPlacer, placements.next(minX >> 4, minZ >> 4));
|
||||
FloatingObjectPlacementTransaction transaction = new FloatingObjectPlacementTransaction(
|
||||
islandPlacer, placements.next(minX >> 4, minZ >> 4), placement.entersWater());
|
||||
int id = rng.i(0, Integer.MAX_VALUE);
|
||||
|
||||
try {
|
||||
|
||||
@@ -90,6 +90,11 @@ public class MantleWriter implements ObjectPassPlacer, AutoCloseable {
|
||||
@Setter(AccessLevel.NONE)
|
||||
@EqualsAndHashCode.Exclude
|
||||
@ToString.Exclude
|
||||
private final ThreadLocal<ObjectWater> objectWater = new ThreadLocal<>();
|
||||
@Getter(AccessLevel.NONE)
|
||||
@Setter(AccessLevel.NONE)
|
||||
@EqualsAndHashCode.Exclude
|
||||
@ToString.Exclude
|
||||
private TerrainAccess terrainAccess;
|
||||
|
||||
public MantleWriter(EngineMantle engineMantle, Mantle<Matter> mantle, int x, int z, int radius, boolean multicore) {
|
||||
@@ -215,6 +220,28 @@ public class MantleWriter implements ObjectPassPlacer, AutoCloseable {
|
||||
return capture;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int beginObjectPlacement(boolean entersWater) {
|
||||
objectWater.set(new ObjectWater(ObjectHydrologyVeto.of(getEngine()), entersWater));
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endObjectPlacement(int checkpoint) {
|
||||
objectWater.remove();
|
||||
}
|
||||
|
||||
private boolean keepsWater(int x, int y, int z, Object value) {
|
||||
ObjectWater water = objectWater.get();
|
||||
if (water == null) {
|
||||
return false;
|
||||
}
|
||||
if (value instanceof NativeBlockState state) {
|
||||
return water.veto().keepsBlock(x, y, z, state, water.entersWater());
|
||||
}
|
||||
return value instanceof MatterCavern && water.veto().keeps(x, y, z, false, water.entersWater());
|
||||
}
|
||||
|
||||
private void recordObjectValue(int x, int y, int z, Class<?> type, Object value) {
|
||||
ObjectPlacementCapture capture = objectPlacementCapture.get();
|
||||
if (capture != null) {
|
||||
@@ -241,7 +268,7 @@ public class MantleWriter implements ObjectPassPlacer, AutoCloseable {
|
||||
MantleChunk<Matter> chunk = acquireChunk(cx, cz);
|
||||
if (chunk == null) return;
|
||||
|
||||
if (protectsSubterrainPlacement(x, y, z)) {
|
||||
if (protectsSubterrainPlacement(x, y, z) || keepsWater(x, y, z, t)) {
|
||||
return;
|
||||
}
|
||||
synchronized (chunk) {
|
||||
@@ -611,7 +638,7 @@ public class MantleWriter implements ObjectPassPlacer, AutoCloseable {
|
||||
}
|
||||
|
||||
MantleChunk<Matter> chunk = acquireChunk(x >> 4, z >> 4);
|
||||
if (chunk == null) {
|
||||
if (chunk == null || keepsWater(x, y, z, baseState)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1007,6 +1034,9 @@ public class MantleWriter implements ObjectPassPlacer, AutoCloseable {
|
||||
naturalOpening ? ALWAYS : NEVER, cavern ? ALWAYS : NEVER) ? (byte) 1 : 0;
|
||||
}
|
||||
|
||||
private record ObjectWater(ObjectHydrologyVeto veto, boolean entersWater) {
|
||||
}
|
||||
|
||||
public final class ObjectPlacementCapture implements AutoCloseable {
|
||||
private final ObjectContinuationBundle.PlacementKey key;
|
||||
private final Long2ObjectOpenHashMap<Matter> fragments = new Long2ObjectOpenHashMap<>();
|
||||
|
||||
+5
-78
@@ -5,10 +5,6 @@ import art.arcane.iris.pack.loading.IrisData;
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.iris.generation.decoration.tree.TreeBlockMaterial;
|
||||
import art.arcane.iris.generation.hydrology.cave.HydrologyCaveCell;
|
||||
import art.arcane.iris.generation.hydrology.engine.HydrologyRuntime;
|
||||
import art.arcane.iris.generation.hydrology.raster.ChunkWaterRaster;
|
||||
import art.arcane.iris.generation.hydrology.raster.WaterRole;
|
||||
import art.arcane.iris.generation.runtime.IrisComplex;
|
||||
import art.arcane.iris.generation.subterrain.SubterrainRasterizer;
|
||||
import art.arcane.iris.generation.block.TileData;
|
||||
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
|
||||
@@ -30,7 +26,6 @@ import java.util.Map;
|
||||
|
||||
final class ObjectDestinationTransaction implements ObjectPassPlacer {
|
||||
private static final Object CLEARED = new Object();
|
||||
private static final int[][] SIDES = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
|
||||
|
||||
private final MantleWriter writer;
|
||||
private final int destinationChunkX;
|
||||
@@ -45,8 +40,7 @@ final class ObjectDestinationTransaction implements ObjectPassPlacer {
|
||||
private int subterrainY;
|
||||
private int subterrainZ;
|
||||
private boolean subterrainProtects;
|
||||
private boolean hydrologyKnown;
|
||||
private HydrologyRuntime hydrology;
|
||||
private ObjectHydrologyVeto waterVeto;
|
||||
private boolean waterPlacement;
|
||||
|
||||
ObjectDestinationTransaction(MantleWriter writer, int destinationChunkX, int destinationChunkZ) {
|
||||
@@ -86,6 +80,7 @@ final class ObjectDestinationTransaction implements ObjectPassPlacer {
|
||||
|
||||
@Override
|
||||
public void endObjectPlacement(int checkpoint) {
|
||||
waterPlacement = false;
|
||||
if (checkpoint >= 0 && checkpoint < log.size()) {
|
||||
placements.add(new PlacementRange(checkpoint, log.size()));
|
||||
}
|
||||
@@ -417,78 +412,10 @@ final class ObjectDestinationTransaction implements ObjectPassPlacer {
|
||||
}
|
||||
|
||||
private boolean hydrologyKeeps(int x, int y, int z, boolean solid, boolean entersWater) {
|
||||
HydrologyRuntime runtime = hydrology();
|
||||
if (runtime == null) {
|
||||
return false;
|
||||
if (waterVeto == null) {
|
||||
waterVeto = ObjectHydrologyVeto.of(getEngine());
|
||||
}
|
||||
ChunkWaterRaster raster = runtime.raster(x >> 4, z >> 4);
|
||||
if (raster.empty()) {
|
||||
return false;
|
||||
}
|
||||
WaterRole role = raster.role(x & 15, z & 15);
|
||||
if (role == WaterRole.INLET && y >= raster.waterHead(x & 15, z & 15) && y <= getEngine().getComplex().naturalTrueHeight(x, z)) {
|
||||
return true;
|
||||
}
|
||||
if (solid && !entersWater && fillsWater(x, y, z)) {
|
||||
return true;
|
||||
}
|
||||
if (role.wet()) {
|
||||
int surface = raster.waterHead(x & 15, z & 15);
|
||||
int fallTop = highestHead(runtime, raster, x, z);
|
||||
if (fallTop > surface && y >= surface && y <= fallTop) {
|
||||
return true;
|
||||
}
|
||||
return !solid && y >= raster.terrainHeight(x & 15, z & 15) && y <= surface;
|
||||
}
|
||||
if (solid || role == WaterRole.NONE) {
|
||||
return false;
|
||||
}
|
||||
int head = Integer.MIN_VALUE;
|
||||
int bed = Integer.MAX_VALUE;
|
||||
for (int[] side : SIDES) {
|
||||
int nx = x + side[0];
|
||||
int nz = z + side[1];
|
||||
ChunkWaterRaster neighbour = neighbour(runtime, raster, x, z, nx, nz);
|
||||
if (neighbour.role(nx & 15, nz & 15).wet()) {
|
||||
head = Math.max(head, neighbour.waterHead(nx & 15, nz & 15));
|
||||
bed = Math.min(bed, neighbour.terrainHeight(nx & 15, nz & 15));
|
||||
}
|
||||
}
|
||||
return y > bed && y <= head;
|
||||
}
|
||||
|
||||
private boolean fillsWater(int x, int y, int z) {
|
||||
IrisComplex complex = getEngine().getComplex();
|
||||
if (!complex.getWaterRoleStream().get(x, z).wet()) {
|
||||
return false;
|
||||
}
|
||||
return y > complex.getRoundedHeighteightStream().get(x, z)
|
||||
&& y <= (int) Math.round(complex.getWaterHeadStream().getDouble(x, z));
|
||||
}
|
||||
|
||||
private static int highestHead(HydrologyRuntime runtime, ChunkWaterRaster raster, int x, int z) {
|
||||
int top = Integer.MIN_VALUE;
|
||||
for (int[] side : SIDES) {
|
||||
int nx = x + side[0];
|
||||
int nz = z + side[1];
|
||||
top = Math.max(top, neighbour(runtime, raster, x, z, nx, nz).waterHead(nx & 15, nz & 15));
|
||||
}
|
||||
return top;
|
||||
}
|
||||
|
||||
private static ChunkWaterRaster neighbour(HydrologyRuntime runtime, ChunkWaterRaster raster, int x, int z, int nx, int nz) {
|
||||
return (nx >> 4) == (x >> 4) && (nz >> 4) == (z >> 4) ? raster : runtime.raster(nx >> 4, nz >> 4);
|
||||
}
|
||||
|
||||
private HydrologyRuntime hydrology() {
|
||||
if (!hydrologyKnown) {
|
||||
Engine engine = getEngine();
|
||||
IrisComplex complex = engine == null ? null : engine.getComplex();
|
||||
HydrologyRuntime runtime = complex == null ? null : complex.getHydrologyRuntime();
|
||||
hydrology = runtime != null && runtime.enabled() ? runtime : null;
|
||||
hydrologyKnown = true;
|
||||
}
|
||||
return hydrology;
|
||||
return waterVeto.keeps(x, y, z, solid, entersWater);
|
||||
}
|
||||
|
||||
private boolean protectsSubterrain(int x, int y, int z) {
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
package art.arcane.iris.generation.mantle;
|
||||
|
||||
import art.arcane.iris.generation.hydrology.engine.HydrologyRuntime;
|
||||
import art.arcane.iris.generation.hydrology.raster.ChunkWaterRaster;
|
||||
import art.arcane.iris.generation.hydrology.raster.WaterRole;
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.iris.generation.runtime.IrisComplex;
|
||||
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
|
||||
|
||||
final class ObjectHydrologyVeto {
|
||||
private static final int[][] SIDES = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
|
||||
private static final ObjectHydrologyVeto NONE = new ObjectHydrologyVeto(null, null);
|
||||
|
||||
private final IrisComplex complex;
|
||||
private final HydrologyRuntime runtime;
|
||||
|
||||
private ObjectHydrologyVeto(IrisComplex complex, HydrologyRuntime runtime) {
|
||||
this.complex = complex;
|
||||
this.runtime = runtime;
|
||||
}
|
||||
|
||||
static ObjectHydrologyVeto of(Engine engine) {
|
||||
IrisComplex complex = engine == null ? null : engine.getComplex();
|
||||
HydrologyRuntime runtime = complex == null ? null : complex.getHydrologyRuntime();
|
||||
return runtime != null && runtime.enabled() ? new ObjectHydrologyVeto(complex, runtime) : NONE;
|
||||
}
|
||||
|
||||
boolean keepsBlock(int x, int y, int z, NativeBlockState state, boolean entersWater) {
|
||||
NativeBlockState base = state.isCustom() && state.placementBaseState() != null ? state.placementBaseState() : state;
|
||||
return keeps(x, y, z, base.isSolid(), entersWater);
|
||||
}
|
||||
|
||||
boolean keeps(int x, int y, int z, boolean solid, boolean entersWater) {
|
||||
if (runtime == null) {
|
||||
return false;
|
||||
}
|
||||
ChunkWaterRaster raster = runtime.raster(x >> 4, z >> 4);
|
||||
if (raster.empty()) {
|
||||
return false;
|
||||
}
|
||||
WaterRole role = raster.role(x & 15, z & 15);
|
||||
if (role == WaterRole.INLET && y >= raster.waterHead(x & 15, z & 15) && y <= complex.naturalTrueHeight(x, z)) {
|
||||
return true;
|
||||
}
|
||||
if (solid && !entersWater && fillsWater(x, y, z)) {
|
||||
return true;
|
||||
}
|
||||
if (role.wet()) {
|
||||
int surface = raster.waterHead(x & 15, z & 15);
|
||||
int fallTop = highestHead(raster, x, z);
|
||||
if (fallTop > surface && y >= surface && y <= fallTop) {
|
||||
return true;
|
||||
}
|
||||
return !solid && y >= raster.terrainHeight(x & 15, z & 15) && y <= surface;
|
||||
}
|
||||
if (solid || role == WaterRole.NONE) {
|
||||
return false;
|
||||
}
|
||||
int head = Integer.MIN_VALUE;
|
||||
int bed = Integer.MAX_VALUE;
|
||||
for (int[] side : SIDES) {
|
||||
int nx = x + side[0];
|
||||
int nz = z + side[1];
|
||||
ChunkWaterRaster neighbour = neighbour(raster, x, z, nx, nz);
|
||||
if (neighbour.role(nx & 15, nz & 15).wet()) {
|
||||
head = Math.max(head, neighbour.waterHead(nx & 15, nz & 15));
|
||||
bed = Math.min(bed, neighbour.terrainHeight(nx & 15, nz & 15));
|
||||
}
|
||||
}
|
||||
return y > bed && y <= head;
|
||||
}
|
||||
|
||||
private boolean fillsWater(int x, int y, int z) {
|
||||
if (!complex.getWaterRoleStream().get(x, z).wet()) {
|
||||
return false;
|
||||
}
|
||||
return y > complex.getRoundedHeighteightStream().get(x, z)
|
||||
&& y <= (int) Math.round(complex.getWaterHeadStream().getDouble(x, z));
|
||||
}
|
||||
|
||||
private int highestHead(ChunkWaterRaster raster, int x, int z) {
|
||||
int top = Integer.MIN_VALUE;
|
||||
for (int[] side : SIDES) {
|
||||
int nx = x + side[0];
|
||||
int nz = z + side[1];
|
||||
top = Math.max(top, neighbour(raster, x, z, nx, nz).waterHead(nx & 15, nz & 15));
|
||||
}
|
||||
return top;
|
||||
}
|
||||
|
||||
private ChunkWaterRaster neighbour(ChunkWaterRaster raster, int x, int z, int nx, int nz) {
|
||||
return (nx >> 4) == (x >> 4) && (nz >> 4) == (z >> 4) ? raster : runtime.raster(nx >> 4, nz >> 4);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package art.arcane.iris.generation.mantle;
|
||||
|
||||
import art.arcane.iris.generation.hydrology.raster.WaterRole;
|
||||
import art.arcane.iris.generation.runtime.IrisComplex;
|
||||
import art.arcane.iris.generation.stream.ProvisionalAnswerException;
|
||||
import art.arcane.iris.generation.stream.ProvisionalSampling;
|
||||
import art.arcane.volmlib.util.stream.ProceduralStream;
|
||||
|
||||
final class StructureCarveWater {
|
||||
static final int CONTAINMENT = 2;
|
||||
static final int FLOOR = 2;
|
||||
private static final StructureCarveWater NONE = new StructureCarveWater(0, 0, 0, 0, null, null);
|
||||
|
||||
private final int minX;
|
||||
private final int minZ;
|
||||
private final int width;
|
||||
private final int depth;
|
||||
private final int[] floors;
|
||||
private final int[] tops;
|
||||
|
||||
private StructureCarveWater(int minX, int minZ, int width, int depth, int[] floors, int[] tops) {
|
||||
this.minX = minX;
|
||||
this.minZ = minZ;
|
||||
this.width = width;
|
||||
this.depth = depth;
|
||||
this.floors = floors;
|
||||
this.tops = tops;
|
||||
}
|
||||
|
||||
static StructureCarveWater of(IrisComplex complex, int minX, int minZ, int maxX, int maxZ) {
|
||||
if (complex == null || maxX < minX || maxZ < minZ) {
|
||||
return NONE;
|
||||
}
|
||||
int width = maxX - minX + 1;
|
||||
int depth = maxZ - minZ + 1;
|
||||
int sampleWidth = width + CONTAINMENT * 2;
|
||||
int sampleDepth = depth + CONTAINMENT * 2;
|
||||
boolean[] wet = new boolean[sampleWidth * sampleDepth];
|
||||
int[] beds = new int[wet.length];
|
||||
int[] heads = new int[wet.length];
|
||||
ProceduralStream<WaterRole> roles = complex.getWaterRoleStream();
|
||||
long revision = ProvisionalSampling.revision();
|
||||
boolean any = false;
|
||||
for (int sz = 0; sz < sampleDepth; sz++) {
|
||||
int z = minZ - CONTAINMENT + sz;
|
||||
for (int sx = 0; sx < sampleWidth; sx++) {
|
||||
int x = minX - CONTAINMENT + sx;
|
||||
if (!roles.get(x, z).wet()) {
|
||||
continue;
|
||||
}
|
||||
int index = sz * sampleWidth + sx;
|
||||
wet[index] = true;
|
||||
beds[index] = complex.getRoundedHeighteightStream().get(x, z);
|
||||
heads[index] = (int) Math.round(complex.getWaterHeadStream().getDouble(x, z));
|
||||
any = true;
|
||||
}
|
||||
}
|
||||
if (ProvisionalSampling.revision() != revision) {
|
||||
throw new ProvisionalAnswerException("Structure carve over " + minX + "," + minZ + " to " + maxX + "," + maxZ
|
||||
+ " read a provisional water answer; structures only carve around final water.");
|
||||
}
|
||||
if (!any) {
|
||||
return NONE;
|
||||
}
|
||||
int[] floors = new int[width * depth];
|
||||
int[] tops = new int[width * depth];
|
||||
for (int z = 0; z < depth; z++) {
|
||||
for (int x = 0; x < width; x++) {
|
||||
int floor = Integer.MAX_VALUE;
|
||||
int top = Integer.MIN_VALUE;
|
||||
for (int dz = -CONTAINMENT; dz <= CONTAINMENT; dz++) {
|
||||
for (int dx = -CONTAINMENT; dx <= CONTAINMENT; dx++) {
|
||||
int sample = (z + CONTAINMENT + dz) * sampleWidth + x + CONTAINMENT + dx;
|
||||
if (!wet[sample]) {
|
||||
continue;
|
||||
}
|
||||
floor = Math.min(floor, beds[sample] - FLOOR);
|
||||
top = dx == 0 && dz == 0 ? Integer.MAX_VALUE : Math.max(top, heads[sample]);
|
||||
}
|
||||
}
|
||||
floors[z * width + x] = floor;
|
||||
tops[z * width + x] = top;
|
||||
}
|
||||
}
|
||||
return new StructureCarveWater(minX, minZ, width, depth, floors, tops);
|
||||
}
|
||||
|
||||
boolean keeps(int x, int y, int z) {
|
||||
if (floors == null) {
|
||||
return false;
|
||||
}
|
||||
int localX = x - minX;
|
||||
int localZ = z - minZ;
|
||||
if (localX < 0 || localZ < 0 || localX >= width || localZ >= depth) {
|
||||
return false;
|
||||
}
|
||||
int index = localZ * width + localX;
|
||||
return y >= floors[index] && y <= tops[index];
|
||||
}
|
||||
}
|
||||
+5
@@ -3,6 +3,7 @@ package art.arcane.iris.structure.nativegen;
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.iris.structure.placement.StructurePlacementGrid;
|
||||
import art.arcane.iris.structure.placement.StructurePlacementScope;
|
||||
import art.arcane.iris.structure.placement.StructureWaterFootprint;
|
||||
|
||||
import art.arcane.iris.generation.runtime.IrisComplex;
|
||||
import art.arcane.iris.structure.placement.IrisStructureAnchorMode;
|
||||
@@ -64,6 +65,10 @@ public final class NativeStructurePlacementPlanner {
|
||||
if (baseY == null) {
|
||||
return null;
|
||||
}
|
||||
if (!placement.isUnderground()
|
||||
&& !StructureWaterFootprint.admitsChunk(activeEngine, placement, source.getStructure(), chunkX, chunkZ)) {
|
||||
return null;
|
||||
}
|
||||
return new NativeStructureStartPlan(placement, source, chunkX, chunkZ, baseY);
|
||||
}
|
||||
|
||||
|
||||
@@ -590,6 +590,10 @@ public final class IrisStructureLocator {
|
||||
"assembled pieces exceed the configured structure or world bounds")) {
|
||||
return null;
|
||||
}
|
||||
if (!placement.isAnchoredUnderground()
|
||||
&& !StructureWaterFootprint.admitsPieces(engine, placement, selectedKey, pieces, cx, cz)) {
|
||||
return null;
|
||||
}
|
||||
if (!allowsResolvedFootprint(engine, placement, structure, pieces)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -130,6 +130,9 @@ public class IrisStructurePlacement {
|
||||
@Description("If false, the placement is skipped when its selected surface or cave column is submerged.")
|
||||
private boolean underwater = false;
|
||||
|
||||
@Description("If true, a surface structure may cover river, stream, pond and lake water, and its pieces and stilts may fill it. If false, a surface placement is skipped when more than 10% of its footprint columns are channel, pond, cascade or waterfall water, and its pieces keep their solid blocks out of the water they touch.")
|
||||
private boolean allowWater = false;
|
||||
|
||||
public IrisStructureTerrain resolvedTerrain() {
|
||||
return terrain == null ? new IrisStructureTerrain() : terrain;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
package art.arcane.iris.structure.placement;
|
||||
|
||||
import art.arcane.iris.generation.hydrology.raster.WaterRole;
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.iris.generation.runtime.IrisComplex;
|
||||
import art.arcane.iris.generation.stream.ProvisionalAnswerException;
|
||||
import art.arcane.iris.generation.stream.ProvisionalSampling;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.stream.ProceduralStream;
|
||||
import it.unimi.dsi.fastutil.longs.LongIterator;
|
||||
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
|
||||
|
||||
public final class StructureWaterFootprint {
|
||||
private static final int MAX_WATER_PERCENT = 10;
|
||||
private static final int CHUNK = 16;
|
||||
|
||||
private StructureWaterFootprint() {
|
||||
}
|
||||
|
||||
public static boolean admitsChunk(Engine engine, IrisStructurePlacement placement, String structureKey,
|
||||
int chunkX, int chunkZ) {
|
||||
IrisComplex complex = engine.getComplex();
|
||||
if (placement.isAllowWater() || complex == null) {
|
||||
return true;
|
||||
}
|
||||
ProceduralStream<WaterRole> roles = complex.getWaterRoleStream();
|
||||
long revision = ProvisionalSampling.revision();
|
||||
int water = 0;
|
||||
int minX = chunkX << 4;
|
||||
int minZ = chunkZ << 4;
|
||||
for (int x = minX; x < minX + CHUNK; x++) {
|
||||
for (int z = minZ; z < minZ + CHUNK; z++) {
|
||||
if (coversWater(roles.get(x, z))) {
|
||||
water++;
|
||||
}
|
||||
}
|
||||
}
|
||||
requireFinal(complex, revision, structureKey, chunkX, chunkZ);
|
||||
return admits(water, CHUNK * CHUNK);
|
||||
}
|
||||
|
||||
public static boolean admitsPieces(Engine engine, IrisStructurePlacement placement, String structureKey,
|
||||
KList<PlacedStructurePiece> pieces, int chunkX, int chunkZ) {
|
||||
IrisComplex complex = engine.getComplex();
|
||||
if (placement.isAllowWater() || complex == null) {
|
||||
return true;
|
||||
}
|
||||
LongOpenHashSet columns = new LongOpenHashSet();
|
||||
for (PlacedStructurePiece piece : pieces) {
|
||||
for (int x = piece.getMinX(); x <= piece.getMaxX(); x++) {
|
||||
for (int z = piece.getMinZ(); z <= piece.getMaxZ(); z++) {
|
||||
columns.add(columnKey(x, z));
|
||||
}
|
||||
}
|
||||
}
|
||||
ProceduralStream<WaterRole> roles = complex.getWaterRoleStream();
|
||||
long revision = ProvisionalSampling.revision();
|
||||
int water = 0;
|
||||
LongIterator iterator = columns.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
long column = iterator.nextLong();
|
||||
if (coversWater(roles.get((int) (column >> 32), (int) column))) {
|
||||
water++;
|
||||
}
|
||||
}
|
||||
requireFinal(complex, revision, structureKey, chunkX, chunkZ);
|
||||
return admits(water, columns.size());
|
||||
}
|
||||
|
||||
static boolean coversWater(WaterRole role) {
|
||||
return switch (role) {
|
||||
case CHANNEL, POND, CASCADE, WATERFALL -> true;
|
||||
case NONE, BANK, SHORE, POND_SHORE, DAM, MOUTH, INLET -> false;
|
||||
};
|
||||
}
|
||||
|
||||
private static boolean admits(int water, int columns) {
|
||||
return (long) water * 100L <= (long) columns * MAX_WATER_PERCENT;
|
||||
}
|
||||
|
||||
private static void requireFinal(IrisComplex complex, long revision, String structureKey, int chunkX, int chunkZ) {
|
||||
if (ProvisionalSampling.revision() == revision || complex.isPlatformMainThread()) {
|
||||
return;
|
||||
}
|
||||
throw new ProvisionalAnswerException("Structure '" + structureKey + "' starting in chunk " + chunkX + "," + chunkZ
|
||||
+ " read a provisional water answer; structures are only placed from final water.");
|
||||
}
|
||||
|
||||
private static long columnKey(int x, int z) {
|
||||
return ((long) x << 32) | (z & 0xffffffffL);
|
||||
}
|
||||
}
|
||||
+59
-4
@@ -18,8 +18,13 @@
|
||||
|
||||
package art.arcane.iris.generation.mantle;
|
||||
|
||||
import art.arcane.iris.generation.hydrology.engine.HydrologyRuntime;
|
||||
import art.arcane.iris.generation.hydrology.raster.ChunkWaterRaster;
|
||||
import art.arcane.iris.generation.hydrology.raster.WaterRole;
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.iris.generation.runtime.IrisComplex;
|
||||
import art.arcane.iris.generation.block.TileData;
|
||||
import art.arcane.volmlib.util.stream.ProceduralStream;
|
||||
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
|
||||
import art.arcane.volmlib.util.math.BlockPosition;
|
||||
import org.junit.Test;
|
||||
@@ -36,6 +41,7 @@ import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyDouble;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.Mockito.inOrder;
|
||||
import static org.mockito.Mockito.mock;
|
||||
@@ -48,7 +54,7 @@ public class FloatingObjectPlacementTransactionTest {
|
||||
public void canopyCommitRechecksSolidsAndSkipsAssociatedMetadata() {
|
||||
IslandObjectPlacer delegate = createPlacer(true);
|
||||
FloatingObjectPlacementTransaction transaction = new FloatingObjectPlacementTransaction(delegate,
|
||||
new ObjectContinuationBundle.PlacementKey(ObjectContinuationBundle.Kind.FLOATING, 0, 0, 0));
|
||||
new ObjectContinuationBundle.PlacementKey(ObjectContinuationBundle.Kind.FLOATING, 0, 0, 0), false);
|
||||
NativeBlockState canopy = mock(NativeBlockState.class);
|
||||
NativeBlockState trunk = mock(NativeBlockState.class);
|
||||
when(trunk.isSolid()).thenReturn(true);
|
||||
@@ -70,7 +76,7 @@ public class FloatingObjectPlacementTransactionTest {
|
||||
public void unsupportedFinalTerrainRejectsBlocksTilesAndMarkersTogether() {
|
||||
IslandObjectPlacer delegate = createPlacer(false);
|
||||
FloatingObjectPlacementTransaction transaction = new FloatingObjectPlacementTransaction(delegate,
|
||||
new ObjectContinuationBundle.PlacementKey(ObjectContinuationBundle.Kind.FLOATING, 0, 0, 0));
|
||||
new ObjectContinuationBundle.PlacementKey(ObjectContinuationBundle.Kind.FLOATING, 0, 0, 0), false);
|
||||
NativeBlockState first = mock(NativeBlockState.class);
|
||||
NativeBlockState second = mock(NativeBlockState.class);
|
||||
TileData tile = mock(TileData.class);
|
||||
@@ -97,7 +103,7 @@ public class FloatingObjectPlacementTransactionTest {
|
||||
public void supportedNeighborChunkCommitsBlocksTilesAndMarkers() {
|
||||
IslandObjectPlacer delegate = createPlacer(true);
|
||||
FloatingObjectPlacementTransaction transaction = new FloatingObjectPlacementTransaction(delegate,
|
||||
new ObjectContinuationBundle.PlacementKey(ObjectContinuationBundle.Kind.FLOATING, 0, 0, 0));
|
||||
new ObjectContinuationBundle.PlacementKey(ObjectContinuationBundle.Kind.FLOATING, 0, 0, 0), false);
|
||||
NativeBlockState first = mock(NativeBlockState.class);
|
||||
NativeBlockState second = mock(NativeBlockState.class);
|
||||
TileData tile = mock(TileData.class);
|
||||
@@ -143,7 +149,7 @@ public class FloatingObjectPlacementTransactionTest {
|
||||
NativeBlockState state = mock(NativeBlockState.class);
|
||||
when(state.key()).thenReturn("minecraft:oak_log");
|
||||
ObjectContinuationBundle.PlacementKey key = new ObjectContinuationBundle.PlacementKey(ObjectContinuationBundle.Kind.FLOATING, 0, 0, 7);
|
||||
FloatingObjectPlacementTransaction transaction = new FloatingObjectPlacementTransaction(delegate, key);
|
||||
FloatingObjectPlacementTransaction transaction = new FloatingObjectPlacementTransaction(delegate, key, false);
|
||||
transaction.set(15, 101, 8, state);
|
||||
transaction.set(16, 101, 8, state);
|
||||
transaction.setData(16, 101, 8, "floating-tree@7");
|
||||
@@ -158,6 +164,55 @@ public class FloatingObjectPlacementTransactionTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void floatingObjectsKeepSolidBlocksOutOfRiverWaterUnlessTheyEnterWater() {
|
||||
IObjectPlacer delegate = mock(IObjectPlacer.class);
|
||||
Engine engine = mock(Engine.class);
|
||||
IrisComplex complex = mock(IrisComplex.class);
|
||||
HydrologyRuntime runtime = mock(HydrologyRuntime.class);
|
||||
ChunkWaterRaster raster = mock(ChunkWaterRaster.class);
|
||||
ProceduralStream<WaterRole> roles = mock(ProceduralStream.class);
|
||||
ProceduralStream<Double> heads = mock(ProceduralStream.class);
|
||||
ProceduralStream<Integer> heights = mock(ProceduralStream.class);
|
||||
when(delegate.getEngine()).thenReturn(engine);
|
||||
when(engine.getComplex()).thenReturn(complex);
|
||||
when(complex.getHydrologyRuntime()).thenReturn(runtime);
|
||||
when(complex.allowsNewDiscreteContentAt(anyInt(), anyInt())).thenReturn(true);
|
||||
when(runtime.enabled()).thenReturn(true);
|
||||
when(runtime.raster(anyInt(), anyInt())).thenReturn(raster);
|
||||
when(raster.role(anyInt(), anyInt())).thenReturn(WaterRole.NONE);
|
||||
when(raster.waterHead(anyInt(), anyInt())).thenReturn(Integer.MIN_VALUE);
|
||||
when(raster.role(3, 3)).thenReturn(WaterRole.CHANNEL);
|
||||
when(raster.waterHead(3, 3)).thenReturn(9);
|
||||
when(raster.terrainHeight(3, 3)).thenReturn(5);
|
||||
when(roles.get(anyDouble(), anyDouble())).thenAnswer(call -> raster.role(local(call.getArgument(0)), local(call.getArgument(1))));
|
||||
when(heads.getDouble(anyDouble(), anyDouble())).thenAnswer(call -> (double) raster.waterHead(local(call.getArgument(0)), local(call.getArgument(1))));
|
||||
when(heights.get(anyDouble(), anyDouble())).thenAnswer(call -> raster.terrainHeight(local(call.getArgument(0)), local(call.getArgument(1))));
|
||||
when(complex.getWaterRoleStream()).thenReturn(roles);
|
||||
when(complex.getWaterHeadStream()).thenReturn(heads);
|
||||
when(complex.getRoundedHeighteightStream()).thenReturn(heights);
|
||||
NativeBlockState stone = mock(NativeBlockState.class);
|
||||
when(stone.isSolid()).thenReturn(true);
|
||||
ObjectContinuationBundle.PlacementKey key = new ObjectContinuationBundle.PlacementKey(ObjectContinuationBundle.Kind.FLOATING, 0, 0, 0);
|
||||
|
||||
FloatingObjectPlacementTransaction land = new FloatingObjectPlacementTransaction(delegate, key, false);
|
||||
land.set(3, 7, 3, stone);
|
||||
land.set(3, 10, 3, stone);
|
||||
assertEquals(FloatingObjectPlacementTransaction.CommitResult.COMMITTED, land.commit());
|
||||
verify(delegate, never()).set(3, 7, 3, stone);
|
||||
verify(delegate).set(3, 10, 3, stone);
|
||||
|
||||
FloatingObjectPlacementTransaction water = new FloatingObjectPlacementTransaction(delegate, key, true);
|
||||
water.set(3, 7, 3, stone);
|
||||
assertEquals(FloatingObjectPlacementTransaction.CommitResult.COMMITTED, water.commit());
|
||||
verify(delegate).set(3, 7, 3, stone);
|
||||
}
|
||||
|
||||
private static int local(Object coordinate) {
|
||||
return (int) Math.floor(((Number) coordinate).doubleValue()) & 15;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private IslandObjectPlacer createPlacer(boolean supportNeighborChunk) {
|
||||
IslandObjectPlacer placer = mock(IslandObjectPlacer.class);
|
||||
|
||||
+170
@@ -0,0 +1,170 @@
|
||||
package art.arcane.iris.generation.mantle;
|
||||
|
||||
import art.arcane.iris.configuration.IrisSettings;
|
||||
import art.arcane.iris.generation.hydrology.raster.WaterRole;
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.iris.generation.runtime.IrisComplex;
|
||||
import art.arcane.iris.pack.loading.IrisData;
|
||||
import art.arcane.iris.structure.object.ObjectPlaceMode;
|
||||
import art.arcane.iris.structure.placement.IrisStructure;
|
||||
import art.arcane.iris.structure.placement.IrisStructurePlacement;
|
||||
import art.arcane.iris.structure.object.IrisObject;
|
||||
import art.arcane.iris.structure.object.IrisObjectRotation;
|
||||
import art.arcane.iris.structure.placement.IrisStructureTerrain;
|
||||
import art.arcane.iris.structure.placement.PlacedStructurePiece;
|
||||
import art.arcane.iris.testsupport.PlatformBinding;
|
||||
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import art.arcane.volmlib.util.matter.MatterCavern;
|
||||
import art.arcane.volmlib.util.stream.ProceduralStream;
|
||||
import art.arcane.volmlib.util.structure.StructureCarveShape;
|
||||
import art.arcane.volmlib.util.structure.StructureTerrainMode;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.mockito.InOrder;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyDouble;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.calls;
|
||||
import static org.mockito.Mockito.inOrder;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class IrisStructureComponentCarveWaterTest {
|
||||
private static final int RIVER_BED = 60;
|
||||
private static final int RIVER_HEAD = 64;
|
||||
private static final int LAND = 70;
|
||||
|
||||
@Rule
|
||||
public final PlatformBinding platform = PlatformBinding.mockPlatform();
|
||||
|
||||
private IrisStructureComponent component;
|
||||
private MantleWriter writer;
|
||||
private IrisSettings previousSettings;
|
||||
|
||||
@Before
|
||||
@SuppressWarnings("unchecked")
|
||||
public void setUp() {
|
||||
previousSettings = IrisSettings.settings;
|
||||
IrisSettings.settings = new IrisSettings();
|
||||
EngineMantle engineMantle = mock(EngineMantle.class);
|
||||
Engine engine = mock(Engine.class);
|
||||
IrisComplex complex = mock(IrisComplex.class);
|
||||
ProceduralStream<WaterRole> roles = mock(ProceduralStream.class);
|
||||
ProceduralStream<Integer> heights = mock(ProceduralStream.class);
|
||||
ProceduralStream<Double> heads = mock(ProceduralStream.class);
|
||||
when(engineMantle.getEngine()).thenReturn(engine);
|
||||
when(engineMantle.getComplex()).thenReturn(complex);
|
||||
when(engineMantle.getData()).thenReturn(mock(IrisData.class));
|
||||
when(engine.getComplex()).thenReturn(complex);
|
||||
when(engine.getMinHeight()).thenReturn(-64);
|
||||
when(engine.getHeight()).thenReturn(384);
|
||||
when(roles.get(anyDouble(), anyDouble())).thenAnswer(call -> river(call.getArgument(0)) ? WaterRole.CHANNEL : WaterRole.NONE);
|
||||
when(heights.get(anyDouble(), anyDouble())).thenAnswer(call -> river(call.getArgument(0)) ? RIVER_BED : LAND);
|
||||
when(heads.getDouble(anyDouble(), anyDouble())).thenAnswer(call -> river(call.getArgument(0)) ? (double) RIVER_HEAD : 63D);
|
||||
when(complex.getWaterRoleStream()).thenReturn(roles);
|
||||
when(complex.getRoundedHeighteightStream()).thenReturn(heights);
|
||||
when(complex.getWaterHeadStream()).thenReturn(heads);
|
||||
component = new IrisStructureComponent(engineMantle);
|
||||
writer = mock(MantleWriter.class);
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
IrisSettings.settings = previousSettings;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void boreSkipsRiverColumnsAndTheirBanks() {
|
||||
component.boreStructure(writer, box(), terrain(StructureTerrainMode.BORE, StructureCarveShape.BOX));
|
||||
|
||||
assertRiverKept();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void forceCarveBoxSkipsRiverColumnsAndTheirBanks() {
|
||||
component.forceCarveStructure(writer, box(), terrain(StructureTerrainMode.FORCE_CARVE, StructureCarveShape.BOX));
|
||||
|
||||
assertRiverKept();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void roundedForceCarveSkipsRiverColumnsAndTheirBanks() {
|
||||
component.forceCarveStructure(writer, slab(), terrain(StructureTerrainMode.FORCE_CARVE, StructureCarveShape.ROUNDED));
|
||||
|
||||
verify(writer, never()).setForcedCarve(eq(3), eq(60), eq(1), any(MatterCavern.class));
|
||||
verify(writer, never()).setForcedCarve(eq(1), eq(60), eq(1), any(MatterCavern.class));
|
||||
verify(writer).setForcedCarve(eq(3), eq(55), eq(1), any(MatterCavern.class));
|
||||
verify(writer).setForcedCarve(eq(0), eq(60), eq(1), any(MatterCavern.class));
|
||||
verify(writer).setForcedCarve(eq(8), eq(60), eq(1), any(MatterCavern.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void piecesPlaceInsideAWaterAwareObjectPlacement() {
|
||||
IrisStructure structure = new IrisStructure().setPlaceMode(ObjectPlaceMode.STRUCTURE_PIECE);
|
||||
IrisStructurePlacement placement = new IrisStructurePlacement();
|
||||
|
||||
component.placePieces(writer, placement, structure, slab(), new RNG(3L));
|
||||
placement.setAllowWater(true);
|
||||
component.placePieces(writer, placement, structure, slab(), new RNG(3L));
|
||||
|
||||
InOrder order = inOrder(writer);
|
||||
order.verify(writer).beginObjectPlacement(false);
|
||||
order.verify(writer, calls(1)).set(anyInt(), anyInt(), anyInt(), any(NativeBlockState.class));
|
||||
order.verify(writer).endObjectPlacement(anyInt());
|
||||
order.verify(writer).beginObjectPlacement(true);
|
||||
order.verify(writer, calls(1)).set(anyInt(), anyInt(), anyInt(), any(NativeBlockState.class));
|
||||
order.verify(writer).endObjectPlacement(anyInt());
|
||||
}
|
||||
|
||||
private void assertRiverKept() {
|
||||
verify(writer, never()).setForcedCarve(eq(3), eq(62), eq(1), any(MatterCavern.class));
|
||||
verify(writer, never()).setForcedCarve(eq(4), eq(68), eq(1), any(MatterCavern.class));
|
||||
verify(writer, never()).setForcedCarve(eq(1), eq(58), eq(1), any(MatterCavern.class));
|
||||
verify(writer, never()).setForcedCarve(eq(6), eq(64), eq(1), any(MatterCavern.class));
|
||||
verify(writer).setForcedCarve(eq(3), eq(55), eq(1), any(MatterCavern.class));
|
||||
verify(writer).setForcedCarve(eq(1), eq(66), eq(1), any(MatterCavern.class));
|
||||
verify(writer).setForcedCarve(eq(0), eq(62), eq(1), any(MatterCavern.class));
|
||||
verify(writer).setForcedCarve(eq(7), eq(62), eq(1), any(MatterCavern.class));
|
||||
}
|
||||
|
||||
private static boolean river(Object x) {
|
||||
int blockX = (int) Math.floor(((Number) x).doubleValue());
|
||||
return blockX == 3 || blockX == 4;
|
||||
}
|
||||
|
||||
private static IrisStructureTerrain terrain(StructureTerrainMode mode, StructureCarveShape shape) {
|
||||
return new IrisStructureTerrain()
|
||||
.setMode(mode)
|
||||
.setShape(shape)
|
||||
.setFloorPadding(10)
|
||||
.setCeilingPadding(4);
|
||||
}
|
||||
|
||||
private static KList<PlacedStructurePiece> box() {
|
||||
return new KList<>(new PlacedStructurePiece(null, null, 4, -4, 1, IrisObjectRotation.of(0, 0, 0),
|
||||
0, -4, 0, 8, 0, 2));
|
||||
}
|
||||
|
||||
private static KList<PlacedStructurePiece> slab() {
|
||||
NativeBlockState stone = mock(NativeBlockState.class);
|
||||
when(stone.isSolid()).thenReturn(true);
|
||||
when(stone.key()).thenReturn("minecraft:stone");
|
||||
when(stone.materialKey()).thenReturn("minecraft:stone");
|
||||
IrisObject object = new IrisObject(9, 1, 3);
|
||||
for (int x = 0; x < 9; x++) {
|
||||
for (int z = 0; z < 3; z++) {
|
||||
object.setUnsigned(x, 0, z, stone);
|
||||
}
|
||||
}
|
||||
return new KList<>(new PlacedStructurePiece(null, object, 4, -4, 1, IrisObjectRotation.of(0, 0, 0),
|
||||
0, -4, 0, 8, -4, 2));
|
||||
}
|
||||
}
|
||||
+15
-3
@@ -32,7 +32,7 @@ public class IrisStructureComponentWaterTest {
|
||||
world.water(WaterRole.CHANNEL, 9, 13);
|
||||
HydrologyWaterFixture.Placer placer = world.placer();
|
||||
IrisObject object = HydrologyWaterFixture.raft();
|
||||
IrisObjectPlacement config = IrisStructureComponent.piecePlacement(new IrisStructure(), piece(object), ObjectPlaceMode.CENTER_HEIGHT);
|
||||
IrisObjectPlacement config = IrisStructureComponent.piecePlacement(new IrisStructure(), piece(object), ObjectPlaceMode.CENTER_HEIGHT, false);
|
||||
|
||||
assertTrue(config.isForcePlace());
|
||||
assertEquals(-1, object.place(0, 0, placer, config, new RNG(7L), world.data()));
|
||||
@@ -49,18 +49,30 @@ public class IrisStructureComponentWaterTest {
|
||||
when(world.complex().getHeightStream()).thenReturn(heights);
|
||||
HydrologyWaterFixture.Placer placer = world.placer();
|
||||
IrisObject object = HydrologyWaterFixture.raft();
|
||||
IrisObjectPlacement config = IrisStructureComponent.piecePlacement(new IrisStructure(), piece(object), ObjectPlaceMode.CENTER_HEIGHT);
|
||||
IrisObjectPlacement config = IrisStructureComponent.piecePlacement(new IrisStructure(), piece(object), ObjectPlaceMode.CENTER_HEIGHT, false);
|
||||
config.setRotateTowardsSlope(true);
|
||||
|
||||
assertEquals(-1, object.place(0, 0, placer, config, new RNG(7L), world.data()));
|
||||
assertTrue(placer.writes().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void forcedSinglePieceStructureThatAllowsWaterPlacesOnFlatRiverWater() {
|
||||
world.water(WaterRole.CHANNEL, 9, 13);
|
||||
HydrologyWaterFixture.Placer placer = world.placer();
|
||||
IrisObject object = HydrologyWaterFixture.raft();
|
||||
IrisObjectPlacement config = IrisStructureComponent.piecePlacement(new IrisStructure(), piece(object), ObjectPlaceMode.CENTER_HEIGHT, true);
|
||||
|
||||
assertTrue(config.entersWater());
|
||||
assertTrue(object.place(0, 0, placer, config, new RNG(7L), world.data()) >= 0);
|
||||
assertEquals(world.headAt(0, 0), placer.lowestWrite());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void forcedSinglePieceStructureStillPlacesOnDryLand() {
|
||||
HydrologyWaterFixture.Placer placer = world.placer();
|
||||
IrisObject object = HydrologyWaterFixture.raft();
|
||||
IrisObjectPlacement config = IrisStructureComponent.piecePlacement(new IrisStructure(), piece(object), ObjectPlaceMode.CENTER_HEIGHT);
|
||||
IrisObjectPlacement config = IrisStructureComponent.piecePlacement(new IrisStructure(), piece(object), ObjectPlaceMode.CENTER_HEIGHT, false);
|
||||
|
||||
assertTrue(object.place(0, 0, placer, config, new RNG(7L), world.data()) >= 0);
|
||||
assertFalse(placer.writes().isEmpty());
|
||||
|
||||
+149
@@ -0,0 +1,149 @@
|
||||
package art.arcane.iris.generation.mantle;
|
||||
|
||||
import art.arcane.iris.generation.hydrology.cave.HydrologyCaveCell;
|
||||
import art.arcane.iris.generation.hydrology.engine.HydrologyRuntime;
|
||||
import art.arcane.iris.generation.hydrology.raster.ChunkWaterRaster;
|
||||
import art.arcane.iris.generation.hydrology.raster.WaterRole;
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.iris.generation.runtime.IrisComplex;
|
||||
import art.arcane.iris.generation.terrain.IrisDimension;
|
||||
import art.arcane.iris.integration.Identifier;
|
||||
import art.arcane.iris.testsupport.PlatformBinding;
|
||||
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
|
||||
import art.arcane.volmlib.util.mantle.runtime.Mantle;
|
||||
import art.arcane.volmlib.util.mantle.runtime.MantleChunk;
|
||||
import art.arcane.volmlib.util.matter.Matter;
|
||||
import art.arcane.volmlib.util.matter.MatterCavern;
|
||||
import art.arcane.volmlib.util.matter.MatterSlice;
|
||||
import art.arcane.volmlib.util.stream.ProceduralStream;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyDouble;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class MantleWriterObjectWaterTest {
|
||||
@Rule
|
||||
public final PlatformBinding platform = PlatformBinding.mockPlatform();
|
||||
|
||||
private MantleWriter writer;
|
||||
private MatterSlice<NativeBlockState> blocks;
|
||||
private MatterSlice<MatterCavern> caverns;
|
||||
private NativeBlockState stone;
|
||||
private NativeBlockState air;
|
||||
|
||||
@Before
|
||||
@SuppressWarnings("unchecked")
|
||||
public void setUp() {
|
||||
EngineMantle engineMantle = mock(EngineMantle.class);
|
||||
Engine engine = mock(Engine.class);
|
||||
IrisComplex complex = mock(IrisComplex.class);
|
||||
HydrologyRuntime runtime = mock(HydrologyRuntime.class);
|
||||
ChunkWaterRaster raster = mock(ChunkWaterRaster.class);
|
||||
Mantle<Matter> mantle = mock(Mantle.class);
|
||||
MantleChunk<Matter> chunk = mock(MantleChunk.class);
|
||||
Matter matter = mock(Matter.class);
|
||||
blocks = mock(MatterSlice.class);
|
||||
caverns = mock(MatterSlice.class);
|
||||
when(engineMantle.getEngine()).thenReturn(engine);
|
||||
when(engineMantle.getComplex()).thenReturn(complex);
|
||||
when(engine.getComplex()).thenReturn(complex);
|
||||
when(engine.getDimension()).thenReturn(mock(IrisDimension.class));
|
||||
when(complex.getHydrologyRuntime()).thenReturn(runtime);
|
||||
when(runtime.enabled()).thenReturn(true);
|
||||
when(runtime.raster(anyInt(), anyInt())).thenReturn(raster);
|
||||
when(raster.role(anyInt(), anyInt())).thenReturn(WaterRole.NONE);
|
||||
when(raster.waterHead(anyInt(), anyInt())).thenReturn(Integer.MIN_VALUE);
|
||||
when(raster.terrainHeight(anyInt(), anyInt())).thenReturn(12);
|
||||
when(raster.role(3, 3)).thenReturn(WaterRole.CHANNEL);
|
||||
when(raster.waterHead(3, 3)).thenReturn(9);
|
||||
when(raster.terrainHeight(3, 3)).thenReturn(5);
|
||||
followRaster(complex, raster);
|
||||
when(mantle.getWorldHeight()).thenReturn(64);
|
||||
when(mantle.getChunk(0, 0)).thenReturn(chunk);
|
||||
when(chunk.use()).thenReturn(chunk);
|
||||
when(mantle.useChunk(0, 0)).thenAnswer(call -> chunk.use());
|
||||
when(chunk.getOrCreate(0)).thenReturn(matter);
|
||||
when(chunk.exists(0)).thenReturn(true);
|
||||
when(chunk.get(0)).thenReturn(matter);
|
||||
when(matter.getClass(any())).thenAnswer(call -> call.getArgument(0).getClass());
|
||||
doReturn(blocks).when(matter).slice(NativeBlockState.class);
|
||||
doReturn(caverns).when(matter).slice(MatterCavern.class);
|
||||
doReturn(mock(MatterSlice.class)).when(matter).getSlice(Identifier.class);
|
||||
doReturn(null).when(matter).getSlice(HydrologyCaveCell.class);
|
||||
stone = mock(NativeBlockState.class);
|
||||
when(stone.isSolid()).thenReturn(true);
|
||||
air = mock(NativeBlockState.class);
|
||||
writer = new MantleWriter(engineMantle, mantle, 0, 0, 0, false);
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
writer.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void structurePiecesKeepOutOfRiverWaterUnlessTheyAllowIt() {
|
||||
MatterCavern cavern = new MatterCavern(true, "", (byte) 3);
|
||||
int land = writer.beginObjectPlacement(false);
|
||||
writer.set(3, 7, 3, stone);
|
||||
writer.set(3, 8, 3, air);
|
||||
writer.setData(3, 6, 3, cavern);
|
||||
writer.set(3, 5, 3, stone);
|
||||
writer.set(3, 10, 3, stone);
|
||||
writer.set(8, 7, 8, stone);
|
||||
writer.endObjectPlacement(land);
|
||||
|
||||
verify(blocks, never()).set(3, 7, 3, stone);
|
||||
verify(blocks, never()).set(3, 8, 3, air);
|
||||
verify(caverns, never()).set(3, 6, 3, cavern);
|
||||
verify(blocks).set(3, 5, 3, stone);
|
||||
verify(blocks).set(3, 10, 3, stone);
|
||||
verify(blocks).set(8, 7, 8, stone);
|
||||
|
||||
int water = writer.beginObjectPlacement(true);
|
||||
writer.set(3, 6, 3, stone);
|
||||
writer.set(3, 9, 3, air);
|
||||
writer.endObjectPlacement(water);
|
||||
|
||||
verify(blocks).set(3, 6, 3, stone);
|
||||
verify(blocks, never()).set(3, 9, 3, air);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void writesOutsideAnObjectPlacementAreNotVetoed() {
|
||||
int land = writer.beginObjectPlacement(false);
|
||||
writer.endObjectPlacement(land);
|
||||
|
||||
writer.set(3, 7, 3, stone);
|
||||
writer.set(3, 8, 3, air);
|
||||
|
||||
verify(blocks).set(3, 7, 3, stone);
|
||||
verify(blocks).set(3, 8, 3, air);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static void followRaster(IrisComplex complex, ChunkWaterRaster raster) {
|
||||
ProceduralStream<WaterRole> roles = mock(ProceduralStream.class);
|
||||
ProceduralStream<Double> heads = mock(ProceduralStream.class);
|
||||
ProceduralStream<Integer> heights = mock(ProceduralStream.class);
|
||||
when(roles.get(anyDouble(), anyDouble())).thenAnswer(call -> raster.role(local(call.getArgument(0)), local(call.getArgument(1))));
|
||||
when(heads.getDouble(anyDouble(), anyDouble())).thenAnswer(call -> (double) raster.waterHead(local(call.getArgument(0)), local(call.getArgument(1))));
|
||||
when(heights.get(anyDouble(), anyDouble())).thenAnswer(call -> raster.terrainHeight(local(call.getArgument(0)), local(call.getArgument(1))));
|
||||
when(complex.getWaterRoleStream()).thenReturn(roles);
|
||||
when(complex.getWaterHeadStream()).thenReturn(heads);
|
||||
when(complex.getRoundedHeighteightStream()).thenReturn(heights);
|
||||
}
|
||||
|
||||
private static int local(Object coordinate) {
|
||||
return (int) Math.floor(((Number) coordinate).doubleValue()) & 15;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -173,7 +173,7 @@ public class ObjectContinuationCanopyTest {
|
||||
when(firstChunk.getOrCreate(0)).thenReturn(first);
|
||||
when(secondChunk.getOrCreate(0)).thenReturn(second);
|
||||
FloatingObjectPlacementTransaction transaction = new FloatingObjectPlacementTransaction(delegate,
|
||||
new ObjectContinuationBundle.PlacementKey(ObjectContinuationBundle.Kind.FLOATING, 0, 0, 0));
|
||||
new ObjectContinuationBundle.PlacementKey(ObjectContinuationBundle.Kind.FLOATING, 0, 0, 0), false);
|
||||
transaction.set(15, 5, 1, trunk);
|
||||
assertTrue(transaction.beginTreeCanopy(new BlockPosition(16, 5, 1)));
|
||||
transaction.set(16, 5, 1, custom);
|
||||
|
||||
+30
-1
@@ -325,7 +325,7 @@ public class ObjectDestinationTransactionTest {
|
||||
IrisObjectPlacement raft = new IrisObjectPlacement().setOnwater(true);
|
||||
IrisObjectPlacement forced = new IrisObjectPlacement().setForcePlace(true);
|
||||
IrisObjectPlacement piece = IrisStructureComponent.piecePlacement(new IrisStructure(), new PlacedStructurePiece(null,
|
||||
new IrisObject(1, 1, 1), 4, 14, 3, IrisObjectRotation.of(0, 0, 0), 4, 14, 3, 4, 14, 3), ObjectPlaceMode.CENTER_HEIGHT);
|
||||
new IrisObject(1, 1, 1), 4, 14, 3, IrisObjectRotation.of(0, 0, 0), 4, 14, 3, 4, 14, 3), ObjectPlaceMode.CENTER_HEIGHT, false);
|
||||
assertTrue(piece.isForcePlace());
|
||||
ObjectDestinationTransaction transaction = new ObjectDestinationTransaction(writer, 0, 0);
|
||||
|
||||
@@ -346,6 +346,35 @@ public class ObjectDestinationTransactionTest {
|
||||
assertEquals("the destination replay keeps the raft and the forced block", 4, destination.mutationCheckpoint());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void endingAWaterPlacementReturnsTheTransactionToLandRules() {
|
||||
MantleWriter writer = writer();
|
||||
IrisComplex complex = mock(IrisComplex.class);
|
||||
HydrologyRuntime runtime = mock(HydrologyRuntime.class);
|
||||
ChunkWaterRaster raster = mock(ChunkWaterRaster.class);
|
||||
when(writer.getEngine().getComplex()).thenReturn(complex);
|
||||
when(complex.getHydrologyRuntime()).thenReturn(runtime);
|
||||
when(runtime.enabled()).thenReturn(true);
|
||||
when(runtime.raster(anyInt(), anyInt())).thenReturn(raster);
|
||||
when(raster.role(anyInt(), anyInt())).thenReturn(WaterRole.NONE);
|
||||
when(raster.waterHead(anyInt(), anyInt())).thenReturn(Integer.MIN_VALUE);
|
||||
when(raster.role(3, 3)).thenReturn(WaterRole.CHANNEL);
|
||||
when(raster.waterHead(3, 3)).thenReturn(14);
|
||||
when(raster.terrainHeight(3, 3)).thenReturn(10);
|
||||
followRasterStreams(complex, raster);
|
||||
NativeBlockState pier = mock(NativeBlockState.class);
|
||||
when(pier.isSolid()).thenReturn(true);
|
||||
ObjectDestinationTransaction transaction = new ObjectDestinationTransaction(writer, 0, 0);
|
||||
|
||||
int raft = transaction.beginObjectPlacement(true);
|
||||
transaction.set(3, 12, 3, pier);
|
||||
transaction.endObjectPlacement(raft);
|
||||
int afterRaft = transaction.mutationCheckpoint();
|
||||
transaction.set(3, 13, 3, pier);
|
||||
|
||||
assertEquals("a write after the water placement ends follows land rules", afterRaft, transaction.mutationCheckpoint());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sourceCaptureCannotReplaceAuthoredRoomSolids() {
|
||||
MantleWriter writer = writer();
|
||||
|
||||
@@ -84,7 +84,7 @@ public class SchemaBuilderIdentityTest {
|
||||
@ClassRule
|
||||
public static final PlatformLeakGuard PLATFORM_GUARD = PlatformLeakGuard.clean();
|
||||
|
||||
private static final String EXPECTED_SCHEMA_DIGEST = "52d7194d5b45874dc57b5446125e1fa66c32a821733cf38c1c8256f1e52738f7";
|
||||
private static final String EXPECTED_SCHEMA_DIGEST = "8d12b6f21c37ae79655854e2a0e5fed57c12f294b28fb988674cf8d7b565f405";
|
||||
|
||||
private static final List<Class<?>> SCHEMA_ROOTS = List.of(
|
||||
IrisDimension.class,
|
||||
|
||||
+114
@@ -4,7 +4,10 @@ import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.iris.generation.runtime.SeedManager;
|
||||
import art.arcane.iris.structure.placement.StructurePlacementGrid;
|
||||
|
||||
import art.arcane.iris.generation.hydrology.raster.WaterRole;
|
||||
import art.arcane.iris.generation.runtime.IrisComplex;
|
||||
import art.arcane.iris.generation.stream.ProvisionalAnswerException;
|
||||
import art.arcane.iris.generation.stream.ProvisionalSampling;
|
||||
import art.arcane.iris.generation.terrain.IrisDimension;
|
||||
import art.arcane.iris.structure.placement.IrisStructureAnchorMode;
|
||||
import art.arcane.iris.structure.placement.IrisStructurePlacement;
|
||||
@@ -16,12 +19,18 @@ import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertThrows;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.mockito.ArgumentMatchers.anyDouble;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
@@ -130,6 +139,77 @@ public class NativeStructurePlacementPlannerTest {
|
||||
verify(waterHead).get(8, 8);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void structuresAvoidRivers() {
|
||||
Engine engine = engine(77L, -64, 384, 150);
|
||||
Map<Long, WaterRole> roles = new HashMap<>();
|
||||
waterComplex(engine, roles, false);
|
||||
IrisStructurePlacement placement = nativePlacement();
|
||||
WaterRole[] water = {WaterRole.CHANNEL, WaterRole.POND, WaterRole.CASCADE, WaterRole.WATERFALL};
|
||||
for (int column = 0; column < 25; column++) {
|
||||
roles.put(columnKey(column & 15, column >> 4), water[column & 3]);
|
||||
}
|
||||
|
||||
assertNotNull("25 of 256 start-chunk columns of river, pond and fall water are within 10%",
|
||||
NativeStructurePlacementPlanner.planAt(engine, placement, 0, 0));
|
||||
|
||||
roles.put(columnKey(9, 1), WaterRole.CHANNEL);
|
||||
assertNull("26 of 256 columns are more than 10% water",
|
||||
NativeStructurePlacementPlanner.planAt(engine, placement, 0, 0));
|
||||
|
||||
roles.clear();
|
||||
WaterRole[] dry = {WaterRole.MOUTH, WaterRole.INLET, WaterRole.SHORE, WaterRole.POND_SHORE, WaterRole.BANK, WaterRole.DAM};
|
||||
for (int column = 0; column < 256; column++) {
|
||||
roles.put(columnKey(column & 15, column >> 4), dry[column % dry.length]);
|
||||
}
|
||||
assertNotNull("mouths, inlets, shores, banks and dams do not count as river water",
|
||||
NativeStructurePlacementPlanner.planAt(engine, placement, 0, 0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void undergroundPlansIgnoreRiversAbove() {
|
||||
Engine engine = engine(982374L, -64, 384, 90);
|
||||
Map<Long, WaterRole> roles = new HashMap<>();
|
||||
waterComplex(engine, roles, false);
|
||||
flood(roles);
|
||||
IrisStructurePlacement placement = nativePlacement()
|
||||
.setUnderground(true)
|
||||
.setMinHeight(-45)
|
||||
.setMaxHeight(-20);
|
||||
|
||||
assertNotNull(NativeStructurePlacementPlanner.planAt(engine, placement, 12, -7));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void allowWaterLetsNativeStructuresCoverRivers() {
|
||||
Engine engine = engine(77L, -64, 384, 150);
|
||||
Map<Long, WaterRole> roles = new HashMap<>();
|
||||
waterComplex(engine, roles, false);
|
||||
flood(roles);
|
||||
IrisStructurePlacement placement = nativePlacement();
|
||||
|
||||
assertNull(NativeStructurePlacementPlanner.planAt(engine, placement, 0, 0));
|
||||
|
||||
placement.setAllowWater(true);
|
||||
assertNotNull(NativeStructurePlacementPlanner.planAt(engine, placement, 0, 0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void provisionalWaterAnswersNeverPlaceANativeStructure() {
|
||||
Engine engine = engine(77L, -64, 384, 150);
|
||||
IrisComplex complex = waterComplex(engine, new HashMap<>(), true);
|
||||
IrisStructurePlacement placement = nativePlacement();
|
||||
|
||||
ProvisionalAnswerException failure = assertThrows(ProvisionalAnswerException.class,
|
||||
() -> NativeStructurePlacementPlanner.planAt(engine, placement, 0, 0));
|
||||
assertTrue(failure.getMessage().contains("minecraft:ancient_city"));
|
||||
assertTrue(failure.getMessage().contains("0,0"));
|
||||
|
||||
when(complex.isPlatformMainThread()).thenReturn(true);
|
||||
assertNotNull("the server thread answers from what it has, as for heights",
|
||||
NativeStructurePlacementPlanner.planAt(engine, placement, 0, 0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void duplicateSelectedStructureUsesOneDeterministicPlan() {
|
||||
Engine engine = engine(77L, -64, 384, 150);
|
||||
@@ -218,6 +298,40 @@ public class NativeStructurePlacementPlannerTest {
|
||||
return engine;
|
||||
}
|
||||
|
||||
private IrisComplex waterComplex(Engine engine, Map<Long, WaterRole> roles, boolean provisional) {
|
||||
IrisComplex complex = mock(IrisComplex.class);
|
||||
@SuppressWarnings("unchecked")
|
||||
ProceduralStream<Double> heads = mock(ProceduralStream.class);
|
||||
@SuppressWarnings("unchecked")
|
||||
ProceduralStream<WaterRole> roleStream = mock(ProceduralStream.class);
|
||||
when(heads.get(anyDouble(), anyDouble())).thenReturn(0D);
|
||||
when(roleStream.get(anyDouble(), anyDouble())).thenAnswer(call -> {
|
||||
if (provisional) {
|
||||
ProvisionalSampling.mark();
|
||||
}
|
||||
return roles.getOrDefault(columnKey(block(call.getArgument(0)), block(call.getArgument(1))), WaterRole.NONE);
|
||||
});
|
||||
when(complex.getWaterHeadStream()).thenReturn(heads);
|
||||
when(complex.getWaterRoleStream()).thenReturn(roleStream);
|
||||
when(complex.allowsNewGenerationChunk(anyInt(), anyInt())).thenReturn(true);
|
||||
when(engine.getComplex()).thenReturn(complex);
|
||||
return complex;
|
||||
}
|
||||
|
||||
private static void flood(Map<Long, WaterRole> roles) {
|
||||
for (int column = 0; column < 256; column++) {
|
||||
roles.put(columnKey(column & 15, column >> 4), WaterRole.CHANNEL);
|
||||
}
|
||||
}
|
||||
|
||||
private static int block(Object coordinate) {
|
||||
return (int) Math.floor(((Number) coordinate).doubleValue());
|
||||
}
|
||||
|
||||
private static long columnKey(int x, int z) {
|
||||
return ((long) x << 32) ^ (z & 0xffffffffL);
|
||||
}
|
||||
|
||||
private void bindPlacements(Engine engine, IrisStructurePlacement... placements) {
|
||||
IrisDimension dimension = engine.getDimension();
|
||||
KList<IrisStructurePlacement> configured = new KList<>();
|
||||
|
||||
+76
@@ -26,6 +26,7 @@ import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.iris.generation.runtime.SeedManager;
|
||||
|
||||
import art.arcane.iris.pack.loading.IrisData;
|
||||
import art.arcane.iris.generation.hydrology.raster.WaterRole;
|
||||
import art.arcane.iris.generation.runtime.IrisComplex;
|
||||
import art.arcane.iris.structure.graph.StructureGraphCatalog;
|
||||
import art.arcane.iris.pack.value.IrisDirection;
|
||||
@@ -45,6 +46,7 @@ import art.arcane.volmlib.util.math.RNG;
|
||||
import art.arcane.volmlib.util.stream.ProceduralStream;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
@@ -447,6 +449,72 @@ public class IrisStructureLocatorContractTest {
|
||||
assertEquals(IrisStructureLocator.LocateStatus.NOT_FOUND, result.status());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void irisStructuresAvoidRivers() {
|
||||
Engine engine = densityEngine(1.0, false, -64, 384, -2032, 2032);
|
||||
IrisObject object = engine.getData().load(IrisObject.class, "test:density/object", false);
|
||||
when(object.getW()).thenReturn(10);
|
||||
when(object.getD()).thenReturn(10);
|
||||
Set<Long> river = new HashSet<>();
|
||||
IrisComplex complex = mock(IrisComplex.class);
|
||||
when(engine.getComplex()).thenReturn(complex);
|
||||
when(complex.allowsNewGenerationFootprint(anyInt(), anyInt(), anyInt(), anyInt())).thenReturn(true);
|
||||
@SuppressWarnings("unchecked")
|
||||
ProceduralStream<Double> waterHead = mock(ProceduralStream.class);
|
||||
when(complex.getWaterHeadStream()).thenReturn(waterHead);
|
||||
when(waterHead.get(anyDouble(), anyDouble())).thenReturn(63D);
|
||||
@SuppressWarnings("unchecked")
|
||||
ProceduralStream<WaterRole> roles = mock(ProceduralStream.class);
|
||||
when(complex.getWaterRoleStream()).thenReturn(roles);
|
||||
when(roles.get(anyDouble(), anyDouble())).thenAnswer(call -> river.contains(columnKey(
|
||||
(int) Math.floor(call.<Double>getArgument(0)), (int) Math.floor(call.<Double>getArgument(1))))
|
||||
? WaterRole.CHANNEL : WaterRole.NONE);
|
||||
when(engine.getHeight(anyInt(), anyInt(), eq(true))).thenReturn(128);
|
||||
when(engine.getDimension().getFluidHeight()).thenReturn(63);
|
||||
IrisStructurePlacement placement = engine.getDimension().getStructures().get(0);
|
||||
|
||||
IrisStructureLocator.ResolvedPlacement dry = IrisStructureLocator.resolvePlacement(engine, placement, 3, 4);
|
||||
assertNotNull(dry);
|
||||
assertEquals(1, dry.pieces().size());
|
||||
PlacedStructurePiece piece = dry.pieces().getFirst();
|
||||
int columns = (piece.getMaxX() - piece.getMinX() + 1) * (piece.getMaxZ() - piece.getMinZ() + 1);
|
||||
int allowed = columns / 10;
|
||||
assertTrue("the footprint must span enough columns to tell 10% apart", allowed >= 4);
|
||||
for (int index = 0; index < allowed; index++) {
|
||||
river.add(columnKey(piece.getMinX() + index, piece.getMinZ()));
|
||||
}
|
||||
|
||||
assertNotNull("a footprint at most 10% river keeps its structure",
|
||||
IrisStructureLocator.resolvePlacement(engine, placement, 3, 4));
|
||||
|
||||
river.add(columnKey(piece.getMinX(), piece.getMaxZ()));
|
||||
assertNull("a footprint more than 10% river is skipped",
|
||||
IrisStructureLocator.resolvePlacement(engine, placement, 3, 4));
|
||||
|
||||
placement.setAllowWater(true);
|
||||
assertNotNull(IrisStructureLocator.resolvePlacement(engine, placement, 3, 4));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void undergroundIrisStructuresIgnoreRiversAbove() {
|
||||
Engine engine = densityEngine(1.0, true, -64, 384, -40, -20);
|
||||
IrisComplex complex = mock(IrisComplex.class);
|
||||
when(engine.getComplex()).thenReturn(complex);
|
||||
when(complex.allowsNewGenerationFootprint(anyInt(), anyInt(), anyInt(), anyInt())).thenReturn(true);
|
||||
@SuppressWarnings("unchecked")
|
||||
ProceduralStream<Double> waterHead = mock(ProceduralStream.class);
|
||||
when(complex.getWaterHeadStream()).thenReturn(waterHead);
|
||||
when(waterHead.get(anyDouble(), anyDouble())).thenReturn(63D);
|
||||
@SuppressWarnings("unchecked")
|
||||
ProceduralStream<WaterRole> roles = mock(ProceduralStream.class);
|
||||
when(complex.getWaterRoleStream()).thenReturn(roles);
|
||||
when(roles.get(anyDouble(), anyDouble())).thenReturn(WaterRole.CHANNEL);
|
||||
when(engine.getHeight(anyInt(), anyInt(), eq(true))).thenReturn(128);
|
||||
IrisStructurePlacement placement = engine.getDimension().getStructures().get(0);
|
||||
|
||||
assertNotNull(IrisStructureLocator.resolvePlacement(engine, placement, 3, 4));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void locateRanksEditableStartsByResolvedBlockOrigin() {
|
||||
Engine engine = densityEngine(1.0, false, -64, 384, -2032, 2032);
|
||||
@@ -457,6 +525,10 @@ public class IrisStructureLocatorContractTest {
|
||||
ProceduralStream<Double> waterHead = mock(ProceduralStream.class);
|
||||
when(complex.getWaterHeadStream()).thenReturn(waterHead);
|
||||
when(waterHead.get(anyDouble(), anyDouble())).thenReturn(63D);
|
||||
@SuppressWarnings("unchecked")
|
||||
ProceduralStream<WaterRole> roles = mock(ProceduralStream.class);
|
||||
when(complex.getWaterRoleStream()).thenReturn(roles);
|
||||
when(roles.get(anyDouble(), anyDouble())).thenReturn(WaterRole.NONE);
|
||||
when(engine.getAllBiomes()).thenReturn(new KList<>());
|
||||
when(engine.getHeight(anyInt(), anyInt(), eq(true))).thenReturn(128);
|
||||
when(engine.getDimension().getFluidHeight()).thenReturn(63);
|
||||
@@ -826,6 +898,10 @@ public class IrisStructureLocatorContractTest {
|
||||
return dx * dx + dz * dz;
|
||||
}
|
||||
|
||||
private static long columnKey(int x, int z) {
|
||||
return ((long) x << 32) ^ (z & 0xffffffffL);
|
||||
}
|
||||
|
||||
private PlacedStructurePiece piece(int minX, int minY, int minZ, int maxX, int maxY, int maxZ) {
|
||||
return new PlacedStructurePiece(null, null, 0, 0, 0, null, minX, minY, minZ, maxX, maxY, maxZ);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user