}
}
@Override
public void completeUpdate() {
ReadyChunkInfo readyChunkInfo = lightMerger.completeMerge();
if (readyChunkInfo != null) {
Chunk chunk = readyChunkInfo.getChunk();
chunk.lock();
try {
chunk.markReady();
if (!readyChunkInfo.isNewChunk()) {
PerformanceMonitor.startActivity("Generating Block Entities");
generateBlockEntities(chunk);
PerformanceMonitor.endActivity();
}
if (readyChunkInfo.getChunkStore() != null) {
readyChunkInfo.getChunkStore().restoreEntities();
}
if (!readyChunkInfo.isNewChunk()) {
PerformanceMonitor.startActivity("Sending OnAddedBlocks");
readyChunkInfo.getBlockPositionMapppings().forEachEntry(new TShortObjectProcedure<TIntList>() {
@Override
public boolean execute(short id, TIntList positions) {
if (positions.size() > 0) {
blockManager.getBlock(id).getEntity().send(new OnAddedBlocks(positions, registry));
}
return true;
}
});
PerformanceMonitor.endActivity();
}
PerformanceMonitor.startActivity("Sending OnActivateBlocks");
readyChunkInfo.getBlockPositionMapppings().forEachEntry(new TShortObjectProcedure<TIntList>() {
@Override
public boolean execute(short id, TIntList positions) {
if (positions.size() > 0) {
blockManager.getBlock(id).getEntity().send(new OnActivatedBlocks(positions, registry));
}
return true;
}
});
PerformanceMonitor.endActivity();
if (!readyChunkInfo.isNewChunk()) {
worldEntity.send(new OnChunkGenerated(readyChunkInfo.getPos()));
}
worldEntity.send(new OnChunkLoaded(readyChunkInfo.getPos()));
for (ChunkRelevanceRegion region : regions.values()) {
region.chunkReady(chunk);
}
} finally {
chunk.unlock();