cn.nukkit.level.generator.task.LightPopulationTask Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of powernukkit Show documentation
Show all versions of powernukkit Show documentation
A Minecraft Bedrock Edition server software implementation made in Java from scratch which supports all new features.
package cn.nukkit.level.generator.task;
import cn.nukkit.Server;
import cn.nukkit.level.Level;
import cn.nukkit.level.format.generic.BaseFullChunk;
import cn.nukkit.scheduler.AsyncTask;
/**
* @author MagicDroidX (Nukkit Project)
*/
public class LightPopulationTask extends AsyncTask {
public final int levelId;
public BaseFullChunk chunk;
public LightPopulationTask(Level level, BaseFullChunk chunk) {
this.levelId = level.getId();
this.chunk = chunk;
}
@Override
public void onRun() {
BaseFullChunk chunk = this.chunk.clone();
if (chunk == null) {
return;
}
chunk.recalculateHeightMap();
chunk.populateSkyLight();
chunk.setLightPopulated();
this.chunk = chunk.clone();
}
@Override
public void onCompletion(Server server) {
Level level = server.getLevel(this.levelId);
BaseFullChunk chunk = this.chunk.clone();
if (level != null) {
if (chunk == null) {
return;
}
level.generateChunkCallback(chunk.getX(), chunk.getZ(), chunk);
}
}
}