mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 00:34:19 +00:00
Read an explicit world Y below zero as a height, not as automatic
An object or structure piece placed at world Y -1, or at any Y that lands below zero, was treated as "sample the height" because every stage tested requestedY < 0. Automatic height is now an explicit flag on the placement run, set by the automatic entry points, and explicit heights of any sign are placed where asked. Automatic placements keep their seeds and heights.
Upstream: 9f0615a97
This commit is contained in:
1 parent
ccdfad8ba5
commit
e3dd61c177
15 files changed
+157
-57
No files matched your search
@@ -44,7 +44,8 @@ public final class ModuleObjectPlacement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param requestedY the height to place at, or a negative value for the placement to sample it
|
* Places the object at {@code requestedY}, which may be below zero in a dimension that reaches down there.
|
||||||
|
*
|
||||||
* @param listener hears each of the object's own blocks once the placement is written; null for none
|
* @param listener hears each of the object's own blocks once the placement is written; null for none
|
||||||
* @param cave the cave the object is placed in, or null outside caves
|
* @param cave the cave the object is placed in, or null outside caves
|
||||||
*/
|
*/
|
||||||
@@ -52,21 +53,42 @@ public final class ModuleObjectPlacement {
|
|||||||
ObjectPlacement config, RNG rng,
|
ObjectPlacement config, RNG rng,
|
||||||
BiConsumer<art.arcane.volmlib.util.math.BlockPosition, PlatformBlockState> listener,
|
BiConsumer<art.arcane.volmlib.util.math.BlockPosition, PlatformBlockState> listener,
|
||||||
CarveResult cave, IrisData data) {
|
CarveResult cave, IrisData data) {
|
||||||
|
ObjectRun run = cave == null
|
||||||
|
? ObjectRun.of(object, config, x, requestedY, z)
|
||||||
|
: ObjectRun.inCave(object, config, x, requestedY, z, caveOf(cave));
|
||||||
|
return place(run, placer, config, rng, listener, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** As {@link #place}, at the height the placement samples from the terrain, or from {@code cave}. */
|
||||||
|
public static ObjectPlacementResult placeAutomatic(IrisObject object, int x, int z, IObjectPlacer placer,
|
||||||
|
ObjectPlacement config, RNG rng,
|
||||||
|
BiConsumer<art.arcane.volmlib.util.math.BlockPosition, PlatformBlockState> listener,
|
||||||
|
CarveResult cave, IrisData data) {
|
||||||
|
ObjectRun run = cave == null
|
||||||
|
? ObjectRun.automatic(object, config, x, z)
|
||||||
|
: ObjectRun.automaticInCave(object, config, x, z, caveOf(cave));
|
||||||
|
return place(run, placer, config, rng, listener, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ObjectRun.Cave caveOf(CarveResult cave) {
|
||||||
|
return new ObjectRun.Cave(cave.getSurface(), cave.getHeight());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ObjectPlacementResult place(ObjectRun run, IObjectPlacer placer, ObjectPlacement config, RNG rng,
|
||||||
|
BiConsumer<art.arcane.volmlib.util.math.BlockPosition, PlatformBlockState> listener,
|
||||||
|
IrisData data) {
|
||||||
Objects.requireNonNull(placer, "Object placer is required.");
|
Objects.requireNonNull(placer, "Object placer is required.");
|
||||||
Objects.requireNonNull(config, "Object placement config is required.");
|
Objects.requireNonNull(config, "Object placement config is required.");
|
||||||
Objects.requireNonNull(rng, "Object placement RNG is required.");
|
Objects.requireNonNull(rng, "Object placement RNG is required.");
|
||||||
Objects.requireNonNull(data, "Object placement data is required.");
|
Objects.requireNonNull(data, "Object placement data is required.");
|
||||||
PlacerTerrain terrain = listener == null ? PlacerTerrain.of(placer, data) : PlacerTerrain.rememberingWrites(placer, data);
|
PlacerTerrain terrain = listener == null ? PlacerTerrain.of(placer, data) : PlacerTerrain.rememberingWrites(placer, data);
|
||||||
ObjectRun run = cave == null
|
|
||||||
? ObjectRun.of(object, config, x, requestedY, z)
|
|
||||||
: ObjectRun.inCave(object, config, x, requestedY, z, new ObjectRun.Cave(cave.getSurface(), cave.getHeight()));
|
|
||||||
PlacementOutcome outcome = placeIn(run, terrain, placer.getEngine(), rng, data);
|
PlacementOutcome outcome = placeIn(run, terrain, placer.getEngine(), rng, data);
|
||||||
if (!outcome.isPlaced()) {
|
if (!outcome.isPlaced()) {
|
||||||
return ObjectPlacementResult.rejected(outcome.rejection().orElseThrow());
|
return ObjectPlacementResult.rejected(outcome.rejection().orElseThrow());
|
||||||
}
|
}
|
||||||
reportObjectBlocks(run, terrain, listener);
|
reportObjectBlocks(run, terrain, listener);
|
||||||
int anchorY = run.anchorY().orElseThrow(() -> new IllegalStateException(
|
int anchorY = run.anchorY().orElseThrow(() -> new IllegalStateException(
|
||||||
"The placement graph placed " + object.name() + " without anchoring it"));
|
"The placement graph placed " + run.object().name() + " without anchoring it"));
|
||||||
return ObjectPlacementResult.placed(anchorY);
|
return ObjectPlacementResult.placed(anchorY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import art.arcane.iris.builtin.objects.ObjectPlacement;
|
|||||||
import art.arcane.iris.builtin.prepare.ObjectRotation;
|
import art.arcane.iris.builtin.prepare.ObjectRotation;
|
||||||
import art.arcane.iris.core.IrisSettings;
|
import art.arcane.iris.core.IrisSettings;
|
||||||
import art.arcane.iris.core.modules.ModuleObjectPlacement;
|
import art.arcane.iris.core.modules.ModuleObjectPlacement;
|
||||||
|
import art.arcane.iris.core.modules.ObjectPlacementResult;
|
||||||
import art.arcane.iris.engine.object.prefab.ObjectTurn;
|
import art.arcane.iris.engine.object.prefab.ObjectTurn;
|
||||||
import art.arcane.volmlib.util.cache.CacheKey;
|
import art.arcane.volmlib.util.cache.CacheKey;
|
||||||
import art.arcane.iris.engine.framework.IrisStructureLocator;
|
import art.arcane.iris.engine.framework.IrisStructureLocator;
|
||||||
@@ -60,6 +61,7 @@ import art.arcane.volmlib.util.mantle.runtime.MantleChunk;
|
|||||||
import art.arcane.volmlib.util.matter.Matter;
|
import art.arcane.volmlib.util.matter.Matter;
|
||||||
import art.arcane.volmlib.util.matter.MatterCavern;
|
import art.arcane.volmlib.util.matter.MatterCavern;
|
||||||
import art.arcane.volmlib.util.matter.MatterStructurePOI;
|
import art.arcane.volmlib.util.matter.MatterStructurePOI;
|
||||||
|
import art.arcane.volmlib.util.math.BlockPosition;
|
||||||
import art.arcane.volmlib.util.math.RNG;
|
import art.arcane.volmlib.util.math.RNG;
|
||||||
import it.unimi.dsi.fastutil.longs.Long2IntMap;
|
import it.unimi.dsi.fastutil.longs.Long2IntMap;
|
||||||
import it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap;
|
import it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap;
|
||||||
@@ -68,6 +70,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.function.BiConsumer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Places the Iris structures of the dimension, its regions and biomes into the mantle for
|
* Places the Iris structures of the dimension, its regions and biomes into the mantle for
|
||||||
@@ -149,26 +152,26 @@ public class StructurePlacing {
|
|||||||
ObjectPlaceMode undergroundMode = mode.placeMode().has(PlaceTrait.CAVE_ANCHORED)
|
ObjectPlaceMode undergroundMode = mode.placeMode().has(PlaceTrait.CAVE_ANCHORED)
|
||||||
? mode : ObjectPlaceMode.STRUCTURE_PIECE;
|
? mode : ObjectPlaceMode.STRUCTURE_PIECE;
|
||||||
for (PlacedStructurePiece p : pieces) {
|
for (PlacedStructurePiece p : pieces) {
|
||||||
if (placeObject(writer, structure, p, undergroundMode, p.getY(), rng,
|
if (placeObject(writer, structure, p, undergroundMode, false, rng,
|
||||||
foundationColumns, supportNonOccluding) == -1) {
|
foundationColumns, supportNonOccluding) == -1) {
|
||||||
failedPieces++;
|
failedPieces++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (mode.placeMode().has(PlaceTrait.FREE_HEIGHT)) {
|
} else if (mode.placeMode().has(PlaceTrait.FREE_HEIGHT)) {
|
||||||
for (PlacedStructurePiece p : pieces) {
|
for (PlacedStructurePiece p : pieces) {
|
||||||
if (placeObject(writer, structure, p, ObjectPlaceMode.STRUCTURE_PIECE, p.getY(), rng,
|
if (placeObject(writer, structure, p, ObjectPlaceMode.STRUCTURE_PIECE, false, rng,
|
||||||
foundationColumns, supportNonOccluding) == -1) {
|
foundationColumns, supportNonOccluding) == -1) {
|
||||||
failedPieces++;
|
failedPieces++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (pieces.size() == 1) {
|
} else if (pieces.size() == 1) {
|
||||||
if (placeObject(writer, structure, pieces.getFirst(), mode, -1, rng,
|
if (placeObject(writer, structure, pieces.getFirst(), mode, true, rng,
|
||||||
foundationColumns, supportNonOccluding) == -1) {
|
foundationColumns, supportNonOccluding) == -1) {
|
||||||
failedPieces++;
|
failedPieces++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (PlacedStructurePiece p : pieces) {
|
for (PlacedStructurePiece p : pieces) {
|
||||||
if (placeObject(writer, structure, p, ObjectPlaceMode.STRUCTURE_PIECE, p.getY(), rng,
|
if (placeObject(writer, structure, p, ObjectPlaceMode.STRUCTURE_PIECE, false, rng,
|
||||||
foundationColumns, supportNonOccluding) == -1) {
|
foundationColumns, supportNonOccluding) == -1) {
|
||||||
failedPieces++;
|
failedPieces++;
|
||||||
}
|
}
|
||||||
@@ -561,7 +564,7 @@ public class StructurePlacing {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private int placeObject(MantleWriter writer, IrisStructure structure, PlacedStructurePiece p,
|
private int placeObject(MantleWriter writer, IrisStructure structure, PlacedStructurePiece p,
|
||||||
ObjectPlaceMode mode, int y, RNG rng, Long2IntOpenHashMap foundationColumns,
|
ObjectPlaceMode mode, boolean sampledHeight, RNG rng, Long2IntOpenHashMap foundationColumns,
|
||||||
boolean supportNonOccluding) {
|
boolean supportNonOccluding) {
|
||||||
IrisObject object = p.getObject();
|
IrisObject object = p.getObject();
|
||||||
String objectKey = object.getLoadKey();
|
String objectKey = object.getLoadKey();
|
||||||
@@ -573,16 +576,20 @@ public class StructurePlacing {
|
|||||||
builder.forcePlace(true);
|
builder.forcePlace(true);
|
||||||
}
|
}
|
||||||
ObjectPlacement config = builder.build();
|
ObjectPlacement config = builder.build();
|
||||||
int placeY = (y == -1) ? -1 : y - engine.getMinHeight();
|
|
||||||
String marker = structurePlacementMarker(structure, p, objectKey);
|
String marker = structurePlacementMarker(structure, p, objectKey);
|
||||||
return ModuleObjectPlacement.place(object, p.getX(), placeY, p.getZ(), writer, config, rng, (position, state) -> {
|
BiConsumer<BlockPosition, PlatformBlockState> listener = (position, state) -> {
|
||||||
StructureFoundationPlanner.recordBaseCell(
|
StructureFoundationPlanner.recordBaseCell(
|
||||||
foundationColumns, position.getX(), position.getY(), position.getZ(), state,
|
foundationColumns, position.getX(), position.getY(), position.getZ(), state,
|
||||||
supportNonOccluding);
|
supportNonOccluding);
|
||||||
if (marker != null && shouldWriteStructureMarker(state)) {
|
if (marker != null && shouldWriteStructureMarker(state)) {
|
||||||
writer.setData(position.getX(), position.getY(), position.getZ(), marker);
|
writer.setData(position.getX(), position.getY(), position.getZ(), marker);
|
||||||
}
|
}
|
||||||
}, null, engine.getData()).heightOrRejected();
|
};
|
||||||
|
ObjectPlacementResult result = sampledHeight
|
||||||
|
? ModuleObjectPlacement.placeAutomatic(object, p.getX(), p.getZ(), writer, config, rng, listener, null, engine.getData())
|
||||||
|
: ModuleObjectPlacement.place(object, p.getX(), p.getY() - engine.getMinHeight(), p.getZ(), writer, config, rng,
|
||||||
|
listener, null, engine.getData());
|
||||||
|
return result.heightOrRejected();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The placement rotation that turns a placed piece the way {@code turn} does. */
|
/** The placement rotation that turns a placed piece the way {@code turn} does. */
|
||||||
|
|||||||
+11
-7
@@ -110,7 +110,7 @@ public class IrisObjectSurfaceSupportPlacementTest {
|
|||||||
placer.carve(0, SURFACE_Y, 0);
|
placer.carve(0, SURFACE_Y, 0);
|
||||||
|
|
||||||
assertEquals("mode " + mode + " must skip over a carved column",
|
assertEquals("mode " + mode + " must skip over a carved column",
|
||||||
-1, place(placer, placement(mode), -1));
|
-1, placeAutomatic(placer, placement(mode)));
|
||||||
assertTrue("mode " + mode + " must not write blocks", placer.written().isEmpty());
|
assertTrue("mode " + mode + " must not write blocks", placer.written().isEmpty());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -120,7 +120,7 @@ public class IrisObjectSurfaceSupportPlacementTest {
|
|||||||
SurfacePlacer placer = new SurfacePlacer();
|
SurfacePlacer placer = new SurfacePlacer();
|
||||||
placer.carve(2, SURFACE_Y, 0);
|
placer.carve(2, SURFACE_Y, 0);
|
||||||
|
|
||||||
assertEquals(-1, place(placer, placement(ObjectPlaceMode.CENTER_HEIGHT), -1));
|
assertEquals(-1, placeAutomatic(placer, placement(ObjectPlaceMode.CENTER_HEIGHT)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -128,14 +128,14 @@ public class IrisObjectSurfaceSupportPlacementTest {
|
|||||||
SurfacePlacer placer = new SurfacePlacer();
|
SurfacePlacer placer = new SurfacePlacer();
|
||||||
placer.carve(6, SURFACE_Y, 0);
|
placer.carve(6, SURFACE_Y, 0);
|
||||||
|
|
||||||
assertTrue(place(placer, placement(ObjectPlaceMode.CENTER_HEIGHT), -1) >= 0);
|
assertTrue(placeAutomatic(placer, placement(ObjectPlaceMode.CENTER_HEIGHT)) >= 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void solidGroundStillPlaces() {
|
public void solidGroundStillPlaces() {
|
||||||
SurfacePlacer placer = new SurfacePlacer();
|
SurfacePlacer placer = new SurfacePlacer();
|
||||||
|
|
||||||
assertTrue(place(placer, placement(ObjectPlaceMode.CENTER_HEIGHT), -1) >= 0);
|
assertTrue(placeAutomatic(placer, placement(ObjectPlaceMode.CENTER_HEIGHT)) >= 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -153,7 +153,7 @@ public class IrisObjectSurfaceSupportPlacementTest {
|
|||||||
ObjectPlacement.Builder placement = placement(ObjectPlaceMode.CENTER_HEIGHT);
|
ObjectPlacement.Builder placement = placement(ObjectPlaceMode.CENTER_HEIGHT);
|
||||||
placement.forcePlace(true);
|
placement.forcePlace(true);
|
||||||
|
|
||||||
assertTrue(place(placer, placement, -1) >= 0);
|
assertTrue(placeAutomatic(placer, placement) >= 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -163,7 +163,7 @@ public class IrisObjectSurfaceSupportPlacementTest {
|
|||||||
ObjectPlacement.Builder placement = placement(ObjectPlaceMode.CENTER_HEIGHT);
|
ObjectPlacement.Builder placement = placement(ObjectPlaceMode.CENTER_HEIGHT);
|
||||||
placement.requireSurfaceSupport(false);
|
placement.requireSurfaceSupport(false);
|
||||||
|
|
||||||
assertTrue(place(placer, placement, -1) >= 0);
|
assertTrue(placeAutomatic(placer, placement) >= 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -248,7 +248,11 @@ public class IrisObjectSurfaceSupportPlacementTest {
|
|||||||
ObjectPlacement.Builder placement = placement(ObjectPlaceMode.FLOATING);
|
ObjectPlacement.Builder placement = placement(ObjectPlaceMode.FLOATING);
|
||||||
placement.translate(ObjectTranslate.of(0, SURFACE_Y + 40, 0, 0));
|
placement.translate(ObjectTranslate.of(0, SURFACE_Y + 40, 0, 0));
|
||||||
|
|
||||||
assertTrue(place(placer, placement, -1) >= 0);
|
assertTrue(placeAutomatic(placer, placement) >= 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private int placeAutomatic(SurfacePlacer placer, ObjectPlacement.Builder placement) {
|
||||||
|
return ModuleObjectPlacement.placeAutomatic(object(), 0, 0, placer, placement.build(), new RNG(1234L), null, null, data).heightOrRejected();
|
||||||
}
|
}
|
||||||
|
|
||||||
private int place(SurfacePlacer placer, ObjectPlacement.Builder placement, int anchorY) {
|
private int place(SurfacePlacer placer, ObjectPlacement.Builder placement, int anchorY) {
|
||||||
|
|||||||
+14
-8
@@ -33,6 +33,7 @@ import java.util.HexFormat;
|
|||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.OptionalInt;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.mockito.ArgumentMatchers.anyString;
|
import static org.mockito.ArgumentMatchers.anyString;
|
||||||
@@ -108,9 +109,14 @@ public class ObjectPlaceModePinTest {
|
|||||||
.translate(ObjectTranslate.of(0, mode == ObjectPlaceMode.FLOATING ? 140 : 2, 0, 0))
|
.translate(ObjectTranslate.of(0, mode == ObjectPlaceMode.FLOATING ? 140 : 2, 0, 0))
|
||||||
.build();
|
.build();
|
||||||
CarveResult cave = isCaveMode(mode) ? new CarveResult(CAVE_FLOOR_Y, CEILING_Y) : null;
|
CarveResult cave = isCaveMode(mode) ? new CarveResult(CAVE_FLOOR_Y, CEILING_Y) : null;
|
||||||
int requestedY = requestedY(mode);
|
OptionalInt requestedY = requestedY(mode);
|
||||||
ModuleObjectPlacement.place(pinnedObject(), OBJECT_X, requestedY, OBJECT_Z, placer, config,
|
if (requestedY.isPresent()) {
|
||||||
new RNG(PLACEMENT_SEED), null, cave, data);
|
ModuleObjectPlacement.place(pinnedObject(), OBJECT_X, requestedY.getAsInt(), OBJECT_Z, placer, config,
|
||||||
|
new RNG(PLACEMENT_SEED), null, cave, data);
|
||||||
|
} else {
|
||||||
|
ModuleObjectPlacement.placeAutomatic(pinnedObject(), OBJECT_X, OBJECT_Z, placer, config,
|
||||||
|
new RNG(PLACEMENT_SEED), null, cave, data);
|
||||||
|
}
|
||||||
return placer.writes();
|
return placer.writes();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,12 +125,12 @@ public class ObjectPlaceModePinTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Cave modes and structure pieces are placed at a height, the way their callers place them; the rest sample. */
|
/** Cave modes and structure pieces are placed at a height, the way their callers place them; the rest sample. */
|
||||||
private static int requestedY(ObjectPlaceMode mode) {
|
private static OptionalInt requestedY(ObjectPlaceMode mode) {
|
||||||
return switch (mode) {
|
return switch (mode) {
|
||||||
case CEILING_HANG -> CEILING_Y - 9;
|
case CEILING_HANG -> OptionalInt.of(CEILING_Y - 9);
|
||||||
case ORGANIC_STILT -> CAVE_FLOOR_Y + 12;
|
case ORGANIC_STILT -> OptionalInt.of(CAVE_FLOOR_Y + 12);
|
||||||
case STRUCTURE_PIECE -> 90;
|
case STRUCTURE_PIECE -> OptionalInt.of(90);
|
||||||
default -> -1;
|
default -> OptionalInt.empty();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+42
-7
@@ -204,7 +204,7 @@ public class ObjectPlacementRegressionTest {
|
|||||||
placement.mode(ObjectPlaceMode.MAX_HEIGHT);
|
placement.mode(ObjectPlaceMode.MAX_HEIGHT);
|
||||||
placement.rotation(ObjectRotation.of(0, 45, 0));
|
placement.rotation(ObjectRotation.of(0, 45, 0));
|
||||||
|
|
||||||
placed(boxObject(5, 1, 3), 0, -1, 0, placer, placement.build(), new RNG(2L), data);
|
placedAutomatic(boxObject(5, 1, 3), 0, 0, placer, placement.build(), new RNG(2L), data);
|
||||||
|
|
||||||
assertTrue(placer.sampledColumns().contains("-2:-2"));
|
assertTrue(placer.sampledColumns().contains("-2:-2"));
|
||||||
assertTrue(placer.sampledColumns().contains("2:2"));
|
assertTrue(placer.sampledColumns().contains("2:2"));
|
||||||
@@ -335,7 +335,7 @@ public class ObjectPlacementRegressionTest {
|
|||||||
RecordingPlacer placer = new RecordingPlacer(null);
|
RecordingPlacer placer = new RecordingPlacer(null);
|
||||||
ObjectPlacement.Builder config = placement();
|
ObjectPlacement.Builder config = placement();
|
||||||
config.mode(ObjectPlaceMode.ERODE_STILT);
|
config.mode(ObjectPlaceMode.ERODE_STILT);
|
||||||
assertEquals(ANCHOR_Y, placed(lineObject(1), 0, -1, 0, placer, config.build(), new RNG(2L), data));
|
assertEquals(ANCHOR_Y, placedAutomatic(lineObject(1), 0, 0, placer, config.build(), new RNG(2L), data));
|
||||||
assertFalse(placer.writes().isEmpty());
|
assertFalse(placer.writes().isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -528,12 +528,36 @@ public class ObjectPlacementRegressionTest {
|
|||||||
assertNull(storage.value(MARKS, TEXT, 1, ANCHOR_Y, 0));
|
assertNull(storage.value(MARKS, TEXT, 1, ANCHOR_Y, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void explicitHeightBelowZeroIsPlacedWhereAsked() {
|
||||||
|
for (int requestedY : new int[]{-1, -3}) {
|
||||||
|
RecordingPlacer placer = new RecordingPlacer(null);
|
||||||
|
ObjectPlacementResult result = ModuleObjectPlacement.place(lineObject(1), 0, requestedY, 0, placer,
|
||||||
|
placement().build(), new RNG(2L), null, null, data);
|
||||||
|
assertTrue(result.isPlaced());
|
||||||
|
assertEquals(requestedY, result.height());
|
||||||
|
assertFalse(placer.writes().isEmpty());
|
||||||
|
assertTrue(placer.writes().stream().allMatch(write -> write.y() == requestedY));
|
||||||
|
assertTrue(placer.sampledColumns().isEmpty());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void automaticHeightSamplesTheTerrain() {
|
||||||
|
RecordingPlacer placer = new RecordingPlacer(null);
|
||||||
|
ObjectPlacementResult result = ModuleObjectPlacement.placeAutomatic(lineObject(1), 0, 0, placer,
|
||||||
|
placement().build(), new RNG(2L), null, null, data);
|
||||||
|
assertTrue(result.isPlaced());
|
||||||
|
assertEquals(ANCHOR_Y, result.height());
|
||||||
|
assertFalse(placer.sampledColumns().isEmpty());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void fromBottomKeepsItsAnchorWithoutSamplingTerrain() {
|
public void fromBottomKeepsItsAnchorWithoutSamplingTerrain() {
|
||||||
RecordingPlacer placer = new RecordingPlacer(null);
|
RecordingPlacer placer = new RecordingPlacer(null);
|
||||||
ObjectPlacement.Builder config = placement();
|
ObjectPlacement.Builder config = placement();
|
||||||
config.fromBottom(true);
|
config.fromBottom(true);
|
||||||
assertEquals(2, placed(lineObject(1), 0, -1, 0, placer, config.build(), new RNG(2L), data));
|
assertEquals(2, placedAutomatic(lineObject(1), 0, 0, placer, config.build(), new RNG(2L), data));
|
||||||
assertTrue(placer.sampledColumns().isEmpty());
|
assertTrue(placer.sampledColumns().isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -543,7 +567,7 @@ public class ObjectPlacementRegressionTest {
|
|||||||
RecordingPlacer placer = new RecordingPlacer(null);
|
RecordingPlacer placer = new RecordingPlacer(null);
|
||||||
ObjectPlacement.Builder config = placement().bore(true).snow(0.1);
|
ObjectPlacement.Builder config = placement().bore(true).snow(0.1);
|
||||||
CarveResult cave = null;
|
CarveResult cave = null;
|
||||||
int anchor = ANCHOR_Y;
|
boolean automatic = false;
|
||||||
switch (reason) {
|
switch (reason) {
|
||||||
case "carving-anchor" -> {
|
case "carving-anchor" -> {
|
||||||
placer.carved = true;
|
placer.carved = true;
|
||||||
@@ -551,7 +575,7 @@ public class ObjectPlacementRegressionTest {
|
|||||||
}
|
}
|
||||||
case "underwater-anchor" -> {
|
case "underwater-anchor" -> {
|
||||||
placer.underwater = true;
|
placer.underwater = true;
|
||||||
anchor = -1;
|
automatic = true;
|
||||||
}
|
}
|
||||||
case "cave-clearance" -> cave = new CarveResult(ANCHOR_Y, ANCHOR_Y + 1);
|
case "cave-clearance" -> cave = new CarveResult(ANCHOR_Y, ANCHOR_Y + 1);
|
||||||
case "fluid-height" -> {
|
case "fluid-height" -> {
|
||||||
@@ -560,13 +584,13 @@ public class ObjectPlacementRegressionTest {
|
|||||||
}
|
}
|
||||||
case "height-clamp" -> config.clamp(TestSettings.of(ObjectLimit.class, "{\"maximumHeight\":" + (ANCHOR_Y - 1) + "}"));
|
case "height-clamp" -> config.clamp(TestSettings.of(ObjectLimit.class, "{\"maximumHeight\":" + (ANCHOR_Y - 1) + "}"));
|
||||||
}
|
}
|
||||||
ObjectPlacementResult result = place(config, anchor, placer, cave);
|
ObjectPlacementResult result = place(config, automatic, placer, cave);
|
||||||
assertEquals(Optional.of(reason), result.rejection());
|
assertEquals(Optional.of(reason), result.rejection());
|
||||||
assertEquals(-1, result.heightOrRejected());
|
assertEquals(-1, result.heightOrRejected());
|
||||||
assertTrue(reason, placer.writes().isEmpty());
|
assertTrue(reason, placer.writes().isEmpty());
|
||||||
|
|
||||||
config.forcePlace(true);
|
config.forcePlace(true);
|
||||||
assertTrue(reason, place(config, anchor, placer, cave).isPlaced());
|
assertTrue(reason, place(config, automatic, placer, cave).isPlaced());
|
||||||
assertFalse(reason, placer.writes().isEmpty());
|
assertFalse(reason, placer.writes().isEmpty());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -711,10 +735,21 @@ public class ObjectPlacementRegressionTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** The height {@code object} was placed at, or -1 when the placement rejected it. */
|
/** The height {@code object} was placed at, or -1 when the placement rejected it. */
|
||||||
|
private static int placedAutomatic(IrisObject object, int x, int z, IObjectPlacer placer, ObjectPlacement config, RNG rng, IrisData data) {
|
||||||
|
return ModuleObjectPlacement.placeAutomatic(object, x, z, placer, config, rng, null, null, data).heightOrRejected();
|
||||||
|
}
|
||||||
|
|
||||||
private static int placed(IrisObject object, int x, int y, int z, IObjectPlacer placer, ObjectPlacement config, RNG rng, IrisData data) {
|
private static int placed(IrisObject object, int x, int y, int z, IObjectPlacer placer, ObjectPlacement config, RNG rng, IrisData data) {
|
||||||
return ModuleObjectPlacement.place(object, x, y, z, placer, config, rng, null, null, data).heightOrRejected();
|
return ModuleObjectPlacement.place(object, x, y, z, placer, config, rng, null, null, data).heightOrRejected();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ObjectPlacementResult place(ObjectPlacement.Builder config, boolean automatic, RecordingPlacer placer, CarveResult cave) {
|
||||||
|
if (automatic) {
|
||||||
|
return ModuleObjectPlacement.placeAutomatic(lineObject(1), 0, 0, placer, config.build(), new RNG(2L), null, cave, data);
|
||||||
|
}
|
||||||
|
return place(config, ANCHOR_Y, placer, cave);
|
||||||
|
}
|
||||||
|
|
||||||
private ObjectPlacementResult place(ObjectPlacement.Builder config, int y, RecordingPlacer placer, CarveResult cave) {
|
private ObjectPlacementResult place(ObjectPlacement.Builder config, int y, RecordingPlacer placer, CarveResult cave) {
|
||||||
return ModuleObjectPlacement.place(lineObject(1), 0, y, 0, placer, config.build(), new RNG(2L), null, cave, data);
|
return ModuleObjectPlacement.place(lineObject(1), 0, y, 0, placer, config.build(), new RNG(2L), null, cave, data);
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-2
@@ -190,7 +190,7 @@ public class NativeStructureObjectVetoTest {
|
|||||||
volumes(volume(-64, -64, -64, 64, 320, 64));
|
volumes(volume(-64, -64, -64, 64, 320, 64));
|
||||||
ObjectPlacement placement = placement().toBuilder().forcePlace(true).build();
|
ObjectPlacement placement = placement().toBuilder().forcePlace(true).build();
|
||||||
|
|
||||||
assertEquals(-1, placed(0, -1, placer, placement));
|
assertEquals(-1, placedAutomatic(0, placer, placement));
|
||||||
assertTrue(placer.written().isEmpty());
|
assertTrue(placer.written().isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -229,7 +229,11 @@ public class NativeStructureObjectVetoTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private int place(RecordingPlacer placer) {
|
private int place(RecordingPlacer placer) {
|
||||||
return placed(0, -1, placer, placement());
|
return placedAutomatic(0, placer, placement());
|
||||||
|
}
|
||||||
|
|
||||||
|
private int placedAutomatic(int x, RecordingPlacer placer, ObjectPlacement config) {
|
||||||
|
return ModuleObjectPlacement.placeAutomatic(tree(), x, 0, placer, config, new RNG(1234L), null, null, data).heightOrRejected();
|
||||||
}
|
}
|
||||||
|
|
||||||
private int placed(int x, int y, RecordingPlacer placer, ObjectPlacement config) {
|
private int placed(int x, int y, RecordingPlacer placer, ObjectPlacement config) {
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ import java.util.OptionalInt;
|
|||||||
*/
|
*/
|
||||||
public final class ObjectRun {
|
public final class ObjectRun {
|
||||||
private static final int NOT_ANCHORED = Integer.MIN_VALUE;
|
private static final int NOT_ANCHORED = Integer.MIN_VALUE;
|
||||||
|
private static final int AUTOMATIC_Y = -1;
|
||||||
private static final int NEIGHBOR_READ_BLOCKS = 1;
|
private static final int NEIGHBOR_READ_BLOCKS = 1;
|
||||||
private static final long X_MULTIPLIER = 0x9E3779B97F4A7C15L;
|
private static final long X_MULTIPLIER = 0x9E3779B97F4A7C15L;
|
||||||
private static final long Z_MULTIPLIER = 0xC2B2AE3D27D4EB4FL;
|
private static final long Z_MULTIPLIER = 0xC2B2AE3D27D4EB4FL;
|
||||||
@@ -56,28 +57,41 @@ public final class ObjectRun {
|
|||||||
private final ObjectPlacement settings;
|
private final ObjectPlacement settings;
|
||||||
private final int x;
|
private final int x;
|
||||||
private final int requestedY;
|
private final int requestedY;
|
||||||
|
private final boolean automaticHeight;
|
||||||
private final int z;
|
private final int z;
|
||||||
private final Cave cave;
|
private final Cave cave;
|
||||||
private final List<BlockPosition> objectBlocks = new ArrayList<>();
|
private final List<BlockPosition> objectBlocks = new ArrayList<>();
|
||||||
private int anchorY = NOT_ANCHORED;
|
private int anchorY = NOT_ANCHORED;
|
||||||
|
|
||||||
private ObjectRun(PlaceableObject object, ObjectPlacement settings, int x, int requestedY, int z, Cave cave) {
|
private ObjectRun(PlaceableObject object, ObjectPlacement settings, int x, int requestedY, boolean automaticHeight, int z,
|
||||||
|
Cave cave) {
|
||||||
this.object = Objects.requireNonNull(object, "object");
|
this.object = Objects.requireNonNull(object, "object");
|
||||||
this.settings = Objects.requireNonNull(settings, "settings");
|
this.settings = Objects.requireNonNull(settings, "settings");
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.requestedY = requestedY;
|
this.requestedY = requestedY;
|
||||||
|
this.automaticHeight = automaticHeight;
|
||||||
this.z = z;
|
this.z = z;
|
||||||
this.cave = cave;
|
this.cave = cave;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @param requestedY the height to place at, or a negative value for the stages to sample it */
|
/** @param requestedY the height to place at, which may be below zero in a dimension that reaches down there */
|
||||||
public static ObjectRun of(PlaceableObject object, ObjectPlacement settings, int x, int requestedY, int z) {
|
public static ObjectRun of(PlaceableObject object, ObjectPlacement settings, int x, int requestedY, int z) {
|
||||||
return new ObjectRun(object, settings, x, requestedY, z, null);
|
return new ObjectRun(object, settings, x, requestedY, false, z, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** A placement inside {@code cave}, which the stages anchor in and keep the object's height within. */
|
/** A placement at the height the stages sample from the terrain. */
|
||||||
|
public static ObjectRun automatic(PlaceableObject object, ObjectPlacement settings, int x, int z) {
|
||||||
|
return new ObjectRun(object, settings, x, AUTOMATIC_Y, true, z, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A placement at {@code requestedY} inside {@code cave}, which the stages anchor in and keep the object's height within. */
|
||||||
public static ObjectRun inCave(PlaceableObject object, ObjectPlacement settings, int x, int requestedY, int z, Cave cave) {
|
public static ObjectRun inCave(PlaceableObject object, ObjectPlacement settings, int x, int requestedY, int z, Cave cave) {
|
||||||
return new ObjectRun(object, settings, x, requestedY, z, Objects.requireNonNull(cave, "cave"));
|
return new ObjectRun(object, settings, x, requestedY, false, z, Objects.requireNonNull(cave, "cave"));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A placement inside {@code cave} at the height the stages sample from it. */
|
||||||
|
public static ObjectRun automaticInCave(PlaceableObject object, ObjectPlacement settings, int x, int z, Cave cave) {
|
||||||
|
return new ObjectRun(object, settings, x, AUTOMATIC_Y, true, z, Objects.requireNonNull(cave, "cave"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -127,11 +141,16 @@ public final class ObjectRun {
|
|||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The height the caller asked for, negative when the stages sample it. */
|
/** The height the caller asked for; meaningless when {@link #automaticHeight()}. */
|
||||||
public int requestedY() {
|
public int requestedY() {
|
||||||
return requestedY;
|
return requestedY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Whether the stages sample the height from the terrain instead of placing at {@link #requestedY()}. */
|
||||||
|
public boolean automaticHeight() {
|
||||||
|
return automaticHeight;
|
||||||
|
}
|
||||||
|
|
||||||
public int z() {
|
public int z() {
|
||||||
return z;
|
return z;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,7 +53,6 @@ import java.util.Set;
|
|||||||
*/
|
*/
|
||||||
final class FloatingPlacer {
|
final class FloatingPlacer {
|
||||||
private static final ObjectRotation NO_ROTATION = ObjectRotation.of(0, 0, 0);
|
private static final ObjectRotation NO_ROTATION = ObjectRotation.of(0, 0, 0);
|
||||||
private static final int SAMPLED_HEIGHT = -1;
|
|
||||||
private static final Set<String> AIR_MATERIALS = Set.of("minecraft:air", "minecraft:cave_air");
|
private static final Set<String> AIR_MATERIALS = Set.of("minecraft:air", "minecraft:cave_air");
|
||||||
|
|
||||||
private final PackWorld world;
|
private final PackWorld world;
|
||||||
@@ -110,7 +109,7 @@ final class FloatingPlacer {
|
|||||||
ObjectPlacement floating = placement.toBuilder().place(List.of(object.name())).build();
|
ObjectPlacement floating = placement.toBuilder().place(List.of(object.name())).build();
|
||||||
int id = random.i(0, Integer.MAX_VALUE);
|
int id = random.i(0, Integer.MAX_VALUE);
|
||||||
try {
|
try {
|
||||||
place(ObjectRun.of(object, floating, worldX, SAMPLED_HEIGHT, worldZ), context.placementTerrain(), object, id);
|
place(ObjectRun.automatic(object, floating, worldX, worldZ), context.placementTerrain(), object, id);
|
||||||
} catch (Throwable failure) {
|
} catch (Throwable failure) {
|
||||||
log.error("Failed to place a floating object", failure);
|
log.error("Failed to place a floating object", failure);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,6 @@ import com.volmit.world.PackWorld;
|
|||||||
*/
|
*/
|
||||||
final class ObjectChunk {
|
final class ObjectChunk {
|
||||||
private static final int REJECTED = -1;
|
private static final int REJECTED = -1;
|
||||||
private static final int SAMPLED_HEIGHT = -1;
|
|
||||||
|
|
||||||
private final PackWorld world;
|
private final PackWorld world;
|
||||||
private final PlacementTerrain terrain;
|
private final PlacementTerrain terrain;
|
||||||
@@ -85,7 +84,7 @@ final class ObjectChunk {
|
|||||||
int placeOnSurface(PlaceableObject object, int x, int z, ObjectPlacement placement, PlacementChanges changes,
|
int placeOnSurface(PlaceableObject object, int x, int z, ObjectPlacement placement, PlacementChanges changes,
|
||||||
PlacementTags tags, String goldenTag) {
|
PlacementTags tags, String goldenTag) {
|
||||||
PlacementTerrain placer = proceduralTerrain(terrain, object, goldenTag);
|
PlacementTerrain placer = proceduralTerrain(terrain, object, goldenTag);
|
||||||
return place(ObjectRun.of(object, EffectiveSettings.withChanges(placement, changes), x, SAMPLED_HEIGHT, z), placer, tags);
|
return place(ObjectRun.automatic(object, EffectiveSettings.withChanges(placement, changes), x, z), placer, tags);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ public final class AnchorModule implements IrisModule {
|
|||||||
PreparedPlacement prepared = context.output(PlacementStages.Prepare.TRANSFORMS);
|
PreparedPlacement prepared = context.output(PlacementStages.Prepare.TRANSFORMS);
|
||||||
PlacementSettings settings = prepared.settings();
|
PlacementSettings settings = prepared.settings();
|
||||||
boolean structurePiece = prepared.mode().has(PlaceTrait.RAW_STAMP);
|
boolean structurePiece = prepared.mode().has(PlaceTrait.RAW_STAMP);
|
||||||
if (!settings.fromBottom() && placement.requestedY() < 0) {
|
if (!settings.fromBottom() && placement.automaticHeight()) {
|
||||||
return new AnchorHeight(sampled(context, placement, prepared));
|
return new AnchorHeight(sampled(context, placement, prepared));
|
||||||
}
|
}
|
||||||
ObjectShape object = placement.object();
|
ObjectShape object = placement.object();
|
||||||
@@ -75,7 +75,7 @@ public final class AnchorModule implements IrisModule {
|
|||||||
context.reject(CARVING_ANCHOR);
|
context.reject(CARVING_ANCHOR);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (placement.requestedY() < 0 || !settings.bottom() || structurePiece) {
|
if (placement.automaticHeight() || !settings.bottom() || structurePiece) {
|
||||||
return new AnchorHeight(y);
|
return new AnchorHeight(y);
|
||||||
}
|
}
|
||||||
y += Math.floorDiv(object.height(), 2);
|
y += Math.floorDiv(object.height(), 2);
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ public final class BlocksModule implements IrisModule {
|
|||||||
if (settings.meld() && !structurePiece && !world.isSolid(x, y, z)) {
|
if (settings.meld() && !structurePiece && !world.isSolid(x, y, z)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (data.properties().containsKey(WATERLOGGED) && shouldWaterlog(world, settings, placement.requestedY(), x, y, z)) {
|
if (data.properties().containsKey(WATERLOGGED) && shouldWaterlog(world, settings, placement.automaticHeight(), x, y, z)) {
|
||||||
data = data.withProperty(WATERLOGGED, TRUE);
|
data = data.withProperty(WATERLOGGED, TRUE);
|
||||||
}
|
}
|
||||||
if (world.has(data, BlockTrait.VINE)) {
|
if (world.has(data, BlockTrait.VINE)) {
|
||||||
@@ -185,11 +185,11 @@ public final class BlocksModule implements IrisModule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Whether a waterloggable block lands in water a waterloggable or underwater placement keeps. */
|
/** Whether a waterloggable block lands in water a waterloggable or underwater placement keeps. */
|
||||||
static boolean shouldWaterlog(PlacementWorld world, PlacementSettings settings, int requestedY, int x, int y, int z) {
|
static boolean shouldWaterlog(PlacementWorld world, PlacementSettings settings, boolean automaticHeight, int x, int y, int z) {
|
||||||
if (!(settings.waterloggable() || settings.underwater())) {
|
if (!(settings.waterloggable() || settings.underwater())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (requestedY >= 0 && settings.carvingSupport() == CarvingMode.CARVING_ONLY) {
|
if (!automaticHeight && settings.carvingSupport() == CarvingMode.CARVING_ONLY) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
BlockState existing = world.get(x, y, z);
|
BlockState existing = world.get(x, y, z);
|
||||||
|
|||||||
@@ -195,7 +195,7 @@ public final class StiltModule implements IrisModule {
|
|||||||
int top = layerY + anchorY;
|
int top = layerY + anchorY;
|
||||||
int highest = prepared.terrain().highest(x, z, true);
|
int highest = prepared.terrain().highest(x, z, true);
|
||||||
if (state.properties().containsKey(BlocksModule.WATERLOGGED)
|
if (state.properties().containsKey(BlocksModule.WATERLOGGED)
|
||||||
&& BlocksModule.shouldWaterlog(world, config, placement.requestedY(), x, highest, z)) {
|
&& BlocksModule.shouldWaterlog(world, config, placement.automaticHeight(), x, highest, z)) {
|
||||||
state = state.withProperty(BlocksModule.WATERLOGGED, BlocksModule.TRUE);
|
state = state.withProperty(BlocksModule.WATERLOGGED, BlocksModule.TRUE);
|
||||||
}
|
}
|
||||||
int lowerBound = highest - 1;
|
int lowerBound = highest - 1;
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ public final class ValidateModule implements IrisModule {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int y = context.output(PlacementStages.Anchor.HEIGHT).y();
|
int y = context.output(PlacementStages.Anchor.HEIGHT).y();
|
||||||
boolean sampled = placement.requestedY() < 0;
|
boolean sampled = placement.automaticHeight();
|
||||||
if (sampled && settings.carvingSupport().supportsSurface() && isOnBedrock(context, prepared, y)) {
|
if (sampled && settings.carvingSupport().supportsSurface() && isOnBedrock(context, prepared, y)) {
|
||||||
warnImplausibleBedrockPlacement(placement, settings, y, context.log());
|
warnImplausibleBedrockPlacement(placement, settings, y, context.log());
|
||||||
context.reject("bedrock-anchor");
|
context.reject("bedrock-anchor");
|
||||||
@@ -124,7 +124,7 @@ public final class ValidateModule implements IrisModule {
|
|||||||
int rotated = prepared.rotatedCenterY();
|
int rotated = prepared.rotatedCenterY();
|
||||||
int translated = prepared.translatedCenterY();
|
int translated = prepared.translatedCenterY();
|
||||||
Optional<ObjectRun.Cave> cave = placement.cave();
|
Optional<ObjectRun.Cave> cave = placement.cave();
|
||||||
if (placement.requestedY() < 0 && !prepared.mode().has(PlaceTrait.FREE_HEIGHT) && !settings.underwater()
|
if (placement.automaticHeight() && !prepared.mode().has(PlaceTrait.FREE_HEIGHT) && !settings.underwater()
|
||||||
&& !settings.onwater() && prepared.terrain().isUnderwater(placement.x(), placement.z())) {
|
&& !settings.onwater() && prepared.terrain().isUnderwater(placement.x(), placement.z())) {
|
||||||
context.reject("underwater-anchor");
|
context.reject("underwater-anchor");
|
||||||
} else if (cave.isPresent()
|
} else if (cave.isPresent()
|
||||||
|
|||||||
@@ -53,6 +53,6 @@ record WorldVolume(int minX, int maxX, int minY, int maxY, int minZ, int maxZ) {
|
|||||||
|
|
||||||
/** Whether each block of the placement follows the surface of its own column. */
|
/** Whether each block of the placement follows the surface of its own column. */
|
||||||
static boolean isPainted(RunningPlacement placement, PreparedPlacement prepared) {
|
static boolean isPainted(RunningPlacement placement, PreparedPlacement prepared) {
|
||||||
return placement.requestedY() < 0 && prepared.mode().anchor() == AnchorSampling.SURFACE;
|
return placement.automaticHeight() && prepared.mode().anchor() == AnchorSampling.SURFACE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -79,11 +79,16 @@ public final class RunningPlacement {
|
|||||||
return run.x();
|
return run.x();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The height the caller asked for, negative when the placement samples it. */
|
/** The height the caller asked for; meaningless when {@link #automaticHeight()}. */
|
||||||
public int requestedY() {
|
public int requestedY() {
|
||||||
return run.requestedY();
|
return run.requestedY();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Whether the placement samples its height from the terrain instead of placing at {@link #requestedY()}. */
|
||||||
|
public boolean automaticHeight() {
|
||||||
|
return run.automaticHeight();
|
||||||
|
}
|
||||||
|
|
||||||
public int z() {
|
public int z() {
|
||||||
return run.z();
|
return run.z();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user