24
24
*/
25
25
package io .github .opencubicchunks .cubicchunks .core .server ;
26
26
27
+ import io .github .opencubicchunks .cubicchunks .api .world .ICubicWorld ;
27
28
import io .github .opencubicchunks .cubicchunks .api .world .storage .StorageFormatProviderBase ;
28
29
import io .github .opencubicchunks .cubicchunks .core .CubicChunksConfig ;
29
- import io .github .opencubicchunks .cubicchunks .core .lighting .LightingManager ;
30
30
import io .github .opencubicchunks .cubicchunks .core .server .chunkio .AsyncBatchingCubeIO ;
31
31
import io .github .opencubicchunks .cubicchunks .core .server .chunkio .ICubeIO ;
32
32
import io .github .opencubicchunks .cubicchunks .core .server .chunkio .async .forge .AsyncWorldIOExecutor ;
61
61
import java .io .IOException ;
62
62
import java .io .UncheckedIOException ;
63
63
import java .nio .file .Path ;
64
+ import java .util .HashSet ;
64
65
import java .util .Iterator ;
65
66
import java .util .List ;
66
67
import java .util .Optional ;
67
- import java .util .Random ;
68
- import java .util .function .BooleanSupplier ;
68
+ import java .util .Set ;
69
69
import java .util .function .Consumer ;
70
70
71
71
import javax .annotation .Detainted ;
@@ -225,17 +225,6 @@ public boolean saveChunks(boolean alwaysTrue) {
225
225
226
226
@ Override
227
227
public boolean tick () {
228
- // NOTE: the return value is completely ignored
229
- profiler .startSection ("providerTick" );
230
- long i = System .currentTimeMillis ();
231
- Random rand = this .world .rand ;
232
- PlayerCubeMap playerCubeMap = ((PlayerCubeMap ) this .world .getPlayerChunkMap ());
233
- Iterator <Cube > watchersIterator = playerCubeMap .getCubeIterator ();
234
- BooleanSupplier tickFaster = () -> System .currentTimeMillis () - i > 40 ;
235
- while (watchersIterator .hasNext ()) {
236
- watchersIterator .next ().tickCubeServer (tickFaster , rand );
237
- }
238
- profiler .endSection ();
239
228
return false ;
240
229
}
241
230
@@ -493,25 +482,25 @@ private boolean populateCube(Cube cube, boolean forceNow) {
493
482
494
483
// for all cubes needed for full population - generate their population requirements
495
484
Box fullPopulation = cubeGen .getFullPopulationRequirements (cube );
496
- if (CubicChunksConfig .useVanillaChunkWorldGenerators ) {
497
- if (cube .getY () >= 0 && cube .getY () < 16 ) {
498
- fullPopulation = new Box (
499
- 0 , -cube .getY (), 0 ,
500
- 0 , 16 - cube .getY () - 1 , 0
501
- ).add (fullPopulation );
502
- }
503
- }
485
+ boolean useVanillaGenerators = ((ICubicWorld ) worldServer ).isCubicWorld ()
486
+ && CubicChunksConfig .useVanillaChunkWorldGenerators
487
+ && cube .getY () >= 0 && cube .getY () < 16 ;
488
+ if (useVanillaGenerators ) {
489
+ fullPopulation = new Box (
490
+ 0 , -cube .getY (), 0 ,
491
+ 0 , 16 - cube .getY () - 1 , 0
492
+ ).add (fullPopulation );
493
+ }
494
+ Set <Cube > newlyPopulatedCubes = new HashSet <>();
504
495
boolean success = fullPopulation .allMatch ((x , y , z ) -> {
505
496
// this also generates the cube
506
497
Cube fullPopulationCube = getCube (x + cubeX , y + cubeY , z + cubeZ );
507
498
Box newBox = cubeGen .getPopulationPregenerationRequirements (fullPopulationCube );
508
- if (CubicChunksConfig .useVanillaChunkWorldGenerators ) {
509
- if (cube .getY () >= 0 && cube .getY () < 16 ) {
510
- newBox = new Box (
511
- 0 , -cube .getY (), 0 ,
512
- 0 , 16 - cube .getY () - 1 , 0
513
- ).add (newBox );
514
- }
499
+ if (useVanillaGenerators ) {
500
+ newBox = new Box (
501
+ 0 , -cube .getY (), 0 ,
502
+ 0 , 16 - cube .getY () - 1 , 0
503
+ ).add (newBox );
515
504
}
516
505
boolean generated = newBox .allMatch ((nx , ny , nz ) -> {
517
506
int genX = cubeX + x + nx ;
@@ -525,21 +514,31 @@ private boolean populateCube(Cube cube, boolean forceNow) {
525
514
// a check for populators that populate more than one cube (vanilla compatibility generator)
526
515
if (!fullPopulationCube .isPopulated ()) {
527
516
cubeGen .populate (fullPopulationCube );
528
- fullPopulationCube . setPopulated ( true );
517
+ newlyPopulatedCubes . add ( fullPopulationCube );
529
518
}
530
519
return true ;
531
520
});
532
521
if (!success ) {
522
+ for (Cube newlyPopulatedCube : newlyPopulatedCubes ) {
523
+ newlyPopulatedCube .setPopulated (true );
524
+ }
533
525
return false ;
534
526
}
535
- if (CubicChunksConfig . useVanillaChunkWorldGenerators ) {
527
+ if (useVanillaGenerators ) {
536
528
Box .Mutable box = fullPopulation .asMutable ();
537
529
box .setY1 (0 );
538
530
box .setY2 (0 );
539
531
box .forEachPoint ((x , y , z ) -> {
540
- GameRegistry .generateWorld (cube .getX () + x , cube .getZ () + z , world , chunkGenerator , world .getChunkProvider ());
532
+ Cube columnCube = getCube (cubeX + x , 0 , cubeZ + z );
533
+ if (!columnCube .isPopulated ()) {
534
+ GameRegistry .generateWorld (cubeX + x , cubeZ + z , world , chunkGenerator , world .getChunkProvider ());
535
+ columnCube .setFullyPopulated (true );
536
+ }
541
537
});
542
538
}
539
+ for (Cube newlyPopulatedCube : newlyPopulatedCubes ) {
540
+ newlyPopulatedCube .setPopulated (true );
541
+ }
543
542
cube .setFullyPopulated (true );
544
543
return true ;
545
544
}
0 commit comments