mirror of
https://github.com/Minestom/Minestom.git
synced 2025-03-02 11:21:15 +01:00
Give access to Chunk to ChunkPopulator
This commit is contained in:
parent
5460d8e6c4
commit
2fc29037fb
@ -4,6 +4,6 @@ import net.minestom.server.instance.batch.ChunkBatch;
|
||||
|
||||
public interface ChunkPopulator {
|
||||
|
||||
void populateChunk(ChunkBatch batch, int chunkX, int chunkZ);
|
||||
void populateChunk(ChunkBatch batch, Chunk chunk);
|
||||
|
||||
}
|
||||
|
@ -62,19 +62,19 @@ public class ChunkBatch implements InstanceBatch {
|
||||
|
||||
public void flushChunkGenerator(ChunkGenerator chunkGenerator, Consumer<Chunk> callback) {
|
||||
batchesPool.execute(() -> {
|
||||
List<ChunkPopulator> populators = chunkGenerator.getPopulators();
|
||||
boolean hasPopulator = populators != null && populators.isEmpty();
|
||||
final List<ChunkPopulator> populators = chunkGenerator.getPopulators();
|
||||
final boolean hasPopulator = populators != null && populators.isEmpty();
|
||||
|
||||
chunkGenerator.generateChunkData(this, chunk.getChunkX(), chunk.getChunkZ());
|
||||
singleThreadFlush(hasPopulator ? null : callback);
|
||||
|
||||
clearData(); // So the populators won't place those blocks again
|
||||
|
||||
if (populators != null && !populators.isEmpty()) {
|
||||
if (hasPopulator) {
|
||||
Iterator<ChunkPopulator> populatorIterator = populators.iterator();
|
||||
while (populatorIterator.hasNext()) {
|
||||
ChunkPopulator chunkPopulator = populatorIterator.next();
|
||||
chunkPopulator.populateChunk(this, chunk.getChunkX(), chunk.getChunkZ());
|
||||
chunkPopulator.populateChunk(this, chunk);
|
||||
}
|
||||
singleThreadFlush(callback);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user