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:
piexel committed 2026-11-10 01:22:46 +01:00
1 parent ccdfad8ba5
commit e3dd61c177
15 files changed
+157 -57

No files matched your search

@@ -53,7 +53,6 @@ import java.util.Set;
*/
final class FloatingPlacer {
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 final PackWorld world;
@@ -110,7 +109,7 @@ final class FloatingPlacer {
ObjectPlacement floating = placement.toBuilder().place(List.of(object.name())).build();
int id = random.i(0, Integer.MAX_VALUE);
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) {
log.error("Failed to place a floating object", failure);
}
@@ -48,7 +48,6 @@ import com.volmit.world.PackWorld;
*/
final class ObjectChunk {
private static final int REJECTED = -1;
private static final int SAMPLED_HEIGHT = -1;
private final PackWorld world;
private final PlacementTerrain terrain;
@@ -85,7 +84,7 @@ final class ObjectChunk {
int placeOnSurface(PlaceableObject object, int x, int z, ObjectPlacement placement, PlacementChanges changes,
PlacementTags tags, String 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);
PlacementSettings settings = prepared.settings();
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));
}
ObjectShape object = placement.object();
@@ -75,7 +75,7 @@ public final class AnchorModule implements IrisModule {
context.reject(CARVING_ANCHOR);
return null;
}
if (placement.requestedY() < 0 || !settings.bottom() || structurePiece) {
if (placement.automaticHeight() || !settings.bottom() || structurePiece) {
return new AnchorHeight(y);
}
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)) {
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);
}
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. */
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())) {
return false;
}
if (requestedY >= 0 && settings.carvingSupport() == CarvingMode.CARVING_ONLY) {
if (!automaticHeight && settings.carvingSupport() == CarvingMode.CARVING_ONLY) {
return false;
}
BlockState existing = world.get(x, y, z);
@@ -195,7 +195,7 @@ public final class StiltModule implements IrisModule {
int top = layerY + anchorY;
int highest = prepared.terrain().highest(x, z, true);
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);
}
int lowerBound = highest - 1;
@@ -84,7 +84,7 @@ public final class ValidateModule implements IrisModule {
return;
}
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)) {
warnImplausibleBedrockPlacement(placement, settings, y, context.log());
context.reject("bedrock-anchor");
@@ -124,7 +124,7 @@ public final class ValidateModule implements IrisModule {
int rotated = prepared.rotatedCenterY();
int translated = prepared.translatedCenterY();
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())) {
context.reject("underwater-anchor");
} 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. */
static boolean isPainted(RunningPlacement placement, PreparedPlacement prepared) {
return placement.requestedY() < 0 && prepared.mode().anchor() == AnchorSampling.SURFACE;
return placement.automaticHeight() && prepared.mode().anchor() == AnchorSampling.SURFACE;
}
}