-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c66cc42
commit 0eed26f
Showing
3 changed files
with
34 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/main/java/cn/wode490390/nukkit/scatteredbuilding/scheduler/ChunkPopulateTask.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package cn.wode490390.nukkit.scatteredbuilding.scheduler; | ||
|
||
import cn.nukkit.level.ChunkManager; | ||
import cn.nukkit.level.format.FullChunk; | ||
import cn.nukkit.level.generator.populator.type.Populator; | ||
import cn.nukkit.math.NukkitRandom; | ||
import cn.nukkit.scheduler.AsyncTask; | ||
import java.util.Collection; | ||
|
||
public class ChunkPopulateTask extends AsyncTask { | ||
|
||
private final ChunkManager level; | ||
private final FullChunk chunk; | ||
private final Collection<Populator> populators; | ||
|
||
public ChunkPopulateTask(ChunkManager level, FullChunk chunk, Collection<Populator> populators) { | ||
this.level = level; | ||
this.chunk = chunk; | ||
this.populators = populators; | ||
} | ||
|
||
@Override | ||
public void onRun() { | ||
int chunkX = this.chunk.getX(); | ||
int chunkZ = this.chunk.getZ(); | ||
NukkitRandom random = new NukkitRandom(0xdeadbeef ^ (chunkX << 8) ^ chunkZ ^ this.level.getSeed()); | ||
this.populators.forEach(populator -> { | ||
populator.populate(this.level, chunkX, chunkZ, random, this.chunk); | ||
}); | ||
} | ||
} |