Single-pass deposit clumps

- Place ellipsoid deposit clumps from the footprint cells instead of rebuilding the clump object
- Skip ore cave-biome lookups when no pack biome scales ore deposits
- Reject terrain-limited clumps before biome work when scaling cannot apply
- Compute the chunk terrain limit once per chunk
- Draw the exposure discard roll only when the discard chance is positive
This commit is contained in:
Brian Neumann-Fopiano committed 2026-10-21 19:16:57 -04:00
1 parent e2430500cf
commit 3bd76d47a9
4 files changed
+341 -135

No files matched your search

@@ -16,6 +16,8 @@ import org.junit.Test;
import org.mockito.MockedStatic;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -258,6 +260,40 @@ public class IrisDepositTuningTest {
assertNull(generator.sampleClumpFootprint(new RNG(1L), data));
}
@Test
public void ellipsoidFootprintCellsMatchTheBuiltClumpInPlacementOrder() {
IrisData data = mock(IrisData.class);
IrisDepositGenerator generator = new IrisDepositGenerator();
for (String key : new String[]{"minecraft:iron_ore", "minecraft:gold_ore", "minecraft:copper_ore"}) {
IrisBlockData block = mock(IrisBlockData.class);
NativeBlockState state = mock(NativeBlockState.class);
when(block.getBlockData(data)).thenReturn(state);
when(state.key()).thenReturn(key);
generator.getPalette().add(block);
}
generator.setShape(IrisDepositShape.VANILLA_ELLIPSOID);
for (int size : new int[]{0, 1, 3, 4, 9, 17, 25, 64}) {
generator.setMinSize(size).setMaxSize(size);
for (long seed = 0; seed < 300; seed++) {
IrisObject clump = generator.getClump(null, new RNG(seed), data);
List<String> expected = new ArrayList<>();
VectorMap<NativeBlockState>.Cursor cursor = clump.getBlocks().cursor();
while (cursor.next()) {
expected.add(cursor.key().getBlockX() + "," + cursor.key().getBlockY() + ","
+ cursor.key().getBlockZ() + "=" + cursor.value().key());
}
RNG sampled = new RNG(seed);
IrisDepositGenerator.ClumpCells cells = generator.sampleClumpFootprint(sampled, data).cells();
List<String> actual = new ArrayList<>();
for (int cell = 0; cell < cells.size(); cell++) {
actual.add(cells.x(cell) + "," + cells.y(cell) + "," + cells.z(cell) + "="
+ cells.block(cell).key());
}
assertEquals("size " + size + " seed " + seed, expected, actual);
}
}
}
@Test
public void vanillaScatteredSizeIsAnUpperCandidateBound() {
IrisData data = mock(IrisData.class);
@@ -107,6 +107,18 @@ public class IrisDepositModifierParityTest {
}
}
@Test
public void unscaledPacksSkipOreCaveBiomeLookupsWithIdenticalOutput() {
for (long seed : new long[]{101L, -73L, 90181L}) {
AtomicInteger scannedLookups = new AtomicInteger();
AtomicInteger unscannedLookups = new AtomicInteger();
long[] scanned = generateConfigured(seed, false, true, true, scannedLookups, null, false);
long[] unscanned = generateConfigured(seed, false, true, false, unscannedLookups, null, false);
assertArrayEquals("seed=" + seed, unscanned, scanned);
assertTrue(scannedLookups.get() < unscannedLookups.get());
}
}
@Test
public void unmatchableSurfaceBiomeFiltersSkipClumpsWithoutChangingOutput() {
long[] expected = {-681153659952315909L, 784L, 2118L, 53L, 67L, 10L};
@@ -126,9 +138,15 @@ public class IrisDepositModifierParityTest {
return generateConfigured(seed, multicore, caveVariant, enumerablePack, caveBiomeLookups, null);
}
@SuppressWarnings("unchecked")
private long[] generateConfigured(long seed, boolean multicore, boolean caveVariant, boolean enumerablePack,
AtomicInteger caveBiomeLookups, AtomicInteger unmatchableClumps) {
return generateConfigured(seed, multicore, caveVariant, enumerablePack, caveBiomeLookups, unmatchableClumps, true);
}
@SuppressWarnings("unchecked")
private long[] generateConfigured(long seed, boolean multicore, boolean caveVariant, boolean enumerablePack,
AtomicInteger caveBiomeLookups, AtomicInteger unmatchableClumps,
boolean oreScaling) {
Engine engine = mock(Engine.class, withSettings().stubOnly().defaultAnswer(RETURNS_DEEP_STUBS));
ChunkContext context = mock(ChunkContext.class, withSettings().stubOnly().defaultAnswer(RETURNS_DEEP_STUBS));
IrisDimension dimension = new IrisDimension();
@@ -136,8 +154,10 @@ public class IrisDepositModifierParityTest {
IrisBiome surface = new IrisBiome();
IrisBiome cave = new IrisBiome();
cave.setLoadKey("allowed");
cave.setOreDepositFrequencyMultiplier(0.65D);
cave.setOreDepositSizeMultiplier(1.5D);
if (oreScaling) {
cave.setOreDepositFrequencyMultiplier(0.65D);
cave.setOreDepositSizeMultiplier(1.5D);
}
IrisBiome denied = new IrisBiome();
denied.setLoadKey("denied");
IrisDepositVariant variant = new IrisDepositVariant().setMinHeight(-64).setMaxHeight(64);