@@ -415,17 +415,57 @@ void mapAddIsland(Layer *l, int * __restrict out, int areaX, int areaZ, int area
415415
416416 if (v11 == 0 && (v00 != 0 || v20 != 0 || v02 != 0 || v22 != 0 ))
417417 {
418- setChunkSeed (l , (int64_t )(x + areaX ), (int64_t )(z + areaZ ));
418+ const int64_t chunkX = (int64_t )(x + areaX );
419+ const int64_t chunkZ = (int64_t )(z + areaZ );
420+ register int64_t cs = ss ;
421+ cs += chunkX ;
422+ cs *= cs * 6364136223846793005LL + 1442695040888963407LL ;
423+ cs += chunkZ ;
424+ cs *= cs * 6364136223846793005LL + 1442695040888963407LL ;
425+ cs += chunkX ;
426+ cs *= cs * 6364136223846793005LL + 1442695040888963407LL ;
427+ cs += chunkZ ;
419428
420429 int v = 1 ;
421- int inc = 1 ;
430+ int inc = 0 ;
422431
423- if (v00 != 0 && mcNextInt (l , inc ++ ) == 0 ) v = v00 ;
424- if (v20 != 0 && mcNextInt (l , inc ++ ) == 0 ) v = v20 ;
425- if (v02 != 0 && mcNextInt (l , inc ++ ) == 0 ) v = v02 ;
426- if (v22 != 0 && mcNextInt (l , inc ++ ) == 0 ) v = v22 ;
432+ if (v00 != 0 )
433+ {
434+ ++ inc ; v = v00 ;
435+ cs *= cs * 6364136223846793005LL + 1442695040888963407LL ;
436+ cs += ws ;
437+ }
438+ if (v20 != 0 )
439+ {
440+ if (++ inc == 1 || (cs & (1LL << 24 )) == 0 ) v = v20 ;
441+ cs *= cs * 6364136223846793005LL + 1442695040888963407LL ;
442+ cs += ws ;
443+ }
444+ if (v02 != 0 )
445+ {
446+ switch (++ inc )
447+ {
448+ case 1 : v = v02 ; break ;
449+ case 2 : if ((cs & (1LL << 24 )) == 0 ) v = v02 ; break ;
450+ default : if (((cs >> 24 ) % 3 ) == 0 ) v = v02 ;
451+ }
452+ cs *= cs * 6364136223846793005LL + 1442695040888963407LL ;
453+ cs += ws ;
454+ }
455+ if (v22 != 0 )
456+ {
457+ switch (++ inc )
458+ {
459+ case 1 : v = v22 ; break ;
460+ case 2 : if ((cs & (1LL << 24 )) == 0 ) v = v22 ; break ;
461+ case 3 : if (((cs >> 24 ) % 3 ) == 0 ) v = v22 ; break ;
462+ default : if ((cs & (3LL << 24 )) == 0 ) v = v22 ;
463+ }
464+ cs *= cs * 6364136223846793005LL + 1442695040888963407LL ;
465+ cs += ws ;
466+ }
427467
428- if (mcNextInt ( l , 3 ) == 0 )
468+ if (( cs >> 24 ) % 3 == 0 )
429469 out [x + z * areaWidth ] = v ;
430470 else if (v == 4 )
431471 out [x + z * areaWidth ] = 4 ;
0 commit comments