package sx.lambda.mstojcevich.voxel.tasks

import groovy.transform.CompileStatic
import sx.lambda.mstojcevich.voxel.VoxelGame

@CompileStatic
/**
 * Updates the propagation of light
 */
class LightUpdater implements RepeatedTask {

    private final VoxelGame game

    public LightUpdater(VoxelGame game) {
        this.game = game
    }

    @Override
    String getIdentifier() {
        return "Light Updater"
    }

    @Override
    void run() {
        try {
            while (!game.isDone()) {
                if (game.world != null) {
                    game.world.processLightQueue()
                }
                sleep(100)
            }
        } catch (Exception e) {
            game.handleCriticalException(e)
        }
    }

}

package sx.lambda.mstojcevich.voxel.tasks

import groovy.transform.CompileStatic
import sx.lambda.mstojcevich.voxel.VoxelGame

@CompileStatic
/**
 * Updates the propagation of light
 */
class LightUpdater implements RepeatedTask {

    private final VoxelGame game

    public LightUpdater(VoxelGame game) {
        this.game = game
    }

    @Override
    String getIdentifier() {
        return "Light Updater"
    }

    @Override
    void run() {
        try {
            while (!game.isDone()) {
//                if (game.world != null) {
//                    game.world.processLightQueue()
//                } Caused random dark spots. Investigation should be done later.
                sleep(1000)
            }
        } catch (Exception e) {
            game.handleCriticalException(e)
        }
    }

}

Comment out the light updating on another thread. Caused an issue with dark spots.
Comment out the light updating on another thread. Caused an issue with dark spots.

Issue probably occurred due to chunks being null during the lighting queue update, meaning that the light change was removed from the queue but not processed at all because its chunk was null. A possible solution could be to keep a queue of updates that didn't work out and throw those in the queue after for processing the next time.
