Public Access
This commit is contained in:
1 parent
a7986001f1
commit
5336eb46b9
6 files changed
+74
-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 = 12;
|
||||
public static final int CURRENT_GENERATION_VERSION = 13;
|
||||
|
||||
public AgeDefinition {
|
||||
Objects.requireNonNull(id, "id");
|
||||
|
||||
@@ -308,13 +308,24 @@ public final class AgeDimensionService {
|
||||
: TILED_BIOME_SCALE
|
||||
);
|
||||
}
|
||||
if (distribution == AgeTraits.BiomeDistribution.TINY && biomes.size() >= 3) {
|
||||
int scaledBiomeScale = switch (distribution) {
|
||||
case TINY -> 0;
|
||||
case SMALL -> 1;
|
||||
case MEDIUM -> 2;
|
||||
case LARGE -> 3;
|
||||
case HUGE -> 4;
|
||||
default -> -1;
|
||||
};
|
||||
if (scaledBiomeScale >= 0 && biomes.size() >= 3) {
|
||||
List<net.minecraft.core.Holder.Reference<Biome>> selected = new java.util.ArrayList<>(biomes);
|
||||
Collections.shuffle(selected, new java.util.Random(age.seed() ^ 0x54494E5942494F4DL));
|
||||
long salt = distribution == AgeTraits.BiomeDistribution.TINY
|
||||
? 0x54494E5942494F4DL
|
||||
: 0x5343414C45444249L;
|
||||
Collections.shuffle(selected, new java.util.Random(age.seed() ^ salt));
|
||||
return new ScaledBiomeSource(
|
||||
HolderSet.direct(List.of(selected.get(0), selected.get(1), selected.get(2))),
|
||||
age.seed(),
|
||||
0
|
||||
scaledBiomeScale
|
||||
);
|
||||
}
|
||||
return MultiNoiseBiomeSource.createFromPreset(
|
||||
|
||||
@@ -298,6 +298,55 @@ public final class LinkingGameTests {
|
||||
"The runtime dimension must apply the persisted celestial period");
|
||||
}
|
||||
}
|
||||
|
||||
AgeTraits.BiomeDistribution[] remainingScaledDistributions = {
|
||||
AgeTraits.BiomeDistribution.SMALL,
|
||||
AgeTraits.BiomeDistribution.MEDIUM,
|
||||
AgeTraits.BiomeDistribution.LARGE,
|
||||
AgeTraits.BiomeDistribution.HUGE
|
||||
};
|
||||
for (int scale = 1; scale <= remainingScaledDistributions.length; scale++) {
|
||||
AgeTraits.BiomeDistribution distribution = remainingScaledDistributions[scale - 1];
|
||||
UUID id = UUID.randomUUID();
|
||||
AgeDefinition definition = new AgeDefinition(
|
||||
id,
|
||||
"Scaled " + distribution,
|
||||
id.getMostSignificantBits(),
|
||||
AgeGenerationProfiles.STANDARD,
|
||||
AgeDefinition.CURRENT_GENERATION_VERSION,
|
||||
helper.getLevel().getGameTime(),
|
||||
net.minecraft.resources.ResourceLocation.fromNamespaceAndPath(
|
||||
Rivencraft.MOD_ID, "gametest/scaled_" + distribution.name().toLowerCase() + "_" + id
|
||||
),
|
||||
null,
|
||||
new AgeTraits(
|
||||
distribution,
|
||||
AgeTraits.Lighting.NORMAL,
|
||||
AgeTraits.Weather.NORMAL,
|
||||
1.0D,
|
||||
0.0F,
|
||||
0.0F
|
||||
)
|
||||
);
|
||||
var level = AgeDimensionService.ensureLoaded(helper.getLevel().getServer(), definition);
|
||||
helper.assertTrue(level != null, distribution + " Biome Distribution must load a runtime dimension");
|
||||
if (level == null) {
|
||||
continue;
|
||||
}
|
||||
var biomeSource = level.getChunkSource().getGenerator().getBiomeSource();
|
||||
helper.assertTrue(biomeSource instanceof net.dnorberg.rivencraft.world.ScaledBiomeSource,
|
||||
distribution + " Biome Distribution must use the serializable scaled biome source");
|
||||
helper.assertValueEqual(
|
||||
biomeSource.possibleBiomes().size(),
|
||||
3,
|
||||
distribution + " Biome Distribution must expose exactly three seeded biomes"
|
||||
);
|
||||
helper.assertValueEqual(
|
||||
((net.dnorberg.rivencraft.world.ScaledBiomeSource)biomeSource).scale(),
|
||||
scale,
|
||||
distribution + " Biome Distribution must use its Legacy scale"
|
||||
);
|
||||
}
|
||||
helper.succeed();
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +36,10 @@ public final class ScaledBiomeSource extends BiomeSource {
|
||||
this.cellWidth = 4 << scale;
|
||||
}
|
||||
|
||||
public int scale() {
|
||||
return scale;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MapCodec<? extends BiomeSource> codec() {
|
||||
return CODEC;
|
||||
|
||||
Reference in new issue
Block a user