Read seeded noise styles flat in blocks

Palette layers, the decorator chance gate and carving child biomes
divide by their zoom or shrink factor only for a style without a seed;
a seeded style is read in plain blocks, so its own zoom is its only
scale and it lines up with every other reader of the same seed.

Ported from v3e a1bd24186. IrisApi 2914ed1, Iris 3b9012535.
This commit is contained in:
piexel committed 2026-11-05 21:02:19 +01:00
1 parent 3ac971c0d9
commit 9852f730a7
5 files changed
+25 -10

No files matched your search

@@ -186,8 +186,16 @@ final class ResolvedDecorator {
if (blocks.isEmpty()) { if (blocks.isEmpty()) {
return false; return false;
} }
double zoom = settings.style().zoom(); return chanceNoisePlacesAt(x, z);
return chanceNoise().sample(x / zoom, z / zoom) <= settings.chance(); }
/**
* Whether the style noise stays under the chance at the column. A style without a seed divides by its zoom here on top
* of its own scale; a seeded one is read in plain blocks.
*/
private boolean chanceNoisePlacesAt(double x, double z) {
double blocksPerSample = settings.style().isSeeded() ? 1 : settings.style().zoom();
return chanceNoise().sample(x / blocksPerSample, z / blocksPerSample) <= settings.chance();
} }
/** The block of the palette at the position, for decorations that fill a column block by block; null when the palette has no block. */ /** The block of the palette at the position, for decorations that fill a column block by block; null when the palette has no block. */
@@ -210,8 +218,7 @@ final class ResolvedDecorator {
return blockAt(x, y, z); return blockAt(x, y, z);
} }
double zoom = settings.style().zoom(); if (!chanceNoisePlacesAt(x, z)) {
if (!(chanceNoise().sample(x / zoom, z / zoom) <= settings.chance())) {
return null; return null;
} }
@@ -94,8 +94,11 @@ public final class ResolvedCarvingEntry {
long idHash = settings.id().trim().hashCode(); long idHash = settings.id().trim().hashCode();
long generatorSeed = seed ^ (idHash << 32) ^ CHILD_GENERATOR_SALT; long generatorSeed = seed ^ (idHash << 32) ^ CHILD_GENERATOR_SALT;
return childGenerators.computeIfAbsent(generatorSeed, key -> { return childGenerators.computeIfAbsent(generatorSeed, key -> {
double scale = Math.max(MIN_CHILD_SCALE, settings.childShrinkFactor()); NoiseSampler children = resources.noise().sampler(settings.childStyle(), key + CHILD_GENERATOR_SIGNATURE);
return resources.noise().sampler(settings.childStyle(), key + CHILD_GENERATOR_SIGNATURE).scaled(scale); if (settings.childStyle().isSeeded()) {
return children;
}
return children.scaled(Math.max(MIN_CHILD_SCALE, settings.childShrinkFactor()));
}); });
} }
} }
@@ -246,9 +246,9 @@ public final class BiomeLayers {
/** Adds the layer's block {@code j} blocks down; a layer that fails to pick adds nothing. */ /** Adds the layer's block {@code j} blocks down; a layer that fails to pick adds nothing. */
private void addBlock(KList<BlockState> blocks, ResolvedLayer layer, int index, int j, double wx, double wz, RNG random) { private void addBlock(KList<BlockState> blocks, ResolvedLayer layer, int index, int j, double wx, double wz, RNG random) {
double zoom = layer.zoom(); double blocksPerSample = layer.blocksPerSample();
try { try {
blocks.add(layer.get(random, index + j, (wx + j) / zoom, j, (wz - j) / zoom)); blocks.add(layer.get(random, index + j, (wx + j) / blocksPerSample, j, (wz - j) / blocksPerSample));
} catch (Throwable e) { } catch (Throwable e) {
log.error("A biome layer failed to pick a block", e); log.error("A biome layer failed to pick a block", e);
} }
@@ -71,8 +71,8 @@ public final class LayerBlocks {
if (size <= 1) { if (size <= 1) {
return size - 1; return size - 1;
} }
double zoom = layer.zoom(); NoiseSampler sampler = layerPicks.noise(parent, signature);
double noise = layerPicks.noise(parent, signature).sample(x / zoom, y / zoom, z / zoom); double noise = layer.style().isSeeded() ? sampler.sample(x, z) : sampler.sample(x / layer.zoom(), y / layer.zoom(), z / layer.zoom());
int index = (int) Math.round(noise * (size - 1)); int index = (int) Math.round(noise * (size - 1));
return index < 0 || index >= size ? 0 : index; return index < 0 || index >= size ? 0 : index;
} }
@@ -71,6 +71,11 @@ public final class ResolvedLayer {
return settings.zoom(); return settings.zoom();
} }
/** How many blocks one step of the layer's block noise spans: its zoom, or 1 for a seeded style, which is read flat. */
public double blocksPerSample() {
return settings.style().isSeeded() ? 1 : settings.zoom();
}
public SlopeClip slopeCondition() { public SlopeClip slopeCondition() {
return settings.slopeCondition(); return settings.slopeCondition();
} }