Implement grid biome distribution
Build / build (push) Canceled after 0s

This commit is contained in:
dnorberg committed 2026-09-22 21:38:56 -04:00
1 parent 73051c5ba6
commit 4886f8bb7d
5 files changed
+45 -5

No files matched your search

@@ -21,7 +21,7 @@ public record AgeDefinition(
public static final ResourceLocation RANDOM_VANILLA_PROFILE = ResourceLocation.fromNamespaceAndPath(
Rivencraft.MOD_ID, "random_vanilla"
);
public static final int CURRENT_GENERATION_VERSION = 10;
public static final int CURRENT_GENERATION_VERSION = 11;
public AgeDefinition {
Objects.requireNonNull(id, "id");
@@ -45,6 +45,7 @@ public final class AgeDimensionService {
private static final int SURFACE_SEARCH_RADIUS = 16;
private static final int FALLBACK_PLATFORM_Y = 63;
private static final int CAVE_SPAWN_SEARCH_Y = 64;
private static final int GRID_BIOME_SCALE = 0;
private static final int TILED_BIOME_SCALE = 4;
private AgeDimensionService() {
@@ -291,12 +292,19 @@ public final class AgeDimensionService {
int index = Math.floorMod(Long.hashCode(age.seed() ^ 0x53494E474C454249L), biomes.size());
return new FixedBiomeSource(biomes.get(index));
}
if (age.traits().biomeDistribution() == AgeTraits.BiomeDistribution.TILED && biomes.size() >= 2) {
AgeTraits.BiomeDistribution distribution = age.traits().biomeDistribution();
if ((distribution == AgeTraits.BiomeDistribution.TILED
|| distribution == AgeTraits.BiomeDistribution.GRID) && biomes.size() >= 2) {
List<net.minecraft.core.Holder.Reference<Biome>> selected = new java.util.ArrayList<>(biomes);
Collections.shuffle(selected, new java.util.Random(age.seed() ^ 0x54494C454442494FL));
long salt = distribution == AgeTraits.BiomeDistribution.GRID
? 0x4752494442494F4DL
: 0x54494C454442494FL;
Collections.shuffle(selected, new java.util.Random(age.seed() ^ salt));
return new CheckerboardColumnBiomeSource(
HolderSet.direct(List.of(selected.get(0), selected.get(1))),
TILED_BIOME_SCALE
distribution == AgeTraits.BiomeDistribution.GRID
? GRID_BIOME_SCALE
: TILED_BIOME_SCALE
);
}
return MultiNoiseBiomeSource.createFromPreset(
@@ -174,6 +174,15 @@ public final class LinkingGameTests {
selectedTraits.celestialAngle(),
selectedTraits.celestialPhase()
)
: profile.equals(AgeGenerationProfiles.ISLAND)
? new AgeTraits(
AgeTraits.BiomeDistribution.GRID,
selectedTraits.lighting(),
selectedTraits.weather(),
selectedTraits.celestialPeriod(),
selectedTraits.celestialAngle(),
selectedTraits.celestialPhase()
)
: selectedTraits;
AgeDefinition definition = new AgeDefinition(
id,
@@ -218,6 +227,24 @@ public final class LinkingGameTests {
helper.assertTrue(origin.equals(diagonalTile),
"Diagonal 256-block Tiled squares must repeat the biome");
}
if (profile.equals(AgeGenerationProfiles.ISLAND)) {
var biomeSource = level.getChunkSource().getGenerator().getBiomeSource();
helper.assertValueEqual(
biomeSource.possibleBiomes().size(),
2,
"Grid Biome Distribution must expose exactly two seeded biomes"
);
var origin = biomeSource.getNoiseBiome(0, 0, 0, null);
var insideOriginChunk = biomeSource.getNoiseBiome(3, 0, 3, null);
var eastChunk = biomeSource.getNoiseBiome(4, 0, 0, null);
var diagonalChunk = biomeSource.getNoiseBiome(4, 0, 4, null);
helper.assertTrue(origin.equals(insideOriginChunk),
"Grid biomes must remain constant inside each 16-block chunk");
helper.assertFalse(origin.equals(eastChunk),
"Adjacent Grid chunks must alternate biomes");
helper.assertTrue(origin.equals(diagonalChunk),
"Diagonal Grid chunks must repeat the biome");
}
if (definition.traits().lighting() == AgeTraits.Lighting.DARK) {
helper.assertFalse(level.dimensionType().hasSkyLight(),
"Dark Lighting Ages must suppress dimension skylight");