use of org.terasology.world.chunks.event.OnChunkLoaded in project Terasology by MovingBlocks.
the class RemoteChunkProvider method completeUpdate.
@Override
public void completeUpdate() {
Chunk chunk = lightMerger.completeMerge();
if (chunk != null) {
chunk.markReady();
listener.onChunkReady(chunk.getPosition());
worldEntity.send(new OnChunkLoaded(chunk.getPosition()));
}
}
use of org.terasology.world.chunks.event.OnChunkLoaded in project Terasology by MovingBlocks.
the class SectorSimulationSystem method chunkLoad.
/**
* Handles the OnChunkLoaded event for sector entities.
*
* Forwards the event to the appropriate sector-scope entities, if they are watching that chunk, and sends a
* {@link SectorEntityLoad} event if this is the first watched chunk to be loaded for that entity.
*
* @param event the event sent when any chunk is loaded
* @param worldEntity ignored
*/
@ReceiveEvent(components = WorldComponent.class)
public void chunkLoad(OnChunkLoaded event, EntityRef worldEntity) {
for (EntityRef entity : entityManager.getEntitiesWith(SectorSimulationComponent.class)) {
if (SectorUtil.getWatchedChunks(entity).contains(event.getChunkPos())) {
entity.send(new OnChunkLoaded(event.getChunkPos()));
if (SectorUtil.onlyWatchedChunk(entity, event.getChunkPos(), chunkProvider)) {
entity.send(new SectorEntityLoad());
}
sendLoadedSectorUpdateEvent(entity, simulationDelta(entity));
}
}
}
Aggregations