Skip to content

Commit

Permalink
Added populators to the clean super flat fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
tastybento committed Jul 28, 2019
1 parent d746eb2 commit c267f5e
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package world.bentobox.bentobox.listeners.flags.worldsettings;

import java.security.SecureRandom;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Random;

import org.bukkit.Bukkit;
import org.bukkit.Material;
Expand Down Expand Up @@ -82,16 +82,19 @@ public void onChunkLoad(ChunkLoadEvent e) {
}

private void cleanChunk(ChunkLoadEvent e, World world, ChunkGenerator cg, MyBiomeGrid grid) {
SecureRandom random = new SecureRandom();
if (!chunkQueue.isEmpty()) {
Pair<Integer, Integer> chunkXZ = chunkQueue.poll();
ChunkData cd = cg.generateChunkData(world, new Random(), e.getChunk().getX(), e.getChunk().getZ(), grid);
ChunkData cd = cg.generateChunkData(world, random, e.getChunk().getX(), e.getChunk().getZ(), grid);
for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) {
for (int y = 0; y < world.getMaxHeight(); y++) {
e.getChunk().getBlock(x, y, z).setBlockData(cd.getBlockData(x, y, z), false);
}
}
}
// Run populators
cg.getDefaultPopulators(world).forEach(pop -> pop.populate(world, random, e.getChunk()));
if (plugin.getSettings().isLogCleanSuperFlatChunks()) {
plugin.log(chunkQueue.size() + " Regenerating superflat chunk " + world.getName() + " " + chunkXZ.x + ", " + chunkXZ.z);
}
Expand Down

0 comments on commit c267f5e

Please sign in to comment.