mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-29 01:04:29 +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 cave the cave the object is placed in, or null outside caves
|
||||
*/
|
||||
@@ -52,21 +53,42 @@ public final class ModuleObjectPlacement {
|
||||
ObjectPlacement config, RNG rng,
|
||||
BiConsumer<art.arcane.volmlib.util.math.BlockPosition, PlatformBlockState> listener,
|
||||
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(config, "Object placement config is required.");
|
||||
Objects.requireNonNull(rng, "Object placement RNG is required.");
|
||||
Objects.requireNonNull(data, "Object placement data is required.");
|
||||
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);
|
||||
if (!outcome.isPlaced()) {
|
||||
return ObjectPlacementResult.rejected(outcome.rejection().orElseThrow());
|
||||
}
|
||||
reportObjectBlocks(run, terrain, listener);
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import art.arcane.iris.builtin.objects.ObjectPlacement;
|
||||
import art.arcane.iris.builtin.prepare.ObjectRotation;
|
||||
import art.arcane.iris.core.IrisSettings;
|
||||
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.volmlib.util.cache.CacheKey;
|
||||
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.MatterCavern;
|
||||
import art.arcane.volmlib.util.matter.MatterStructurePOI;
|
||||
import art.arcane.volmlib.util.math.BlockPosition;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import it.unimi.dsi.fastutil.longs.Long2IntMap;
|
||||
import it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap;
|
||||
@@ -68,6 +70,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
/**
|
||||
* 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)
|
||||
? mode : ObjectPlaceMode.STRUCTURE_PIECE;
|
||||
for (PlacedStructurePiece p : pieces) {
|
||||
if (placeObject(writer, structure, p, undergroundMode, p.getY(), rng,
|
||||
if (placeObject(writer, structure, p, undergroundMode, false, rng,
|
||||
foundationColumns, supportNonOccluding) == -1) {
|
||||
failedPieces++;
|
||||
}
|
||||
}
|
||||
} else if (mode.placeMode().has(PlaceTrait.FREE_HEIGHT)) {
|
||||
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) {
|
||||
failedPieces++;
|
||||
}
|
||||
}
|
||||
} 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) {
|
||||
failedPieces++;
|
||||
}
|
||||
} else {
|
||||
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) {
|
||||
failedPieces++;
|
||||
}
|
||||
@@ -561,7 +564,7 @@ public class StructurePlacing {
|
||||
}
|
||||
|
||||
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) {
|
||||
IrisObject object = p.getObject();
|
||||
String objectKey = object.getLoadKey();
|
||||
@@ -573,16 +576,20 @@ public class StructurePlacing {
|
||||
builder.forcePlace(true);
|
||||
}
|
||||
ObjectPlacement config = builder.build();
|
||||
int placeY = (y == -1) ? -1 : y - engine.getMinHeight();
|
||||
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(
|
||||
foundationColumns, position.getX(), position.getY(), position.getZ(), state,
|
||||
supportNonOccluding);
|
||||
if (marker != null && shouldWriteStructureMarker(state)) {
|
||||
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. */
|
||||
|
||||
Reference in new issue
Block a user