Add seed validation for server world creation and override-seed property

The dedicated server previously picked a completely random seed with no
biome diversity checks (the client validates but the server skipped it).
On top of that, the client's findSeed() was hardcoded to only check a
54-chunk (Classic) area, so Large worlds had no diversity guarantee
beyond the center.

New server worlds now use findSeed() scaled to the full target world
size. Added override-seed in server.properties to fix existing worlds
without deleting them.
This commit is contained in:
itsRevela
2026-03-24 13:07:04 -05:00
parent 5dad6c24f7
commit 08f14e32ae
10 changed files with 66 additions and 9 deletions
+4 -4
View File
@@ -411,9 +411,9 @@ void BiomeSource::update()
// 4J added - find a seed for this biomesource that matches certain criteria
#ifdef __PSVITA__
int64_t BiomeSource::findSeed(LevelType *generator, bool* pServerRunning) // MGH - added pRunning, so we can early out of this on Vita as it can take up to 60 secs
int64_t BiomeSource::findSeed(LevelType *generator, bool* pServerRunning, int worldSizeChunks)
#else
int64_t BiomeSource::findSeed(LevelType *generator)
int64_t BiomeSource::findSeed(LevelType *generator, int worldSizeChunks)
#endif
{
@@ -440,8 +440,8 @@ int64_t BiomeSource::findSeed(LevelType *generator)
// Raw biome data has one result per 4x4 group of tiles.
// Removing a border of 8 from each side since we'll be doing special things at the edge to turn our world into an island, and so don't want to count things
// in the edge region in case they later get removed
static const int biomeWidth = ( 54 * 4 ) - 16; // Should be even so we can offset evenly
static const int biomeOffset = -( biomeWidth / 2 );
const int biomeWidth = ( worldSizeChunks * 4 ) - 16; // Should be even so we can offset evenly
const int biomeOffset = -( biomeWidth / 2 );
// Storage for our biome indices
intArray indices = intArray( biomeWidth * biomeWidth );
+2 -2
View File
@@ -36,9 +36,9 @@ private:
static void getFracs(intArray indices, float *fracs); // 4J added
public:
#ifdef __PSVITA__
static int64_t findSeed(LevelType *generator, bool* pServerRunning); // MGH - added pRunning, so we can early out of this on Vita as it can take up to 60 secs // 4J added
static int64_t findSeed(LevelType *generator, bool* pServerRunning, int worldSizeChunks = 54);
#else
static int64_t findSeed(LevelType *generator); // 4J added
static int64_t findSeed(LevelType *generator, int worldSizeChunks = 54);
#endif
~BiomeSource();
+9
View File
@@ -13,6 +13,15 @@ LevelData::LevelData()
LevelData::LevelData(CompoundTag *tag)
{
seed = tag->getLong(L"RandomSeed");
// Allow server.properties to override the world seed for biome generation
// on existing worlds (e.g. to fix monotonous biomes after world expansion).
if (app.HasSeedOverride())
{
app.DebugPrintf("Overriding world seed: %lld -> %lld\n", seed, app.GetSeedOverride());
seed = app.GetSeedOverride();
}
m_pGenerator = LevelType::lvl_normal;
if (tag->contains(L"generatorName"))
{