Fixed the chunk generator not being executed when no populator is defined

This commit is contained in:
themode 2020-11-15 10:44:11 +01:00
parent f1d046753c
commit beebf18af2
2 changed files with 17 additions and 10 deletions

View File

@ -79,18 +79,25 @@ public class ChunkBatch implements InstanceBatch {
}
}
/**
* Called to fill the chunk batch.
*
* @param chunkGenerator the chunk generator
* @param callback the optional callback executed once the batch is done
*/
public void flushChunkGenerator(@NotNull ChunkGenerator chunkGenerator, @Nullable ChunkCallback callback) {
final List<ChunkPopulator> populators = chunkGenerator.getPopulators();
final boolean hasPopulator = populators != null && !populators.isEmpty();
// Check if there is anything to process
if (blocks.isEmpty() && !hasPopulator) {
OptionalCallback.execute(callback, chunk);
return;
}
BLOCK_BATCH_POOL.execute(() -> {
final List<ChunkPopulator> populators = chunkGenerator.getPopulators();
final boolean hasPopulator = populators != null && !populators.isEmpty();
chunkGenerator.generateChunkData(this, chunk.getChunkX(), chunk.getChunkZ());
// Check if there is anything to process
if (blocks.isEmpty() && !hasPopulator) {
OptionalCallback.execute(callback, chunk);
return;
}
singleThreadFlush(hasPopulator ? null : callback, true);
clearData(); // So the populators won't place those blocks again

View File

@ -43,7 +43,7 @@ public class PlayerInit {
NoiseTestGenerator noiseTestGenerator = new NoiseTestGenerator();
instanceContainer = MinecraftServer.getInstanceManager().createInstanceContainer(DimensionType.OVERWORLD);
instanceContainer.enableAutoChunkLoad(true);
instanceContainer.setChunkGenerator(noiseTestGenerator);
instanceContainer.setChunkGenerator(chunkGeneratorDemo);
// Load some chunks beforehand
final int loopStart = -3;