mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-12-02 02:34:24 +00:00
Force place ignores water
- Add ObjectWaterRule with KEEP_OUT, ENTERS_WATER and FORCED, carried through placers, mutation logs and source plans - Skip the whole hydrology veto for forced placements in MantleWriter, ObjectDestinationTransaction and FloatingObjectPlacementTransaction - Skip the hydrology-support and uneven-water rejections for every forcePlace placement - Admit forced Iris pieces past the 10% limit and the submerged start check in IrisStructureLocator - Decide piece mode and forcing once in IrisStructurePlacement so locate and generation agree - Remove forcedByStructure, now covered by forcePlace - Update tests to the new behaviour, including a piece inside a river and a forced object over a channel
This commit is contained in:
27 files changed
+310
-161
No files matched your search
+7
-6
@@ -23,6 +23,7 @@ import art.arcane.iris.generation.runtime.Engine;
|
|||||||
import art.arcane.iris.generation.runtime.IrisComplex;
|
import art.arcane.iris.generation.runtime.IrisComplex;
|
||||||
import art.arcane.iris.structure.object.IObjectPlacer;
|
import art.arcane.iris.structure.object.IObjectPlacer;
|
||||||
import art.arcane.iris.generation.block.TileData;
|
import art.arcane.iris.generation.block.TileData;
|
||||||
|
import art.arcane.iris.structure.object.ObjectWaterRule;
|
||||||
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
|
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
|
||||||
import art.arcane.volmlib.util.math.BlockPosition;
|
import art.arcane.volmlib.util.math.BlockPosition;
|
||||||
import art.arcane.iris.generation.block.B;
|
import art.arcane.iris.generation.block.B;
|
||||||
@@ -44,18 +45,18 @@ final class FloatingObjectPlacementTransaction implements IObjectPlacer {
|
|||||||
private final ObjectContinuationBundle.PlacementKey placementKey;
|
private final ObjectContinuationBundle.PlacementKey placementKey;
|
||||||
private final KList<BufferedMutation> mutations;
|
private final KList<BufferedMutation> mutations;
|
||||||
private final Map<PositionKey, NativeBlockState> bufferedBlocks;
|
private final Map<PositionKey, NativeBlockState> bufferedBlocks;
|
||||||
private final boolean entersWater;
|
private final ObjectWaterRule waterRule;
|
||||||
private ObjectHydrologyVeto waterVeto;
|
private ObjectHydrologyVeto waterVeto;
|
||||||
private int blockWrites;
|
private int blockWrites;
|
||||||
private BlockPosition canopyPosition;
|
private BlockPosition canopyPosition;
|
||||||
|
|
||||||
FloatingObjectPlacementTransaction(IObjectPlacer delegate, ObjectContinuationBundle.PlacementKey placementKey,
|
FloatingObjectPlacementTransaction(IObjectPlacer delegate, ObjectContinuationBundle.PlacementKey placementKey,
|
||||||
boolean entersWater) {
|
ObjectWaterRule waterRule) {
|
||||||
this.delegate = Objects.requireNonNull(delegate);
|
this.delegate = Objects.requireNonNull(delegate);
|
||||||
this.placementKey = Objects.requireNonNull(placementKey);
|
this.placementKey = Objects.requireNonNull(placementKey);
|
||||||
this.mutations = new KList<>();
|
this.mutations = new KList<>();
|
||||||
this.bufferedBlocks = new HashMap<>();
|
this.bufferedBlocks = new HashMap<>();
|
||||||
this.entersWater = entersWater;
|
this.waterRule = waterRule;
|
||||||
}
|
}
|
||||||
|
|
||||||
CommitResult commit() {
|
CommitResult commit() {
|
||||||
@@ -161,7 +162,7 @@ final class FloatingObjectPlacementTransaction implements IObjectPlacer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void set(int x, int y, int z, NativeBlockState state) {
|
public void set(int x, int y, int z, NativeBlockState state) {
|
||||||
if (state == null || waterVeto().keepsBlock(x, y, z, state, entersWater)) {
|
if (state == null || waterVeto().keepsBlock(x, y, z, state, waterRule)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mutations.add(new BlockMutation(x, y, z, state, isCanopy(x, y, z)));
|
mutations.add(new BlockMutation(x, y, z, state, isCanopy(x, y, z)));
|
||||||
@@ -251,9 +252,9 @@ final class FloatingObjectPlacementTransaction implements IObjectPlacer {
|
|||||||
|
|
||||||
private boolean keepsWater(int x, int y, int z, Object data) {
|
private boolean keepsWater(int x, int y, int z, Object data) {
|
||||||
if (data instanceof NativeBlockState state) {
|
if (data instanceof NativeBlockState state) {
|
||||||
return waterVeto().keepsBlock(x, y, z, state, entersWater);
|
return waterVeto().keepsBlock(x, y, z, state, waterRule);
|
||||||
}
|
}
|
||||||
return data instanceof MatterCavern && waterVeto().keeps(x, y, z, false, entersWater);
|
return data instanceof MatterCavern && waterVeto().keeps(x, y, z, false, waterRule);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ObjectHydrologyVeto waterVeto() {
|
private ObjectHydrologyVeto waterVeto() {
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
package art.arcane.iris.generation.mantle;
|
package art.arcane.iris.generation.mantle;
|
||||||
|
|
||||||
|
import art.arcane.iris.structure.object.ObjectWaterRule;
|
||||||
import art.arcane.volmlib.util.structure.StructureCarvingFootprint;
|
import art.arcane.volmlib.util.structure.StructureCarvingFootprint;
|
||||||
|
|
||||||
import art.arcane.volmlib.util.structure.StructureCarveEnvelope;
|
import art.arcane.volmlib.util.structure.StructureCarveEnvelope;
|
||||||
@@ -162,29 +163,19 @@ public class IrisStructureComponent extends IrisMantleComponent {
|
|||||||
KList<PlacedStructurePiece> pieces, RNG rng) {
|
KList<PlacedStructurePiece> pieces, RNG rng) {
|
||||||
IrisStructureStiltSettings stilt = placement.getStilt();
|
IrisStructureStiltSettings stilt = placement.getStilt();
|
||||||
PieceRun run = new PieceRun(structure, rng, stilt == null ? null : new Long2IntOpenHashMap(),
|
PieceRun run = new PieceRun(structure, rng, stilt == null ? null : new Long2IntOpenHashMap(),
|
||||||
stilt != null && stilt.isSupportNonOccluding(), placement.isAllowWater());
|
stilt != null && stilt.isSupportNonOccluding());
|
||||||
ObjectPlaceMode mode = structure.getPlaceMode();
|
ObjectPlaceMode mode = placement.pieceMode(structure, pieces.size());
|
||||||
|
boolean forced = placement.forcesPieces(structure, pieces.size());
|
||||||
|
boolean sampledHeight = forced && !placement.isAnchoredUnderground();
|
||||||
|
ObjectWaterRule rule = forced ? ObjectWaterRule.FORCED
|
||||||
|
: placement.isAllowWater() ? ObjectWaterRule.ENTERS_WATER : ObjectWaterRule.KEEP_OUT;
|
||||||
int failedPieces = 0;
|
int failedPieces = 0;
|
||||||
writer.beginObjectPlacement(run.allowWater());
|
writer.beginObjectPlacement(rule);
|
||||||
try {
|
try {
|
||||||
if (placement.isAnchoredUnderground()) {
|
for (PlacedStructurePiece p : pieces) {
|
||||||
ObjectPlaceMode undergroundMode = (mode == ObjectPlaceMode.ORGANIC_STILT || mode == ObjectPlaceMode.CEILING_HANG)
|
if (placeObject(writer, run, p, mode, sampledHeight) == -1) {
|
||||||
? 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++;
|
failedPieces++;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
for (PlacedStructurePiece p : pieces) {
|
|
||||||
if (placeObject(writer, run, p, ObjectPlaceMode.STRUCTURE_PIECE, false) == -1) {
|
|
||||||
failedPieces++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (failedPieces == 0 && stilt != null) {
|
if (failedPieces == 0 && stilt != null) {
|
||||||
placeFoundation(writer, run.foundationColumns(), stilt, rng, !placement.isAnchoredUnderground());
|
placeFoundation(writer, run.foundationColumns(), stilt, rng, !placement.isAnchoredUnderground());
|
||||||
@@ -593,7 +584,6 @@ public class IrisStructureComponent extends IrisMantleComponent {
|
|||||||
}
|
}
|
||||||
if (mode != ObjectPlaceMode.STRUCTURE_PIECE && mode != ObjectPlaceMode.FLOATING) {
|
if (mode != ObjectPlaceMode.STRUCTURE_PIECE && mode != ObjectPlaceMode.FLOATING) {
|
||||||
config.setForcePlace(true);
|
config.setForcePlace(true);
|
||||||
config.setForcedByStructure(true);
|
|
||||||
}
|
}
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
@@ -720,6 +710,6 @@ public class IrisStructureComponent extends IrisMantleComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private record PieceRun(IrisStructure structure, RNG rng, Long2IntOpenHashMap foundationColumns,
|
private record PieceRun(IrisStructure structure, RNG rng, Long2IntOpenHashMap foundationColumns,
|
||||||
boolean supportNonOccluding, boolean allowWater) {
|
boolean supportNonOccluding) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+3
-3
@@ -217,7 +217,7 @@ public class MantleFloatingObjectComponent extends IrisMantleComponent {
|
|||||||
int id = rng.i(0, Integer.MAX_VALUE);
|
int id = rng.i(0, Integer.MAX_VALUE);
|
||||||
|
|
||||||
FloatingObjectPlacementTransaction transaction = new FloatingObjectPlacementTransaction(
|
FloatingObjectPlacementTransaction transaction = new FloatingObjectPlacementTransaction(
|
||||||
writer, placements.next(minX >> 4, minZ >> 4), placement.entersWater());
|
writer, placements.next(minX >> 4, minZ >> 4), placement.waterRule());
|
||||||
try {
|
try {
|
||||||
int resultY = obj.place(xx, zz, transaction, floatingPlacement, rng, (b, bd) -> {
|
int resultY = obj.place(xx, zz, transaction, floatingPlacement, rng, (b, bd) -> {
|
||||||
String marker = placementMarker(obj, id);
|
String marker = placementMarker(obj, id);
|
||||||
@@ -312,7 +312,7 @@ public class MantleFloatingObjectComponent extends IrisMantleComponent {
|
|||||||
|
|
||||||
IslandObjectPlacer islandPlacer = IslandObjectPlacer.top(writer, sampleProvider, entry, pickTopY);
|
IslandObjectPlacer islandPlacer = IslandObjectPlacer.top(writer, sampleProvider, entry, pickTopY);
|
||||||
FloatingObjectPlacementTransaction transaction = new FloatingObjectPlacementTransaction(
|
FloatingObjectPlacementTransaction transaction = new FloatingObjectPlacementTransaction(
|
||||||
islandPlacer, placements.next(minX >> 4, minZ >> 4), placement.entersWater());
|
islandPlacer, placements.next(minX >> 4, minZ >> 4), placement.waterRule());
|
||||||
int id = rng.i(0, Integer.MAX_VALUE);
|
int id = rng.i(0, Integer.MAX_VALUE);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -426,7 +426,7 @@ public class MantleFloatingObjectComponent extends IrisMantleComponent {
|
|||||||
|
|
||||||
IslandObjectPlacer islandPlacer = IslandObjectPlacer.bottom(writer, sampleProvider, entry, pickBottomY);
|
IslandObjectPlacer islandPlacer = IslandObjectPlacer.bottom(writer, sampleProvider, entry, pickBottomY);
|
||||||
FloatingObjectPlacementTransaction transaction = new FloatingObjectPlacementTransaction(
|
FloatingObjectPlacementTransaction transaction = new FloatingObjectPlacementTransaction(
|
||||||
islandPlacer, placements.next(minX >> 4, minZ >> 4), placement.entersWater());
|
islandPlacer, placements.next(minX >> 4, minZ >> 4), placement.waterRule());
|
||||||
int id = rng.i(0, Integer.MAX_VALUE);
|
int id = rng.i(0, Integer.MAX_VALUE);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -751,7 +751,7 @@ public class MantleObjectComponent extends IrisMantleComponent {
|
|||||||
try {
|
try {
|
||||||
int placeResult = -1;
|
int placeResult = -1;
|
||||||
CaveObjectPlacementTransaction.CommitResult commitResult = CaveObjectPlacementTransaction.CommitResult.EMPTY;
|
CaveObjectPlacementTransaction.CommitResult commitResult = CaveObjectPlacementTransaction.CommitResult.EMPTY;
|
||||||
int continuation = writer.beginObjectPlacement(placement.entersWater());
|
int continuation = writer.beginObjectPlacement(placement.waterRule());
|
||||||
if (carving) {
|
if (carving) {
|
||||||
int caveFloorY = caveAnchor.y();
|
int caveFloorY = caveAnchor.y();
|
||||||
if (golden) {
|
if (golden) {
|
||||||
@@ -1015,7 +1015,7 @@ public class MantleObjectComponent extends IrisMantleComponent {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
String marker = placementMarker(v, id, "surface");
|
String marker = placementMarker(v, id, "surface");
|
||||||
int continuation = writer.beginObjectPlacement(effectivePlacement.entersWater());
|
int continuation = writer.beginObjectPlacement(effectivePlacement.waterRule());
|
||||||
int result = v.place(xx, zz, placePlacer, effectivePlacement, rng, (b, data) -> {
|
int result = v.place(xx, zz, placePlacer, effectivePlacement, rng, (b, data) -> {
|
||||||
if (marker != null) {
|
if (marker != null) {
|
||||||
writer.setData(b.getX(), b.getY(), b.getZ(), marker);
|
writer.setData(b.getX(), b.getY(), b.getZ(), marker);
|
||||||
@@ -1202,7 +1202,7 @@ public class MantleObjectComponent extends IrisMantleComponent {
|
|||||||
IrisObjectPlacement effectivePlacement = resolveCavePlacement(objectPlacement, object, caveProfile);
|
IrisObjectPlacement effectivePlacement = resolveCavePlacement(objectPlacement, object, caveProfile);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
int continuation = writer.beginObjectPlacement(effectivePlacement.entersWater());
|
int continuation = writer.beginObjectPlacement(effectivePlacement.waterRule());
|
||||||
ContainedPlacementResult contained = placeContainedCaveObject(
|
ContainedPlacementResult contained = placeContainedCaveObject(
|
||||||
writer,
|
writer,
|
||||||
object,
|
object,
|
||||||
@@ -1400,7 +1400,7 @@ public class MantleObjectComponent extends IrisMantleComponent {
|
|||||||
}
|
}
|
||||||
boolean treePlacement = isTreePlacement(v, objectPlacement);
|
boolean treePlacement = isTreePlacement(v, objectPlacement);
|
||||||
String marker = placementMarker(v, id, "upper");
|
String marker = placementMarker(v, id, "upper");
|
||||||
int continuation = writer.beginObjectPlacement(placement.entersWater());
|
int continuation = writer.beginObjectPlacement(placement.waterRule());
|
||||||
int result;
|
int result;
|
||||||
try {
|
try {
|
||||||
result = v.place(xx, anchorY, zz, writer, placement, rng, (b, data) -> {
|
result = v.place(xx, anchorY, zz, writer, placement, rng, (b, data) -> {
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ package art.arcane.iris.generation.mantle;
|
|||||||
|
|
||||||
|
|
||||||
import art.arcane.iris.spi.IrisLogging;
|
import art.arcane.iris.spi.IrisLogging;
|
||||||
|
import art.arcane.iris.structure.object.ObjectWaterRule;
|
||||||
import art.arcane.iris.world.storage.matter.TileWrapper;
|
import art.arcane.iris.world.storage.matter.TileWrapper;
|
||||||
import art.arcane.iris.world.storage.matter.PreObjectMatterCell;
|
import art.arcane.iris.world.storage.matter.PreObjectMatterCell;
|
||||||
import art.arcane.iris.configuration.IrisSettings;
|
import art.arcane.iris.configuration.IrisSettings;
|
||||||
@@ -221,8 +222,8 @@ public class MantleWriter implements ObjectPassPlacer, AutoCloseable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int beginObjectPlacement(boolean entersWater) {
|
public int beginObjectPlacement(ObjectWaterRule rule) {
|
||||||
objectWater.set(new ObjectWater(ObjectHydrologyVeto.of(getEngine()), entersWater));
|
objectWater.set(new ObjectWater(ObjectHydrologyVeto.of(getEngine()), rule));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -237,9 +238,9 @@ public class MantleWriter implements ObjectPassPlacer, AutoCloseable {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (value instanceof NativeBlockState state) {
|
if (value instanceof NativeBlockState state) {
|
||||||
return water.veto().keepsBlock(x, y, z, state, water.entersWater());
|
return water.veto().keepsBlock(x, y, z, state, water.rule());
|
||||||
}
|
}
|
||||||
return value instanceof MatterCavern && water.veto().keeps(x, y, z, false, water.entersWater());
|
return value instanceof MatterCavern && water.veto().keeps(x, y, z, false, water.rule());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void recordObjectValue(int x, int y, int z, Class<?> type, Object value) {
|
private void recordObjectValue(int x, int y, int z, Class<?> type, Object value) {
|
||||||
@@ -1034,7 +1035,7 @@ public class MantleWriter implements ObjectPassPlacer, AutoCloseable {
|
|||||||
naturalOpening ? ALWAYS : NEVER, cavern ? ALWAYS : NEVER) ? (byte) 1 : 0;
|
naturalOpening ? ALWAYS : NEVER, cavern ? ALWAYS : NEVER) ? (byte) 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private record ObjectWater(ObjectHydrologyVeto veto, boolean entersWater) {
|
private record ObjectWater(ObjectHydrologyVeto veto, ObjectWaterRule rule) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public final class ObjectPlacementCapture implements AutoCloseable {
|
public final class ObjectPlacementCapture implements AutoCloseable {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package art.arcane.iris.generation.mantle;
|
package art.arcane.iris.generation.mantle;
|
||||||
|
|
||||||
|
import art.arcane.iris.structure.object.ObjectWaterRule;
|
||||||
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
|
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@@ -10,6 +11,7 @@ final class MutationLog {
|
|||||||
private static final byte CUSTOM = 1;
|
private static final byte CUSTOM = 1;
|
||||||
private static final byte CANOPY = 2;
|
private static final byte CANOPY = 2;
|
||||||
private static final byte ENTERS_WATER = 4;
|
private static final byte ENTERS_WATER = 4;
|
||||||
|
private static final byte FORCED = 8;
|
||||||
|
|
||||||
private int size;
|
private int size;
|
||||||
private int[] x = new int[32];
|
private int[] x = new int[32];
|
||||||
@@ -30,16 +32,16 @@ final class MutationLog {
|
|||||||
throw new IllegalArgumentException("Object mutation type " + key.type().getName()
|
throw new IllegalArgumentException("Object mutation type " + key.type().getName()
|
||||||
+ " does not match its value " + value.getClass().getName());
|
+ " does not match its value " + value.getClass().getName());
|
||||||
}
|
}
|
||||||
log.add(key.x(), key.y(), key.z(), value, false, set.canopy(), false);
|
log.add(key.x(), key.y(), key.z(), value, false, set.canopy(), ObjectWaterRule.KEEP_OUT);
|
||||||
}
|
}
|
||||||
case ObjectDestinationTransaction.CustomBlockMutation block -> log.add(key.x(), key.y(), key.z(),
|
case ObjectDestinationTransaction.CustomBlockMutation block -> log.add(key.x(), key.y(), key.z(),
|
||||||
Objects.requireNonNull(block.state(), "custom block state"), true, block.canopy(), false);
|
Objects.requireNonNull(block.state(), "custom block state"), true, block.canopy(), ObjectWaterRule.KEEP_OUT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return log;
|
return log;
|
||||||
}
|
}
|
||||||
|
|
||||||
void add(int blockX, int blockY, int blockZ, Object value, boolean custom, boolean canopy, boolean entersWater) {
|
void add(int blockX, int blockY, int blockZ, Object value, boolean custom, boolean canopy, ObjectWaterRule rule) {
|
||||||
if (size == values.length) {
|
if (size == values.length) {
|
||||||
int capacity = size * 2;
|
int capacity = size * 2;
|
||||||
x = Arrays.copyOf(x, capacity);
|
x = Arrays.copyOf(x, capacity);
|
||||||
@@ -52,7 +54,7 @@ final class MutationLog {
|
|||||||
y[size] = blockY;
|
y[size] = blockY;
|
||||||
z[size] = blockZ;
|
z[size] = blockZ;
|
||||||
values[size] = value;
|
values[size] = value;
|
||||||
flags[size] = (byte) ((custom ? CUSTOM : 0) | (canopy ? CANOPY : 0) | (entersWater ? ENTERS_WATER : 0));
|
flags[size] = (byte) ((custom ? CUSTOM : 0) | (canopy ? CANOPY : 0) | (rule == ObjectWaterRule.ENTERS_WATER ? ENTERS_WATER : 0) | (rule == ObjectWaterRule.FORCED ? FORCED : 0));
|
||||||
size++;
|
size++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,8 +86,11 @@ final class MutationLog {
|
|||||||
return (flags[index] & CANOPY) != 0;
|
return (flags[index] & CANOPY) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean entersWater(int index) {
|
ObjectWaterRule waterRule(int index) {
|
||||||
return (flags[index] & ENTERS_WATER) != 0;
|
if ((flags[index] & FORCED) != 0) {
|
||||||
|
return ObjectWaterRule.FORCED;
|
||||||
|
}
|
||||||
|
return (flags[index] & ENTERS_WATER) != 0 ? ObjectWaterRule.ENTERS_WATER : ObjectWaterRule.KEEP_OUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
Class<?> type(int index) {
|
Class<?> type(int index) {
|
||||||
|
|||||||
+20
-19
@@ -7,6 +7,7 @@ import art.arcane.iris.generation.decoration.tree.TreeBlockMaterial;
|
|||||||
import art.arcane.iris.generation.hydrology.cave.HydrologyCaveCell;
|
import art.arcane.iris.generation.hydrology.cave.HydrologyCaveCell;
|
||||||
import art.arcane.iris.generation.subterrain.SubterrainRasterizer;
|
import art.arcane.iris.generation.subterrain.SubterrainRasterizer;
|
||||||
import art.arcane.iris.generation.block.TileData;
|
import art.arcane.iris.generation.block.TileData;
|
||||||
|
import art.arcane.iris.structure.object.ObjectWaterRule;
|
||||||
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
|
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
|
||||||
import art.arcane.volmlib.util.math.BlockPosition;
|
import art.arcane.volmlib.util.math.BlockPosition;
|
||||||
import art.arcane.iris.generation.block.B;
|
import art.arcane.iris.generation.block.B;
|
||||||
@@ -41,7 +42,7 @@ final class ObjectDestinationTransaction implements ObjectPassPlacer {
|
|||||||
private int subterrainZ;
|
private int subterrainZ;
|
||||||
private boolean subterrainProtects;
|
private boolean subterrainProtects;
|
||||||
private ObjectHydrologyVeto waterVeto;
|
private ObjectHydrologyVeto waterVeto;
|
||||||
private boolean waterPlacement;
|
private ObjectWaterRule waterRule = ObjectWaterRule.KEEP_OUT;
|
||||||
|
|
||||||
ObjectDestinationTransaction(MantleWriter writer, int destinationChunkX, int destinationChunkZ) {
|
ObjectDestinationTransaction(MantleWriter writer, int destinationChunkX, int destinationChunkZ) {
|
||||||
this.writer = writer;
|
this.writer = writer;
|
||||||
@@ -73,8 +74,8 @@ final class ObjectDestinationTransaction implements ObjectPassPlacer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int beginObjectPlacement(boolean entersWater) {
|
public int beginObjectPlacement(ObjectWaterRule rule) {
|
||||||
waterPlacement = entersWater;
|
waterRule = rule;
|
||||||
return log.size();
|
return log.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,7 +88,7 @@ final class ObjectDestinationTransaction implements ObjectPassPlacer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void endObjectPlacement() {
|
public void endObjectPlacement() {
|
||||||
waterPlacement = false;
|
waterRule = ObjectWaterRule.KEEP_OUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
void apply(ObjectSourcePlan plan) {
|
void apply(ObjectSourcePlan plan) {
|
||||||
@@ -107,7 +108,7 @@ final class ObjectDestinationTransaction implements ObjectPassPlacer {
|
|||||||
Object value = plan.valueAt(index);
|
Object value = plan.valueAt(index);
|
||||||
boolean custom = ObjectSourcePlan.isCustom(cell);
|
boolean custom = ObjectSourcePlan.isCustom(cell);
|
||||||
boolean canopy = ObjectSourcePlan.isCanopy(cell);
|
boolean canopy = ObjectSourcePlan.isCanopy(cell);
|
||||||
boolean entersWater = ObjectSourcePlan.entersWater(cell);
|
ObjectWaterRule rule = ObjectSourcePlan.waterRule(cell);
|
||||||
if (custom || value instanceof NativeBlockState) {
|
if (custom || value instanceof NativeBlockState) {
|
||||||
NativeBlockState existing = canopy ? get(x, y, z) : null;
|
NativeBlockState existing = canopy ? get(x, y, z) : null;
|
||||||
skipCanopy = existing != null && existing.isSolid();
|
skipCanopy = existing != null && existing.isSolid();
|
||||||
@@ -116,9 +117,9 @@ final class ObjectDestinationTransaction implements ObjectPassPlacer {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (custom) {
|
if (custom) {
|
||||||
set(x, y, z, (NativeBlockState) value, canopy, entersWater);
|
set(x, y, z, (NativeBlockState) value, canopy, rule);
|
||||||
} else {
|
} else {
|
||||||
setData(x, y, z, value, canopy, entersWater);
|
setData(x, y, z, value, canopy, rule);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -183,17 +184,17 @@ final class ObjectDestinationTransaction implements ObjectPassPlacer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void set(int x, int y, int z, NativeBlockState state) {
|
public void set(int x, int y, int z, NativeBlockState state) {
|
||||||
set(x, y, z, state, isCanopy(x, y, z), waterPlacement);
|
set(x, y, z, state, isCanopy(x, y, z), waterRule);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void set(int x, int y, int z, NativeBlockState state, boolean canopy, boolean entersWater) {
|
private void set(int x, int y, int z, NativeBlockState state, boolean canopy, ObjectWaterRule rule) {
|
||||||
if (state == null) {
|
if (state == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String placementKey = state.deferredPlacementKey();
|
String placementKey = state.deferredPlacementKey();
|
||||||
NativeBlockState baseState = state.placementBaseState();
|
NativeBlockState baseState = state.placementBaseState();
|
||||||
if (state.isCustom() && placementKey != null && baseState != null) {
|
if (state.isCustom() && placementKey != null && baseState != null) {
|
||||||
if (!canSetBlock(x, y, z) || hydrologyKeeps(x, y, z, baseState.isSolid(), entersWater)) {
|
if (!canSetBlock(x, y, z) || hydrologyKeeps(x, y, z, baseState.isSolid(), rule)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Identifier identifier = Identifier.fromString(placementKey);
|
Identifier identifier = Identifier.fromString(placementKey);
|
||||||
@@ -201,10 +202,10 @@ final class ObjectDestinationTransaction implements ObjectPassPlacer {
|
|||||||
cell.block = baseState;
|
cell.block = baseState;
|
||||||
cell.tile = CLEARED;
|
cell.tile = CLEARED;
|
||||||
cell.identifier = identifier;
|
cell.identifier = identifier;
|
||||||
log.add(x, y, z, state, true, canopy, entersWater);
|
log.add(x, y, z, state, true, canopy, rule);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setData(x, y, z, state, canopy, entersWater);
|
setData(x, y, z, state, canopy, rule);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -295,18 +296,18 @@ final class ObjectDestinationTransaction implements ObjectPassPlacer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T> void setData(int x, int y, int z, T data) {
|
public <T> void setData(int x, int y, int z, T data) {
|
||||||
setData(x, y, z, data, isCanopy(x, y, z), waterPlacement);
|
setData(x, y, z, data, isCanopy(x, y, z), waterRule);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setData(int x, int y, int z, Object data, boolean canopy, boolean entersWater) {
|
private void setData(int x, int y, int z, Object data, boolean canopy, ObjectWaterRule rule) {
|
||||||
if (data == null || y < 0 || y >= worldHeight
|
if (data == null || y < 0 || y >= worldHeight
|
||||||
|| protectsSubterrain(x, y, z)) {
|
|| protectsSubterrain(x, y, z)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (data instanceof NativeBlockState state && (!canSetBlock(x, y, z) || hydrologyKeeps(x, y, z, state.isSolid(), entersWater))) {
|
if (data instanceof NativeBlockState state && (!canSetBlock(x, y, z) || hydrologyKeeps(x, y, z, state.isSolid(), rule))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (data instanceof MatterCavern && (hasProtectedHydrology(x, y, z) || hydrologyKeeps(x, y, z, false, entersWater))) {
|
if (data instanceof MatterCavern && (hasProtectedHydrology(x, y, z) || hydrologyKeeps(x, y, z, false, rule))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Class<?> type = data instanceof NativeBlockState ? NativeBlockState.class : data.getClass();
|
Class<?> type = data instanceof NativeBlockState ? NativeBlockState.class : data.getClass();
|
||||||
@@ -318,7 +319,7 @@ final class ObjectDestinationTransaction implements ObjectPassPlacer {
|
|||||||
} else {
|
} else {
|
||||||
cell.put(type, data);
|
cell.put(type, data);
|
||||||
}
|
}
|
||||||
log.add(x, y, z, data, false, canopy, entersWater);
|
log.add(x, y, z, data, false, canopy, rule);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -415,11 +416,11 @@ final class ObjectDestinationTransaction implements ObjectPassPlacer {
|
|||||||
&& !protectsSubterrain(x, y, z);
|
&& !protectsSubterrain(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean hydrologyKeeps(int x, int y, int z, boolean solid, boolean entersWater) {
|
private boolean hydrologyKeeps(int x, int y, int z, boolean solid, ObjectWaterRule rule) {
|
||||||
if (waterVeto == null) {
|
if (waterVeto == null) {
|
||||||
waterVeto = ObjectHydrologyVeto.of(getEngine());
|
waterVeto = ObjectHydrologyVeto.of(getEngine());
|
||||||
}
|
}
|
||||||
return waterVeto.keeps(x, y, z, solid, entersWater);
|
return waterVeto.keeps(x, y, z, solid, rule);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean protectsSubterrain(int x, int y, int z) {
|
private boolean protectsSubterrain(int x, int y, int z) {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import art.arcane.iris.generation.hydrology.raster.ChunkWaterRaster;
|
|||||||
import art.arcane.iris.generation.hydrology.raster.WaterRole;
|
import art.arcane.iris.generation.hydrology.raster.WaterRole;
|
||||||
import art.arcane.iris.generation.runtime.Engine;
|
import art.arcane.iris.generation.runtime.Engine;
|
||||||
import art.arcane.iris.generation.runtime.IrisComplex;
|
import art.arcane.iris.generation.runtime.IrisComplex;
|
||||||
|
import art.arcane.iris.structure.object.ObjectWaterRule;
|
||||||
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
|
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
|
||||||
|
|
||||||
final class ObjectHydrologyVeto {
|
final class ObjectHydrologyVeto {
|
||||||
@@ -25,13 +26,13 @@ final class ObjectHydrologyVeto {
|
|||||||
return runtime != null && runtime.enabled() ? new ObjectHydrologyVeto(complex, runtime) : NONE;
|
return runtime != null && runtime.enabled() ? new ObjectHydrologyVeto(complex, runtime) : NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean keepsBlock(int x, int y, int z, NativeBlockState state, boolean entersWater) {
|
boolean keepsBlock(int x, int y, int z, NativeBlockState state, ObjectWaterRule rule) {
|
||||||
NativeBlockState base = state.isCustom() && state.placementBaseState() != null ? state.placementBaseState() : state;
|
NativeBlockState base = state.isCustom() && state.placementBaseState() != null ? state.placementBaseState() : state;
|
||||||
return keeps(x, y, z, base.isSolid(), entersWater);
|
return keeps(x, y, z, base.isSolid(), rule);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean keeps(int x, int y, int z, boolean solid, boolean entersWater) {
|
boolean keeps(int x, int y, int z, boolean solid, ObjectWaterRule rule) {
|
||||||
if (runtime == null) {
|
if (runtime == null || rule == ObjectWaterRule.FORCED) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ChunkWaterRaster raster = runtime.raster(x >> 4, z >> 4);
|
ChunkWaterRaster raster = runtime.raster(x >> 4, z >> 4);
|
||||||
@@ -42,7 +43,7 @@ final class ObjectHydrologyVeto {
|
|||||||
if (role == WaterRole.INLET && y >= raster.waterHead(x & 15, z & 15) && y <= complex.naturalTrueHeight(x, z)) {
|
if (role == WaterRole.INLET && y >= raster.waterHead(x & 15, z & 15) && y <= complex.naturalTrueHeight(x, z)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (solid && !entersWater && fillsWater(x, y, z)) {
|
if (solid && rule != ObjectWaterRule.ENTERS_WATER && fillsWater(x, y, z)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (role.wet()) {
|
if (role.wet()) {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package art.arcane.iris.generation.mantle;
|
package art.arcane.iris.generation.mantle;
|
||||||
|
|
||||||
import art.arcane.iris.structure.object.IObjectPlacer;
|
import art.arcane.iris.structure.object.IObjectPlacer;
|
||||||
|
import art.arcane.iris.structure.object.ObjectWaterRule;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
public interface ObjectPassPlacer extends IObjectPlacer {
|
public interface ObjectPassPlacer extends IObjectPlacer {
|
||||||
@@ -8,7 +9,7 @@ public interface ObjectPassPlacer extends IObjectPlacer {
|
|||||||
|
|
||||||
byte[] getCarvedColumn(int x, int z, int height);
|
byte[] getCarvedColumn(int x, int z, int height);
|
||||||
|
|
||||||
default int beginObjectPlacement(boolean entersWater) {
|
default int beginObjectPlacement(ObjectWaterRule rule) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package art.arcane.iris.generation.mantle;
|
|||||||
import art.arcane.iris.generation.decoration.tree.TreeBlockMaterial;
|
import art.arcane.iris.generation.decoration.tree.TreeBlockMaterial;
|
||||||
import art.arcane.iris.generation.hydrology.cave.HydrologyCaveCell;
|
import art.arcane.iris.generation.hydrology.cave.HydrologyCaveCell;
|
||||||
import art.arcane.iris.integration.Identifier;
|
import art.arcane.iris.integration.Identifier;
|
||||||
|
import art.arcane.iris.structure.object.ObjectWaterRule;
|
||||||
import art.arcane.iris.world.storage.matter.IrisMatterSupport;
|
import art.arcane.iris.world.storage.matter.IrisMatterSupport;
|
||||||
import art.arcane.iris.world.storage.matter.TileWrapper;
|
import art.arcane.iris.world.storage.matter.TileWrapper;
|
||||||
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
|
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
|
||||||
@@ -33,7 +34,8 @@ final class ObjectSourcePlan {
|
|||||||
private static final int CUSTOM_BIT = 1 << 8;
|
private static final int CUSTOM_BIT = 1 << 8;
|
||||||
private static final int CANOPY_BIT = 1 << 9;
|
private static final int CANOPY_BIT = 1 << 9;
|
||||||
private static final int ENTERS_WATER_BIT = 1 << 10;
|
private static final int ENTERS_WATER_BIT = 1 << 10;
|
||||||
private static final int Y_SHIFT = 11;
|
private static final int FORCED_BIT = 1 << 11;
|
||||||
|
private static final int Y_SHIFT = 12;
|
||||||
private static final int MAXIMUM_Y = (1 << (31 - Y_SHIFT)) - 1;
|
private static final int MAXIMUM_Y = (1 << (31 - Y_SHIFT)) - 1;
|
||||||
|
|
||||||
private final long[] destinations;
|
private final long[] destinations;
|
||||||
@@ -91,7 +93,7 @@ final class ObjectSourcePlan {
|
|||||||
throw new IllegalArgumentException("Object mutation height is outside the plan range: " + y);
|
throw new IllegalArgumentException("Object mutation height is outside the plan range: " + y);
|
||||||
}
|
}
|
||||||
cells[position] = (y << Y_SHIFT) | (log.custom(logged) ? CUSTOM_BIT : 0) | (log.canopy(logged) ? CANOPY_BIT : 0)
|
cells[position] = (y << Y_SHIFT) | (log.custom(logged) ? CUSTOM_BIT : 0) | (log.canopy(logged) ? CANOPY_BIT : 0)
|
||||||
| (log.entersWater(logged) ? ENTERS_WATER_BIT : 0) | ((log.z(logged) & 15) << 4) | (log.x(logged) & 15);
|
| waterBits(log.waterRule(logged)) | ((log.z(logged) & 15) << 4) | (log.x(logged) & 15);
|
||||||
valueIndexes[position] = table.indexOf(log.value(logged));
|
valueIndexes[position] = table.indexOf(log.value(logged));
|
||||||
}
|
}
|
||||||
values = table.values.toArray();
|
values = table.values.toArray();
|
||||||
@@ -242,8 +244,19 @@ final class ObjectSourcePlan {
|
|||||||
return (cell & CANOPY_BIT) != 0;
|
return (cell & CANOPY_BIT) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean entersWater(int cell) {
|
static ObjectWaterRule waterRule(int cell) {
|
||||||
return (cell & ENTERS_WATER_BIT) != 0;
|
if ((cell & FORCED_BIT) != 0) {
|
||||||
|
return ObjectWaterRule.FORCED;
|
||||||
|
}
|
||||||
|
return (cell & ENTERS_WATER_BIT) != 0 ? ObjectWaterRule.ENTERS_WATER : ObjectWaterRule.KEEP_OUT;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int waterBits(ObjectWaterRule rule) {
|
||||||
|
return switch (rule) {
|
||||||
|
case KEEP_OUT -> 0;
|
||||||
|
case ENTERS_WATER -> ENTERS_WATER_BIT;
|
||||||
|
case FORCED -> FORCED_BIT;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
ObjectDestinationTransaction.Mutation mutationAt(int chunkX, int chunkZ, int index) {
|
ObjectDestinationTransaction.Mutation mutationAt(int chunkX, int chunkZ, int index) {
|
||||||
|
|||||||
@@ -201,7 +201,6 @@ public class IrisObjectPlacement {
|
|||||||
@Description("Ignore any placement restrictions for this object")
|
@Description("Ignore any placement restrictions for this object")
|
||||||
@SerializedName(value = "forcePlace", alternate = {"force"})
|
@SerializedName(value = "forcePlace", alternate = {"force"})
|
||||||
private boolean forcePlace = false;
|
private boolean forcePlace = false;
|
||||||
private transient boolean forcedByStructure = false;
|
|
||||||
private transient AtomicCache<TableCache> cache = new AtomicCache<>();
|
private transient AtomicCache<TableCache> cache = new AtomicCache<>();
|
||||||
private transient AtomicCache<CompatStatus> compatCache = new AtomicCache<>();
|
private transient AtomicCache<CompatStatus> compatCache = new AtomicCache<>();
|
||||||
@Getter(AccessLevel.NONE)
|
@Getter(AccessLevel.NONE)
|
||||||
@@ -307,8 +306,11 @@ public class IrisObjectPlacement {
|
|||||||
return place.size() == 1 ? place.getFirst() : place.toString(", ");
|
return place.size() == 1 ? place.getFirst() : place.toString(", ");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean entersWater() {
|
public ObjectWaterRule waterRule() {
|
||||||
return underwater || onwater || forcePlace && !forcedByStructure;
|
if (forcePlace) {
|
||||||
|
return ObjectWaterRule.FORCED;
|
||||||
|
}
|
||||||
|
return underwater || onwater ? ObjectWaterRule.ENTERS_WATER : ObjectWaterRule.KEEP_OUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IrisObjectPlacement toPlacement(String... place) {
|
public IrisObjectPlacement toPlacement(String... place) {
|
||||||
@@ -354,7 +356,6 @@ public class IrisObjectPlacement {
|
|||||||
p.setAllowedCollisions(allowedCollisions);
|
p.setAllowedCollisions(allowedCollisions);
|
||||||
p.setForbiddenCollisions(forbiddenCollisions);
|
p.setForbiddenCollisions(forbiddenCollisions);
|
||||||
p.setForcePlace(forcePlace);
|
p.setForcePlace(forcePlace);
|
||||||
p.setForcedByStructure(forcedByStructure);
|
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package art.arcane.iris.structure.object;
|
||||||
|
|
||||||
|
public enum ObjectWaterRule {
|
||||||
|
KEEP_OUT,
|
||||||
|
ENTERS_WATER,
|
||||||
|
FORCED
|
||||||
|
}
|
||||||
+2
-2
@@ -56,12 +56,12 @@ final class PlacementModuleSurfaceSupport implements PlacementModule {
|
|||||||
|
|
||||||
private static String hydrologyRejection(PlacementContext context, PlacementState state) {
|
private static String hydrologyRejection(PlacementContext context, PlacementState state) {
|
||||||
IrisObjectPlacement config = state.config;
|
IrisObjectPlacement config = state.config;
|
||||||
if (!context.automatic || config.isForcedByStructure() || !config.getCarvingSupport().supportsSurface()
|
if (!context.automatic || config.isForcePlace() || !config.getCarvingSupport().supportsSurface()
|
||||||
|| config.getMode() == ObjectPlaceMode.FLOATING || config.getMode() == ObjectPlaceMode.STRUCTURE_PIECE) {
|
|| config.getMode() == ObjectPlaceMode.FLOATING || config.getMode() == ObjectPlaceMode.STRUCTURE_PIECE) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
boolean painted = state.paintProjection != null;
|
boolean painted = state.paintProjection != null;
|
||||||
if (config.entersWater()) {
|
if (config.waterRule() == ObjectWaterRule.ENTERS_WATER) {
|
||||||
return (painted
|
return (painted
|
||||||
? IrisSurfaceSupport.intersectsUnevenWater(context.placer, context.x, context.z, null, null, 0, 0, 0, state.paintSupport)
|
? IrisSurfaceSupport.intersectsUnevenWater(context.placer, context.x, context.z, null, null, 0, 0, 0, state.paintSupport)
|
||||||
: IrisSurfaceSupport.intersectsUnevenWater(context.placer, context.x, context.z, config.getTranslate(),
|
: IrisSurfaceSupport.intersectsUnevenWater(context.placer, context.x, context.z, config.getTranslate(),
|
||||||
|
|||||||
@@ -536,6 +536,11 @@ public final class IrisStructureLocator {
|
|||||||
// Gated out on this Minecraft version; the pack report already says why.
|
// Gated out on this Minecraft version; the pack report already says why.
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
boolean submerged = !placement.resolvedAnchor().isCave() && !placement.isUnderwater()
|
||||||
|
&& NativeStructurePlacementPlanner.isSubmerged(engine, originX, originZ);
|
||||||
|
if (submerged && !placement.forcesPieces(structure, 1)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
StructureGraphCompilation compilation = StructureGraphCatalog.compile(engine.getData(), structure);
|
StructureGraphCompilation compilation = StructureGraphCatalog.compile(engine.getData(), structure);
|
||||||
if (!compilation.isAssemblyViable()) {
|
if (!compilation.isAssemblyViable()) {
|
||||||
throw new IllegalStateException("Iris structure '" + selectedKey
|
throw new IllegalStateException("Iris structure '" + selectedKey
|
||||||
@@ -545,6 +550,9 @@ public final class IrisStructureLocator {
|
|||||||
StructureAssembler assembler = StructureAssembler.forData(
|
StructureAssembler assembler = StructureAssembler.forData(
|
||||||
engine.getData(), structure, new IrisPosition(originX, baseY, originZ));
|
engine.getData(), structure, new IrisPosition(originX, baseY, originZ));
|
||||||
StructureAssemblyResult assembly = assembler.assemble(rng);
|
StructureAssemblyResult assembly = assembler.assemble(rng);
|
||||||
|
if (submerged && !placement.forcesPieces(structure, assembly.pieces().size())) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
if (!requirePlacementOutput(placement, selectedKey, cx, cz,
|
if (!requirePlacementOutput(placement, selectedKey, cx, cz,
|
||||||
assembly.hasOutput(), "runtime assembly produced " + assembly.status() + ": " + assembly.detail())) {
|
assembly.hasOutput(), "runtime assembly produced " + assembly.status() + ": " + assembly.detail())) {
|
||||||
return null;
|
return null;
|
||||||
@@ -593,6 +601,7 @@ public final class IrisStructureLocator {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (!placement.isAnchoredUnderground() && !placement.isAllowWater()
|
if (!placement.isAnchoredUnderground() && !placement.isAllowWater()
|
||||||
|
&& !placement.forcesPieces(structure, pieces.size())
|
||||||
&& !StructureWaterRules.admitsFootprint(IrisStructureWater.mantle(engine.getComplex()), pieceFootprints(pieces))) {
|
&& !StructureWaterRules.admitsFootprint(IrisStructureWater.mantle(engine.getComplex()), pieceFootprints(pieces))) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -687,10 +696,6 @@ public final class IrisStructureLocator {
|
|||||||
if (worldMin > worldMax) {
|
if (worldMin > worldMax) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (!placement.isUnderwater()
|
|
||||||
&& NativeStructurePlacementPlanner.isSubmerged(engine, originX, originZ)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (placement.resolvedAnchor() == IrisStructureAnchorMode.SURFACE) {
|
if (placement.resolvedAnchor() == IrisStructureAnchorMode.SURFACE) {
|
||||||
int surfaceY = Engine.hostHeight(engine, originX, originZ, true) + engine.getMinHeight();
|
int surfaceY = Engine.hostHeight(engine, originX, originZ, true) + engine.getMinHeight();
|
||||||
return surfaceY < placement.getMinHeight() || surfaceY > placement.getMaxHeight() ? null : surfaceY;
|
return surfaceY < placement.getMinHeight() || surfaceY > placement.getMaxHeight() ? null : surfaceY;
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
package art.arcane.iris.structure.placement;
|
package art.arcane.iris.structure.placement;
|
||||||
|
|
||||||
|
import art.arcane.iris.structure.object.ObjectPlaceMode;
|
||||||
import art.arcane.iris.generation.biome.IrisBiome;
|
import art.arcane.iris.generation.biome.IrisBiome;
|
||||||
import art.arcane.iris.pack.validation.CompatPools;
|
import art.arcane.iris.pack.validation.CompatPools;
|
||||||
import art.arcane.iris.structure.nativegen.IrisNativeStructure;
|
import art.arcane.iris.structure.nativegen.IrisNativeStructure;
|
||||||
@@ -152,6 +153,19 @@ public class IrisStructurePlacement {
|
|||||||
return anchor;
|
return anchor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ObjectPlaceMode pieceMode(IrisStructure structure, int pieces) {
|
||||||
|
ObjectPlaceMode mode = structure.getPlaceMode();
|
||||||
|
if (isAnchoredUnderground()) {
|
||||||
|
return mode == ObjectPlaceMode.ORGANIC_STILT || mode == ObjectPlaceMode.CEILING_HANG
|
||||||
|
? mode : ObjectPlaceMode.STRUCTURE_PIECE;
|
||||||
|
}
|
||||||
|
return pieces == 1 && mode != ObjectPlaceMode.FLOATING ? mode : ObjectPlaceMode.STRUCTURE_PIECE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean forcesPieces(IrisStructure structure, int pieces) {
|
||||||
|
return pieceMode(structure, pieces) != ObjectPlaceMode.STRUCTURE_PIECE;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isAnchoredUnderground() {
|
public boolean isAnchoredUnderground() {
|
||||||
IrisStructureAnchorMode activeAnchor = resolvedAnchor();
|
IrisStructureAnchorMode activeAnchor = resolvedAnchor();
|
||||||
return activeAnchor == IrisStructureAnchorMode.HEIGHT_BAND || activeAnchor.isCave();
|
return activeAnchor == IrisStructureAnchorMode.HEIGHT_BAND || activeAnchor.isCave();
|
||||||
|
|||||||
+16
-7
@@ -24,6 +24,7 @@ import art.arcane.iris.generation.hydrology.raster.WaterRole;
|
|||||||
import art.arcane.iris.generation.runtime.Engine;
|
import art.arcane.iris.generation.runtime.Engine;
|
||||||
import art.arcane.iris.generation.runtime.IrisComplex;
|
import art.arcane.iris.generation.runtime.IrisComplex;
|
||||||
import art.arcane.iris.generation.block.TileData;
|
import art.arcane.iris.generation.block.TileData;
|
||||||
|
import art.arcane.iris.structure.object.ObjectWaterRule;
|
||||||
import art.arcane.volmlib.util.stream.ProceduralStream;
|
import art.arcane.volmlib.util.stream.ProceduralStream;
|
||||||
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
|
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
|
||||||
import art.arcane.volmlib.util.math.BlockPosition;
|
import art.arcane.volmlib.util.math.BlockPosition;
|
||||||
@@ -54,7 +55,7 @@ public class FloatingObjectPlacementTransactionTest {
|
|||||||
public void canopyCommitRechecksSolidsAndSkipsAssociatedMetadata() {
|
public void canopyCommitRechecksSolidsAndSkipsAssociatedMetadata() {
|
||||||
IslandObjectPlacer delegate = createPlacer(true);
|
IslandObjectPlacer delegate = createPlacer(true);
|
||||||
FloatingObjectPlacementTransaction transaction = new FloatingObjectPlacementTransaction(delegate,
|
FloatingObjectPlacementTransaction transaction = new FloatingObjectPlacementTransaction(delegate,
|
||||||
new ObjectContinuationBundle.PlacementKey(ObjectContinuationBundle.Kind.FLOATING, 0, 0, 0), false);
|
new ObjectContinuationBundle.PlacementKey(ObjectContinuationBundle.Kind.FLOATING, 0, 0, 0), ObjectWaterRule.KEEP_OUT);
|
||||||
NativeBlockState canopy = mock(NativeBlockState.class);
|
NativeBlockState canopy = mock(NativeBlockState.class);
|
||||||
NativeBlockState trunk = mock(NativeBlockState.class);
|
NativeBlockState trunk = mock(NativeBlockState.class);
|
||||||
when(trunk.isSolid()).thenReturn(true);
|
when(trunk.isSolid()).thenReturn(true);
|
||||||
@@ -76,7 +77,7 @@ public class FloatingObjectPlacementTransactionTest {
|
|||||||
public void unsupportedFinalTerrainRejectsBlocksTilesAndMarkersTogether() {
|
public void unsupportedFinalTerrainRejectsBlocksTilesAndMarkersTogether() {
|
||||||
IslandObjectPlacer delegate = createPlacer(false);
|
IslandObjectPlacer delegate = createPlacer(false);
|
||||||
FloatingObjectPlacementTransaction transaction = new FloatingObjectPlacementTransaction(delegate,
|
FloatingObjectPlacementTransaction transaction = new FloatingObjectPlacementTransaction(delegate,
|
||||||
new ObjectContinuationBundle.PlacementKey(ObjectContinuationBundle.Kind.FLOATING, 0, 0, 0), false);
|
new ObjectContinuationBundle.PlacementKey(ObjectContinuationBundle.Kind.FLOATING, 0, 0, 0), ObjectWaterRule.KEEP_OUT);
|
||||||
NativeBlockState first = mock(NativeBlockState.class);
|
NativeBlockState first = mock(NativeBlockState.class);
|
||||||
NativeBlockState second = mock(NativeBlockState.class);
|
NativeBlockState second = mock(NativeBlockState.class);
|
||||||
TileData tile = mock(TileData.class);
|
TileData tile = mock(TileData.class);
|
||||||
@@ -103,7 +104,7 @@ public class FloatingObjectPlacementTransactionTest {
|
|||||||
public void supportedNeighborChunkCommitsBlocksTilesAndMarkers() {
|
public void supportedNeighborChunkCommitsBlocksTilesAndMarkers() {
|
||||||
IslandObjectPlacer delegate = createPlacer(true);
|
IslandObjectPlacer delegate = createPlacer(true);
|
||||||
FloatingObjectPlacementTransaction transaction = new FloatingObjectPlacementTransaction(delegate,
|
FloatingObjectPlacementTransaction transaction = new FloatingObjectPlacementTransaction(delegate,
|
||||||
new ObjectContinuationBundle.PlacementKey(ObjectContinuationBundle.Kind.FLOATING, 0, 0, 0), false);
|
new ObjectContinuationBundle.PlacementKey(ObjectContinuationBundle.Kind.FLOATING, 0, 0, 0), ObjectWaterRule.KEEP_OUT);
|
||||||
NativeBlockState first = mock(NativeBlockState.class);
|
NativeBlockState first = mock(NativeBlockState.class);
|
||||||
NativeBlockState second = mock(NativeBlockState.class);
|
NativeBlockState second = mock(NativeBlockState.class);
|
||||||
TileData tile = mock(TileData.class);
|
TileData tile = mock(TileData.class);
|
||||||
@@ -149,7 +150,7 @@ public class FloatingObjectPlacementTransactionTest {
|
|||||||
NativeBlockState state = mock(NativeBlockState.class);
|
NativeBlockState state = mock(NativeBlockState.class);
|
||||||
when(state.key()).thenReturn("minecraft:oak_log");
|
when(state.key()).thenReturn("minecraft:oak_log");
|
||||||
ObjectContinuationBundle.PlacementKey key = new ObjectContinuationBundle.PlacementKey(ObjectContinuationBundle.Kind.FLOATING, 0, 0, 7);
|
ObjectContinuationBundle.PlacementKey key = new ObjectContinuationBundle.PlacementKey(ObjectContinuationBundle.Kind.FLOATING, 0, 0, 7);
|
||||||
FloatingObjectPlacementTransaction transaction = new FloatingObjectPlacementTransaction(delegate, key, false);
|
FloatingObjectPlacementTransaction transaction = new FloatingObjectPlacementTransaction(delegate, key, ObjectWaterRule.KEEP_OUT);
|
||||||
transaction.set(15, 101, 8, state);
|
transaction.set(15, 101, 8, state);
|
||||||
transaction.set(16, 101, 8, state);
|
transaction.set(16, 101, 8, state);
|
||||||
transaction.setData(16, 101, 8, "floating-tree@7");
|
transaction.setData(16, 101, 8, "floating-tree@7");
|
||||||
@@ -166,7 +167,7 @@ public class FloatingObjectPlacementTransactionTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void floatingObjectsKeepSolidBlocksOutOfRiverWaterUnlessTheyEnterWater() {
|
public void floatingObjectsFollowTheirWaterRuleInRiverWater() {
|
||||||
IObjectPlacer delegate = mock(IObjectPlacer.class);
|
IObjectPlacer delegate = mock(IObjectPlacer.class);
|
||||||
Engine engine = mock(Engine.class);
|
Engine engine = mock(Engine.class);
|
||||||
IrisComplex complex = mock(IrisComplex.class);
|
IrisComplex complex = mock(IrisComplex.class);
|
||||||
@@ -196,17 +197,25 @@ public class FloatingObjectPlacementTransactionTest {
|
|||||||
when(stone.isSolid()).thenReturn(true);
|
when(stone.isSolid()).thenReturn(true);
|
||||||
ObjectContinuationBundle.PlacementKey key = new ObjectContinuationBundle.PlacementKey(ObjectContinuationBundle.Kind.FLOATING, 0, 0, 0);
|
ObjectContinuationBundle.PlacementKey key = new ObjectContinuationBundle.PlacementKey(ObjectContinuationBundle.Kind.FLOATING, 0, 0, 0);
|
||||||
|
|
||||||
FloatingObjectPlacementTransaction land = new FloatingObjectPlacementTransaction(delegate, key, false);
|
FloatingObjectPlacementTransaction land = new FloatingObjectPlacementTransaction(delegate, key, ObjectWaterRule.KEEP_OUT);
|
||||||
land.set(3, 7, 3, stone);
|
land.set(3, 7, 3, stone);
|
||||||
land.set(3, 10, 3, stone);
|
land.set(3, 10, 3, stone);
|
||||||
assertEquals(FloatingObjectPlacementTransaction.CommitResult.COMMITTED, land.commit());
|
assertEquals(FloatingObjectPlacementTransaction.CommitResult.COMMITTED, land.commit());
|
||||||
verify(delegate, never()).set(3, 7, 3, stone);
|
verify(delegate, never()).set(3, 7, 3, stone);
|
||||||
verify(delegate).set(3, 10, 3, stone);
|
verify(delegate).set(3, 10, 3, stone);
|
||||||
|
|
||||||
FloatingObjectPlacementTransaction water = new FloatingObjectPlacementTransaction(delegate, key, true);
|
FloatingObjectPlacementTransaction water = new FloatingObjectPlacementTransaction(delegate, key, ObjectWaterRule.ENTERS_WATER);
|
||||||
water.set(3, 7, 3, stone);
|
water.set(3, 7, 3, stone);
|
||||||
assertEquals(FloatingObjectPlacementTransaction.CommitResult.COMMITTED, water.commit());
|
assertEquals(FloatingObjectPlacementTransaction.CommitResult.COMMITTED, water.commit());
|
||||||
verify(delegate).set(3, 7, 3, stone);
|
verify(delegate).set(3, 7, 3, stone);
|
||||||
|
|
||||||
|
NativeBlockState air = mock(NativeBlockState.class);
|
||||||
|
FloatingObjectPlacementTransaction forced = new FloatingObjectPlacementTransaction(delegate, key, ObjectWaterRule.FORCED);
|
||||||
|
forced.set(3, 8, 3, stone);
|
||||||
|
forced.set(3, 6, 3, air);
|
||||||
|
assertEquals(FloatingObjectPlacementTransaction.CommitResult.COMMITTED, forced.commit());
|
||||||
|
verify(delegate).set(3, 8, 3, stone);
|
||||||
|
verify(delegate).set(3, 6, 3, air);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int local(Object coordinate) {
|
private static int local(Object coordinate) {
|
||||||
|
|||||||
+4
-3
@@ -6,6 +6,7 @@ import art.arcane.iris.generation.runtime.Engine;
|
|||||||
import art.arcane.iris.generation.runtime.IrisComplex;
|
import art.arcane.iris.generation.runtime.IrisComplex;
|
||||||
import art.arcane.iris.pack.loading.IrisData;
|
import art.arcane.iris.pack.loading.IrisData;
|
||||||
import art.arcane.iris.structure.object.ObjectPlaceMode;
|
import art.arcane.iris.structure.object.ObjectPlaceMode;
|
||||||
|
import art.arcane.iris.structure.object.ObjectWaterRule;
|
||||||
import art.arcane.iris.structure.placement.IrisStructure;
|
import art.arcane.iris.structure.placement.IrisStructure;
|
||||||
import art.arcane.iris.structure.placement.IrisStructurePlacement;
|
import art.arcane.iris.structure.placement.IrisStructurePlacement;
|
||||||
import art.arcane.iris.structure.object.IrisObject;
|
import art.arcane.iris.structure.object.IrisObject;
|
||||||
@@ -121,10 +122,10 @@ public class IrisStructureComponentCarveWaterTest {
|
|||||||
component.placePieces(writer, placement, structure, slab(), new RNG(3L));
|
component.placePieces(writer, placement, structure, slab(), new RNG(3L));
|
||||||
|
|
||||||
InOrder order = inOrder(writer);
|
InOrder order = inOrder(writer);
|
||||||
order.verify(writer).beginObjectPlacement(false);
|
order.verify(writer).beginObjectPlacement(ObjectWaterRule.KEEP_OUT);
|
||||||
order.verify(writer, calls(1)).set(anyInt(), anyInt(), anyInt(), any(NativeBlockState.class));
|
order.verify(writer, calls(1)).set(anyInt(), anyInt(), anyInt(), any(NativeBlockState.class));
|
||||||
order.verify(writer).endObjectPlacement();
|
order.verify(writer).endObjectPlacement();
|
||||||
order.verify(writer).beginObjectPlacement(true);
|
order.verify(writer).beginObjectPlacement(ObjectWaterRule.ENTERS_WATER);
|
||||||
order.verify(writer, calls(1)).set(anyInt(), anyInt(), anyInt(), any(NativeBlockState.class));
|
order.verify(writer, calls(1)).set(anyInt(), anyInt(), anyInt(), any(NativeBlockState.class));
|
||||||
order.verify(writer).endObjectPlacement();
|
order.verify(writer).endObjectPlacement();
|
||||||
}
|
}
|
||||||
@@ -151,7 +152,7 @@ public class IrisStructureComponentCarveWaterTest {
|
|||||||
|
|
||||||
assertSame(failure, thrown);
|
assertSame(failure, thrown);
|
||||||
InOrder order = inOrder(writer);
|
InOrder order = inOrder(writer);
|
||||||
order.verify(writer).beginObjectPlacement(false);
|
order.verify(writer).beginObjectPlacement(ObjectWaterRule.KEEP_OUT);
|
||||||
order.verify(writer).endObjectPlacement();
|
order.verify(writer).endObjectPlacement();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+56
-35
@@ -13,6 +13,7 @@ import art.arcane.iris.structure.object.IrisObject;
|
|||||||
import art.arcane.iris.structure.object.IrisObjectPlacement;
|
import art.arcane.iris.structure.object.IrisObjectPlacement;
|
||||||
import art.arcane.iris.structure.object.IrisObjectRotation;
|
import art.arcane.iris.structure.object.IrisObjectRotation;
|
||||||
import art.arcane.iris.structure.object.ObjectPlaceMode;
|
import art.arcane.iris.structure.object.ObjectPlaceMode;
|
||||||
|
import art.arcane.iris.structure.object.ObjectWaterRule;
|
||||||
import art.arcane.iris.structure.placement.IrisStructure;
|
import art.arcane.iris.structure.placement.IrisStructure;
|
||||||
import art.arcane.iris.structure.placement.IrisStructureLocator;
|
import art.arcane.iris.structure.placement.IrisStructureLocator;
|
||||||
import art.arcane.iris.structure.placement.IrisStructurePlacement;
|
import art.arcane.iris.structure.placement.IrisStructurePlacement;
|
||||||
@@ -104,18 +105,19 @@ public class IrisStructureComponentWaterTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void forcedSinglePieceStructureStaysOutOfRiverWater() {
|
public void aForcedPieceFullyInsideARiverWritesEveryBlock() {
|
||||||
world.water(WaterRole.CHANNEL, 9, 13);
|
world.water(WaterRole.CHANNEL, 9, 13);
|
||||||
|
|
||||||
int failed = placeSinglePiece(new IrisStructurePlacement());
|
int failed = placeSinglePiece(new IrisStructurePlacement());
|
||||||
|
|
||||||
assertEquals(0, failed);
|
assertEquals(0, failed);
|
||||||
assertFalse("the part of the piece above the water places", writes.isEmpty());
|
assertEquals("every block of the raft lands", 10, writes.size());
|
||||||
assertNoWaterOverwritten();
|
assertEquals(world.headAt(X, Z), lowestWriteAt(X, Z));
|
||||||
|
assertEquals(world.headAt(X - 1, Z - 1), lowestWriteAt(X - 1, Z - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void forcedSinglePieceStructureTurnedTowardsTheSlopeStaysOutOfRiverWater() {
|
public void aForcedPieceTurnedTowardsTheSlopeWritesThroughTheRiver() {
|
||||||
world.water(WaterRole.CHANNEL, 9, 13);
|
world.water(WaterRole.CHANNEL, 9, 13);
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
ProceduralStream<Double> heights = mock(ProceduralStream.class);
|
ProceduralStream<Double> heights = mock(ProceduralStream.class);
|
||||||
@@ -126,17 +128,16 @@ public class IrisStructureComponentWaterTest {
|
|||||||
IrisObjectPlacement config = IrisStructureComponent.piecePlacement(new IrisStructure(), piece(object), ObjectPlaceMode.CENTER_HEIGHT);
|
IrisObjectPlacement config = IrisStructureComponent.piecePlacement(new IrisStructure(), piece(object), ObjectPlaceMode.CENTER_HEIGHT);
|
||||||
config.setRotateTowardsSlope(true);
|
config.setRotateTowardsSlope(true);
|
||||||
|
|
||||||
writer.beginObjectPlacement(false);
|
writer.beginObjectPlacement(config.waterRule());
|
||||||
int result = object.place(X, Z, writer, config, new RNG(7L), world.data());
|
int result = object.place(X, Z, writer, config, new RNG(7L), world.data());
|
||||||
writer.endObjectPlacement();
|
writer.endObjectPlacement();
|
||||||
|
|
||||||
assertTrue(result >= 0);
|
assertTrue(result >= 0);
|
||||||
assertFalse(writes.isEmpty());
|
assertEquals(10, writes.size());
|
||||||
assertNoWaterOverwritten();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void aFewWetSupportColumnsDoNotStopAForcedSinglePiece() {
|
public void aForcedPieceWritesAcrossWetSupportColumns() {
|
||||||
world.column(X + 1, Z, WaterRole.CHANNEL, 15, 19);
|
world.column(X + 1, Z, WaterRole.CHANNEL, 15, 19);
|
||||||
world.column(X - 1, Z, WaterRole.SHORE, 15, 19);
|
world.column(X - 1, Z, WaterRole.SHORE, 15, 19);
|
||||||
world.column(X, Z + 1, WaterRole.DAM, 15, 19);
|
world.column(X, Z + 1, WaterRole.DAM, 15, 19);
|
||||||
@@ -145,14 +146,12 @@ public class IrisStructureComponentWaterTest {
|
|||||||
|
|
||||||
assertEquals(0, failed);
|
assertEquals(0, failed);
|
||||||
int anchorLayer = lowestWriteAt(X, Z);
|
int anchorLayer = lowestWriteAt(X, Z);
|
||||||
assertEquals("the anchor column keeps its block", world.floorAt(X, Z), anchorLayer);
|
assertEquals(world.floorAt(X, Z), anchorLayer);
|
||||||
assertTrue("the anchor layer sits inside the river column's water",
|
assertEquals("the river column keeps the piece's block", anchorLayer, lowestWriteAt(X + 1, Z));
|
||||||
anchorLayer > world.floorAt(X + 1, Z) && anchorLayer <= world.headAt(X + 1, Z));
|
|
||||||
assertNoWaterOverwritten();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void replaceSourceKeepsAForcedSinglePieceOverWaterWithoutFailingTheChunk() {
|
public void replaceSourceKeepsAForcedPieceOverWaterWithoutFailingTheChunk() {
|
||||||
world.water(WaterRole.CHANNEL, 9, 13);
|
world.water(WaterRole.CHANNEL, 9, 13);
|
||||||
IrisStructurePlacement placement = new IrisStructurePlacement()
|
IrisStructurePlacement placement = new IrisStructurePlacement()
|
||||||
.setNativeSuppression(NativeStructureSuppression.REPLACE_SOURCE);
|
.setNativeSuppression(NativeStructureSuppression.REPLACE_SOURCE);
|
||||||
@@ -161,36 +160,24 @@ public class IrisStructureComponentWaterTest {
|
|||||||
|
|
||||||
IrisStructureComponent.requireAppliedPieces(resolved(placement), 0, 0, failed);
|
IrisStructureComponent.requireAppliedPieces(resolved(placement), 0, 0, failed);
|
||||||
assertEquals(0, failed);
|
assertEquals(0, failed);
|
||||||
assertNoWaterOverwritten();
|
assertEquals(10, writes.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void replaceSourceKeepsAWaterPieceOnUnevenWaterWithoutFailingTheChunk() {
|
public void aForcedPieceWritesAcrossAFallWhetherOrNotItAllowsWater() {
|
||||||
world.water(WaterRole.CHANNEL, 9, 13);
|
world.water(WaterRole.CHANNEL, 9, 13);
|
||||||
world.column(X + 1, Z, WaterRole.CHANNEL, 9, 16);
|
world.column(X + 1, Z, WaterRole.CHANNEL, 9, 16);
|
||||||
IrisStructurePlacement placement = new IrisStructurePlacement()
|
|
||||||
.setNativeSuppression(NativeStructureSuppression.REPLACE_SOURCE)
|
|
||||||
.setAllowWater(true);
|
|
||||||
|
|
||||||
int failed = placeSinglePiece(placement);
|
assertEquals(0, placeSinglePiece(new IrisStructurePlacement()));
|
||||||
|
assertEquals(10, writes.size());
|
||||||
|
writes.clear();
|
||||||
|
|
||||||
IrisStructureComponent.requireAppliedPieces(resolved(placement), 0, 0, failed);
|
assertEquals(0, placeSinglePiece(new IrisStructurePlacement().setAllowWater(true)));
|
||||||
assertEquals(0, failed);
|
assertEquals(10, writes.size());
|
||||||
assertEquals("a piece that allows water fills it", world.headAt(X - 1, Z - 1), lowestWriteAt(X - 1, Z - 1));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void forcedSinglePieceStructureThatAllowsWaterPlacesOnFlatRiverWater() {
|
public void aForcedPiecePlacesOnDryLand() {
|
||||||
world.water(WaterRole.CHANNEL, 9, 13);
|
|
||||||
|
|
||||||
int failed = placeSinglePiece(new IrisStructurePlacement().setAllowWater(true));
|
|
||||||
|
|
||||||
assertEquals(0, failed);
|
|
||||||
assertEquals(world.headAt(X, Z), lowestWriteAt(X, Z));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void forcedSinglePieceStructureStillPlacesOnDryLand() {
|
|
||||||
int failed = placeSinglePiece(new IrisStructurePlacement());
|
int failed = placeSinglePiece(new IrisStructurePlacement());
|
||||||
|
|
||||||
assertEquals(0, failed);
|
assertEquals(0, failed);
|
||||||
@@ -198,12 +185,46 @@ public class IrisStructureComponentWaterTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void objectsThatForcePlaceThemselvesStillStayOffUnevenWater() {
|
public void objectsThatForcePlaceThemselvesWriteThroughUnevenWater() {
|
||||||
world.water(WaterRole.CHANNEL, 9, 13);
|
world.water(WaterRole.CHANNEL, 9, 13);
|
||||||
world.column(X + 1, Z, WaterRole.CHANNEL, 9, 16);
|
world.column(X + 1, Z, WaterRole.CHANNEL, 9, 16);
|
||||||
IrisObject object = HydrologyWaterFixture.raft();
|
IrisObject object = HydrologyWaterFixture.raft();
|
||||||
|
IrisObjectPlacement config = new IrisObjectPlacement().setForcePlace(true);
|
||||||
|
|
||||||
int result = object.place(X, Z, writer, new IrisObjectPlacement().setForcePlace(true), new RNG(7L), world.data());
|
writer.beginObjectPlacement(config.waterRule());
|
||||||
|
int result = object.place(X, Z, writer, config, new RNG(7L), world.data());
|
||||||
|
writer.endObjectPlacement();
|
||||||
|
|
||||||
|
assertTrue(result >= 0);
|
||||||
|
assertEquals("every block lands over the channel", 10, writes.size());
|
||||||
|
assertEquals(world.headAt(X, Z), lowestWriteAt(X, Z));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void unforcedPiecesKeepTheVeto() {
|
||||||
|
world.water(WaterRole.CHANNEL, 9, 13);
|
||||||
|
IrisObject object = HydrologyWaterFixture.raft();
|
||||||
|
IrisStructure structure = new IrisStructure().setPlaceMode(ObjectPlaceMode.STRUCTURE_PIECE);
|
||||||
|
int head = world.headAt(X, Z);
|
||||||
|
PlacedStructurePiece explicit = new PlacedStructurePiece(null, object, X, head + 1, Z, IrisObjectRotation.of(0, 0, 0),
|
||||||
|
X - 1, head, Z - 1, X + 1, head + 2, Z + 1);
|
||||||
|
|
||||||
|
assertEquals(0, component.placePieces(writer, new IrisStructurePlacement(), structure, new KList<>(explicit), new RNG(7L)));
|
||||||
|
|
||||||
|
assertFalse("the block above the water places", writes.isEmpty());
|
||||||
|
assertNoWaterOverwritten();
|
||||||
|
writes.clear();
|
||||||
|
|
||||||
|
assertEquals(0, component.placePieces(writer, new IrisStructurePlacement().setAllowWater(true), structure, new KList<>(explicit), new RNG(7L)));
|
||||||
|
assertTrue("allowWater fills the water", writes.stream().anyMatch(write -> write.y() == head));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void unforcedObjectsStayOffRiverWater() {
|
||||||
|
world.water(WaterRole.CHANNEL, 9, 13);
|
||||||
|
IrisObject object = HydrologyWaterFixture.raft();
|
||||||
|
|
||||||
|
int result = object.place(X, Z, writer, new IrisObjectPlacement(), new RNG(7L), world.data());
|
||||||
|
|
||||||
assertEquals(-1, result);
|
assertEquals(-1, result);
|
||||||
assertTrue(writes.isEmpty());
|
assertTrue(writes.isEmpty());
|
||||||
|
|||||||
+4
-3
@@ -16,6 +16,7 @@ import art.arcane.iris.pack.loading.IrisData;
|
|||||||
import art.arcane.iris.structure.object.IObjectPlacer;
|
import art.arcane.iris.structure.object.IObjectPlacer;
|
||||||
import art.arcane.iris.structure.object.IrisObject;
|
import art.arcane.iris.structure.object.IrisObject;
|
||||||
import art.arcane.iris.structure.object.IrisObjectPlacement;
|
import art.arcane.iris.structure.object.IrisObjectPlacement;
|
||||||
|
import art.arcane.iris.structure.object.ObjectWaterRule;
|
||||||
import art.arcane.volmlib.util.collection.KList;
|
import art.arcane.volmlib.util.collection.KList;
|
||||||
import art.arcane.volmlib.util.math.RNG;
|
import art.arcane.volmlib.util.math.RNG;
|
||||||
import art.arcane.volmlib.util.matter.MatterCavern;
|
import art.arcane.volmlib.util.matter.MatterCavern;
|
||||||
@@ -273,7 +274,7 @@ public class MantleObjectComponentWaterPlacementTest {
|
|||||||
when(placement.getAllowedCollisions()).thenReturn(new KList<>());
|
when(placement.getAllowedCollisions()).thenReturn(new KList<>());
|
||||||
when(placement.getForbiddenCollisions()).thenReturn(new KList<>());
|
when(placement.getForbiddenCollisions()).thenReturn(new KList<>());
|
||||||
when(placement.scaleObject(any(RNG.class), any(), any())).thenReturn(object);
|
when(placement.scaleObject(any(RNG.class), any(), any())).thenReturn(object);
|
||||||
when(placement.entersWater()).thenReturn(true);
|
when(placement.waterRule()).thenReturn(ObjectWaterRule.ENTERS_WATER);
|
||||||
return placement;
|
return placement;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -283,14 +284,14 @@ public class MantleObjectComponentWaterPlacementTest {
|
|||||||
|
|
||||||
private void assertEndedUnrecorded() {
|
private void assertEndedUnrecorded() {
|
||||||
InOrder order = inOrder(placer);
|
InOrder order = inOrder(placer);
|
||||||
order.verify(placer).beginObjectPlacement(true);
|
order.verify(placer).beginObjectPlacement(ObjectWaterRule.ENTERS_WATER);
|
||||||
order.verify(placer).endObjectPlacement();
|
order.verify(placer).endObjectPlacement();
|
||||||
verify(placer, never()).recordObjectPlacement(anyInt());
|
verify(placer, never()).recordObjectPlacement(anyInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertRecordedThenEnded() {
|
private void assertRecordedThenEnded() {
|
||||||
InOrder order = inOrder(placer);
|
InOrder order = inOrder(placer);
|
||||||
order.verify(placer).beginObjectPlacement(true);
|
order.verify(placer).beginObjectPlacement(ObjectWaterRule.ENTERS_WATER);
|
||||||
order.verify(placer).recordObjectPlacement(anyInt());
|
order.verify(placer).recordObjectPlacement(anyInt());
|
||||||
order.verify(placer).endObjectPlacement();
|
order.verify(placer).endObjectPlacement();
|
||||||
}
|
}
|
||||||
|
|||||||
+18
-3
@@ -8,6 +8,7 @@ import art.arcane.iris.generation.runtime.Engine;
|
|||||||
import art.arcane.iris.generation.runtime.IrisComplex;
|
import art.arcane.iris.generation.runtime.IrisComplex;
|
||||||
import art.arcane.iris.generation.terrain.IrisDimension;
|
import art.arcane.iris.generation.terrain.IrisDimension;
|
||||||
import art.arcane.iris.integration.Identifier;
|
import art.arcane.iris.integration.Identifier;
|
||||||
|
import art.arcane.iris.structure.object.ObjectWaterRule;
|
||||||
import art.arcane.iris.testsupport.PlatformBinding;
|
import art.arcane.iris.testsupport.PlatformBinding;
|
||||||
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
|
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
|
||||||
import art.arcane.volmlib.util.mantle.runtime.Mantle;
|
import art.arcane.volmlib.util.mantle.runtime.Mantle;
|
||||||
@@ -93,7 +94,7 @@ public class MantleWriterObjectWaterTest {
|
|||||||
@Test
|
@Test
|
||||||
public void structurePiecesKeepOutOfRiverWaterUnlessTheyAllowIt() {
|
public void structurePiecesKeepOutOfRiverWaterUnlessTheyAllowIt() {
|
||||||
MatterCavern cavern = new MatterCavern(true, "", (byte) 3);
|
MatterCavern cavern = new MatterCavern(true, "", (byte) 3);
|
||||||
int land = writer.beginObjectPlacement(false);
|
int land = writer.beginObjectPlacement(ObjectWaterRule.KEEP_OUT);
|
||||||
writer.set(3, 7, 3, stone);
|
writer.set(3, 7, 3, stone);
|
||||||
writer.set(3, 8, 3, air);
|
writer.set(3, 8, 3, air);
|
||||||
writer.setData(3, 6, 3, cavern);
|
writer.setData(3, 6, 3, cavern);
|
||||||
@@ -109,7 +110,7 @@ public class MantleWriterObjectWaterTest {
|
|||||||
verify(blocks).set(3, 10, 3, stone);
|
verify(blocks).set(3, 10, 3, stone);
|
||||||
verify(blocks).set(8, 7, 8, stone);
|
verify(blocks).set(8, 7, 8, stone);
|
||||||
|
|
||||||
int water = writer.beginObjectPlacement(true);
|
int water = writer.beginObjectPlacement(ObjectWaterRule.ENTERS_WATER);
|
||||||
writer.set(3, 6, 3, stone);
|
writer.set(3, 6, 3, stone);
|
||||||
writer.set(3, 9, 3, air);
|
writer.set(3, 9, 3, air);
|
||||||
writer.endObjectPlacement();
|
writer.endObjectPlacement();
|
||||||
@@ -118,9 +119,23 @@ public class MantleWriterObjectWaterTest {
|
|||||||
verify(blocks, never()).set(3, 9, 3, air);
|
verify(blocks, never()).set(3, 9, 3, air);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void forcedPlacementsWriteThroughRiverWater() {
|
||||||
|
MatterCavern cavern = new MatterCavern(true, "", (byte) 3);
|
||||||
|
writer.beginObjectPlacement(ObjectWaterRule.FORCED);
|
||||||
|
writer.set(3, 7, 3, stone);
|
||||||
|
writer.set(3, 8, 3, air);
|
||||||
|
writer.setData(3, 6, 3, cavern);
|
||||||
|
writer.endObjectPlacement();
|
||||||
|
|
||||||
|
verify(blocks).set(3, 7, 3, stone);
|
||||||
|
verify(blocks).set(3, 8, 3, air);
|
||||||
|
verify(caverns).set(3, 6, 3, cavern);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void writesOutsideAnObjectPlacementAreNotVetoed() {
|
public void writesOutsideAnObjectPlacementAreNotVetoed() {
|
||||||
int land = writer.beginObjectPlacement(false);
|
int land = writer.beginObjectPlacement(ObjectWaterRule.KEEP_OUT);
|
||||||
writer.endObjectPlacement();
|
writer.endObjectPlacement();
|
||||||
|
|
||||||
writer.set(3, 7, 3, stone);
|
writer.set(3, 7, 3, stone);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package art.arcane.iris.generation.mantle;
|
package art.arcane.iris.generation.mantle;
|
||||||
|
|
||||||
|
import art.arcane.iris.structure.object.ObjectWaterRule;
|
||||||
import art.arcane.iris.testsupport.KeyedBlockState;
|
import art.arcane.iris.testsupport.KeyedBlockState;
|
||||||
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
|
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -21,7 +22,8 @@ public class MutationLogTest {
|
|||||||
new ObjectDestinationTransaction.SetMutation(new ObjectDestinationTransaction.DataKey(3, 70, -2, String.class), "marker", true),
|
new ObjectDestinationTransaction.SetMutation(new ObjectDestinationTransaction.DataKey(3, 70, -2, String.class), "marker", true),
|
||||||
new ObjectDestinationTransaction.CustomBlockMutation(new ObjectDestinationTransaction.DataKey(-17, 4, 40, NativeBlockState.class), state, false)));
|
new ObjectDestinationTransaction.CustomBlockMutation(new ObjectDestinationTransaction.DataKey(-17, 4, 40, NativeBlockState.class), state, false)));
|
||||||
for (int index = 0; index < 100; index++) {
|
for (int index = 0; index < 100; index++) {
|
||||||
log.add(index, index + 1, -index, "grow" + index, (index & 1) == 0, (index & 2) == 0, (index & 4) == 0);
|
log.add(index, index + 1, -index, "grow" + index, (index & 1) == 0, (index & 2) == 0,
|
||||||
|
(index & 4) == 0 ? ObjectWaterRule.ENTERS_WATER : (index & 8) == 0 ? ObjectWaterRule.FORCED : ObjectWaterRule.KEEP_OUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
assertEquals(102, log.size());
|
assertEquals(102, log.size());
|
||||||
@@ -41,9 +43,10 @@ public class MutationLogTest {
|
|||||||
assertFalse(log.custom(101));
|
assertFalse(log.custom(101));
|
||||||
assertTrue(log.canopy(98));
|
assertTrue(log.canopy(98));
|
||||||
assertFalse(log.canopy(100));
|
assertFalse(log.canopy(100));
|
||||||
assertFalse(log.entersWater(0));
|
assertEquals(ObjectWaterRule.KEEP_OUT, log.waterRule(0));
|
||||||
assertTrue(log.entersWater(98));
|
assertEquals(ObjectWaterRule.ENTERS_WATER, log.waterRule(98));
|
||||||
assertFalse(log.entersWater(6));
|
assertEquals(ObjectWaterRule.FORCED, log.waterRule(6));
|
||||||
|
assertEquals(ObjectWaterRule.KEEP_OUT, log.waterRule(14));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -62,7 +65,7 @@ public class MutationLogTest {
|
|||||||
int z = (index * 5) - 20;
|
int z = (index * 5) - 20;
|
||||||
String value = "value" + (index % 9);
|
String value = "value" + (index % 9);
|
||||||
boolean canopy = index % 4 == 0;
|
boolean canopy = index % 4 == 0;
|
||||||
log.add(x, y, z, value, false, canopy, false);
|
log.add(x, y, z, value, false, canopy, ObjectWaterRule.KEEP_OUT);
|
||||||
if (index >= 10) {
|
if (index >= 10) {
|
||||||
tail.add(new ObjectDestinationTransaction.SetMutation(new ObjectDestinationTransaction.DataKey(x, y, z, String.class), value, canopy));
|
tail.add(new ObjectDestinationTransaction.SetMutation(new ObjectDestinationTransaction.DataKey(x, y, z, String.class), value, canopy));
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -8,6 +8,7 @@ import art.arcane.iris.spi.IrisPlatform;
|
|||||||
import art.arcane.iris.spi.IrisPlatforms;
|
import art.arcane.iris.spi.IrisPlatforms;
|
||||||
import art.arcane.iris.spi.PlatformRegistries;
|
import art.arcane.iris.spi.PlatformRegistries;
|
||||||
import art.arcane.iris.structure.object.IObjectPlacer;
|
import art.arcane.iris.structure.object.IObjectPlacer;
|
||||||
|
import art.arcane.iris.structure.object.ObjectWaterRule;
|
||||||
import art.arcane.iris.testsupport.PlatformLeakGuard;
|
import art.arcane.iris.testsupport.PlatformLeakGuard;
|
||||||
import art.arcane.iris.world.storage.matter.IrisMatterSupport;
|
import art.arcane.iris.world.storage.matter.IrisMatterSupport;
|
||||||
import art.arcane.iris.world.storage.matter.TileWrapper;
|
import art.arcane.iris.world.storage.matter.TileWrapper;
|
||||||
@@ -173,7 +174,7 @@ public class ObjectContinuationCanopyTest {
|
|||||||
when(firstChunk.getOrCreate(0)).thenReturn(first);
|
when(firstChunk.getOrCreate(0)).thenReturn(first);
|
||||||
when(secondChunk.getOrCreate(0)).thenReturn(second);
|
when(secondChunk.getOrCreate(0)).thenReturn(second);
|
||||||
FloatingObjectPlacementTransaction transaction = new FloatingObjectPlacementTransaction(delegate,
|
FloatingObjectPlacementTransaction transaction = new FloatingObjectPlacementTransaction(delegate,
|
||||||
new ObjectContinuationBundle.PlacementKey(ObjectContinuationBundle.Kind.FLOATING, 0, 0, 0), false);
|
new ObjectContinuationBundle.PlacementKey(ObjectContinuationBundle.Kind.FLOATING, 0, 0, 0), ObjectWaterRule.KEEP_OUT);
|
||||||
transaction.set(15, 5, 1, trunk);
|
transaction.set(15, 5, 1, trunk);
|
||||||
assertTrue(transaction.beginTreeCanopy(new BlockPosition(16, 5, 1)));
|
assertTrue(transaction.beginTreeCanopy(new BlockPosition(16, 5, 1)));
|
||||||
transaction.set(16, 5, 1, custom);
|
transaction.set(16, 5, 1, custom);
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import art.arcane.iris.integration.Identifier;
|
|||||||
import art.arcane.iris.pack.loading.IrisData;
|
import art.arcane.iris.pack.loading.IrisData;
|
||||||
import art.arcane.iris.pack.loading.IrisRegistrant;
|
import art.arcane.iris.pack.loading.IrisRegistrant;
|
||||||
import art.arcane.iris.pack.loading.ResourceLoader;
|
import art.arcane.iris.pack.loading.ResourceLoader;
|
||||||
|
import art.arcane.iris.structure.object.ObjectWaterRule;
|
||||||
import art.arcane.iris.world.entity.IrisSpawner;
|
import art.arcane.iris.world.entity.IrisSpawner;
|
||||||
import art.arcane.iris.world.storage.matter.IrisMatterContext;
|
import art.arcane.iris.world.storage.matter.IrisMatterContext;
|
||||||
import art.arcane.iris.spi.IrisPlatform;
|
import art.arcane.iris.spi.IrisPlatform;
|
||||||
@@ -58,16 +59,16 @@ public class ObjectContinuationTest {
|
|||||||
public void onlyAcceptedCrossingPlacementsLeaveFutureFragments() throws Exception {
|
public void onlyAcceptedCrossingPlacementsLeaveFutureFragments() throws Exception {
|
||||||
Fixture fixture = new Fixture();
|
Fixture fixture = new Fixture();
|
||||||
ObjectDestinationTransaction source = new ObjectDestinationTransaction(fixture.writer, 0, 0);
|
ObjectDestinationTransaction source = new ObjectDestinationTransaction(fixture.writer, 0, 0);
|
||||||
int checkpoint = source.beginObjectPlacement(false);
|
int checkpoint = source.beginObjectPlacement(ObjectWaterRule.KEEP_OUT);
|
||||||
source.setData(1, 5, 1, "inside");
|
source.setData(1, 5, 1, "inside");
|
||||||
source.recordObjectPlacement(checkpoint);
|
source.recordObjectPlacement(checkpoint);
|
||||||
source.endObjectPlacement();
|
source.endObjectPlacement();
|
||||||
checkpoint = source.beginObjectPlacement(false);
|
checkpoint = source.beginObjectPlacement(ObjectWaterRule.KEEP_OUT);
|
||||||
source.setData(15, 5, 1, "crossing");
|
source.setData(15, 5, 1, "crossing");
|
||||||
source.setData(16, 5, 1, "crossing");
|
source.setData(16, 5, 1, "crossing");
|
||||||
source.recordObjectPlacement(checkpoint);
|
source.recordObjectPlacement(checkpoint);
|
||||||
source.endObjectPlacement();
|
source.endObjectPlacement();
|
||||||
checkpoint = source.beginObjectPlacement(false);
|
checkpoint = source.beginObjectPlacement(ObjectWaterRule.KEEP_OUT);
|
||||||
source.setData(32, 5, 1, "unrelated");
|
source.setData(32, 5, 1, "unrelated");
|
||||||
source.setData(48, 5, 1, "unrelated");
|
source.setData(48, 5, 1, "unrelated");
|
||||||
source.recordObjectPlacement(checkpoint);
|
source.recordObjectPlacement(checkpoint);
|
||||||
|
|||||||
+22
-14
@@ -16,6 +16,7 @@ import art.arcane.iris.generation.terrain.IrisDimension;
|
|||||||
import art.arcane.iris.generation.terrain.Terrain3DColumnFixtures;
|
import art.arcane.iris.generation.terrain.Terrain3DColumnFixtures;
|
||||||
import art.arcane.iris.spi.IrisPlatform;
|
import art.arcane.iris.spi.IrisPlatform;
|
||||||
import art.arcane.iris.spi.IrisPlatforms;
|
import art.arcane.iris.spi.IrisPlatforms;
|
||||||
|
import art.arcane.iris.structure.object.ObjectWaterRule;
|
||||||
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
|
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
|
||||||
import art.arcane.volmlib.util.math.BlockPosition;
|
import art.arcane.volmlib.util.math.BlockPosition;
|
||||||
import art.arcane.iris.structure.object.DecayControlPlacer;
|
import art.arcane.iris.structure.object.DecayControlPlacer;
|
||||||
@@ -193,14 +194,14 @@ public class ObjectDestinationTransactionTest {
|
|||||||
transaction.set(3, 9, 3, pier);
|
transaction.set(3, 9, 3, pier);
|
||||||
transaction.set(6, 18, 6, pier);
|
transaction.set(6, 18, 6, pier);
|
||||||
assertEquals("a pier keeps its blocks on the river bed and the shore", start + 2, transaction.mutationCheckpoint());
|
assertEquals("a pier keeps its blocks on the river bed and the shore", start + 2, transaction.mutationCheckpoint());
|
||||||
transaction.beginObjectPlacement(true);
|
transaction.beginObjectPlacement(ObjectWaterRule.ENTERS_WATER);
|
||||||
transaction.set(3, 10, 3, pier);
|
transaction.set(3, 10, 3, pier);
|
||||||
transaction.set(4, 15, 3, pier);
|
transaction.set(4, 15, 3, pier);
|
||||||
assertEquals("an underwater pier keeps its blocks in the river", start + 4, transaction.mutationCheckpoint());
|
assertEquals("an underwater pier keeps its blocks in the river", start + 4, transaction.mutationCheckpoint());
|
||||||
transaction.set(3, 12, 3, pier);
|
transaction.set(3, 12, 3, pier);
|
||||||
transaction.set(3, 10, 3, vine);
|
transaction.set(3, 10, 3, vine);
|
||||||
assertEquals("an underwater object still keeps out of falls and open water", start + 4, transaction.mutationCheckpoint());
|
assertEquals("an underwater object still keeps out of falls and open water", start + 4, transaction.mutationCheckpoint());
|
||||||
transaction.beginObjectPlacement(false);
|
transaction.beginObjectPlacement(ObjectWaterRule.KEEP_OUT);
|
||||||
transaction.set(3, 16, 3, vine);
|
transaction.set(3, 16, 3, vine);
|
||||||
transaction.set(3, 8, 3, vine);
|
transaction.set(3, 8, 3, vine);
|
||||||
transaction.set(6, 19, 6, vine);
|
transaction.set(6, 19, 6, vine);
|
||||||
@@ -239,12 +240,12 @@ public class ObjectDestinationTransactionTest {
|
|||||||
transaction.set(3, 10, 3, boulder);
|
transaction.set(3, 10, 3, boulder);
|
||||||
assertEquals("nothing an object places roofs or fills the slot between its water and the cliff top", start,
|
assertEquals("nothing an object places roofs or fills the slot between its water and the cliff top", start,
|
||||||
transaction.mutationCheckpoint());
|
transaction.mutationCheckpoint());
|
||||||
transaction.beginObjectPlacement(true);
|
transaction.beginObjectPlacement(ObjectWaterRule.ENTERS_WATER);
|
||||||
transaction.set(3, 10, 3, boulder);
|
transaction.set(3, 10, 3, boulder);
|
||||||
transaction.set(3, 12, 3, boulder);
|
transaction.set(3, 12, 3, boulder);
|
||||||
assertEquals("an underwater object's solid block below the water may still sit on the slot bed", start + 1,
|
assertEquals("an underwater object's solid block below the water may still sit on the slot bed", start + 1,
|
||||||
transaction.mutationCheckpoint());
|
transaction.mutationCheckpoint());
|
||||||
transaction.beginObjectPlacement(false);
|
transaction.beginObjectPlacement(ObjectWaterRule.KEEP_OUT);
|
||||||
transaction.set(3, 31, 3, leaves);
|
transaction.set(3, 31, 3, leaves);
|
||||||
transaction.set(3, 36, 3, leaves);
|
transaction.set(3, 36, 3, leaves);
|
||||||
transaction.set(3, 33, 3, boulder);
|
transaction.set(3, 33, 3, boulder);
|
||||||
@@ -289,7 +290,7 @@ public class ObjectDestinationTransactionTest {
|
|||||||
setCanopy(transaction, 5, 14, 3, leaves);
|
setCanopy(transaction, 5, 14, 3, leaves);
|
||||||
assertEquals("the bed, the air above the surface and dry land keep their leaves", start + 4,
|
assertEquals("the bed, the air above the surface and dry land keep their leaves", start + 4,
|
||||||
transaction.mutationCheckpoint());
|
transaction.mutationCheckpoint());
|
||||||
int underwater = transaction.beginObjectPlacement(true);
|
int underwater = transaction.beginObjectPlacement(ObjectWaterRule.ENTERS_WATER);
|
||||||
transaction.set(3, 12, 3, leaves);
|
transaction.set(3, 12, 3, leaves);
|
||||||
transaction.set(4, 9, 3, leaves);
|
transaction.set(4, 9, 3, leaves);
|
||||||
assertEquals("an underwater object keeps its solid blocks in the water", underwater + 2,
|
assertEquals("an underwater object keeps its solid blocks in the water", underwater + 2,
|
||||||
@@ -304,7 +305,7 @@ public class ObjectDestinationTransactionTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void onwaterRaftsAndOwnForcedObjectsKeepTheirLayerOnRiversButForcedStructurePiecesDoNot() {
|
public void onwaterRaftsAndForcedPlacementsKeepTheirWritesThroughReplay() {
|
||||||
MantleWriter writer = writer();
|
MantleWriter writer = writer();
|
||||||
IrisComplex complex = mock(IrisComplex.class);
|
IrisComplex complex = mock(IrisComplex.class);
|
||||||
HydrologyRuntime runtime = mock(HydrologyRuntime.class);
|
HydrologyRuntime runtime = mock(HydrologyRuntime.class);
|
||||||
@@ -330,21 +331,28 @@ public class ObjectDestinationTransactionTest {
|
|||||||
assertTrue(piece.isForcePlace());
|
assertTrue(piece.isForcePlace());
|
||||||
ObjectDestinationTransaction transaction = new ObjectDestinationTransaction(writer, 0, 0);
|
ObjectDestinationTransaction transaction = new ObjectDestinationTransaction(writer, 0, 0);
|
||||||
|
|
||||||
int raftStart = transaction.beginObjectPlacement(raft.entersWater());
|
int raftStart = transaction.beginObjectPlacement(raft.waterRule());
|
||||||
for (int x = 3; x <= 5; x++) {
|
for (int x = 3; x <= 5; x++) {
|
||||||
transaction.set(x, 14, 3, plank);
|
transaction.set(x, 14, 3, plank);
|
||||||
}
|
}
|
||||||
assertEquals("a one-block onwater raft keeps its layer on the river surface", raftStart + 3, transaction.mutationCheckpoint());
|
assertEquals("a one-block onwater raft keeps its layer on the river surface", raftStart + 3, transaction.mutationCheckpoint());
|
||||||
int forcedStart = transaction.beginObjectPlacement(forced.entersWater());
|
assertEquals(ObjectWaterRule.FORCED, forced.waterRule());
|
||||||
|
assertEquals(ObjectWaterRule.FORCED, piece.waterRule());
|
||||||
|
int forcedStart = transaction.beginObjectPlacement(forced.waterRule());
|
||||||
transaction.set(3, 13, 3, plank);
|
transaction.set(3, 13, 3, plank);
|
||||||
assertEquals("an object's own forcePlace keeps its solid blocks in the river", forcedStart + 1, transaction.mutationCheckpoint());
|
transaction.set(3, 12, 3, mock(NativeBlockState.class));
|
||||||
int pieceStart = transaction.beginObjectPlacement(piece.entersWater());
|
transaction.setData(3, 11, 3, new MatterCavern(true, "", (byte) 3));
|
||||||
|
assertEquals("a forced object writes solid blocks, open blocks and carves through the river", forcedStart + 3, transaction.mutationCheckpoint());
|
||||||
|
int pieceStart = transaction.beginObjectPlacement(piece.waterRule());
|
||||||
transaction.set(4, 13, 3, plank);
|
transaction.set(4, 13, 3, plank);
|
||||||
transaction.set(5, 11, 3, plank);
|
transaction.set(5, 11, 3, plank);
|
||||||
assertEquals("a forced structure piece still keeps its solid blocks out of the river", pieceStart, transaction.mutationCheckpoint());
|
assertEquals("a forced structure piece writes through the river", pieceStart + 2, transaction.mutationCheckpoint());
|
||||||
|
int landStart = transaction.beginObjectPlacement(ObjectWaterRule.KEEP_OUT);
|
||||||
|
transaction.set(4, 12, 3, plank);
|
||||||
|
assertEquals("an unforced object stays out of the river", landStart, transaction.mutationCheckpoint());
|
||||||
ObjectDestinationTransaction destination = new ObjectDestinationTransaction(writer, 0, 0);
|
ObjectDestinationTransaction destination = new ObjectDestinationTransaction(writer, 0, 0);
|
||||||
destination.apply(transaction.sourcePlanSince(raftStart));
|
destination.apply(transaction.sourcePlanSince(raftStart));
|
||||||
assertEquals("the destination replay keeps the raft and the forced block", 4, destination.mutationCheckpoint());
|
assertEquals("the destination replay keeps the forced writes beside the raft", 8, destination.mutationCheckpoint());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -367,7 +375,7 @@ public class ObjectDestinationTransactionTest {
|
|||||||
when(pier.isSolid()).thenReturn(true);
|
when(pier.isSolid()).thenReturn(true);
|
||||||
ObjectDestinationTransaction transaction = new ObjectDestinationTransaction(writer, 0, 0);
|
ObjectDestinationTransaction transaction = new ObjectDestinationTransaction(writer, 0, 0);
|
||||||
|
|
||||||
int raft = transaction.beginObjectPlacement(true);
|
int raft = transaction.beginObjectPlacement(ObjectWaterRule.ENTERS_WATER);
|
||||||
transaction.set(3, 12, 3, pier);
|
transaction.set(3, 12, 3, pier);
|
||||||
transaction.recordObjectPlacement(raft);
|
transaction.recordObjectPlacement(raft);
|
||||||
transaction.endObjectPlacement();
|
transaction.endObjectPlacement();
|
||||||
@@ -385,7 +393,7 @@ public class ObjectDestinationTransactionTest {
|
|||||||
when(pier.isSolid()).thenReturn(true);
|
when(pier.isSolid()).thenReturn(true);
|
||||||
ObjectDestinationTransaction transaction = new ObjectDestinationTransaction(writer, 0, 0);
|
ObjectDestinationTransaction transaction = new ObjectDestinationTransaction(writer, 0, 0);
|
||||||
|
|
||||||
transaction.beginObjectPlacement(true);
|
transaction.beginObjectPlacement(ObjectWaterRule.ENTERS_WATER);
|
||||||
transaction.set(3, 12, 3, pier);
|
transaction.set(3, 12, 3, pier);
|
||||||
transaction.endObjectPlacement();
|
transaction.endObjectPlacement();
|
||||||
int afterRaft = transaction.mutationCheckpoint();
|
int afterRaft = transaction.mutationCheckpoint();
|
||||||
|
|||||||
-2
@@ -88,7 +88,6 @@ public class IrisObjectPlacementToPlacementTest {
|
|||||||
source.setAllowedCollisions(allowedCollisions);
|
source.setAllowedCollisions(allowedCollisions);
|
||||||
source.setForbiddenCollisions(forbiddenCollisions);
|
source.setForbiddenCollisions(forbiddenCollisions);
|
||||||
source.setForcePlace(true);
|
source.setForcePlace(true);
|
||||||
source.setForcedByStructure(true);
|
|
||||||
|
|
||||||
IrisObjectPlacement copy = source.toPlacement("objects/replaced");
|
IrisObjectPlacement copy = source.toPlacement("objects/replaced");
|
||||||
|
|
||||||
@@ -133,6 +132,5 @@ public class IrisObjectPlacementToPlacementTest {
|
|||||||
assertSame(allowedCollisions, copy.getAllowedCollisions());
|
assertSame(allowedCollisions, copy.getAllowedCollisions());
|
||||||
assertSame(forbiddenCollisions, copy.getForbiddenCollisions());
|
assertSame(forbiddenCollisions, copy.getForbiddenCollisions());
|
||||||
assertTrue(copy.isForcePlace());
|
assertTrue(copy.isForcePlace());
|
||||||
assertTrue(copy.isForcedByStructure());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+12
-1
@@ -131,7 +131,7 @@ public class PlacementModuleSurfaceSupportTest {
|
|||||||
world.water(WaterRole.CHANNEL, 9, 13);
|
world.water(WaterRole.CHANNEL, 9, 13);
|
||||||
world.column(1, 0, WaterRole.CHANNEL, 8, 12);
|
world.column(1, 0, WaterRole.CHANNEL, 8, 12);
|
||||||
|
|
||||||
for (IrisObjectPlacement placement : List.of(underwater(), onwater(), forced())) {
|
for (IrisObjectPlacement placement : List.of(underwater(), onwater())) {
|
||||||
HydrologyWaterFixture.Placer placer = world.placer();
|
HydrologyWaterFixture.Placer placer = world.placer();
|
||||||
|
|
||||||
assertEquals(-1, place(HydrologyWaterFixture.raft(), placer, placement));
|
assertEquals(-1, place(HydrologyWaterFixture.raft(), placer, placement));
|
||||||
@@ -139,6 +139,17 @@ public class PlacementModuleSurfaceSupportTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void forcedObjectsPlaceOnWaterAtAnotherHeadAndOnDams() {
|
||||||
|
world.water(WaterRole.CHANNEL, 9, 13);
|
||||||
|
world.column(1, 0, WaterRole.CHANNEL, 8, 12);
|
||||||
|
world.column(0, 1, WaterRole.DAM, 8, 12);
|
||||||
|
HydrologyWaterFixture.Placer placer = world.placer();
|
||||||
|
|
||||||
|
assertTrue(place(HydrologyWaterFixture.raft(), placer, forced()) >= 0);
|
||||||
|
assertFalse(placer.writes().isEmpty());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void waterObjectsNeverPlaceOnProvisionalHydrology() {
|
public void waterObjectsNeverPlaceOnProvisionalHydrology() {
|
||||||
world.water(WaterRole.POND, 7, 13);
|
world.water(WaterRole.POND, 7, 13);
|
||||||
|
|||||||
+40
@@ -500,6 +500,46 @@ public class IrisStructureLocatorContractTest {
|
|||||||
assertNotNull(IrisStructureLocator.resolvePlacement(engine, placement, 3, 4));
|
assertNotNull(IrisStructureLocator.resolvePlacement(engine, placement, 3, 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void forcedSinglePiecesPlaceInTheMiddleOfARiver() {
|
||||||
|
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);
|
||||||
|
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(124D);
|
||||||
|
when(waterHead.getDouble(anyDouble(), anyDouble())).thenReturn(124D);
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
ProceduralStream<WaterRole> roles = mock(ProceduralStream.class);
|
||||||
|
when(complex.getWaterRoleStream()).thenReturn(roles);
|
||||||
|
when(roles.get(anyDouble(), anyDouble())).thenReturn(WaterRole.CHANNEL);
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
ProceduralStream<Integer> beds = mock(ProceduralStream.class);
|
||||||
|
when(beds.get(anyDouble(), anyDouble())).thenReturn(120);
|
||||||
|
when(complex.getRoundedHeighteightStream()).thenReturn(beds);
|
||||||
|
when(engine.getHeight(anyInt(), anyInt(), eq(true))).thenReturn(120);
|
||||||
|
when(engine.getDimension().getFluidHeight()).thenReturn(63);
|
||||||
|
IrisStructurePlacement placement = engine.getDimension().getStructures().get(0);
|
||||||
|
IrisStructure structure = engine.getData().load(IrisStructure.class, "test:density", false);
|
||||||
|
|
||||||
|
assertNull("an unforced structure stays off a submerged start",
|
||||||
|
IrisStructureLocator.resolvePlacement(engine, placement, 3, 4));
|
||||||
|
placement.setUnderwater(true);
|
||||||
|
assertNull("an unforced structure keeps the 10% limit",
|
||||||
|
IrisStructureLocator.resolvePlacement(engine, placement, 3, 4));
|
||||||
|
placement.setUnderwater(false);
|
||||||
|
|
||||||
|
structure.setPlaceMode(ObjectPlaceMode.CENTER_HEIGHT);
|
||||||
|
|
||||||
|
assertNotNull("a forced piece places on a river column and over a river footprint",
|
||||||
|
IrisStructureLocator.resolvePlacement(engine, placement, 3, 4));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void undergroundIrisStructuresIgnoreRiversAbove() {
|
public void undergroundIrisStructuresIgnoreRiversAbove() {
|
||||||
Engine engine = densityEngine(1.0, true, -64, 384, -40, -20);
|
Engine engine = densityEngine(1.0, true, -64, 384, -40, -20);
|
||||||
|
|||||||
Reference in new issue
Block a user