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:
Brian Fopiano committed 2026-11-02 19:01:55 -05:00
1 parent d6a3456024
commit 4ddbcc9c97
27 files changed
+310 -161

No files matched your search

@@ -23,6 +23,7 @@ import art.arcane.iris.generation.runtime.Engine;
import art.arcane.iris.generation.runtime.IrisComplex;
import art.arcane.iris.structure.object.IObjectPlacer;
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.util.math.BlockPosition;
import art.arcane.iris.generation.block.B;
@@ -44,18 +45,18 @@ final class FloatingObjectPlacementTransaction implements IObjectPlacer {
private final ObjectContinuationBundle.PlacementKey placementKey;
private final KList<BufferedMutation> mutations;
private final Map<PositionKey, NativeBlockState> bufferedBlocks;
private final boolean entersWater;
private final ObjectWaterRule waterRule;
private ObjectHydrologyVeto waterVeto;
private int blockWrites;
private BlockPosition canopyPosition;
FloatingObjectPlacementTransaction(IObjectPlacer delegate, ObjectContinuationBundle.PlacementKey placementKey,
boolean entersWater) {
ObjectWaterRule waterRule) {
this.delegate = Objects.requireNonNull(delegate);
this.placementKey = Objects.requireNonNull(placementKey);
this.mutations = new KList<>();
this.bufferedBlocks = new HashMap<>();
this.entersWater = entersWater;
this.waterRule = waterRule;
}
CommitResult commit() {
@@ -161,7 +162,7 @@ final class FloatingObjectPlacementTransaction implements IObjectPlacer {
@Override
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;
}
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) {
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() {
@@ -18,6 +18,7 @@
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.StructureCarveEnvelope;
@@ -162,29 +163,19 @@ public class IrisStructureComponent extends IrisMantleComponent {
KList<PlacedStructurePiece> pieces, RNG rng) {
IrisStructureStiltSettings stilt = placement.getStilt();
PieceRun run = new PieceRun(structure, rng, stilt == null ? null : new Long2IntOpenHashMap(),
stilt != null && stilt.isSupportNonOccluding(), placement.isAllowWater());
ObjectPlaceMode mode = structure.getPlaceMode();
stilt != null && stilt.isSupportNonOccluding());
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;
writer.beginObjectPlacement(run.allowWater());
writer.beginObjectPlacement(rule);
try {
if (placement.isAnchoredUnderground()) {
ObjectPlaceMode undergroundMode = (mode == ObjectPlaceMode.ORGANIC_STILT || mode == ObjectPlaceMode.CEILING_HANG)
? mode : ObjectPlaceMode.STRUCTURE_PIECE;
for (PlacedStructurePiece p : pieces) {
if (placeObject(writer, run, p, undergroundMode, false) == -1) {
failedPieces++;
}
}
} else if (pieces.size() == 1 && mode != ObjectPlaceMode.STRUCTURE_PIECE && mode != ObjectPlaceMode.FLOATING) {
if (placeObject(writer, run, pieces.getFirst(), mode, true) == -1) {
for (PlacedStructurePiece p : pieces) {
if (placeObject(writer, run, p, mode, sampledHeight) == -1) {
failedPieces++;
}
} else {
for (PlacedStructurePiece p : pieces) {
if (placeObject(writer, run, p, ObjectPlaceMode.STRUCTURE_PIECE, false) == -1) {
failedPieces++;
}
}
}
if (failedPieces == 0 && stilt != null) {
placeFoundation(writer, run.foundationColumns(), stilt, rng, !placement.isAnchoredUnderground());
@@ -593,7 +584,6 @@ public class IrisStructureComponent extends IrisMantleComponent {
}
if (mode != ObjectPlaceMode.STRUCTURE_PIECE && mode != ObjectPlaceMode.FLOATING) {
config.setForcePlace(true);
config.setForcedByStructure(true);
}
return config;
}
@@ -720,6 +710,6 @@ public class IrisStructureComponent extends IrisMantleComponent {
}
private record PieceRun(IrisStructure structure, RNG rng, Long2IntOpenHashMap foundationColumns,
boolean supportNonOccluding, boolean allowWater) {
boolean supportNonOccluding) {
}
}
@@ -217,7 +217,7 @@ public class MantleFloatingObjectComponent extends IrisMantleComponent {
int id = rng.i(0, Integer.MAX_VALUE);
FloatingObjectPlacementTransaction transaction = new FloatingObjectPlacementTransaction(
writer, placements.next(minX >> 4, minZ >> 4), placement.entersWater());
writer, placements.next(minX >> 4, minZ >> 4), placement.waterRule());
try {
int resultY = obj.place(xx, zz, transaction, floatingPlacement, rng, (b, bd) -> {
String marker = placementMarker(obj, id);
@@ -312,7 +312,7 @@ public class MantleFloatingObjectComponent extends IrisMantleComponent {
IslandObjectPlacer islandPlacer = IslandObjectPlacer.top(writer, sampleProvider, entry, pickTopY);
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);
try {
@@ -426,7 +426,7 @@ public class MantleFloatingObjectComponent extends IrisMantleComponent {
IslandObjectPlacer islandPlacer = IslandObjectPlacer.bottom(writer, sampleProvider, entry, pickBottomY);
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);
try {
@@ -751,7 +751,7 @@ public class MantleObjectComponent extends IrisMantleComponent {
try {
int placeResult = -1;
CaveObjectPlacementTransaction.CommitResult commitResult = CaveObjectPlacementTransaction.CommitResult.EMPTY;
int continuation = writer.beginObjectPlacement(placement.entersWater());
int continuation = writer.beginObjectPlacement(placement.waterRule());
if (carving) {
int caveFloorY = caveAnchor.y();
if (golden) {
@@ -1015,7 +1015,7 @@ public class MantleObjectComponent extends IrisMantleComponent {
}
try {
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) -> {
if (marker != null) {
writer.setData(b.getX(), b.getY(), b.getZ(), marker);
@@ -1202,7 +1202,7 @@ public class MantleObjectComponent extends IrisMantleComponent {
IrisObjectPlacement effectivePlacement = resolveCavePlacement(objectPlacement, object, caveProfile);
try {
int continuation = writer.beginObjectPlacement(effectivePlacement.entersWater());
int continuation = writer.beginObjectPlacement(effectivePlacement.waterRule());
ContainedPlacementResult contained = placeContainedCaveObject(
writer,
object,
@@ -1400,7 +1400,7 @@ public class MantleObjectComponent extends IrisMantleComponent {
}
boolean treePlacement = isTreePlacement(v, objectPlacement);
String marker = placementMarker(v, id, "upper");
int continuation = writer.beginObjectPlacement(placement.entersWater());
int continuation = writer.beginObjectPlacement(placement.waterRule());
int result;
try {
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.structure.object.ObjectWaterRule;
import art.arcane.iris.world.storage.matter.TileWrapper;
import art.arcane.iris.world.storage.matter.PreObjectMatterCell;
import art.arcane.iris.configuration.IrisSettings;
@@ -221,8 +222,8 @@ public class MantleWriter implements ObjectPassPlacer, AutoCloseable {
}
@Override
public int beginObjectPlacement(boolean entersWater) {
objectWater.set(new ObjectWater(ObjectHydrologyVeto.of(getEngine()), entersWater));
public int beginObjectPlacement(ObjectWaterRule rule) {
objectWater.set(new ObjectWater(ObjectHydrologyVeto.of(getEngine()), rule));
return -1;
}
@@ -237,9 +238,9 @@ public class MantleWriter implements ObjectPassPlacer, AutoCloseable {
return false;
}
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) {
@@ -1034,7 +1035,7 @@ public class MantleWriter implements ObjectPassPlacer, AutoCloseable {
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 {
@@ -1,5 +1,6 @@
package art.arcane.iris.generation.mantle;
import art.arcane.iris.structure.object.ObjectWaterRule;
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
import java.util.Arrays;
@@ -10,6 +11,7 @@ final class MutationLog {
private static final byte CUSTOM = 1;
private static final byte CANOPY = 2;
private static final byte ENTERS_WATER = 4;
private static final byte FORCED = 8;
private int size;
private int[] x = new int[32];
@@ -30,16 +32,16 @@ final class MutationLog {
throw new IllegalArgumentException("Object mutation type " + key.type().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(),
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;
}
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) {
int capacity = size * 2;
x = Arrays.copyOf(x, capacity);
@@ -52,7 +54,7 @@ final class MutationLog {
y[size] = blockY;
z[size] = blockZ;
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++;
}
@@ -84,8 +86,11 @@ final class MutationLog {
return (flags[index] & CANOPY) != 0;
}
boolean entersWater(int index) {
return (flags[index] & ENTERS_WATER) != 0;
ObjectWaterRule waterRule(int index) {
if ((flags[index] & FORCED) != 0) {
return ObjectWaterRule.FORCED;
}
return (flags[index] & ENTERS_WATER) != 0 ? ObjectWaterRule.ENTERS_WATER : ObjectWaterRule.KEEP_OUT;
}
Class<?> type(int index) {
@@ -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.subterrain.SubterrainRasterizer;
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.util.math.BlockPosition;
import art.arcane.iris.generation.block.B;
@@ -41,7 +42,7 @@ final class ObjectDestinationTransaction implements ObjectPassPlacer {
private int subterrainZ;
private boolean subterrainProtects;
private ObjectHydrologyVeto waterVeto;
private boolean waterPlacement;
private ObjectWaterRule waterRule = ObjectWaterRule.KEEP_OUT;
ObjectDestinationTransaction(MantleWriter writer, int destinationChunkX, int destinationChunkZ) {
this.writer = writer;
@@ -73,8 +74,8 @@ final class ObjectDestinationTransaction implements ObjectPassPlacer {
}
@Override
public int beginObjectPlacement(boolean entersWater) {
waterPlacement = entersWater;
public int beginObjectPlacement(ObjectWaterRule rule) {
waterRule = rule;
return log.size();
}
@@ -87,7 +88,7 @@ final class ObjectDestinationTransaction implements ObjectPassPlacer {
@Override
public void endObjectPlacement() {
waterPlacement = false;
waterRule = ObjectWaterRule.KEEP_OUT;
}
void apply(ObjectSourcePlan plan) {
@@ -107,7 +108,7 @@ final class ObjectDestinationTransaction implements ObjectPassPlacer {
Object value = plan.valueAt(index);
boolean custom = ObjectSourcePlan.isCustom(cell);
boolean canopy = ObjectSourcePlan.isCanopy(cell);
boolean entersWater = ObjectSourcePlan.entersWater(cell);
ObjectWaterRule rule = ObjectSourcePlan.waterRule(cell);
if (custom || value instanceof NativeBlockState) {
NativeBlockState existing = canopy ? get(x, y, z) : null;
skipCanopy = existing != null && existing.isSolid();
@@ -116,9 +117,9 @@ final class ObjectDestinationTransaction implements ObjectPassPlacer {
continue;
}
if (custom) {
set(x, y, z, (NativeBlockState) value, canopy, entersWater);
set(x, y, z, (NativeBlockState) value, canopy, rule);
} 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
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) {
return;
}
String placementKey = state.deferredPlacementKey();
NativeBlockState baseState = state.placementBaseState();
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;
}
Identifier identifier = Identifier.fromString(placementKey);
@@ -201,10 +202,10 @@ final class ObjectDestinationTransaction implements ObjectPassPlacer {
cell.block = baseState;
cell.tile = CLEARED;
cell.identifier = identifier;
log.add(x, y, z, state, true, canopy, entersWater);
log.add(x, y, z, state, true, canopy, rule);
return;
}
setData(x, y, z, state, canopy, entersWater);
setData(x, y, z, state, canopy, rule);
}
@Override
@@ -295,18 +296,18 @@ final class ObjectDestinationTransaction implements ObjectPassPlacer {
@Override
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
|| protectsSubterrain(x, y, z)) {
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;
}
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;
}
Class<?> type = data instanceof NativeBlockState ? NativeBlockState.class : data.getClass();
@@ -318,7 +319,7 @@ final class ObjectDestinationTransaction implements ObjectPassPlacer {
} else {
cell.put(type, data);
}
log.add(x, y, z, data, false, canopy, entersWater);
log.add(x, y, z, data, false, canopy, rule);
}
@Override
@@ -415,11 +416,11 @@ final class ObjectDestinationTransaction implements ObjectPassPlacer {
&& !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) {
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) {
@@ -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.runtime.Engine;
import art.arcane.iris.generation.runtime.IrisComplex;
import art.arcane.iris.structure.object.ObjectWaterRule;
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
final class ObjectHydrologyVeto {
@@ -25,13 +26,13 @@ final class ObjectHydrologyVeto {
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;
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) {
if (runtime == null) {
boolean keeps(int x, int y, int z, boolean solid, ObjectWaterRule rule) {
if (runtime == null || rule == ObjectWaterRule.FORCED) {
return false;
}
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)) {
return true;
}
if (solid && !entersWater && fillsWater(x, y, z)) {
if (solid && rule != ObjectWaterRule.ENTERS_WATER && fillsWater(x, y, z)) {
return true;
}
if (role.wet()) {
@@ -1,6 +1,7 @@
package art.arcane.iris.generation.mantle;
import art.arcane.iris.structure.object.IObjectPlacer;
import art.arcane.iris.structure.object.ObjectWaterRule;
import org.jetbrains.annotations.Nullable;
public interface ObjectPassPlacer extends IObjectPlacer {
@@ -8,7 +9,7 @@ public interface ObjectPassPlacer extends IObjectPlacer {
byte[] getCarvedColumn(int x, int z, int height);
default int beginObjectPlacement(boolean entersWater) {
default int beginObjectPlacement(ObjectWaterRule rule) {
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.hydrology.cave.HydrologyCaveCell;
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.TileWrapper;
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 CANOPY_BIT = 1 << 9;
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 final long[] destinations;
@@ -91,7 +93,7 @@ final class ObjectSourcePlan {
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)
| (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));
}
values = table.values.toArray();
@@ -242,8 +244,19 @@ final class ObjectSourcePlan {
return (cell & CANOPY_BIT) != 0;
}
static boolean entersWater(int cell) {
return (cell & ENTERS_WATER_BIT) != 0;
static ObjectWaterRule waterRule(int cell) {
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) {
@@ -201,7 +201,6 @@ public class IrisObjectPlacement {
@Description("Ignore any placement restrictions for this object")
@SerializedName(value = "forcePlace", alternate = {"force"})
private boolean forcePlace = false;
private transient boolean forcedByStructure = false;
private transient AtomicCache<TableCache> cache = new AtomicCache<>();
private transient AtomicCache<CompatStatus> compatCache = new AtomicCache<>();
@Getter(AccessLevel.NONE)
@@ -307,8 +306,11 @@ public class IrisObjectPlacement {
return place.size() == 1 ? place.getFirst() : place.toString(", ");
}
public boolean entersWater() {
return underwater || onwater || forcePlace && !forcedByStructure;
public ObjectWaterRule waterRule() {
if (forcePlace) {
return ObjectWaterRule.FORCED;
}
return underwater || onwater ? ObjectWaterRule.ENTERS_WATER : ObjectWaterRule.KEEP_OUT;
}
public IrisObjectPlacement toPlacement(String... place) {
@@ -354,7 +356,6 @@ public class IrisObjectPlacement {
p.setAllowedCollisions(allowedCollisions);
p.setForbiddenCollisions(forbiddenCollisions);
p.setForcePlace(forcePlace);
p.setForcedByStructure(forcedByStructure);
return p;
}
@@ -0,0 +1,7 @@
package art.arcane.iris.structure.object;
public enum ObjectWaterRule {
KEEP_OUT,
ENTERS_WATER,
FORCED
}
@@ -56,12 +56,12 @@ final class PlacementModuleSurfaceSupport implements PlacementModule {
private static String hydrologyRejection(PlacementContext context, PlacementState state) {
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) {
return null;
}
boolean painted = state.paintProjection != null;
if (config.entersWater()) {
if (config.waterRule() == ObjectWaterRule.ENTERS_WATER) {
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, config.getTranslate(),
@@ -536,6 +536,11 @@ public final class IrisStructureLocator {
// Gated out on this Minecraft version; the pack report already says why.
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);
if (!compilation.isAssemblyViable()) {
throw new IllegalStateException("Iris structure '" + selectedKey
@@ -545,6 +550,9 @@ public final class IrisStructureLocator {
StructureAssembler assembler = StructureAssembler.forData(
engine.getData(), structure, new IrisPosition(originX, baseY, originZ));
StructureAssemblyResult assembly = assembler.assemble(rng);
if (submerged && !placement.forcesPieces(structure, assembly.pieces().size())) {
return null;
}
if (!requirePlacementOutput(placement, selectedKey, cx, cz,
assembly.hasOutput(), "runtime assembly produced " + assembly.status() + ": " + assembly.detail())) {
return null;
@@ -593,6 +601,7 @@ public final class IrisStructureLocator {
return null;
}
if (!placement.isAnchoredUnderground() && !placement.isAllowWater()
&& !placement.forcesPieces(structure, pieces.size())
&& !StructureWaterRules.admitsFootprint(IrisStructureWater.mantle(engine.getComplex()), pieceFootprints(pieces))) {
return null;
}
@@ -687,10 +696,6 @@ public final class IrisStructureLocator {
if (worldMin > worldMax) {
return null;
}
if (!placement.isUnderwater()
&& NativeStructurePlacementPlanner.isSubmerged(engine, originX, originZ)) {
return null;
}
if (placement.resolvedAnchor() == IrisStructureAnchorMode.SURFACE) {
int surfaceY = Engine.hostHeight(engine, originX, originZ, true) + engine.getMinHeight();
return surfaceY < placement.getMinHeight() || surfaceY > placement.getMaxHeight() ? null : surfaceY;
@@ -18,6 +18,7 @@
package art.arcane.iris.structure.placement;
import art.arcane.iris.structure.object.ObjectPlaceMode;
import art.arcane.iris.generation.biome.IrisBiome;
import art.arcane.iris.pack.validation.CompatPools;
import art.arcane.iris.structure.nativegen.IrisNativeStructure;
@@ -152,6 +153,19 @@ public class IrisStructurePlacement {
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() {
IrisStructureAnchorMode activeAnchor = resolvedAnchor();
return activeAnchor == IrisStructureAnchorMode.HEIGHT_BAND || activeAnchor.isCave();